refactor(logs): 重构日志服务相关配置和线路数据分析逻辑
- 将CsLogsPOMapper.xml从cs-device模块迁移至cs-system模块 - 更新CsLogsFeignClient的服务器配置从CS_DEVICE_BOOT到CS_SYSTEM_BOOT - 优化CsGroupServiceImpl中的设备线路查询逻辑,直接使用敏感用户ID获取线路数据 - 在StableDataServiceImpl中新增电网侧和负荷侧字典常量定义 - 重构线路数据过滤逻辑,按电网侧和负荷侧分别处理数据 - 添加数据分组处理机制,区分治理前后数据并设置相应标识
This commit is contained in:
@@ -1337,12 +1337,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
|||||||
result.put("before", new ArrayList<>());
|
result.put("before", new ArrayList<>());
|
||||||
result.put("after", new ArrayList<>());
|
result.put("after", new ArrayList<>());
|
||||||
String sensitiveUserId = param.getSensitiveUserId();
|
String sensitiveUserId = param.getSensitiveUserId();
|
||||||
List<CsEquipmentDeliveryPO> devList = csLineFeignClient.getDevBySensitiveUser(Collections.singletonList(sensitiveUserId)).getData();
|
List<CsLinePO> linePOList = csLineFeignClient.getLinesByDevList(Collections.singletonList(sensitiveUserId)).getData();
|
||||||
if (CollUtil.isEmpty(devList)) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
List<String> devIds = devList.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
|
|
||||||
List<CsLinePO> linePOList = csLineFeignClient.getLinesByDevList(devIds).getData();
|
|
||||||
DictData loadSideDictData = dicDataFeignClient.getDicDataByCode(LOAD_SIDE_DICT_CODE).getData();
|
DictData loadSideDictData = dicDataFeignClient.getDicDataByCode(LOAD_SIDE_DICT_CODE).getData();
|
||||||
DictData gridSideDictData = dicDataFeignClient.getDicDataByCode(GRID_SIDE_DICT_CODE).getData();
|
DictData gridSideDictData = dicDataFeignClient.getDicDataByCode(GRID_SIDE_DICT_CODE).getData();
|
||||||
CsLinePO gridSideLine = linePOList.stream().filter(linePO -> linePO.getPosition().equals(gridSideDictData.getId())).findFirst().orElse(null);
|
CsLinePO gridSideLine = linePOList.stream().filter(linePO -> linePO.getPosition().equals(gridSideDictData.getId())).findFirst().orElse(null);
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.njcn.system.api.CsStatisticalSetFeignClient;
|
|||||||
import com.njcn.system.api.DicDataFeignClient;
|
import com.njcn.system.api.DicDataFeignClient;
|
||||||
import com.njcn.system.api.EpdFeignClient;
|
import com.njcn.system.api.EpdFeignClient;
|
||||||
import com.njcn.system.enums.DicDataEnum;
|
import com.njcn.system.enums.DicDataEnum;
|
||||||
|
import com.njcn.system.pojo.po.DictData;
|
||||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.influxdb.dto.QueryResult;
|
import org.influxdb.dto.QueryResult;
|
||||||
@@ -63,6 +64,8 @@ public class StableDataServiceImpl implements StableDataService {
|
|||||||
private final CsStatisticalSetFeignClient csStatisticalSetFeignClient;
|
private final CsStatisticalSetFeignClient csStatisticalSetFeignClient;
|
||||||
private final InfluxDbParamUtil influxDbParamUtil;
|
private final InfluxDbParamUtil influxDbParamUtil;
|
||||||
private final EquipmentFeignClient equipmentFeignClient;
|
private final EquipmentFeignClient equipmentFeignClient;
|
||||||
|
private final String GRID_SIDE_DICT_CODE = "Grid_Side";
|
||||||
|
private final String LOAD_SIDE_DICT_CODE = "Load_Side";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -251,56 +254,80 @@ public class StableDataServiceImpl implements StableDataService {
|
|||||||
if(CollectionUtil.isEmpty(csLinePOList)){
|
if(CollectionUtil.isEmpty(csLinePOList)){
|
||||||
throw new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR);
|
throw new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR);
|
||||||
}
|
}
|
||||||
String areaId = dicDataFeignClient.getDicDataByCode(DicDataEnum.OUTPUT_SIDE.getCode()).getData().getId();
|
DictData loadSideDictData = dicDataFeignClient.getDicDataByCode(LOAD_SIDE_DICT_CODE).getData();
|
||||||
Optional.ofNullable(csLinePOList).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
|
DictData gridSideDictData = dicDataFeignClient.getDicDataByCode(GRID_SIDE_DICT_CODE).getData();
|
||||||
List<CsLinePO> csLinePOList1 = csLinePOList.stream().filter(temp -> Objects.equals(areaId, temp.getPosition())).collect(Collectors.toList());
|
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();
|
List<EleEpdPqd> data = csStatisticalSetFeignClient.queryStatisticalSelect(Collections.singletonList(commonStatisticalQueryParam.getStatisticalId())).getData();
|
||||||
if(CollectionUtil.isNotEmpty(data)){
|
if(CollectionUtil.isNotEmpty(data)){
|
||||||
List<CsLinePO> finalCsLinePOList = csLinePOList;
|
|
||||||
data.forEach(epdPqd->{
|
data.forEach(epdPqd->{
|
||||||
String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse("");
|
String frequency = Optional.ofNullable(commonStatisticalQueryParam.getFrequency()).orElse("");
|
||||||
if(StringUtils.isEmpty(commonStatisticalQueryParam.getFrequency())){
|
if(StringUtils.isEmpty(commonStatisticalQueryParam.getFrequency())){
|
||||||
frequency ="";
|
frequency ="";
|
||||||
}else {
|
}else {
|
||||||
frequency = "_"+commonStatisticalQueryParam.getFrequency();
|
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);
|
|
||||||
}
|
}
|
||||||
commonQueryParam.setPhasic(epdPqd.getPhase());
|
String finalFrequency1 = frequency;
|
||||||
commonQueryParam.setStartTime(commonStatisticalQueryParam.getStartTime() + " 00:00:00");
|
List<CommonQueryParam> commonQueryParams = csLinePOList1.stream().map(temp -> {
|
||||||
commonQueryParam.setEndTime(commonStatisticalQueryParam.getEndTime() + " 23:59:59");
|
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
||||||
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType().toUpperCase());
|
commonQueryParam.setLineId(temp.getLineId());
|
||||||
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
|
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
|
||||||
commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(temp.getLineId()));
|
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;
|
return commonQueryParam;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
|
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
|
||||||
|
if (CollectionUtil.isNotEmpty(deviceRtData)) {
|
||||||
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
Map<String, List<StatisticalDataDTO> > map = deviceRtData.stream().collect(Collectors.groupingBy(StatisticalDataDTO::getLineId));
|
||||||
ThdDataVO vo = new ThdDataVO();
|
map.forEach((key, value) -> {
|
||||||
vo.setLineId(temp.getLineId());
|
if (!Objects.isNull(loadSideLine) && Objects.equals(key, loadSideLine.getLineId())) {
|
||||||
vo.setPhase(temp.getPhaseType());
|
List<ThdDataVO> collect1 = value.stream().map(temp -> {
|
||||||
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
ThdDataVO vo = new ThdDataVO();
|
||||||
vo.setPosition(position);
|
vo.setLineId(temp.getLineId());
|
||||||
vo.setTime(temp.getTime());
|
vo.setPhase(temp.getPhaseType());
|
||||||
vo.setStatMethod(temp.getValueType());
|
vo.setPosition(loadSideLine.getPosition());
|
||||||
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
vo.setTime(temp.getTime());
|
||||||
vo.setStatisticalIndex(epdPqd.getId());
|
vo.setStatMethod(temp.getValueType());
|
||||||
vo.setUnit(epdPqd.getUnit());
|
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
||||||
vo.setStatisticalName(epdPqd.getName());
|
vo.setStatisticalIndex(epdPqd.getId());
|
||||||
vo.setAnotherName(epdPqd.getShowName());
|
vo.setUnit(epdPqd.getUnit());
|
||||||
return vo;
|
vo.setStatisticalName(epdPqd.getName());
|
||||||
}).collect(Collectors.toList());
|
vo.setAnotherName("治理前");
|
||||||
result.addAll(collect1);
|
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;
|
return result;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
/**
|
/**
|
||||||
* @author xy
|
* @author xy
|
||||||
*/
|
*/
|
||||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/cslog", fallbackFactory = CsLogsClientFallbackFactory.class,contextId = "cslog")
|
@FeignClient(value = ServerInfo.CS_SYSTEM_BOOT, path = "/cslog", fallbackFactory = CsLogsClientFallbackFactory.class,contextId = "cslog")
|
||||||
public interface CsLogsFeignClient {
|
public interface CsLogsFeignClient {
|
||||||
|
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.njcn.csdevice.mapper.CsLogsPOMapper">
|
<mapper namespace="com.njcn.cssystem.mapper.CsLogsPOMapper">
|
||||||
<resultMap id="BaseResultMap" type="com.njcn.csdevice.pojo.po.CsLogsPO">
|
<resultMap id="BaseResultMap" type="com.njcn.cssystem.pojo.po.CsLogsPO">
|
||||||
<!--@mbg.generated-->
|
<!--@mbg.generated-->
|
||||||
<!--@Table cs_logs-->
|
<!--@Table cs_logs-->
|
||||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||||
Reference in New Issue
Block a user