diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/CsGroupController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/CsGroupController.java index fdde7d1..50ebba5 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/CsGroupController.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/CsGroupController.java @@ -179,9 +179,5 @@ public class CsGroupController extends BaseController { Map> result = csGroupService.sensitiveUserTrendData(param); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } - - - - } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java index d0b46e9..2ae97db 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsGroupServiceImpl.java @@ -39,8 +39,10 @@ import com.njcn.csdevice.service.ICsLedgerService; import com.njcn.csdevice.util.InfluxDbParamUtil; import com.njcn.csdevice.utils.DataChangeUtil; import com.njcn.csharmonic.api.EventFeignClient; +import com.njcn.csharmonic.api.PqGovernPlanFeignClient; import com.njcn.csharmonic.constant.HarmonicConstant; import com.njcn.csharmonic.param.*; +import com.njcn.csharmonic.pojo.po.PqGovernPlan; import com.njcn.csharmonic.pojo.vo.ThdDataTdVO; import com.njcn.csharmonic.pojo.vo.ThdDataVO; import com.njcn.device.biz.mapper.OverLimitWlMapper; @@ -51,7 +53,6 @@ import com.njcn.influx.pojo.dto.StatisticalDataDTO; import com.njcn.influx.service.CommonService; import com.njcn.influx.service.EvtDataService; import com.njcn.system.api.*; -import com.njcn.system.pojo.po.DictData; import com.njcn.system.pojo.po.EleEpdPqd; import com.njcn.system.pojo.po.EleEvtParm; import com.njcn.system.pojo.vo.CsStatisticalSetVO; @@ -112,6 +113,7 @@ public class CsGroupServiceImpl extends ServiceImpl impl private final String GRID_SIDE_DICT_CODE = "Grid_Side"; private final String LOAD_SIDE_DICT_CODE = "Load_Side"; private final CsLinePOService csLinePOService; + private final PqGovernPlanFeignClient pqGovernPlanFeignClient; @Override @Transactional(rollbackFor = Exception.class) @@ -1336,12 +1338,10 @@ public class CsGroupServiceImpl extends ServiceImpl impl } result.put("before", new ArrayList<>()); result.put("after", new ArrayList<>()); - String sensitiveUserId = param.getSensitiveUserId(); - List linePOList = csLineFeignClient.getLinesByDevList(Collections.singletonList(sensitiveUserId)).getData(); - DictData loadSideDictData = dicDataFeignClient.getDicDataByCode(LOAD_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 loadSideLine = linePOList.stream().filter(linePO -> linePO.getPosition().equals(loadSideDictData.getId())).findFirst().orElse(null); + PqGovernPlan plan = pqGovernPlanFeignClient.getById(param.getSensitiveUserId()).getData(); + if (Objects.isNull(plan)) { + return result; + } TrendDataQueryParam trendDataQueryParam = new TrendDataQueryParam(); trendDataQueryParam.setSearchBeginTime(param.getSearchBeginTime()); trendDataQueryParam.setSearchEndTime(param.getSearchEndTime()); @@ -1357,17 +1357,14 @@ public class CsGroupServiceImpl extends ServiceImpl impl return queryParam; }).collect(Collectors.toList()); trendDataQueryParam.setList(indexList); - if (loadSideLine != null) { - trendDataQueryParam.setLineId(loadSideLine.getLineId()); - List thdDataList = this.trendData(trendDataQueryParam); - result.put("before", thdDataList); - } - if (gridSideLine != null) { - trendDataQueryParam.setLineId(gridSideLine.getLineId()); - List thdDataList = this.trendData(trendDataQueryParam); - result.put("after", thdDataList); - } - + //治理前 + trendDataQueryParam.setLineId(plan.getGovernBefore()); + List thdDataList1 = this.trendData(trendDataQueryParam); + result.put("before", thdDataList1); + //治理后 + trendDataQueryParam.setLineId(plan.getGovernAfter()); + List thdDataList2 = this.trendData(trendDataQueryParam); + result.put("after", thdDataList2); return result; } diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/api/PqGovernPlanFeignClient.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/api/PqGovernPlanFeignClient.java index b5fc1dc..c25f4d1 100644 --- a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/api/PqGovernPlanFeignClient.java +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/api/PqGovernPlanFeignClient.java @@ -9,6 +9,7 @@ import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @@ -27,4 +28,8 @@ public interface PqGovernPlanFeignClient { @ApiOperation("清空治理前后监测点数据") HttpResult> getListByMonitorPoint(@RequestBody List ids); + @GetMapping("/getById") + @ApiOperation("根据ID查询治理方案") + HttpResult getById(@RequestParam("id") String id); + } diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/api/fallback/PqGovernPlanClientFallbackFactory.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/api/fallback/PqGovernPlanClientFallbackFactory.java index 44eaea4..127efcb 100644 --- a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/api/fallback/PqGovernPlanClientFallbackFactory.java +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/api/fallback/PqGovernPlanClientFallbackFactory.java @@ -37,6 +37,12 @@ public class PqGovernPlanClientFallbackFactory implements FallbackFactory getById(String id) { + log.error("{}异常,降级处理,异常为:{}","根据ID查询治理方案异常",cause.toString()); + throw new BusinessException(finalExceptionEnum); + } }; } } diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/PqGovernPlanController.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/PqGovernPlanController.java index 1013eea..cae202e 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/PqGovernPlanController.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/PqGovernPlanController.java @@ -109,7 +109,7 @@ public class PqGovernPlanController extends BaseController { @ApiImplicitParam(name = "ids", value = "监测点id集合", required = true) public HttpResult> getListByMonitorPoint(@RequestBody List ids) { String methodDescribe = getMethodDescribe("clearGovernPoints"); - List result = pqGovernPlanService.getListByMonitorPoint(ids); + List result = pqGovernPlanService.getListByMonitorPoint(ids,null); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); } diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/IPqGovernPlanService.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/IPqGovernPlanService.java index f1a0938..25451b2 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/IPqGovernPlanService.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/IPqGovernPlanService.java @@ -67,6 +67,6 @@ public interface IPqGovernPlanService extends IService { * @param ids 监测点id集合 * @return 治理方案列表 */ - List getListByMonitorPoint(List ids); + List getListByMonitorPoint(List ids, String governType); } diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventUserPOServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventUserPOServiceImpl.java index 1ef19c3..a025b38 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventUserPOServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventUserPOServiceImpl.java @@ -457,7 +457,9 @@ public class CsEventUserPOServiceImpl extends ServiceImpl tempUid = (List) item.getUid().get(i); - if (item.getUid().get(i) instanceof List) { List rawList = (List) item.getUid().get(i); List tempUid = rawList.stream() @@ -214,8 +201,8 @@ public class LineTargetServiceImpl implements ILineTargetService { .collect(Collectors.toList()); String s = tempUid.get(tempUid.size() - 1); String[] tempTable = s.replace("$", "").split("#"); - result.add(getLineRtDataNew(item.getId(),item.getLineId(),tempTable[3],tempTable[0],Objects.equals(tempTable[1],"T")?"T":tempTable[1],tempTable[2],temp,item.getUnit().get(i))); -// result.add(getLineRtData(item.getId(),item.getLineId(),tempUid.get(3),tempUid.get(0),tempUid.get(1),tempUid.get(2).toUpperCase(),temp,"%")); + phasic = Objects.equals(tempTable[1],"M") ? "T" : tempTable[1]; + result.add(getLineRtDataNew(item.getId(),item.getLineId(),tempTable[3],tempTable[0],phasic,tempTable[2],temp,item.getUnit().get(i))); } } } diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/PqGovernPlanServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/PqGovernPlanServiceImpl.java index 37775fc..904d7df 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/PqGovernPlanServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/PqGovernPlanServiceImpl.java @@ -21,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -130,11 +131,14 @@ public class PqGovernPlanServiceImpl extends ServiceImpl getListByMonitorPoint(List ids) { + public List getListByMonitorPoint(List ids, String type) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.and(w -> w.in(PqGovernPlan::getGovernBefore, ids) .or() .in(PqGovernPlan::getGovernAfter, ids)); + if (!Objects.isNull(type)) { + wrapper.eq(PqGovernPlan::getGovernType, type); + } return this.list(wrapper); } diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/PqSensitiveUserServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/PqSensitiveUserServiceImpl.java index d5e5644..58936f1 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/PqSensitiveUserServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/PqSensitiveUserServiceImpl.java @@ -82,7 +82,7 @@ public class PqSensitiveUserServiceImpl extends ServiceImpl governPlans = pqGovernPlanService.getListByMonitorPoint(lineIds); + List governPlans = pqGovernPlanService.getListByMonitorPoint(lineIds,null); if (CollUtil.isEmpty(governPlans)) { return result; } @@ -115,7 +115,7 @@ public class PqSensitiveUserServiceImpl extends ServiceImpl governPlans = pqGovernPlanService.getListByMonitorPoint(lineIds); + List governPlans = pqGovernPlanService.getListByMonitorPoint(lineIds,null); if (CollUtil.isEmpty(governPlans)) { return result; } @@ -146,31 +146,33 @@ public class PqSensitiveUserServiceImpl extends ServiceImpl> getUserDevTree(String type) { Map> map = new LinkedHashMap<>(); - List userList = this.list(); - if (CollUtil.isNotEmpty(userList)) { - String governType = Objects.equals(type, "apf") ? "harmonic" : "event"; - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(PqGovernPlan::getGovernType, governType) - .orderByAsc(PqGovernPlan::getSort); - List planList = pqGovernPlanService.list(wrapper); - Map> planMap = new LinkedHashMap<>(); - if (CollUtil.isNotEmpty(planList)) { - planMap = planList.stream() - .collect(Collectors.groupingBy( - PqGovernPlan::getPid, - LinkedHashMap::new, - Collectors.toList() - )); - } - Map> finalPlanMap = planMap; - userList.forEach(item -> { - map.put(item.getName(), finalPlanMap.get(item.getId())); - }); + //根据用户获取监测点id + List lineIds = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData(); + if (CollUtil.isEmpty(lineIds)) { + return map; } + //根据监测点id获取治理用户 + String governType = Objects.equals(type, "apf") ? "harmonic" : "event"; + List governPlans = pqGovernPlanService.getListByMonitorPoint(lineIds,governType); + if (CollUtil.isEmpty(governPlans)) { + return map; + } + List userList = this.list(); + if (CollUtil.isEmpty(userList)) { + return map; + } + Map> planMap = governPlans.stream().collect(Collectors.groupingBy( + PqGovernPlan::getPid, + LinkedHashMap::new, + Collectors.toList() + )); + Map userMap = userList.stream().collect(Collectors.toMap(PqSensitiveUser::getId, item -> item)); + planMap.forEach((k,v)->{ + map.put(userMap.get(k).getName(), v); + }); return map; } - private void checkParam(PqSensitiveUserParam param,boolean update){ DictData data = dicDataFeignClient.getDicDataById(param.getLoadType()).getData(); if(Objects.isNull(data)){ diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/RStatLimitRateDServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/RStatLimitRateDServiceImpl.java index 0b5fd84..eaade2b 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/RStatLimitRateDServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/RStatLimitRateDServiceImpl.java @@ -177,26 +177,23 @@ public class RStatLimitRateDServiceImpl extends ServiceImpl ratePage = this.page(new Page(param.getPageNum(), param.getPageSize()), new LambdaQueryWrapper() - .eq(RStatLimitRateDPO::getPhasicType, "T") - .ge(StrUtil.isNotBlank(param.getSearchBeginTime()), RStatLimitRateDPO::getTime, param.getSearchBeginTime()) - .le(StrUtil.isNotBlank(param.getSearchEndTime()), RStatLimitRateDPO::getTime, param.getSearchEndTime()) - .in(RStatLimitRateDPO::getLineId, keywordsLineIds) - .groupBy(RStatLimitRateDPO::getLineId) - .select(RStatLimitRateDPO::getLineId) - ); - BeanUtil.copyProperties(ratePage, result); - List records = ratePage.getRecords(); - if (CollUtil.isEmpty(records)) { + // 按监测点总数手动分页,确保没有数据的监测点也能展示 + result.setTotal(keywordsLineIds.size()); + int fromIndex = (param.getPageNum() - 1) * param.getPageSize(); + if (fromIndex >= keywordsLineIds.size()) { return result; } + int toIndex = Math.min(fromIndex + param.getPageSize(), keywordsLineIds.size()); + List pageLineIds = new ArrayList<>(keywordsLineIds.subList(fromIndex, toIndex)); + List list = new ArrayList<>(); MainLineVO mainLineVO; - List devDetailDTOList = csCommTerminalFeignClient.getLedgerByLineId(keywordsLineIds).getData(); - Map devDetailDTOMap = devDetailDTOList.stream().collect(Collectors.toMap(DevDetailDTO::getLineId, item -> item)); + List devDetailDTOList = csCommTerminalFeignClient.getLedgerByLineId(pageLineIds).getData(); + Map devDetailDTOMap = CollUtil.isEmpty(devDetailDTOList) + ? Collections.emptyMap() + : devDetailDTOList.stream().collect(Collectors.toMap(DevDetailDTO::getLineId, item -> item)); //根据监测点获取治理方案 - List pqGovernPlans = pqGovernPlanFeignClient.getListByMonitorPoint(keywordsLineIds).getData(); + List pqGovernPlans = pqGovernPlanFeignClient.getListByMonitorPoint(pageLineIds).getData(); Map pqGovernPlanMap1 = Collections.emptyMap(); Map pqGovernPlanMap2 = Collections.emptyMap(); if (CollUtil.isNotEmpty(pqGovernPlans)) { @@ -204,14 +201,23 @@ public class RStatLimitRateDServiceImpl extends ServiceImpl item)); } - for (RStatLimitRateDPO record : records) { - String lineId = record.getLineId(); + for (String lineId : pageLineIds) { mainLineVO = new MainLineVO(); mainLineVO.setLineId(lineId); - mainLineVO.setEngineeringName(devDetailDTOMap.get(lineId).getEngineeringName()); - mainLineVO.setProjectName(devDetailDTOMap.get(lineId).getProjectName()); - mainLineVO.setDevName(devDetailDTOMap.get(lineId).getEquipmentName()); - mainLineVO.setLineName(devDetailDTOMap.get(lineId).getLineName()); + DevDetailDTO devDetailDTO = devDetailDTOMap.get(lineId); + if (devDetailDTO != null) { + mainLineVO.setEngineeringName(devDetailDTO.getEngineeringName()); + mainLineVO.setProjectName(devDetailDTO.getProjectName()); + mainLineVO.setDevName(devDetailDTO.getEquipmentName()); + mainLineVO.setLineName(devDetailDTO.getLineName()); + mainLineVO.setObjType(devDetailDTO.getObjType()); + if (ObjectUtil.isNotNull(devDetailDTO.getObjType())) { + DictData dictData = dicDataFeignClient.getDicDataById(devDetailDTO.getObjType()).getData(); + if (dictData != null) { + mainLineVO.setObjType(dictData.getName()); + } + } + } PqGovernPlan plan1 = pqGovernPlanMap1.get(lineId); if (!Objects.isNull(plan1)) { mainLineVO.setGovern(Objects.isNull(plan1.getGovernMethod()) ? "未治理" : plan1.getGovernMethod()); @@ -220,13 +226,6 @@ public class RStatLimitRateDServiceImpl extends ServiceImpl { EleEpdTreeVO reportTreeVO = new EleEpdTreeVO(); - reportTreeVO.setName(value.get(0).getName()); + if (Objects.isNull(value.get(0).getOtherName())) { + reportTreeVO.setName(value.get(0).getName()); + } else { + reportTreeVO.setName(value.get(0).getOtherName()); + } reportTreeVO.setShowName(value.get(0).getShowName()); //存在1-50次 2-50次情况 @@ -57,7 +61,7 @@ public class EleEpdPqdServiceImpl extends ServiceImpl reHarm = new ArrayList<>(); for (int i = value.get(0).getHarmStart(); i <= value.get(0).getHarmEnd(); i++) { EleEpdTreeVO reportTreeCount = new EleEpdTreeVO(); - reportTreeCount.setName(value.get(0).getName() + "_" + i); + reportTreeCount.setName(reportTreeVO.getName() + "_" + i); reportTreeCount.setShowName(i + "次" + value.get(0).getShowName()); reportTreeVO.setFlag(1); assPhase(value, reportTreeCount, reportTreeCount.getName()); @@ -65,7 +69,7 @@ public class EleEpdPqdServiceImpl extends ServiceImpl