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