refactor(logs): 重构日志服务相关配置和线路数据分析逻辑
- 将CsLogsPOMapper.xml从cs-device模块迁移至cs-system模块 - 更新CsLogsFeignClient的服务器配置从CS_DEVICE_BOOT到CS_SYSTEM_BOOT - 优化CsGroupServiceImpl中的设备线路查询逻辑,直接使用敏感用户ID获取线路数据 - 在StableDataServiceImpl中新增电网侧和负荷侧字典常量定义 - 重构线路数据过滤逻辑,按电网侧和负荷侧分别处理数据 - 添加数据分组处理机制,区分治理前后数据并设置相应标识
This commit is contained in:
@@ -28,6 +28,7 @@ import com.njcn.system.api.CsStatisticalSetFeignClient;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.EpdFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
@@ -63,6 +64,8 @@ public class StableDataServiceImpl implements StableDataService {
|
||||
private final CsStatisticalSetFeignClient csStatisticalSetFeignClient;
|
||||
private final InfluxDbParamUtil influxDbParamUtil;
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
private final String GRID_SIDE_DICT_CODE = "Grid_Side";
|
||||
private final String LOAD_SIDE_DICT_CODE = "Load_Side";
|
||||
|
||||
|
||||
@Override
|
||||
@@ -251,56 +254,80 @@ public class StableDataServiceImpl implements StableDataService {
|
||||
if(CollectionUtil.isEmpty(csLinePOList)){
|
||||
throw new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR);
|
||||
}
|
||||
String areaId = dicDataFeignClient.getDicDataByCode(DicDataEnum.OUTPUT_SIDE.getCode()).getData().getId();
|
||||
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
|
||||
List<CsLinePO> csLinePOList1 = csLinePOList.stream().filter(temp -> Objects.equals(areaId, temp.getPosition())).collect(Collectors.toList());
|
||||
DictData loadSideDictData = dicDataFeignClient.getDicDataByCode(LOAD_SIDE_DICT_CODE).getData();
|
||||
DictData gridSideDictData = dicDataFeignClient.getDicDataByCode(GRID_SIDE_DICT_CODE).getData();
|
||||
CsLinePO gridSideLine = csLinePOList.stream().filter(linePO -> linePO.getPosition().equals(gridSideDictData.getId())).findFirst().orElse(null);
|
||||
CsLinePO loadSideLine = csLinePOList.stream().filter(linePO -> linePO.getPosition().equals(loadSideDictData.getId())).findFirst().orElse(null);
|
||||
List<CsLinePO> csLinePOList1 = new ArrayList<>();
|
||||
csLinePOList1.add(gridSideLine);csLinePOList1.add(loadSideLine);
|
||||
List<EleEpdPqd> data = csStatisticalSetFeignClient.queryStatisticalSelect(Collections.singletonList(commonStatisticalQueryParam.getStatisticalId())).getData();
|
||||
if(CollectionUtil.isNotEmpty(data)){
|
||||
List<CsLinePO> finalCsLinePOList = csLinePOList;
|
||||
data.forEach(epdPqd->{
|
||||
String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse("");
|
||||
if(StringUtils.isEmpty(commonStatisticalQueryParam.getFrequency())){
|
||||
frequency ="";
|
||||
}else {
|
||||
frequency = "_"+commonStatisticalQueryParam.getFrequency();
|
||||
}
|
||||
String finalFrequency1 = frequency;
|
||||
List<CommonQueryParam> commonQueryParams = csLinePOList1.stream().map(temp -> {
|
||||
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
||||
commonQueryParam.setLineId(temp.getLineId());
|
||||
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
|
||||
if (epdPqd.getName() == null || epdPqd.getName().isEmpty()) {
|
||||
commonQueryParam.setColumnName(epdPqd.getName()+ finalFrequency1);
|
||||
} else {
|
||||
commonQueryParam.setColumnName(epdPqd.getOtherName()+ finalFrequency1);
|
||||
String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse("");
|
||||
if(StringUtils.isEmpty(commonStatisticalQueryParam.getFrequency())){
|
||||
frequency ="";
|
||||
}else {
|
||||
frequency = "_"+commonStatisticalQueryParam.getFrequency();
|
||||
}
|
||||
commonQueryParam.setPhasic(epdPqd.getPhase());
|
||||
commonQueryParam.setStartTime(commonStatisticalQueryParam.getStartTime() + " 00:00:00");
|
||||
commonQueryParam.setEndTime(commonStatisticalQueryParam.getEndTime() + " 23:59:59");
|
||||
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType().toUpperCase());
|
||||
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
|
||||
commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(temp.getLineId()));
|
||||
String finalFrequency1 = frequency;
|
||||
List<CommonQueryParam> commonQueryParams = csLinePOList1.stream().map(temp -> {
|
||||
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
||||
commonQueryParam.setLineId(temp.getLineId());
|
||||
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
|
||||
if (epdPqd.getName() == null || epdPqd.getName().isEmpty()) {
|
||||
commonQueryParam.setColumnName(epdPqd.getName()+ finalFrequency1);
|
||||
} else {
|
||||
commonQueryParam.setColumnName(epdPqd.getOtherName()+ finalFrequency1);
|
||||
}
|
||||
commonQueryParam.setPhasic(epdPqd.getPhase());
|
||||
commonQueryParam.setStartTime(commonStatisticalQueryParam.getStartTime() + " 00:00:00");
|
||||
commonQueryParam.setEndTime(commonStatisticalQueryParam.getEndTime() + " 23:59:59");
|
||||
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType().toUpperCase());
|
||||
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
|
||||
commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(temp.getLineId()));
|
||||
|
||||
return commonQueryParam;
|
||||
}).collect(Collectors.toList());
|
||||
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
|
||||
|
||||
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
||||
ThdDataVO vo = new ThdDataVO();
|
||||
vo.setLineId(temp.getLineId());
|
||||
vo.setPhase(temp.getPhaseType());
|
||||
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
||||
vo.setPosition(position);
|
||||
vo.setTime(temp.getTime());
|
||||
vo.setStatMethod(temp.getValueType());
|
||||
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
||||
vo.setStatisticalIndex(epdPqd.getId());
|
||||
vo.setUnit(epdPqd.getUnit());
|
||||
vo.setStatisticalName(epdPqd.getName());
|
||||
vo.setAnotherName(epdPqd.getShowName());
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
result.addAll(collect1);
|
||||
return commonQueryParam;
|
||||
}).collect(Collectors.toList());
|
||||
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
|
||||
if (CollectionUtil.isNotEmpty(deviceRtData)) {
|
||||
Map<String, List<StatisticalDataDTO> > map = deviceRtData.stream().collect(Collectors.groupingBy(StatisticalDataDTO::getLineId));
|
||||
map.forEach((key, value) -> {
|
||||
if (!Objects.isNull(loadSideLine) && Objects.equals(key, loadSideLine.getLineId())) {
|
||||
List<ThdDataVO> collect1 = value.stream().map(temp -> {
|
||||
ThdDataVO vo = new ThdDataVO();
|
||||
vo.setLineId(temp.getLineId());
|
||||
vo.setPhase(temp.getPhaseType());
|
||||
vo.setPosition(loadSideLine.getPosition());
|
||||
vo.setTime(temp.getTime());
|
||||
vo.setStatMethod(temp.getValueType());
|
||||
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
||||
vo.setStatisticalIndex(epdPqd.getId());
|
||||
vo.setUnit(epdPqd.getUnit());
|
||||
vo.setStatisticalName(epdPqd.getName());
|
||||
vo.setAnotherName("治理前");
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
result.addAll(collect1);
|
||||
}
|
||||
if (!Objects.isNull(gridSideLine) && Objects.equals(key, gridSideLine.getLineId())) {
|
||||
List<ThdDataVO> collect1 = value.stream().map(temp -> {
|
||||
ThdDataVO vo = new ThdDataVO();
|
||||
vo.setLineId(temp.getLineId());
|
||||
vo.setPhase(temp.getPhaseType());
|
||||
vo.setPosition(gridSideLine.getPosition());
|
||||
vo.setTime(temp.getTime());
|
||||
vo.setStatMethod(temp.getValueType());
|
||||
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
||||
vo.setStatisticalIndex(epdPqd.getId());
|
||||
vo.setUnit(epdPqd.getUnit());
|
||||
vo.setStatisticalName(epdPqd.getName());
|
||||
vo.setAnotherName("治理后");
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
result.addAll(collect1);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user