diff --git a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/mysql/upload/impl/RUploadSubstationStatisticalDataDServiceImpl.java b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/mysql/upload/impl/RUploadSubstationStatisticalDataDServiceImpl.java index 634468671..edf292883 100644 --- a/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/mysql/upload/impl/RUploadSubstationStatisticalDataDServiceImpl.java +++ b/pqs-prepare/prepare-boot/src/main/java/com/njcn/prepare/harmonic/service/mysql/upload/impl/RUploadSubstationStatisticalDataDServiceImpl.java @@ -1,33 +1,29 @@ package com.njcn.prepare.harmonic.service.mysql.upload.impl; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.IdUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.device.biz.commApi.CommTerminalGeneralClient; import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO; -import com.njcn.device.biz.pojo.dto.DeptGetSubStationDTO; +import com.njcn.device.biz.pojo.dto.LineDevGetDTO; import com.njcn.device.biz.pojo.param.DeptGetLineParam; import com.njcn.device.pms.api.StatationStatClient; import com.njcn.device.pms.pojo.param.PmsStatationStatInfoParam; import com.njcn.device.pms.pojo.po.PmsMidLedger; import com.njcn.device.pms.pojo.po.StatationStat; -import com.njcn.harmonic.pojo.po.upload.RUploadPointStatisticalDataD; import com.njcn.harmonic.pojo.po.upload.RUploadSubstationStatisticalDataD; import com.njcn.prepare.harmonic.enums.UploadEnum; import com.njcn.prepare.harmonic.mapper.mysql.dim.PmsMidLedgerMapper; import com.njcn.prepare.harmonic.mapper.mysql.upload.RUploadSubstationStatisticalDataDMapper; import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam; import com.njcn.prepare.harmonic.service.mysql.upload.IRUploadSubstationStatisticalDataDService; -import com.njcn.system.enums.DicDataTypeEnum; -import com.njcn.system.pojo.po.DictData; import com.njcn.user.api.DeptFeignClient; import com.njcn.user.pojo.po.Dept; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.collections.CollectionUtils; import org.springframework.stereotype.Service; import java.util.*; @@ -50,6 +46,7 @@ public class RUploadSubstationStatisticalDataDServiceImpl extends MppServiceImpl private final DeptFeignClient deptFeignClient; private final StatationStatClient statationStatClient; private final PmsMidLedgerMapper pmsMidLedgerMapper; + private final CommTerminalGeneralClient commTerminalGeneralClient; @Override public void insertSubStatisticalDataDay(CalculatedParam calculatedParam) { List result = new ArrayList<>(); @@ -57,11 +54,20 @@ public class RUploadSubstationStatisticalDataDServiceImpl extends MppServiceImpl Dept data = deptFeignClient.getRootDept().getData(); String provinceId = deptFeignClient.getDepSonIdByDeptId(data.getId()).getData().get(0); Dept dept = deptFeignClient.getDeptById(provinceId).getData(); + //获取部门监测点关系 + DeptGetLineParam deptGetLineParam = new DeptGetLineParam(); + deptGetLineParam.setDeptId(data.getId()); + deptGetLineParam.setSystemType(0); + List deptGetChildrenList = commTerminalGeneralClient.deptGetLine(deptGetLineParam).getData(); + Map> deptChildren = deptGetChildrenList.stream().collect(Collectors.groupingBy(DeptGetChildrenMoreDTO::getUnitId)); //变电站id List subList = calculatedParam.getIdList(); - //获取变电站信息 + //获取监测变电站信息 List subInfo = getSubstationInfo(subList); Map> subMap = subInfo.stream().collect(Collectors.groupingBy(StatationStat::getOrgId)); + //获取中台变电站信息 + List midSubInfo = this.getSubstationInfo(); + Map> midSubMap = midSubInfo.stream().collect(Collectors.groupingBy(PmsMidLedger::getSectionId)); //获取所有部门单位信息 List deptList = deptFeignClient.getAllDept().getData(); Map> deptMap = deptList.stream().collect(Collectors.groupingBy(Dept::getCode)); @@ -75,8 +81,16 @@ public class RUploadSubstationStatisticalDataDServiceImpl extends MppServiceImpl rUploadSubstationStatisticalDataD.setProvinceId(dept.getCode()); rUploadSubstationStatisticalDataD.setProvinceName(dept.getName()); rUploadSubstationStatisticalDataD.setUploadStatus(Integer.parseInt(UploadEnum.UPLOAD_STATUS_0.getCode())); + //计算在线监测点数 + List l = deptChildren.get(k).get(0).getLineBaseList(); + if (CollUtil.isNotEmpty(l)){ + l = l.stream().filter(o->Objects.equals(o.getIsUpToGrid(),1)).collect(Collectors.toList()); + rUploadSubstationStatisticalDataD.setOnlineMonitorNum(l.size()); + } else { + rUploadSubstationStatisticalDataD.setOnlineMonitorNum(0); + } //处理层级关系 && 处理基础数据 - getDeptLevel(list,rUploadSubstationStatisticalDataD,deptList,deptMap,k,subMap); + this.getDeptLevel(list,rUploadSubstationStatisticalDataD,deptList,deptMap,k,subMap,midSubMap); result.add(rUploadSubstationStatisticalDataD); } }); @@ -120,13 +134,14 @@ public class RUploadSubstationStatisticalDataDServiceImpl extends MppServiceImpl * 判断当前部门的层级 * @return */ - public void getDeptLevel(List list, RUploadSubstationStatisticalDataD rUploadSubstationStatisticalDataD, List deptList, Map> map, String code, Map> subMap) { + public void getDeptLevel(List list, RUploadSubstationStatisticalDataD rUploadSubstationStatisticalDataD, List deptList, Map> map, String code, Map> subMap, Map> midSubMap) { switch (list.size()) { //省级 case 2: rUploadSubstationStatisticalDataD.setCityId(""); rUploadSubstationStatisticalDataD.setCountyId(""); int ct = 0; + int ct2 = 0; //处理基础数据 String i = deptList.stream().filter(o->Objects.equals(o.getCode(),code)).findAny().orElse(null).getId(); List cList = deptList.stream().filter(o->Objects.equals(o.getPid(),i)).map(Dept::getCode).collect(Collectors.toList()); @@ -138,13 +153,20 @@ public class RUploadSubstationStatisticalDataDServiceImpl extends MppServiceImpl if (CollectionUtil.isNotEmpty(l)){ ct = ct + l.size(); } - + List l2 = midSubMap.get(item); + if (CollectionUtil.isNotEmpty(l2)){ + ct2 = ct2 + l2.size(); + } } - rUploadSubstationStatisticalDataD.setSubstationCount(ct == 0 ? null:ct); + rUploadSubstationStatisticalDataD.setSubstationCount(ct2 == 0 ? null:ct2); + rUploadSubstationStatisticalDataD.setRunSubstationNum(ct2 == 0 ? null:ct2); + rUploadSubstationStatisticalDataD.setMonitorSubstaionNum(ct == 0 ? null:ct); + rUploadSubstationStatisticalDataD.setMonitoringRate(Objects.isNull(rUploadSubstationStatisticalDataD.getSubstationCount())?null:ct*1.0/rUploadSubstationStatisticalDataD.getSubstationCount()*100); break; //市级 case 3: int count = 0; + int count2 = 0; //处理层级 rUploadSubstationStatisticalDataD.setCityId(code); rUploadSubstationStatisticalDataD.setCityName(map.get(code).get(0).getName()); @@ -157,11 +179,19 @@ public class RUploadSubstationStatisticalDataDServiceImpl extends MppServiceImpl if (CollectionUtil.isNotEmpty(l)){ count = count + l.size(); } + List l2 = midSubMap.get(item); + if (CollectionUtil.isNotEmpty(l2)){ + count2 = count2 + l2.size(); + } } - rUploadSubstationStatisticalDataD.setSubstationCount(count == 0 ? null:count); + rUploadSubstationStatisticalDataD.setSubstationCount(count2 == 0 ? null:count2); + rUploadSubstationStatisticalDataD.setRunSubstationNum(count2 == 0 ? null:count2); + rUploadSubstationStatisticalDataD.setMonitorSubstaionNum(count == 0 ? null:count); + rUploadSubstationStatisticalDataD.setMonitoringRate(Objects.isNull(rUploadSubstationStatisticalDataD.getSubstationCount())?null:count*1.0/rUploadSubstationStatisticalDataD.getSubstationCount()*100); break; //县级 case 4: + int size = 0; //处理层级 String parentCode = deptList.stream().filter(o->Objects.equals(o.getId(),list.get(3))).findFirst().orElse(null).getCode(); rUploadSubstationStatisticalDataD.setCityId(parentCode); @@ -170,9 +200,18 @@ public class RUploadSubstationStatisticalDataDServiceImpl extends MppServiceImpl rUploadSubstationStatisticalDataD.setCountyName(map.get(code).get(0).getName()); //处理基础数据 List l = subMap.get(code); + List l2 = midSubMap.get(code); if (CollectionUtil.isNotEmpty(l)){ - rUploadSubstationStatisticalDataD.setSubstationCount(l.size()); + rUploadSubstationStatisticalDataD.setMonitorSubstaionNum(l.size()); + size = l.size(); + } else { + rUploadSubstationStatisticalDataD.setMonitorSubstaionNum(0); } + if (CollectionUtil.isNotEmpty(l2)){ + rUploadSubstationStatisticalDataD.setSubstationCount(l2.size()); + rUploadSubstationStatisticalDataD.setRunSubstationNum(l2.size()); + } + rUploadSubstationStatisticalDataD.setMonitoringRate(Objects.isNull(rUploadSubstationStatisticalDataD.getSubstationCount())?null: size * 1.0 / rUploadSubstationStatisticalDataD.getSubstationCount() * 100); break; default: break;