diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/controller/DeptLineController.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/controller/DeptLineController.java index 6d35187f9..46da5156d 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/controller/DeptLineController.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/controller/DeptLineController.java @@ -168,10 +168,10 @@ public class DeptLineController extends BaseController { @OperateInfo(info = LogEnum.SYSTEM_COMMON) @PostMapping("/getAllData") - @ApiOperation("获取部门监测点表所有数据") + @ApiOperation("获取部门监测点表数据(仅查询在运监测点)") public HttpResult> getAllData() { String methodDescribe = getMethodDescribe("getAllData"); - List list = deptLineMapper.selectList(null); + List list = deptLineMapper.getOnlineMonitor(); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); } } diff --git a/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/mapper/DeptLineMapper.java b/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/mapper/DeptLineMapper.java index 9a50f5355..e600def5d 100644 --- a/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/mapper/DeptLineMapper.java +++ b/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/mapper/DeptLineMapper.java @@ -95,4 +95,6 @@ public interface DeptLineMapper extends BaseMapper { List selectSubStationList(@Param("param") SubstationParam substationParam); List getLineByDeptIdAndNewStation(@Param("ids") List id,@Param("dictTree")List dictTree); + + List getOnlineMonitor(); } diff --git a/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/mapper/mapping/DeptLineMapper.xml b/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/mapper/mapping/DeptLineMapper.xml index e1e2e7bb2..9b7791ac4 100644 --- a/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/mapper/mapping/DeptLineMapper.xml +++ b/pqs-device/pq-device/pq-device-com/src/main/java/com/njcn/device/line/mapper/mapping/DeptLineMapper.xml @@ -300,4 +300,16 @@ + + + diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/impl/LineWarningServiceImpl.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/impl/LineWarningServiceImpl.java index 4df00b9fe..1accb1f2c 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/impl/LineWarningServiceImpl.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/impl/LineWarningServiceImpl.java @@ -160,12 +160,15 @@ public class LineWarningServiceImpl extends MppServiceImpl result = new ArrayList<>(); + List channelData = new ArrayList<>(); //获取指标集合(10个指标) List dataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.STEADY_STATIS.getCode()).getData(); Map targetMap = dataList.stream().collect(Collectors.toMap(DictData::getCode, Function.identity())); //获取监测点和部门表关系 List deptLines = deptLineFeignClient.getAllData().getData(); - Map> deptLineMap = deptLines.stream().collect(Collectors.groupingBy(DeptLine::getLineId)); +// Map> deptLineMap = deptLines.stream().collect(Collectors.groupingBy(DeptLine::getLineId)); + Map deptLineMap = deptLines.stream().collect(Collectors.toMap(DeptLine::getLineId, Function.identity())); + //获取监测点按时间统计越限天数 LocalDate firstDayOfMonth = Objects.isNull(startTime) ? LocalDate.now().minusDays(1).with(TemporalAdjusters.firstDayOfMonth()) : LocalDate.parse(startTime); String date = Objects.isNull(startTime) ? DateUtil.format(firstDayOfMonth.atStartOfDay(), DatePattern.NORM_DATE_PATTERN) : startTime; @@ -175,7 +178,7 @@ public class LineWarningServiceImpl extends MppServiceImpl { - String deptId = Objects.isNull(deptLineMap.get(item.getLineId())) ? null : deptLineMap.get(item.getLineId()).get(0).getId(); + String deptId = Objects.isNull(deptLineMap.get(item.getLineId())) ? null : deptLineMap.get(item.getLineId()).getId(); //频率偏差 LineWarning l1 = overData(firstDayOfMonth, item.getLineId(), deptId, targetMap.get(DicDataEnum.FREQUENCY_DEV.getCode()).getId(), item.getFreqDevOvertime()); //电压偏差 @@ -206,7 +209,7 @@ public class LineWarningServiceImpl extends MppServiceImpl list = lineIntegrityClient.getNoData(param).getData(); if (CollUtil.isNotEmpty(list)) { list.forEach(item -> { - String deptId = Objects.isNull(deptLineMap.get(item.getLineId())) ? null : deptLineMap.get(item.getLineId()).get(0).getId(); + String deptId = Objects.isNull(deptLineMap.get(item.getLineId())) ? null : deptLineMap.get(item.getLineId()).getId(); LineWarning lineWarning = new LineWarning(); lineWarning.setAlarmTime(firstDayOfMonth); lineWarning.setDeptId(deptId); @@ -220,7 +223,7 @@ public class LineWarningServiceImpl extends MppServiceImpl list2 = pqDataVerifyCountClient.getAnomalousData(param).getData(); if (CollUtil.isNotEmpty(list2)) { list2.forEach(item -> { - String deptId = Objects.isNull(deptLineMap.get(item.getLineId())) ? null : deptLineMap.get(item.getLineId()).get(0).getId(); + String deptId = Objects.isNull(deptLineMap.get(item.getLineId())) ? null : deptLineMap.get(item.getLineId()).getId(); LineWarning lineWarning = new LineWarning(); lineWarning.setAlarmTime(firstDayOfMonth); lineWarning.setDeptId(deptId); @@ -230,8 +233,37 @@ public class LineWarningServiceImpl extends MppServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.between(LineWarning::getAlarmTime,date,endDate); + List oldData = this.list(lambdaQueryWrapper); + if (CollUtil.isNotEmpty(oldData) && CollUtil.isNotEmpty(result)) { + // 创建结果数据的查找Map + Map resultMap = result.stream() + .collect(Collectors.toMap( + item -> buildKey(item.getDeptId(), item.getLineId(), item.getTargetType()), + Function.identity() + )); + for (LineWarning oldItem : oldData) { + String key = buildKey(oldItem.getDeptId(), oldItem.getLineId(), oldItem.getTargetType()); + LineWarning matchingResult = resultMap.get(key); + if (matchingResult != null) { + oldItem.setOverLimitDay(matchingResult.getOverLimitDay()); + oldItem.setUpdateTime(LocalDateTime.now()); + channelData.add(oldItem); + } + } + } + if (CollUtil.isNotEmpty(channelData)) { + this.saveOrUpdateBatchByMultiId(channelData); + } else { + this.saveOrUpdateBatchByMultiId(result); + } + } - this.saveOrUpdateBatchByMultiId(result); + + private static String buildKey(String deptId, String lineId, String targetType) { + return deptId + "|" + lineId + "|" + targetType; } @Override