1.国网上送数据增加非空判断

2.调整国网上送主网监测点统计和典型源荷统计的算法逻辑
This commit is contained in:
wr
2024-03-14 11:28:30 +08:00
parent 0316e9d40e
commit fb8d02cd7e
7 changed files with 128 additions and 11 deletions

View File

@@ -35,6 +35,7 @@
FROM
pq_typical_source_create
<where>
AND compute_date is not null
<if test="param.provinceId != null and param.provinceId != '' ">
AND provinceId = #{param.provinceId}
</if>
@@ -115,6 +116,7 @@
FROM
pq_typical_source_create
<where>
AND compute_date is not null
<if test="param.provinceId != null and param.provinceId != '' ">
AND provinceId = #{param.provinceId}
</if>

View File

@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO;
@@ -146,7 +147,7 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
case "1402":
rUploadPointStatisticalDataD.setStationType(dictDataMap.get(DicDataEnum.Power_Station.getCode()).getId());
break;
case "2600":
case "2300":
rUploadPointStatisticalDataD.setStationType(dictDataMap.get(DicDataEnum.Smelting_Load.getCode()).getId());
break;
case "2400":
@@ -274,13 +275,7 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
String endTime = DateUtil.format(DateUtil.endOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN);
//数据集
List<RUploadPointStatisticalDataD> list = this.baseMapper.pointStatisticalMonthData(beginMonth,startTime,endTime,"02");
if (CollUtil.isNotEmpty(list)){
list.forEach(item->{
item.setId(IdUtil.simpleUUID());
item.setComputeDate(calculatedParam.getDataDate());
});
this.saveOrUpdateBatchByMultiId(list,1000);
}
dataProcessing(calculatedParam,list);
}
@Override
@@ -293,6 +288,115 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
String endTime = DateUtil.format(DateUtil.endOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN);
//数据集
List<RUploadPointStatisticalDataD> list = this.baseMapper.pointStatisticalMonthData(beginMonth,startTime,endTime,"01");
dataProcessing(calculatedParam,list);
}
/**
*
* @param calculatedParam
* @param list 数据处理
*/
private void dataProcessing(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam,List<RUploadPointStatisticalDataD> list) {
//数据分组
Map<String, List<RUploadPointStatisticalDataD>> listMap = list.stream().collect(Collectors.groupingBy(x -> x.getProvinceId() + x.getCityId() + x.getCountyId()));
//获取省级单位id
Dept root = deptFeignClient.getRootDept().getData();
String provinceId = deptFeignClient.getDepSonIdByDeptId(root.getId()).getData().get(0);
Dept dept = deptFeignClient.getDeptById(provinceId).getData();
//获取所有单位
List<Dept> deptList = deptFeignClient.getAllDept().getData();
Map<String, List<Dept>> deptMap = deptList.stream().collect(Collectors.groupingBy(Dept::getCode));
//查询所有一级树字典
List<SysDicTreePO> sysDicTreePOList = dictTreeFeignClient.queryAll().getData();
List<SysDicTreePO> temTreeList = sysDicTreePOList.stream().filter(item -> Objects.equals(item.getCode(), DicTreeEnum.Trans_Sub.getCode())
|| Objects.equals(item.getCode(), DicTreeEnum.Converter.getCode()) || Objects.equals(item.getCode(), DicTreeEnum.Ele_Railways.getCode())
|| Objects.equals(item.getCode(), DicTreeEnum.Wind_Farms.getCode()) || Objects.equals(item.getCode(), DicTreeEnum.Power_Station.getCode())
|| Objects.equals(item.getCode(), DicTreeEnum.Smelting_Load.getCode()) || Objects.equals(item.getCode(), DicTreeEnum.Imp_Users.getCode())
).collect(Collectors.toList());
//站别大类
List<DictData> dictDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.Station_Type.getCode()).getData();
Map<String,DictData> dictDataMap = dictDataList.stream().collect(Collectors.toMap(DictData::getCode,Function.identity()));
//获取对象类型下字类型
Map<String,List<String>> mapKey = new HashMap<>();
List<String> otherIds = new ArrayList<>();
for(SysDicTreePO sysDicTreePO : temTreeList){
List<SysDicTreePO> temList = sysDicTreePOList.stream().filter(item->item.getPid().equals(sysDicTreePO.getId())).collect(Collectors.toList());
List<String> ids = temList.stream().map(SysDicTreePO::getId).distinct().collect(Collectors.toList());
ids.add(sysDicTreePO.getId());
mapKey.put(sysDicTreePO.getCode(),ids);
otherIds.addAll(ids);
}
RUploadPointStatisticalDataD data;
for (DeptGetChildrenMoreDTO item : calculatedParam.getIdList()) {
//获取国网上送监测点
List<LineDevGetDTO> temBaseList = item.getLineBaseList().stream().filter(o -> Objects.equals(o.getIsUpToGrid(), 1)).collect(Collectors.toList());
long monitorCount = temBaseList.stream().map(LineDevGetDTO::getPointId).distinct().count();
long devCount = temBaseList.stream().map(LineDevGetDTO::getDevId).distinct().count();
//其他类型
List<LineDevGetDTO> otherMonitor = item.getLineBaseList().stream().filter(me->!otherIds.contains(me.getObjType())).collect(Collectors.toList());
data=new RUploadPointStatisticalDataD();
data.setProvinceId(dept.getCode());
data.setProvinceName(dept.getName());
judgeLevel(item.getDeptLevel(), data, item.getUnitId(), item.getUnitName(), deptList, deptMap);
if(listMap.containsKey(data.getProvinceId() + data.getCityId() + data.getCountyId())){
List<RUploadPointStatisticalDataD> orgData = listMap.get(data.getProvinceId() + data.getCityId() + data.getCountyId());
//根据所属站别进行分类
Map<String, RUploadPointStatisticalDataD> stationTypeMap = orgData.stream().collect(Collectors.toMap(x -> x.getStationType(), Function.identity()));
mapKey.forEach((key, val) -> {
List<LineDevGetDTO> keyItem = temBaseList.stream().filter(o -> val.contains(o.getObjType())).collect(Collectors.toList());
String stationType = "";
switch (key){
case "2100":
stationType=dictDataMap.get(DicDataEnum.Trans_Sub.getCode()).getId();
break;
case "1200":
stationType=dictDataMap.get(DicDataEnum.Converter.getCode()).getId();
break;
case "1300":
stationType=dictDataMap.get(DicDataEnum.Ele_Railways.getCode()).getId();
break;
case "1401":
stationType=dictDataMap.get(DicDataEnum.Wind_Farms.getCode()).getId();
break;
case "1402":
stationType=dictDataMap.get(DicDataEnum.Power_Station.getCode()).getId();
break;
case "2300":
stationType=dictDataMap.get(DicDataEnum.Smelting_Load.getCode()).getId();
break;
case "2400":
stationType=dictDataMap.get(DicDataEnum.Imp_Users.getCode()).getId();
break;
}
if(stationTypeMap.containsKey(stationType)){
long pointCount = keyItem.stream().map(LineDevGetDTO::getPointId).distinct().count();
RUploadPointStatisticalDataD rUploadPointStatisticalDataD = stationTypeMap.get(stationType);
if(ObjectUtil.isNull(devCount)){
System.out.println();
}
rUploadPointStatisticalDataD.setRunTerminalNum((int) devCount);
rUploadPointStatisticalDataD.setOnlineMonitorNum((int) monitorCount);
rUploadPointStatisticalDataD.setRunMonitorNum((int) monitorCount);
rUploadPointStatisticalDataD.setStationMonitorNum((int)pointCount);
}
});
//其他类型
if(stationTypeMap.containsKey(dictDataMap.get(DicDataEnum.Station_Other.getCode()).getId())){
long pointCount = otherMonitor.stream().map(LineDevGetDTO::getPointId).distinct().count();
RUploadPointStatisticalDataD rUploadPointStatisticalDataD = stationTypeMap.get(dictDataMap.get(DicDataEnum.Station_Other.getCode()).getId());
rUploadPointStatisticalDataD.setRunTerminalNum((int) devCount);
rUploadPointStatisticalDataD.setOnlineMonitorNum((int) monitorCount);
rUploadPointStatisticalDataD.setRunMonitorNum((int) monitorCount);
rUploadPointStatisticalDataD.setStationMonitorNum((int)pointCount);
}
}
}
if (CollUtil.isNotEmpty(list)){
list.forEach(item->{
item.setId(IdUtil.simpleUUID());
@@ -302,6 +406,10 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
}
}
/**
* r_stat_integrity_d表中获取数据应收数、实收数
*/