1.河北修改
This commit is contained in:
@@ -213,13 +213,13 @@ public class IRDimBusGlobalDController extends BaseController {
|
||||
|
||||
|
||||
/**
|
||||
* 新增重算月数据
|
||||
* 选择月,会补招这个月每天的数据
|
||||
* @author cdf
|
||||
* @date 2024/3/22
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/reCalMonthUploadAlgorithm")
|
||||
@ApiOperation("重新计算四个算法")
|
||||
@ApiOperation("补招月每天的数据")
|
||||
@ApiImplicitParam(name = "statisticDate", value = "重新计算的月份", required = true)
|
||||
public HttpResult<String> reCalUploadAlgorithmAllMonth(@DateTimeStrValid(format = "yyyy-MM") @RequestParam("statisticDate") String statisticDate,@RequestParam("type") String type) {
|
||||
String methodDescribe = getMethodDescribe("reCalUploadAlgorithmAllMonth");
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.prepare.harmonic.mapper.mysql.line;
|
||||
|
||||
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.device.pms.pojo.po.PmsRunStatistic;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
* @since 2024-04-17
|
||||
*/
|
||||
public interface PmsRunStatisticMapper extends MppBaseMapper<PmsRunStatistic> {
|
||||
|
||||
}
|
||||
@@ -6,15 +6,21 @@ 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 cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.device.biz.commApi.CommLineClient;
|
||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO;
|
||||
import com.njcn.device.biz.pojo.dto.LineDTO;
|
||||
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
|
||||
import com.njcn.device.pms.pojo.po.PmsRunStatistic;
|
||||
import com.njcn.device.pq.pojo.po.RStatIntegrityD;
|
||||
import com.njcn.harmonic.pojo.po.upload.RUploadPointStatisticalDataD;
|
||||
import com.njcn.prepare.harmonic.enums.UploadEnum;
|
||||
import com.njcn.prepare.harmonic.mapper.mysql.area.ROperatingIndexDPOMapper;
|
||||
import com.njcn.prepare.harmonic.mapper.mysql.day.RStatIntegrityDMapper;
|
||||
import com.njcn.prepare.harmonic.mapper.mysql.line.PmsRunStatisticMapper;
|
||||
import com.njcn.prepare.harmonic.mapper.mysql.upload.RUploadPointStatisticalDataDMapper;
|
||||
import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam;
|
||||
import com.njcn.prepare.harmonic.pojo.dto.UploadPointStatisticalParam;
|
||||
@@ -37,6 +43,8 @@ import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 主配网监测点统计数据-日表 服务实现类
|
||||
@@ -50,13 +58,17 @@ import java.util.stream.Collectors;
|
||||
public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUploadPointStatisticalDataDMapper, RUploadPointStatisticalDataD> implements IRUploadPointStatisticalDataDService {
|
||||
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
private final ROperatingIndexDPOMapper rOperatingIndexDPOMapper;
|
||||
|
||||
private final RStatIntegrityDMapper rStatIntegrityDMapper;
|
||||
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final PmsRunStatisticMapper pmsRunStatisticMapper;
|
||||
|
||||
private final CommLineClient commLineClient;
|
||||
|
||||
/**
|
||||
* 此算法用于计算底层数据,方便国网数据上送
|
||||
* 1.表中存储所有单位,没有数据的暂时设置为0
|
||||
@@ -65,6 +77,8 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
|
||||
*/
|
||||
@Override
|
||||
public void insertPointStatisticalDataDay(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam) {
|
||||
|
||||
|
||||
List<RUploadPointStatisticalDataD> result = new ArrayList<>();
|
||||
//获取省级单位id
|
||||
Dept data = deptFeignClient.getRootDept().getData();
|
||||
@@ -75,11 +89,12 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
|
||||
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());
|
||||
).collect(toList());
|
||||
|
||||
Map<String, List<String>> mapKey = new HashMap<>();
|
||||
List<String> otherIds = new ArrayList<>();
|
||||
@@ -93,18 +108,19 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
|
||||
Objects.equals(item.getCode(), DicTreeEnum.Lifting_Load.getCode()) ||
|
||||
Objects.equals(item.getCode(), DicTreeEnum.Electrolytic_Load.getCode())
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
.collect(toList());
|
||||
} else {
|
||||
temList = sysDicTreePOList.stream().filter(item -> item.getPid().equals(sysDicTreePO.getId()) ||
|
||||
item.getId().equals(sysDicTreePO.getId())
|
||||
).collect(Collectors.toList());
|
||||
).collect(toList());
|
||||
}
|
||||
List<String> ids = temList.stream().map(SysDicTreePO::getId).distinct().collect(Collectors.toList());
|
||||
List<String> ids = temList.stream().map(SysDicTreePO::getId).distinct().collect(toList());
|
||||
mapKey.put(sysDicTreePO.getCode(), ids);
|
||||
otherIds.addAll(ids);
|
||||
}
|
||||
|
||||
|
||||
//所属场站与对象类型存在联系
|
||||
List<DictData> dictDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.Station_Type.getCode()).getData();
|
||||
Map<String, DictData> dictDataMap = dictDataList.stream().collect(Collectors.toMap(DictData::getCode, Function.identity()));
|
||||
|
||||
@@ -112,28 +128,56 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
|
||||
//获取所有单位
|
||||
List<Dept> deptList = deptFeignClient.getAllDept().getData();
|
||||
Map<String, List<Dept>> deptMap = deptList.stream().collect(Collectors.groupingBy(Dept::getCode));
|
||||
//筛选国网上送监测点
|
||||
List<DeptGetChildrenMoreDTO> l1 = calculatedParam.getIdList();
|
||||
|
||||
//获取数据个数
|
||||
//获取数据完整性相关数据
|
||||
List<RStatIntegrityD> dataList = getStatIntegrityData(calculatedParam.getDataDate());
|
||||
l1.forEach(item -> {
|
||||
|
||||
|
||||
|
||||
//下面先从表里获取在运测点相关数据,当表里没数据时候再从接口获取
|
||||
//首先获取pms_run_statistic表是否存在执行日期的数据
|
||||
List<PmsRunStatistic> pmsRunStatisticsList = pmsRunStatisticMapper.selectList(new LambdaQueryWrapper<PmsRunStatistic>().eq(PmsRunStatistic::getStatisticDate,calculatedParam.getDataDate()));
|
||||
|
||||
//筛选国网上送监测点
|
||||
List<DeptGetChildrenMoreDTO> deptAll = calculatedParam.getIdList();
|
||||
|
||||
Map<String,PmsRunStatistic> pmsRunStatisticMap = pmsRunStatisticsList.stream().collect(Collectors.toMap(PmsRunStatistic::getDeptId,Function.identity()));
|
||||
List<String> monitorIds = CollectionUtil.toList(pmsRunStatisticMap.get(dept.getCode()).getRunMonitorIds().split(StrUtil.COMMA));
|
||||
List<LineDTO> lineDTOList = commLineClient.getLineDetailBatch(monitorIds).getData();
|
||||
|
||||
deptAll.forEach(item -> {
|
||||
|
||||
//筛选出国网
|
||||
List<LineDevGetDTO> newBaseList;
|
||||
|
||||
//调过全国这个单位
|
||||
if (Objects.equals(Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_1.getCode()), item.getDeptLevel())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(CollectionUtil.isEmpty(pmsRunStatisticsList)){
|
||||
//正常流程
|
||||
newBaseList = item.getLineBaseList().stream().filter(o -> Objects.equals(o.getIsUpToGrid(), 1)).collect(toList());
|
||||
}else {
|
||||
String[] monitorTemIds = pmsRunStatisticMap.get(item.getUnitId()).getRunMonitorIds().split(StrUtil.COMMA);
|
||||
List<String> temIds = Arrays.stream(monitorTemIds).collect(toList());
|
||||
|
||||
List<LineDevGetDTO> newBaseList = item.getLineBaseList().stream().filter(o -> Objects.equals(o.getIsUpToGrid(), 1)).collect(Collectors.toList());
|
||||
newBaseList = lineDTOList.stream().filter(o -> temIds.contains(o.getLineId())).map(it->{
|
||||
LineDevGetDTO lineDevGetDTO = new LineDevGetDTO();
|
||||
lineDevGetDTO.setPointId(it.getLineId());
|
||||
lineDevGetDTO.setDevId(it.getDevId());
|
||||
lineDevGetDTO.setObjType(it.getObjType());
|
||||
return lineDevGetDTO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
List<String> upMonitorIds = newBaseList.stream().map(LineDevGetDTO::getPointId).distinct().collect(toList());
|
||||
List<String> upDevIds = newBaseList.stream().map(LineDevGetDTO::getDevId).distinct().collect(toList());
|
||||
|
||||
List<String> upMonitorIds = newBaseList.stream().map(LineDevGetDTO::getPointId).distinct().collect(Collectors.toList());
|
||||
List<String> upDevIds = newBaseList.stream().map(LineDevGetDTO::getDevId).distinct().collect(Collectors.toList());
|
||||
|
||||
|
||||
List<LineDevGetDTO> finalNewBaseList = newBaseList;
|
||||
mapKey.forEach((key, val) -> {
|
||||
List<LineDevGetDTO> keyItem = newBaseList.stream().filter(o -> val.contains(o.getObjType())).collect(Collectors.toList());
|
||||
List<LineDevGetDTO> keyItem = finalNewBaseList.stream().filter(o -> val.contains(o.getObjType())).collect(toList());
|
||||
RUploadPointStatisticalDataD rUploadPointStatisticalDataD = new RUploadPointStatisticalDataD();
|
||||
switch (key) {
|
||||
case "2100":
|
||||
@@ -178,7 +222,7 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
|
||||
rUploadPointStatisticalDataD.setRunMonitorNum(upMonitorIds.size());
|
||||
|
||||
|
||||
List<RStatIntegrityD> l3 = dataList.stream().filter(it -> upMonitorIds.contains(it.getLineIndex())).collect(Collectors.toList());
|
||||
List<RStatIntegrityD> l3 = dataList.stream().filter(it -> upMonitorIds.contains(it.getLineIndex())).collect(toList());
|
||||
int due = l3.stream().mapToInt(RStatIntegrityD::getDueTime).sum();
|
||||
int real = l3.stream().mapToInt(RStatIntegrityD::getRealTime).sum();
|
||||
rUploadPointStatisticalDataD.setExpectCollectNum(due);
|
||||
@@ -216,13 +260,13 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
|
||||
//fixme over
|
||||
judgeLevel(item.getDeptLevel(), rUploadPointStatisticalDataD, item.getUnitId(), item.getUnitName(), deptList, deptMap);
|
||||
|
||||
List<LineDevGetDTO> otherMonitor = newBaseList.stream().filter(me -> !otherIds.contains(me.getObjType())).collect(Collectors.toList());
|
||||
List<LineDevGetDTO> otherMonitor = newBaseList.stream().filter(me -> !otherIds.contains(me.getObjType())).collect(toList());
|
||||
long pointCount = otherMonitor.stream().map(LineDevGetDTO::getPointId).distinct().count();
|
||||
rUploadPointStatisticalDataD.setRunTerminalNum(upDevIds.size());
|
||||
rUploadPointStatisticalDataD.setRunMonitorNum(upMonitorIds.size());
|
||||
|
||||
|
||||
List<RStatIntegrityD> l3 = dataList.stream().filter(it -> newBaseList.stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList()).contains(it.getLineIndex())).collect(Collectors.toList());
|
||||
List<RStatIntegrityD> l3 = dataList.stream().filter(it -> newBaseList.stream().map(LineDevGetDTO::getPointId).collect(toList()).contains(it.getLineIndex())).collect(toList());
|
||||
int due = l3.stream().mapToInt(RStatIntegrityD::getDueTime).sum();
|
||||
int real = l3.stream().mapToInt(RStatIntegrityD::getRealTime).sum();
|
||||
rUploadPointStatisticalDataD.setExpectCollectNum(due);
|
||||
@@ -243,6 +287,8 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
//查询数据如果有数据,将data_id置为null,这样就保留之前的唯一id
|
||||
LambdaQueryWrapper<RUploadPointStatisticalDataD> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
@@ -434,7 +480,7 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
|
||||
rUploadPointStatisticalDataD.setCountyId("");
|
||||
} else if (Objects.equals(level, Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_4.getCode()))) {
|
||||
result = UploadEnum.STATISTICAL_LEVEL_5.getCode();
|
||||
List<String> list = Arrays.stream(map.get(id).get(0).getPids().split(",")).map(String::trim).collect(Collectors.toList());
|
||||
List<String> list = Arrays.stream(map.get(id).get(0).getPids().split(",")).map(String::trim).collect(toList());
|
||||
String parentCode = deptList.stream().filter(o -> Objects.equals(o.getId(), list.get(3))).findFirst().orElse(null).getCode();
|
||||
rUploadPointStatisticalDataD.setCityId(parentCode);
|
||||
rUploadPointStatisticalDataD.setCityName(map.get(parentCode).get(0).getName());
|
||||
|
||||
Reference in New Issue
Block a user