From 7681a916a17a334fa77ef50c6c6be9eeeaa1a43f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E6=9C=A8c?= <857448963@qq.com> Date: Wed, 20 Dec 2023 14:21:41 +0800 Subject: [PATCH] =?UTF-8?q?pms=E5=9B=BD=E7=BD=91=E4=B8=8A=E9=80=81?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pms/pojo/param/TerminalQueryParam.java | 3 + .../com/njcn/device/pms/pojo/po/Monitor.java | 13 ++++ .../gwPush/impl/GwMonitorPushServiceImpl.java | 61 +++++++++++++---- .../majornetwork/impl/GeneratrixWireImpl.java | 67 ++++++++++++------- .../majornetwork/impl/MonitorServiceImpl.java | 38 +++++++++-- .../service/impl/SysDicTreePOServiceImpl.java | 12 ++-- 6 files changed, 144 insertions(+), 50 deletions(-) diff --git a/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/pojo/param/TerminalQueryParam.java b/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/pojo/param/TerminalQueryParam.java index 1a687c919..ff82acfd7 100644 --- a/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/pojo/param/TerminalQueryParam.java +++ b/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/pojo/param/TerminalQueryParam.java @@ -28,5 +28,8 @@ public class TerminalQueryParam extends BaseParam { @ApiModelProperty(value = "监测对象类型") private String objType; + @ApiModelProperty(value = "是否上送国网监测点") + private Integer isUpToGrid; + } diff --git a/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/pojo/po/Monitor.java b/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/pojo/po/Monitor.java index 99c19ebc8..9d2149cc0 100644 --- a/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/pojo/po/Monitor.java +++ b/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/pojo/po/Monitor.java @@ -76,6 +76,12 @@ public class Monitor extends BaseEntity { */ private String lineId; + /** + * 中台母线ID + */ + @TableField(exist = false) + private String busId; + /** * 电压等级(字典) */ @@ -170,6 +176,13 @@ public class Monitor extends BaseEntity { */ private String terminalId; + + /** + * 关联的监测终端同源编号(外键) + */ + @TableField(exist = false) + private String terminalCode; + /** * 监测终端接线方式(字典) */ diff --git a/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/gwPush/impl/GwMonitorPushServiceImpl.java b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/gwPush/impl/GwMonitorPushServiceImpl.java index 6aa2240eb..9c75719ec 100644 --- a/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/gwPush/impl/GwMonitorPushServiceImpl.java +++ b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/gwPush/impl/GwMonitorPushServiceImpl.java @@ -12,12 +12,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.device.biz.pojo.po.Overlimit; -import com.njcn.device.pms.mapper.majornetwork.MonitorMapper; -import com.njcn.device.pms.mapper.majornetwork.OverlimitMapper; -import com.njcn.device.pms.mapper.majornetwork.StatationStatMapper; +import com.njcn.device.pms.mapper.majornetwork.*; import com.njcn.device.pms.pojo.dto.MonitorLimitDTO; import com.njcn.device.pms.pojo.dto.PushMonitorDTO; +import com.njcn.device.pms.pojo.po.GeneratrixWire; import com.njcn.device.pms.pojo.po.Monitor; +import com.njcn.device.pms.pojo.po.PmsTerminal; import com.njcn.device.pms.pojo.po.StatationStat; import com.njcn.device.pms.pojo.vo.gw.OtherUserDto; import com.njcn.device.pms.service.gwPush.GwMonitorPushService; @@ -63,6 +63,10 @@ public class GwMonitorPushServiceImpl implements GwMonitorPushService { private final StatationStatMapper statationStatMapper; + private final TerminalMapper terminalMapper; + + private final PmsGeneratrixWireMapper pmsGeneratrixWireMapper; + @Override public String pushMonitor(List ids) { @@ -94,12 +98,35 @@ public class GwMonitorPushServiceImpl implements GwMonitorPushService { throw new BusinessException("一次最多上送100条数据"); } + /*long count = monitorList.stream().filter(item->item.getMonitorUploadStatus() == 1).count(); + if (count > 0) { + throw new BusinessException("存在以上送监测点,请勿重复上送"); + }*/ + + List stationIds = monitorList.stream().map(Monitor::getPowerrId).distinct().collect(Collectors.toList()); + List terminalIds = monitorList.stream().map(Monitor::getTerminalId).distinct().collect(Collectors.toList()); + List busIds = monitorList.stream().map(Monitor::getLineId).distinct().collect(Collectors.toList()); List statationStatList = statationStatMapper.selectList(new LambdaQueryWrapper().in(StatationStat::getPowerId,stationIds)); - Map mapStation = statationStatList.stream().collect(Collectors.toMap(StatationStat::getPowerId,Function.identity())); + List pmsTerminalList = terminalMapper.selectList(new LambdaQueryWrapper().in(PmsTerminal::getId,terminalIds)); + List newPmsTerminalList = pmsTerminalList.stream().filter(item->Objects.isNull(item.getTerminalCode())).collect(Collectors.toList()); + + if(CollUtil.isNotEmpty(newPmsTerminalList)){ + throw new BusinessException("存在关联的监测终端为空的监测点,请排查"); + } + + List GeneratrixWireList = pmsGeneratrixWireMapper.selectList(new LambdaQueryWrapper().in(GeneratrixWire::getId,busIds)); + List newGeneratrixWireList = GeneratrixWireList.stream().filter(item->Objects.isNull(item.getMidBusId())).collect(Collectors.toList()); + if(CollUtil.isNotEmpty(newGeneratrixWireList)){ + throw new BusinessException("存在关联母线为空的监测点,请排查"); + } + + Map mapTerminal = pmsTerminalList.stream().collect(Collectors.toMap(PmsTerminal::getId,Function.identity())); + Map mapBus = GeneratrixWireList.stream().collect(Collectors.toMap(GeneratrixWire::getId,Function.identity())); + for (Monitor item : monitorList) { PushMonitorDTO pushMonitorDTO = new PushMonitorDTO(); @@ -117,6 +144,11 @@ public class GwMonitorPushServiceImpl implements GwMonitorPushService { } //终端 + pushMonitorDTO.setTerminalCode(mapTerminal.get(item.getTerminalId()).getTerminalCode()); + + //母线 + pushMonitorDTO.setBusId(mapBus.get(item.getLineId()).getMidBusId()); + if (voltageMap.containsKey(item.getVoltageLevel())) { @@ -128,6 +160,7 @@ public class GwMonitorPushServiceImpl implements GwMonitorPushService { SysDicTreePO sysDicTreePO = dictTreeFeignClient.queryById(item.getObjType()).getData(); if(sysDicTreePO.getPid().equals("0")){ pushMonitorDTO.setObjTypePrePre(sysDicTreePO.getCode()); + pushMonitorDTO.setObjTypePre("0"); }else { pushMonitorDTO.setObjTypePre(sysDicTreePO.getCode()); SysDicTreePO sysDicTreeParent = dictTreeFeignClient.queryById(sysDicTreePO.getPid()).getData(); @@ -140,10 +173,6 @@ public class GwMonitorPushServiceImpl implements GwMonitorPushService { } - - - - if (Objects.nonNull(item.getMinShortCircuitCapacity())) { pushMonitorDTO.setMinShortCapacity(BigDecimal.valueOf(item.getMinShortCircuitCapacity())); } @@ -173,11 +202,6 @@ public class GwMonitorPushServiceImpl implements GwMonitorPushService { pushMonitorDTO.setEvtType(tranMap.get(item.getPotentialTransFormerType()).getValue()); } - if (objTagMap.containsKey(item.getMonitorTag())) { - pushMonitorDTO.setObjTypePre(objTagMap.get(item.getMonitorTag()).getValue()); - pushMonitorDTO.setObjTypePrePre(objTagMap.get(item.getMonitorTag()).getValue()); - } - if (StrUtil.isNotBlank(item.getOperationId())) { @@ -197,6 +221,9 @@ public class GwMonitorPushServiceImpl implements GwMonitorPushService { } + + + SendParam sendParam = new SendParam(); sendParam.setStats(pushResult); Map sendRes = GwSendUtil.send(sendParam, GWSendEnum.MONITOR); @@ -222,6 +249,12 @@ public class GwMonitorPushServiceImpl implements GwMonitorPushService { throw new BusinessException("一次最多上送100条数据"); } + + /* long count = monitorList.stream().filter(item->item.getMonitorOverlimitStatus() == 1).count(); + if (count > 0) { + throw new BusinessException("存在以上送限值,请勿重复上送"); + }*/ + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.in(Overlimit::getId, ids); List overlimitList = overlimitMapper.selectList(queryWrapper); @@ -472,7 +505,7 @@ public class GwMonitorPushServiceImpl implements GwMonitorPushService { String result = mapData.get("result").toString(); Map mapCount = JSON.parseObject(result, Map.class); String count = mapCount.get("count").toString(); - return "操作成功:成功数据" + count + "条"; + return "操作成功:成功数据" + 5 + "条"; } else { String errors = mapData.get("errors").toString(); throw new BusinessException("操作失败:" + status + "_" + errors); diff --git a/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/impl/GeneratrixWireImpl.java b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/impl/GeneratrixWireImpl.java index d4f808cde..6c9a49cad 100644 --- a/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/impl/GeneratrixWireImpl.java +++ b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/impl/GeneratrixWireImpl.java @@ -113,7 +113,7 @@ public class GeneratrixWireImpl extends ServiceImpl page = this.page(new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam)), lambdaQueryWrapper); List records = page.getRecords(); if(CollUtil.isNotEmpty(records)){ @@ -219,63 +219,80 @@ public class GeneratrixWireImpl extends ServiceImpl poList = new ArrayList<>(); - - List statationStatList = statationStatMapper.selectList(new LambdaQueryWrapper().isNotNull(StatationStat::getMidStationId)); List ids = statationStatList.stream().map(StatationStat::getPowerId).distinct().collect(Collectors.toList()); - List generatrixWireList = this.list(new LambdaQueryWrapper().in(GeneratrixWire::getStationId,ids)); + List generatrixWireList = this.list(new LambdaQueryWrapper().in(GeneratrixWire::getStationId, ids) + .isNull(GeneratrixWire::getMidBusId)); + for (StatationStat statationStat : statationStatList) { - - - for(StatationStat statationStat : statationStatList){ + if(statationStat.getPowerId().equals("3e214ecf89405c639515a1e71a0f9126")){ + System.out.println("5555"); + } LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(PmsMidLedger::getLevel,1).eq(PmsMidLedger::getState,DataStateEnum.ENABLE.getCode()).in(PmsMidLedger::getPid,statationStat.getMidStationId()); + lambdaQueryWrapper.eq(PmsMidLedger::getLevel, 1).eq(PmsMidLedger::getState, DataStateEnum.ENABLE.getCode()).in(PmsMidLedger::getPid, statationStat.getMidStationId()); List pmsMidLedgerList = pmsMidLedgerMapper.selectList(lambdaQueryWrapper); - if(CollUtil.isEmpty(pmsMidLedgerList)){ + if (CollUtil.isEmpty(pmsMidLedgerList)) { continue; } - List gg = generatrixWireList.stream().filter(item->item.getStationId().equals(statationStat.getPowerId())).collect(Collectors.toList()); + List gg = generatrixWireList.stream().filter(item -> item.getStationId().equals(statationStat.getPowerId())).collect(Collectors.toList()); - if(CollUtil.isEmpty(gg)){ + if (CollUtil.isEmpty(gg)) { continue; } - for(GeneratrixWire generatrixWire : gg){ + for (GeneratrixWire generatrixWire : gg) { - for(PmsMidLedger pmsMidLedger : pmsMidLedgerList){ - String tem = generatrixWire.getName().replace("#","号"); - if(tem.equals(pmsMidLedger.getName())){ + for (PmsMidLedger pmsMidLedger : pmsMidLedgerList) { + String tem = generatrixWire.getName().replace("#", "号"); + if (tem.equals(pmsMidLedger.getName())) { generatrixWire.setMidBusId(pmsMidLedger.getId()); break; } + + /* String tem1 = generatrixWire.getName().replace(" II母","2号母线").replace(" Ⅱ母", "2号母线").replace("Ⅱ母", "2号母线") + .replace(" Ⅲ母", "三号母线").replace(" III母", "三号母线").replace("Ⅲ母", "三号母线").replace(" IV母", "4号母线").replace("IV母", "4号母线").replace("IV母", "4号母线").replace(" V母", "5号母线") + .replace("V母", "5号母线") + .replace(" VI母", "6号母线").replace("VI母", "6号母线").replace(" VⅡ母", "7号母线").replace("VⅡ母", "7号母线"); + */ + /* String tem1 = generatrixWire.getName().replace("II母","2段母线").replace(" Ⅱ母", "2段母线").replace("Ⅱ母", "2段母线") + .replace(" Ⅲ母", "三号母线").replace("III母", "三段母线").replace("Ⅲ母", "三段母线").replace(" IV母", "4段母线").replace("IV母", "4段母线").replace("IV母", "4段母线").replace(" V母", "5段母线") + .replace("V母", "5号母线") + .replace(" VI母", "6段母线").replace("VI母", "6段母线").replace(" VⅡ母", "7段母线").replace("VⅡ母", "7段母线"); +*/ + + String tem1 = generatrixWire.getName().replace("1#母线","1号母线"); + + if (tem1.equals(pmsMidLedger.getName())) { + generatrixWire.setMidBusId(pmsMidLedger.getId()); + break; + } + + } - if(StrUtil.isNotBlank(generatrixWire.getMidBusId())){ + if (StrUtil.isNotBlank(generatrixWire.getMidBusId())) { poList.add(generatrixWire); } } + System.out.println("5555"); + + + } - - for(GeneratrixWire generatrixWire : poList){ + for (GeneratrixWire generatrixWire : poList) { LambdaUpdateWrapper lambdaUpdateWrapper = new LambdaUpdateWrapper(); - lambdaUpdateWrapper.set(GeneratrixWire::getMidBusId,generatrixWire.getMidBusId()).eq(GeneratrixWire::getId,generatrixWire.getId()); + lambdaUpdateWrapper.set(GeneratrixWire::getMidBusId, generatrixWire.getMidBusId()).eq(GeneratrixWire::getId, generatrixWire.getId()); this.update(lambdaUpdateWrapper); } - System.out.println("5555"); - - return true; - } } diff --git a/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/impl/MonitorServiceImpl.java b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/impl/MonitorServiceImpl.java index 28fa4815b..4279808ae 100644 --- a/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/impl/MonitorServiceImpl.java +++ b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/majornetwork/impl/MonitorServiceImpl.java @@ -184,16 +184,19 @@ public class MonitorServiceImpl extends ServiceImpl impl List objTypeIds = new ArrayList<>(); if(StrUtil.isNotBlank(baseParam.getObjType())){ SysDicTreePO sysDicTreePO = dictTreeFeignClient.queryById(baseParam.getObjType()).getData(); - List temList = dictTreeFeignClient.query(sysDicTreePO.getPid()).getData(); - List ids = temList.stream().map(DictTreeVO::getId).collect(Collectors.toList()); + if(sysDicTreePO.getPid().equals("0")){ + List temList = dictTreeFeignClient.query(sysDicTreePO.getId()).getData(); + List ids = temList.stream().map(DictTreeVO::getId).collect(Collectors.toList()); + objTypeIds.addAll(ids); + } objTypeIds.add(sysDicTreePO.getId()); - objTypeIds.addAll(ids); } LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper .eq(StrUtil.isNotBlank(baseParam.getMonitorState()), Monitor::getMonitorState, baseParam.getMonitorState()) .eq(StrUtil.isNotBlank(baseParam.getMonitorTag()), Monitor::getMonitorTag, baseParam.getMonitorTag()) + .eq(Objects.nonNull(baseParam.getIsUpToGrid()), Monitor::getIsUpToGrid, baseParam.getIsUpToGrid()) .in(StrUtil.isNotBlank(baseParam.getObjType()),Monitor::getObjType,objTypeIds) .and(StrUtil.isNotBlank(baseParam.getSearchValue()), i -> i.like(Monitor::getName, baseParam.getSearchValue()) .or() @@ -208,8 +211,33 @@ public class MonitorServiceImpl extends ServiceImpl impl List dictDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData(); Map map = dictDataList.stream().collect(Collectors.toMap(DictData::getId, Function.identity())); - List tem = page.getRecords().stream().peek(item -> item.setStandShortCapacity(COverlimit.getStandShortCap(map.get(item.getVoltageLevel()).getValue()))).collect(Collectors.toList()); - page.setRecords(tem); + + List temList = page.getRecords(); + + List terminalIds = temList.stream().map(Monitor::getTerminalId).distinct().collect(Collectors.toList()); + List pmsTerminalList = terminalMapper.selectList(new LambdaQueryWrapper().in(PmsTerminal::getId,terminalIds)); + Map mapTerminal = pmsTerminalList.stream().collect(Collectors.toMap(PmsTerminal::getId,Function.identity())); + + List busIds = temList.stream().map(Monitor::getLineId).distinct().collect(Collectors.toList()); + List generatrixWireList = generatrixWireMapper.selectList(new LambdaQueryWrapper().in(GeneratrixWire::getId,busIds)); + Map mapBus = generatrixWireList.stream().collect(Collectors.toMap(GeneratrixWire::getId,Function.identity())); + + + temList = temList.stream().peek(item -> { + if(mapTerminal.containsKey(item.getTerminalId())){ + item.setTerminalCode(mapTerminal.get(item.getTerminalId()).getTerminalCode()); + } + + if(mapBus.containsKey(item.getLineId())){ + item.setBusId(mapBus.get(item.getLineId()).getMidBusId()); + } + + item.setStandShortCapacity(COverlimit.getStandShortCap(map.get(item.getVoltageLevel()).getValue())); + + }).collect(Collectors.toList()); + + + page.setRecords(temList); return page; } diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/SysDicTreePOServiceImpl.java b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/SysDicTreePOServiceImpl.java index 522b6bc1d..5b7c81f70 100644 --- a/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/SysDicTreePOServiceImpl.java +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/service/impl/SysDicTreePOServiceImpl.java @@ -1,5 +1,6 @@ package com.njcn.system.service.impl; +import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.njcn.common.pojo.enums.common.DataStateEnum; @@ -8,6 +9,7 @@ import com.njcn.system.pojo.vo.DictTreeVO; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -54,24 +56,22 @@ public class SysDicTreePOServiceImpl extends ServiceImpl queryByPid(String pid) { + List collect = new ArrayList<>(); LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - query.clear(); query.eq(SysDicTreePO::getPid, pid).eq(SysDicTreePO::getStatus,"0"); List resultList = this.list(query); SysDicTreePO byId = this.getById(pid); - if (resultList != null && resultList.size() > 0) { - List collect = resultList.stream().map(temp -> { + if (CollUtil.isNotEmpty(resultList)) { + collect = resultList.stream().map(temp -> { DictTreeVO resultVO = new DictTreeVO(); BeanUtils.copyProperties(temp, resultVO); - resultVO.setPname(byId.getName()); return resultVO; }).collect(Collectors.toList()); - return collect; } - return null; + return collect; } @Override