|
|
|
|
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.njcn.common.pojo.exception.BusinessException;
|
|
|
|
|
import com.njcn.csdevice.api.CsLineFeignClient;
|
|
|
|
|
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
|
|
|
|
import com.njcn.csdevice.mapper.CsDataArrayMapper;
|
|
|
|
|
import com.njcn.csdevice.mapper.CsGroArrMapper;
|
|
|
|
|
@@ -22,7 +23,9 @@ import com.njcn.csdevice.service.ICsDataArrayService;
|
|
|
|
|
import com.njcn.csdevice.service.ICsGroupService;
|
|
|
|
|
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
|
|
|
|
import com.njcn.influx.service.CommonService;
|
|
|
|
|
import com.njcn.system.api.DicDataFeignClient;
|
|
|
|
|
import com.njcn.system.api.EpdFeignClient;
|
|
|
|
|
import com.njcn.system.enums.DicDataEnum;
|
|
|
|
|
import com.njcn.system.pojo.po.EleEpdPqd;
|
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
@@ -59,6 +62,10 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|
|
|
|
|
|
|
|
|
private final EpdFeignClient epdFeignClient;
|
|
|
|
|
|
|
|
|
|
private final CsLineFeignClient csLineFeignClient;
|
|
|
|
|
|
|
|
|
|
private final DicDataFeignClient dicDataFeignClient;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public List<CsGroupVO> getGroupData(String dataSet) {
|
|
|
|
|
@@ -82,15 +89,28 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|
|
|
|
if (pageRes.getTotal() != 0) {
|
|
|
|
|
List<DataGroupTemplateVO> groupList = pageRes.getRecords();
|
|
|
|
|
List<String> group = groupList.stream().map(DataGroupTemplateVO::getId).collect(Collectors.toList());
|
|
|
|
|
String position = csLineFeignClient.getPositionById(lineId).getData();
|
|
|
|
|
if (Objects.isNull(position)){
|
|
|
|
|
throw new BusinessException(AlgorithmResponseEnum.POSITION_ERROR);
|
|
|
|
|
}
|
|
|
|
|
String clDid = null;
|
|
|
|
|
String areaCode = dicDataFeignClient.getDicDataById(position).getData().getCode();
|
|
|
|
|
if (Objects.equals(areaCode, DicDataEnum.OUTPUT_SIDE.getCode())){
|
|
|
|
|
clDid = "0";
|
|
|
|
|
} else if (Objects.equals(areaCode, DicDataEnum.LOAD_SIDE.getCode())){
|
|
|
|
|
clDid = "1";
|
|
|
|
|
} else if (Objects.equals(areaCode, DicDataEnum.GRID_SIDE.getCode())){
|
|
|
|
|
clDid = "2";
|
|
|
|
|
}
|
|
|
|
|
//获取当前组的所有指标项
|
|
|
|
|
List<EnergyTemplateVO> list = csDataArrayMapper.getArrayByGroup(group);
|
|
|
|
|
list.forEach(item->{
|
|
|
|
|
for (EnergyTemplateVO item : list) {
|
|
|
|
|
EnergyTemplateVO vo = new EnergyTemplateVO();
|
|
|
|
|
BeanUtils.copyProperties(item,vo);
|
|
|
|
|
EleEpdPqd eleEpdPqd = epdFeignClient.selectById(item.getDataId()).getData();
|
|
|
|
|
vo.setClassId(eleEpdPqd.getClassId());
|
|
|
|
|
vo.setUnit(eleEpdPqd.getUnit());
|
|
|
|
|
StatisticalDataDTO statisticalDataDTO = commonService.getLineRtData(lineId,eleEpdPqd.getClassId(),item.getName(),item.getPhase(),item.getStatMethod());
|
|
|
|
|
StatisticalDataDTO statisticalDataDTO = commonService.getLineRtData(lineId,eleEpdPqd.getClassId(),item.getName(),item.getPhase(),item.getStatMethod(),clDid);
|
|
|
|
|
if (!Objects.isNull(statisticalDataDTO)){
|
|
|
|
|
vo.setTime(statisticalDataDTO.getTime());
|
|
|
|
|
vo.setDataValue(BigDecimal.valueOf(statisticalDataDTO.getValue()).setScale(4, RoundingMode.UP).doubleValue());
|
|
|
|
|
@@ -98,7 +118,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|
|
|
|
vo.setDataValue(3.1415926);
|
|
|
|
|
}
|
|
|
|
|
arrayList.add(vo);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (CollectionUtil.isNotEmpty(arrayList)){
|
|
|
|
|
List<DataGroupTemplateVO> grList = groupList.stream().peek((item) -> {item.setChildren(getChildren(item.getId(), arrayList));}).collect(Collectors.toList());
|
|
|
|
|
pageTurn.setRecords(grList);
|
|
|
|
|
@@ -125,15 +145,29 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|
|
|
|
if (pageRes.getTotal() != 0) {
|
|
|
|
|
List<DataGroupTemplateVO> groupList = pageRes.getRecords();
|
|
|
|
|
List<String> group = groupList.stream().map(DataGroupTemplateVO::getId).collect(Collectors.toList());
|
|
|
|
|
String position = csLineFeignClient.getPositionById(energyBaseParam.getLineId()).getData();
|
|
|
|
|
if (Objects.isNull(position)){
|
|
|
|
|
throw new BusinessException(AlgorithmResponseEnum.POSITION_ERROR);
|
|
|
|
|
}
|
|
|
|
|
String clDid = null;
|
|
|
|
|
String areaCode = dicDataFeignClient.getDicDataById(position).getData().getCode();
|
|
|
|
|
if (Objects.equals(areaCode, DicDataEnum.OUTPUT_SIDE.getCode())){
|
|
|
|
|
clDid = "0";
|
|
|
|
|
} else if (Objects.equals(areaCode, DicDataEnum.LOAD_SIDE.getCode())){
|
|
|
|
|
clDid = "1";
|
|
|
|
|
} else if (Objects.equals(areaCode, DicDataEnum.GRID_SIDE.getCode())){
|
|
|
|
|
clDid = "2";
|
|
|
|
|
}
|
|
|
|
|
//获取当前组的所有指标项
|
|
|
|
|
List<EnergyTemplateVO> list = csDataArrayMapper.getArrayByGroup(group);
|
|
|
|
|
list.forEach(item->{
|
|
|
|
|
|
|
|
|
|
for (EnergyTemplateVO item : list) {
|
|
|
|
|
EnergyTemplateVO vo = new EnergyTemplateVO();
|
|
|
|
|
BeanUtils.copyProperties(item,vo);
|
|
|
|
|
EleEpdPqd eleEpdPqd = epdFeignClient.selectById(item.getDataId()).getData();
|
|
|
|
|
vo.setClassId(eleEpdPqd.getClassId());
|
|
|
|
|
vo.setUnit(eleEpdPqd.getUnit());
|
|
|
|
|
StatisticalDataDTO statisticalDataDTO = commonService.getLineHistoryData(energyBaseParam.getLineId(),eleEpdPqd.getClassId(),item.getName(),energyBaseParam.getStartTime(),energyBaseParam.getEndTime());
|
|
|
|
|
StatisticalDataDTO statisticalDataDTO = commonService.getLineHistoryData(energyBaseParam.getLineId(),eleEpdPqd.getClassId(),item.getName(),energyBaseParam.getStartTime(),energyBaseParam.getEndTime(),clDid);
|
|
|
|
|
if (!Objects.isNull(statisticalDataDTO)){
|
|
|
|
|
vo.setMaxValue(BigDecimal.valueOf(statisticalDataDTO.getMaxValue()).setScale(4, RoundingMode.UP).doubleValue());
|
|
|
|
|
vo.setMinValue(BigDecimal.valueOf(statisticalDataDTO.getMinValue()).setScale(4, RoundingMode.UP).doubleValue());
|
|
|
|
|
@@ -142,7 +176,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|
|
|
|
vo.setMinValue(3.1415956);
|
|
|
|
|
}
|
|
|
|
|
arrayList.add(vo);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (CollectionUtil.isNotEmpty(arrayList)){
|
|
|
|
|
List<DataGroupTemplateVO> grList = groupList.stream().peek((item) -> {item.setChildren(getChildren(item.getId(), arrayList));}).collect(Collectors.toList());
|
|
|
|
|
pageTurn.setRecords(grList);
|
|
|
|
|
|