1.国网上送统计四个算法修改

This commit is contained in:
wr
2024-05-11 16:44:05 +08:00
parent b0553d9c32
commit 1e9644c8a3
12 changed files with 612 additions and 260 deletions

View File

@@ -268,7 +268,8 @@ public class IRDimBusGlobalDController extends BaseController {
baseParam.setFullChain(false); baseParam.setFullChain(false);
baseParam.setRepair(false); baseParam.setRepair(false);
baseParam.setDataDate(endDate); baseParam.setDataDate(endDate);
set.add("r_upload_substation_statistical_data_m"); // set.add("r_upload_substation_statistical_data_m");
set.add("r_upload_substation_statistical_data_y");
baseParam.setTagNames(set); baseParam.setTagNames(set);
liteFlowFeignClient.substationExecutor(baseParam); liteFlowFeignClient.substationExecutor(baseParam);
}else if("3".equals(type)){ }else if("3".equals(type)){

View File

@@ -1,18 +0,0 @@
package com.njcn.prepare.harmonic.mapper.mysql.line;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticD;
/**
* <p>
* Mapper 接口
* </p>
*
* @author cdf
* @since 2024-04-17
*/
public interface PmsRunStatisticMapper extends MppBaseMapper<PmsRunStatisticD> {
}

View File

@@ -1,5 +1,6 @@
package com.njcn.prepare.harmonic.service.mysql.Impl.area; package com.njcn.prepare.harmonic.service.mysql.Impl.area;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
@@ -13,11 +14,9 @@ import com.njcn.prepare.harmonic.mapper.mysql.area.RStatOrgDMapper;
import com.njcn.prepare.harmonic.mapper.mysql.area.RStatOrgMMapper; import com.njcn.prepare.harmonic.mapper.mysql.area.RStatOrgMMapper;
import com.njcn.prepare.harmonic.mapper.mysql.area.RStatOrgQMapper; import com.njcn.prepare.harmonic.mapper.mysql.area.RStatOrgQMapper;
import com.njcn.prepare.harmonic.mapper.mysql.area.RStatOrgYMapper; import com.njcn.prepare.harmonic.mapper.mysql.area.RStatOrgYMapper;
import com.njcn.prepare.harmonic.mapper.mysql.line.RMpPartHarmonicDetailDMapper; import com.njcn.prepare.harmonic.mapper.mysql.line.*;
import com.njcn.prepare.harmonic.mapper.mysql.line.RMpPartHarmonicDetailMMapper;
import com.njcn.prepare.harmonic.mapper.mysql.line.RMpSurplusHarmonicDetailDMapper;
import com.njcn.prepare.harmonic.mapper.mysql.line.RMpSurplusHarmonicDetailMMapper;
import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam; import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam;
import com.njcn.prepare.harmonic.pojo.mysql.ROperatingMonitorDPO;
import com.njcn.prepare.harmonic.pojo.mysql.po.*; import com.njcn.prepare.harmonic.pojo.mysql.po.*;
import com.njcn.prepare.harmonic.service.mysql.area.*; import com.njcn.prepare.harmonic.service.mysql.area.*;
import com.njcn.prepare.harmonic.utils.PublicUtil; import com.njcn.prepare.harmonic.utils.PublicUtil;
@@ -65,20 +64,21 @@ public class RStatHarmonicServiceImpl implements RStatHarmonicService {
private final RStatOrgMMapper rStatOrgMMapper; private final RStatOrgMMapper rStatOrgMMapper;
private final RStatOrgQMapper rStatOrgQMapper; private final RStatOrgQMapper rStatOrgQMapper;
private final RStatOrgYMapper rStatOrgYMapper; private final RStatOrgYMapper rStatOrgYMapper;
private final ROperatingMonitorDMapper rOperatingMonitorDMapper;
private final DicDataFeignClient dicDataFeignClient;
private final
DicDataFeignClient dicDataFeignClient;
@Override @Override
public void handleDay(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam) { public void handleDay(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam) {
List<RStatHarmonicDPO> rStatHarmonicDPOList = new ArrayList<>(); List<RStatHarmonicDPO> rStatHarmonicDPOList = new ArrayList<>();
LocalDate localDate = LocalDateTimeUtil.parseDate(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN); LocalDate localDate = LocalDateTimeUtil.parseDate(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN);
/*获取监测点类型类型*/ /*获取监测点类型类型*/
QueryWrapper<ROperatingMonitorDPO> rOperatingMonitorDPOQueryWrapper = new QueryWrapper<>();
QueryWrapper<RMpPartHarmonicDetailD> queryWrapper = new QueryWrapper<>(); QueryWrapper<RMpPartHarmonicDetailD> queryWrapper = new QueryWrapper<>();
QueryWrapper<RMpSurplusHarmonicDetailD> rMpSurplusHarmonicDetailDQueryWrapper = new QueryWrapper<>(); QueryWrapper<RMpSurplusHarmonicDetailD> rMpSurplusHarmonicDetailDQueryWrapper = new QueryWrapper<>();
QueryWrapper<RStatOrgDPO> rStatOrgDPOQueryWrapper = new QueryWrapper<>(); QueryWrapper<RStatOrgDPO> rStatOrgDPOQueryWrapper = new QueryWrapper<>();
@@ -104,16 +104,24 @@ public class RStatHarmonicServiceImpl implements RStatHarmonicService {
Map<String, List<LineDevGetDTO>> collect = lineBaseList.stream().collect(Collectors.groupingBy(LineDevGetDTO::getLineTag)); Map<String, List<LineDevGetDTO>> collect = lineBaseList.stream().collect(Collectors.groupingBy(LineDevGetDTO::getLineTag));
collect.forEach((k, v)->{ collect.forEach((k, v)->{
List<String> collect1 = v.stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList()); List<String> collect1 = v.stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
/*todo 取有效监测点进行匹配*/
rOperatingMonitorDPOQueryWrapper.clear();
rOperatingMonitorDPOQueryWrapper.select("measurement_point_id").
in("measurement_point_id",collect1).
gt("effective_minute_count",0).
eq("data_date",localDate);
List<ROperatingMonitorDPO> rOperatingMonitorDPOS = rOperatingMonitorDMapper.selectList(rOperatingMonitorDPOQueryWrapper);
List<String> effLineIds = rOperatingMonitorDPOS.stream().map(ROperatingMonitorDPO::getMeasurementPointId).distinct().collect(Collectors.toList());
queryWrapper.clear(); queryWrapper.clear();
queryWrapper.select("is_freq","is_v_dev","is_v","is_i","is_unbalance","is_i_neg"). queryWrapper.select("is_freq","is_v_dev","is_v","is_i","is_unbalance","is_i_neg").
in("measurement_point_id",collect1). in("measurement_point_id",effLineIds).
eq("data_date",localDate); eq("data_date",localDate);
List<RMpPartHarmonicDetailD> rMpPartHarmonicDetailDS = rMpPartHarmonicDetailDMapper.selectList(queryWrapper); List<RMpPartHarmonicDetailD> rMpPartHarmonicDetailDS = rMpPartHarmonicDetailDMapper.selectList(queryWrapper);
rMpSurplusHarmonicDetailDQueryWrapper.clear(); rMpSurplusHarmonicDetailDQueryWrapper.clear();
rMpSurplusHarmonicDetailDQueryWrapper.select("is_flicker","is_inuharm"). rMpSurplusHarmonicDetailDQueryWrapper.select("is_flicker","is_inuharm").
in("measurement_point_id",collect1). in("measurement_point_id",effLineIds).
eq("data_date",localDate); eq("data_date",localDate);
List<RMpSurplusHarmonicDetailD> rMpSurplusHarmonicDetailDS = rMpSurplusHarmonicDetailDMapper.selectList(rMpSurplusHarmonicDetailDQueryWrapper); List<RMpSurplusHarmonicDetailD> rMpSurplusHarmonicDetailDS = rMpSurplusHarmonicDetailDMapper.selectList(rMpSurplusHarmonicDetailDQueryWrapper);
@@ -213,7 +221,7 @@ public class RStatHarmonicServiceImpl implements RStatHarmonicService {
DateTime end = DateUtil.endOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)); DateTime end = DateUtil.endOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN));
LocalDate localDate = LocalDateTimeUtil.parseDate( DateUtil.format(begin, DatePattern.NORM_DATE_PATTERN), DatePattern.NORM_DATE_PATTERN); LocalDate localDate = LocalDateTimeUtil.parseDate( DateUtil.format(begin, DatePattern.NORM_DATE_PATTERN), DatePattern.NORM_DATE_PATTERN);
QueryWrapper<ROperatingMonitorDPO> rOperatingMonitorDPOQueryWrapper = new QueryWrapper<>();
QueryWrapper<RMpPartHarmonicDetailM> queryWrapper = new QueryWrapper<>(); QueryWrapper<RMpPartHarmonicDetailM> queryWrapper = new QueryWrapper<>();
QueryWrapper<RMpSurplusHarmonicDetailM> rMpSurplusHarmonicDetailMQueryWrapper = new QueryWrapper<>(); QueryWrapper<RMpSurplusHarmonicDetailM> rMpSurplusHarmonicDetailMQueryWrapper = new QueryWrapper<>();
QueryWrapper<RStatOrgMPO> rStatOrgMPOQueryWrapper = new QueryWrapper<>(); QueryWrapper<RStatOrgMPO> rStatOrgMPOQueryWrapper = new QueryWrapper<>();
@@ -241,16 +249,24 @@ public class RStatHarmonicServiceImpl implements RStatHarmonicService {
Map<String, List<LineDevGetDTO>> collect = lineBaseList.stream().collect(Collectors.groupingBy(LineDevGetDTO::getLineTag)); Map<String, List<LineDevGetDTO>> collect = lineBaseList.stream().collect(Collectors.groupingBy(LineDevGetDTO::getLineTag));
collect.forEach((k, v) -> { collect.forEach((k, v) -> {
List<String> collect1 = v.stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList()); List<String> collect1 = v.stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
/*todo 取有效监测点进行匹配*/
rOperatingMonitorDPOQueryWrapper.clear();
rOperatingMonitorDPOQueryWrapper.select("measurement_point_id").
in("measurement_point_id",collect1).
gt("effective_minute_count",0).
between("data_date",begin,end);
List<ROperatingMonitorDPO> rOperatingMonitorDPOS = rOperatingMonitorDMapper.selectList(rOperatingMonitorDPOQueryWrapper);
List<String> effLineIds = rOperatingMonitorDPOS.stream().map(ROperatingMonitorDPO::getMeasurementPointId).distinct().collect(Collectors.toList());
queryWrapper.clear(); queryWrapper.clear();
queryWrapper.select("measurement_point_id","freq_over_day", "v_dev_over_day", "v_over_day", "i_over_day", "unbalance_over_day", "i_neg_over_day"). queryWrapper.select("measurement_point_id","freq_over_day", "v_dev_over_day", "v_over_day", "i_over_day", "unbalance_over_day", "i_neg_over_day").
in("measurement_point_id", collect1). in("measurement_point_id", effLineIds).
between("data_date",begin,end); between("data_date",begin,end);
List<RMpPartHarmonicDetailM> rMpPartHarmonicDetailMS = rMpPartHarmonicDetailMMapper.selectList(queryWrapper); List<RMpPartHarmonicDetailM> rMpPartHarmonicDetailMS = rMpPartHarmonicDetailMMapper.selectList(queryWrapper);
rMpSurplusHarmonicDetailMQueryWrapper.clear(); rMpSurplusHarmonicDetailMQueryWrapper.clear();
rMpSurplusHarmonicDetailMQueryWrapper.select("measurement_point_id","flicker_over_day", "inuharm_over_day"). rMpSurplusHarmonicDetailMQueryWrapper.select("measurement_point_id","flicker_over_day", "inuharm_over_day").
in("measurement_point_id", collect1). in("measurement_point_id", effLineIds).
between("data_date",begin,end); between("data_date",begin,end);
List<RMpSurplusHarmonicDetailM> rMpSurplusHarmonicDetailMS = rMpSurplusHarmonicDetailMMapper.selectList(rMpSurplusHarmonicDetailMQueryWrapper); List<RMpSurplusHarmonicDetailM> rMpSurplusHarmonicDetailMS = rMpSurplusHarmonicDetailMMapper.selectList(rMpSurplusHarmonicDetailMQueryWrapper);
@@ -401,7 +417,7 @@ public class RStatHarmonicServiceImpl implements RStatHarmonicService {
DateTime end = DateUtil.endOfQuarter(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)); DateTime end = DateUtil.endOfQuarter(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN));
LocalDate localDate = LocalDateTimeUtil.parseDate( DateUtil.format(begin, DatePattern.NORM_DATE_PATTERN), DatePattern.NORM_DATE_PATTERN); LocalDate localDate = LocalDateTimeUtil.parseDate( DateUtil.format(begin, DatePattern.NORM_DATE_PATTERN), DatePattern.NORM_DATE_PATTERN);
QueryWrapper<ROperatingMonitorDPO> rOperatingMonitorDPOQueryWrapper = new QueryWrapper<>();
QueryWrapper<RMpPartHarmonicDetailM> queryWrapper = new QueryWrapper<>(); QueryWrapper<RMpPartHarmonicDetailM> queryWrapper = new QueryWrapper<>();
QueryWrapper<RMpSurplusHarmonicDetailM> rMpSurplusHarmonicDetailMQueryWrapper = new QueryWrapper<>(); QueryWrapper<RMpSurplusHarmonicDetailM> rMpSurplusHarmonicDetailMQueryWrapper = new QueryWrapper<>();
QueryWrapper<RStatOrgQPO> rStatOrgQPOQueryWrapper = new QueryWrapper<>(); QueryWrapper<RStatOrgQPO> rStatOrgQPOQueryWrapper = new QueryWrapper<>();
@@ -429,20 +445,28 @@ public class RStatHarmonicServiceImpl implements RStatHarmonicService {
Map<String, List<LineDevGetDTO>> collect = lineBaseList.stream().collect(Collectors.groupingBy(LineDevGetDTO::getLineTag)); Map<String, List<LineDevGetDTO>> collect = lineBaseList.stream().collect(Collectors.groupingBy(LineDevGetDTO::getLineTag));
collect.forEach((k, v) -> { collect.forEach((k, v) -> {
List<String> collect1 = v.stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList()); List<String> collect1 = v.stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
/*todo 取有效监测点进行匹配*/
queryWrapper.clear(); rOperatingMonitorDPOQueryWrapper.clear();
queryWrapper.select("measurement_point_id","freq_over_day", "v_dev_over_day", "v_over_day", "i_over_day", "unbalance_over_day", "i_neg_over_day"). rOperatingMonitorDPOQueryWrapper.select("measurement_point_id").
in("measurement_point_id", collect1). in("measurement_point_id",collect1).
gt("effective_minute_count",0).
between("data_date",begin,end); between("data_date",begin,end);
List<ROperatingMonitorDPO> rOperatingMonitorDPOS = rOperatingMonitorDMapper.selectList(rOperatingMonitorDPOQueryWrapper);
List<RMpPartHarmonicDetailM> rMpPartHarmonicDetailMS = rMpPartHarmonicDetailMMapper.selectList(queryWrapper); List<String> effLineIds = rOperatingMonitorDPOS.stream().map(ROperatingMonitorDPO::getMeasurementPointId).distinct().collect(Collectors.toList());
List<RMpPartHarmonicDetailM> rMpPartHarmonicDetailMS =new ArrayList<>();
rMpSurplusHarmonicDetailMQueryWrapper.clear(); List<RMpSurplusHarmonicDetailM> rMpSurplusHarmonicDetailMS=new ArrayList<>();
rMpSurplusHarmonicDetailMQueryWrapper.select("measurement_point_id","flicker_over_day", "inuharm_over_day"). if(CollUtil.isNotEmpty(effLineIds)){
in("measurement_point_id", collect1). queryWrapper.clear();
between("data_date",begin,end); queryWrapper.select("measurement_point_id","freq_over_day", "v_dev_over_day", "v_over_day", "i_over_day", "unbalance_over_day", "i_neg_over_day").
List<RMpSurplusHarmonicDetailM> rMpSurplusHarmonicDetailMS = rMpSurplusHarmonicDetailMMapper.selectList(rMpSurplusHarmonicDetailMQueryWrapper); in("measurement_point_id", effLineIds).
between("data_date",begin,end);
rMpPartHarmonicDetailMS.addAll(rMpPartHarmonicDetailMMapper.selectList(queryWrapper));
rMpSurplusHarmonicDetailMQueryWrapper.clear();
rMpSurplusHarmonicDetailMQueryWrapper.select("measurement_point_id","flicker_over_day", "inuharm_over_day").
in("measurement_point_id", effLineIds).
between("data_date",begin,end);
rMpSurplusHarmonicDetailMS.addAll(rMpSurplusHarmonicDetailMMapper.selectList(rMpSurplusHarmonicDetailMQueryWrapper));
}
rStatOrgQPOQueryWrapper.clear(); rStatOrgQPOQueryWrapper.clear();
rStatOrgQPOQueryWrapper.select("effective_measurement_accrued"). rStatOrgQPOQueryWrapper.select("effective_measurement_accrued").
eq("org_no", deptGetChildrenMoreDTO.getUnitId()). eq("org_no", deptGetChildrenMoreDTO.getUnitId()).
@@ -609,6 +633,7 @@ public class RStatHarmonicServiceImpl implements RStatHarmonicService {
/*获取监测点类型类型*/ /*获取监测点类型类型*/
QueryWrapper<ROperatingMonitorDPO> rOperatingMonitorDPOQueryWrapper = new QueryWrapper<>();
QueryWrapper<RMpPartHarmonicDetailM> queryWrapper = new QueryWrapper<>(); QueryWrapper<RMpPartHarmonicDetailM> queryWrapper = new QueryWrapper<>();
QueryWrapper<RMpSurplusHarmonicDetailM> rMpSurplusHarmonicDetailMQueryWrapper = new QueryWrapper<>(); QueryWrapper<RMpSurplusHarmonicDetailM> rMpSurplusHarmonicDetailMQueryWrapper = new QueryWrapper<>();
QueryWrapper<RStatOrgYPO> rStatOrgYPOQueryWrapper = new QueryWrapper<>(); QueryWrapper<RStatOrgYPO> rStatOrgYPOQueryWrapper = new QueryWrapper<>();
@@ -637,17 +662,25 @@ public class RStatHarmonicServiceImpl implements RStatHarmonicService {
Map<String, List<LineDevGetDTO>> collect = lineBaseList.stream().collect(Collectors.groupingBy(LineDevGetDTO::getLineTag)); Map<String, List<LineDevGetDTO>> collect = lineBaseList.stream().collect(Collectors.groupingBy(LineDevGetDTO::getLineTag));
collect.forEach((k, v) -> { collect.forEach((k, v) -> {
List<String> collect1 = v.stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList()); List<String> collect1 = v.stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
/*todo 取有效监测点进行匹配*/
rOperatingMonitorDPOQueryWrapper.clear();
rOperatingMonitorDPOQueryWrapper.select("measurement_point_id").
in("measurement_point_id",collect1).
gt("effective_minute_count",0).
between("data_date",begin,end);
List<ROperatingMonitorDPO> rOperatingMonitorDPOS = rOperatingMonitorDMapper.selectList(rOperatingMonitorDPOQueryWrapper);
List<String> effLineIds = rOperatingMonitorDPOS.stream().map(ROperatingMonitorDPO::getMeasurementPointId).distinct().collect(Collectors.toList());
queryWrapper.clear(); queryWrapper.clear();
queryWrapper.select("measurement_point_id","freq_over_day", "v_dev_over_day", "v_over_day", "i_over_day", "unbalance_over_day", "i_neg_over_day"). queryWrapper.select("measurement_point_id","freq_over_day", "v_dev_over_day", "v_over_day", "i_over_day", "unbalance_over_day", "i_neg_over_day").
in("measurement_point_id", collect1). in("measurement_point_id", effLineIds).
between("data_date",begin,end); between("data_date",begin,end);
List<RMpPartHarmonicDetailM> rMpPartHarmonicDetailMS = rMpPartHarmonicDetailMMapper.selectList(queryWrapper); List<RMpPartHarmonicDetailM> rMpPartHarmonicDetailMS = rMpPartHarmonicDetailMMapper.selectList(queryWrapper);
rMpSurplusHarmonicDetailMQueryWrapper.clear(); rMpSurplusHarmonicDetailMQueryWrapper.clear();
rMpSurplusHarmonicDetailMQueryWrapper.select("measurement_point_id","flicker_over_day", "inuharm_over_day"). rMpSurplusHarmonicDetailMQueryWrapper.select("measurement_point_id","flicker_over_day", "inuharm_over_day").
in("measurement_point_id", collect1). in("measurement_point_id", effLineIds).
between("data_date",begin,end); between("data_date",begin,end);
List<RMpSurplusHarmonicDetailM> rMpSurplusHarmonicDetailMS = rMpSurplusHarmonicDetailMMapper.selectList(rMpSurplusHarmonicDetailMQueryWrapper); List<RMpSurplusHarmonicDetailM> rMpSurplusHarmonicDetailMS = rMpSurplusHarmonicDetailMMapper.selectList(rMpSurplusHarmonicDetailMQueryWrapper);

View File

@@ -1,5 +1,6 @@
package com.njcn.prepare.harmonic.service.mysql.Impl.area; package com.njcn.prepare.harmonic.service.mysql.Impl.area;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
@@ -75,7 +76,6 @@ public class RStatOrgServiceImpl implements RStatOrgService {
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.00");
@Override @Override
public void handler(List<DeptGetChildrenMoreDTO> data, String dataDate, Integer type) { public void handler(List<DeptGetChildrenMoreDTO> data, String dataDate, Integer type) {
switch (type) { switch (type) {
case 1: case 1:
@@ -549,16 +549,19 @@ public class RStatOrgServiceImpl implements RStatOrgService {
rStatOrgQPO.setEffectiveMeasurementAverage(Double.parseDouble(value)); rStatOrgQPO.setEffectiveMeasurementAverage(Double.parseDouble(value));
/*3、3、累计有效接入监测点数*/ /*3、3、累计有效接入监测点数*/
long count = rOperatingMonitorDPOS.stream().map(ROperatingMonitorDPO::getMeasurementPointId).distinct().count(); List<String> monitorIds = rOperatingMonitorDPOS.stream().map(ROperatingMonitorDPO::getMeasurementPointId).distinct().collect(Collectors.toList());
rStatOrgQPO.setEffectiveMeasurementAccrued(Integer.valueOf(count+"")); rStatOrgQPO.setEffectiveMeasurementAccrued(monitorIds.size());
/*4、日均稳态超标监测点数*/ /*4、日均稳态超标监测点数 TODO 用有效监测点*/
rmpTargetWarnDPOQueryWrapper.clear(); List<RMpTargetWarnDPO> rMpTargetWarnDPOS=new ArrayList<>();
rmpTargetWarnDPOQueryWrapper.select("measurement_point_id"). if(CollUtil.isNotEmpty(monitorIds)){
in("measurement_point_id",collect1). rmpTargetWarnDPOQueryWrapper.clear();
eq("is_harmonic",1). rmpTargetWarnDPOQueryWrapper.select("measurement_point_id").
between("data_date",begin,end); in("measurement_point_id",monitorIds).
List<RMpTargetWarnDPO> rMpTargetWarnDPOS = rMpTargetWarnDMapper.selectList(rmpTargetWarnDPOQueryWrapper); eq("is_harmonic",1).
between("data_date",begin,end);
rMpTargetWarnDPOS.addAll(rMpTargetWarnDMapper.selectList(rmpTargetWarnDPOQueryWrapper));
}
String value1 = df.format((float)rMpTargetWarnDPOS.size()/ days); String value1 = df.format((float)rMpTargetWarnDPOS.size()/ days);
rStatOrgQPO.setHarmonicMeasurementAverage(Double.parseDouble(value1)); rStatOrgQPO.setHarmonicMeasurementAverage(Double.parseDouble(value1));

View File

@@ -1,11 +1,13 @@
package com.njcn.prepare.harmonic.service.mysql.send.impl; package com.njcn.prepare.harmonic.service.mysql.send.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO; import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO;
@@ -15,13 +17,19 @@ import com.njcn.device.pms.pojo.po.Monitor;
import com.njcn.harmonic.pojo.po.RMpPartHarmonicDetailD; import com.njcn.harmonic.pojo.po.RMpPartHarmonicDetailD;
import com.njcn.harmonic.pojo.po.RMpSurplusHarmonicDetailD; import com.njcn.harmonic.pojo.po.RMpSurplusHarmonicDetailD;
import com.njcn.harmonic.pojo.po.send.PqTypicalSourceCreatePO; import com.njcn.harmonic.pojo.po.send.PqTypicalSourceCreatePO;
import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticD;
import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticM;
import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticY;
import com.njcn.prepare.harmonic.mapper.mysql.line.RMpPartHarmonicDetailDMapper; import com.njcn.prepare.harmonic.mapper.mysql.line.RMpPartHarmonicDetailDMapper;
import com.njcn.prepare.harmonic.mapper.mysql.line.RMpSurplusHarmonicDetailDMapper; import com.njcn.prepare.harmonic.mapper.mysql.line.RMpSurplusHarmonicDetailDMapper;
import com.njcn.prepare.harmonic.mapper.mysql.send.PqTypicalSourceCreatePOMapper; import com.njcn.prepare.harmonic.mapper.mysql.send.PqTypicalSourceCreatePOMapper;
import com.njcn.prepare.harmonic.mapper.mysql.upload.PmsRunStatisticDMapper;
import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam; import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam;
import com.njcn.prepare.harmonic.pojo.mysql.ROperatingMonitorDPO; import com.njcn.prepare.harmonic.pojo.mysql.ROperatingMonitorDPO;
import com.njcn.prepare.harmonic.service.mysql.line.ROperatingMonitorService; import com.njcn.prepare.harmonic.service.mysql.line.ROperatingMonitorService;
import com.njcn.prepare.harmonic.service.mysql.send.PqTypicalSourceCreatePOService; import com.njcn.prepare.harmonic.service.mysql.send.PqTypicalSourceCreatePOService;
import com.njcn.prepare.harmonic.service.mysql.upload.IPmsRunStatisticMService;
import com.njcn.prepare.harmonic.service.mysql.upload.IPmsRunStatisticYService;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.DictTreeFeignClient; import com.njcn.system.api.DictTreeFeignClient;
import com.njcn.system.enums.DicDataEnum; import com.njcn.system.enums.DicDataEnum;
@@ -67,6 +75,10 @@ public class PqTypicalSourceCreatePOServiceImpl extends ServiceImpl<PqTypicalSou
private final RMpPartHarmonicDetailDMapper rMpPartHarmonicDetailDMapper; private final RMpPartHarmonicDetailDMapper rMpPartHarmonicDetailDMapper;
private final RMpSurplusHarmonicDetailDMapper rMpSurplusHarmonicDetailDMapper; private final RMpSurplusHarmonicDetailDMapper rMpSurplusHarmonicDetailDMapper;
private final ROperatingMonitorService rOperatingMonitorService; private final ROperatingMonitorService rOperatingMonitorService;
private final PmsRunStatisticDMapper runStatisticDMapper;
private final IPmsRunStatisticMService runStatisticMService;
private final IPmsRunStatisticYService runStatisticYService;
/* /*
*01 电压 *01 电压
@@ -79,6 +91,10 @@ public class PqTypicalSourceCreatePOServiceImpl extends ServiceImpl<PqTypicalSou
* */ * */
@Override @Override
public void handlerDay(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam) { public void handlerDay(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam) {
List<PmsRunStatisticD> pmsRunStatisticsListD = runStatisticDMapper.selectList(new LambdaQueryWrapper<PmsRunStatisticD>().eq(PmsRunStatisticD::getStatisticDate,calculatedParam.getDataDate()));
Map<String, PmsRunStatisticD> pmsRunStatisticMap = pmsRunStatisticsListD.stream().collect(Collectors.toMap(PmsRunStatisticD::getDeptId,Function.identity()));
List<PqTypicalSourceCreatePO> pqTypicalSourceCreatePOList = new ArrayList<>(); List<PqTypicalSourceCreatePO> pqTypicalSourceCreatePOList = new ArrayList<>();
LocalDate localDate = LocalDateTimeUtil.parseDate(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN); LocalDate localDate = LocalDateTimeUtil.parseDate(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN);
@@ -141,7 +157,17 @@ public class PqTypicalSourceCreatePOServiceImpl extends ServiceImpl<PqTypicalSou
List<DictData> supvVoltageDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData(); List<DictData> supvVoltageDicList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE.getCode()).getData();
Map<String, DictData> mapVoltage = supvVoltageDicList.stream().collect(Collectors.toMap(DictData::getId, Function.identity())); Map<String, DictData> mapVoltage = supvVoltageDicList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
for (DeptGetChildrenMoreDTO deptGetChildrenMoreDTO : calculatedParam.getIdList()) { for (DeptGetChildrenMoreDTO deptGetChildrenMoreDTO : calculatedParam.getIdList()) {
List<String> collect1 = deptGetChildrenMoreDTO.getLineBaseList().stream().filter(temp->Objects.equals(temp.getIsUpToGrid(),1)).map(LineDevGetDTO::getPointId).collect(Collectors.toList()); List<String> collect1;
if(pmsRunStatisticMap.containsKey(deptGetChildrenMoreDTO.getUnitId())){
String typicalOnlineIds = pmsRunStatisticMap.get(deptGetChildrenMoreDTO.getUnitId()).getTypicalOnlineIds();
if(StrUtil.isNotBlank(typicalOnlineIds)){
collect1 = CollectionUtil.toList(typicalOnlineIds.split(StrUtil.COMMA));
}else {
collect1 = deptGetChildrenMoreDTO.getLineBaseList().stream().filter(temp->Objects.equals(temp.getIsUpToGrid(),1)).map(LineDevGetDTO::getPointId).collect(Collectors.toList());
}
} else {
collect1 = deptGetChildrenMoreDTO.getLineBaseList().stream().filter(temp->Objects.equals(temp.getIsUpToGrid(),1)).map(LineDevGetDTO::getPointId).collect(Collectors.toList());
}
List<Monitor> monitorList; List<Monitor> monitorList;
if (!CollectionUtils.isEmpty(collect1)) { if (!CollectionUtils.isEmpty(collect1)) {
monitorList = monitorClient.getMonitorList(collect1).getData(); monitorList = monitorClient.getMonitorList(collect1).getData();
@@ -290,6 +316,11 @@ public class PqTypicalSourceCreatePOServiceImpl extends ServiceImpl<PqTypicalSou
String end = DateUtil.endOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)).toString(); String end = DateUtil.endOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)).toString();
String date = begin.substring(0, 7); String date = begin.substring(0, 7);
List<PmsRunStatisticM> pmsRunStatistic = runStatisticMService.selectListByDate(begin, end,calculatedParam.getDataDate());
Map<String, PmsRunStatisticM> pmsRunStatisticMap = pmsRunStatistic.stream().collect(Collectors.toMap(PmsRunStatisticM::getDeptId,Function.identity()));
List<SysDicTreePO> sysdictreepo = dictTreeFeignClient.queryAll().getData(); List<SysDicTreePO> sysdictreepo = dictTreeFeignClient.queryAll().getData();
List<String> windfarm_user = Stream.of( List<String> windfarm_user = Stream.of(
@@ -328,7 +359,17 @@ public class PqTypicalSourceCreatePOServiceImpl extends ServiceImpl<PqTypicalSou
Map<String, PvTerminalTreeVO> mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity())); Map<String, PvTerminalTreeVO> mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity()));
for (DeptGetChildrenMoreDTO deptGetChildrenMoreDTO : calculatedParam.getIdList()) { for (DeptGetChildrenMoreDTO deptGetChildrenMoreDTO : calculatedParam.getIdList()) {
List<String> collect1 = deptGetChildrenMoreDTO.getLineBaseList().stream().filter(temp->Objects.equals(temp.getIsUpToGrid(),1)).map(LineDevGetDTO::getPointId).collect(Collectors.toList()); List<String> collect1;
if(pmsRunStatisticMap.containsKey(deptGetChildrenMoreDTO.getUnitId())){
String typicalOnlineIds = pmsRunStatisticMap.get(deptGetChildrenMoreDTO.getUnitId()).getTypicalOnlineIds();
if(StrUtil.isNotBlank(typicalOnlineIds)){
collect1 = CollectionUtil.toList(typicalOnlineIds.split(StrUtil.COMMA));
}else {
collect1 = deptGetChildrenMoreDTO.getLineBaseList().stream().filter(temp->Objects.equals(temp.getIsUpToGrid(),1)).map(LineDevGetDTO::getPointId).collect(Collectors.toList());
}
} else {
collect1 = deptGetChildrenMoreDTO.getLineBaseList().stream().filter(temp->Objects.equals(temp.getIsUpToGrid(),1)).map(LineDevGetDTO::getPointId).collect(Collectors.toList());
}
List<Monitor> monitorList; List<Monitor> monitorList;
if (!CollectionUtils.isEmpty(collect1)) { if (!CollectionUtils.isEmpty(collect1)) {
monitorList = monitorClient.getMonitorList(collect1).getData(); monitorList = monitorClient.getMonitorList(collect1).getData();
@@ -450,6 +491,8 @@ public class PqTypicalSourceCreatePOServiceImpl extends ServiceImpl<PqTypicalSou
String begin = DateUtil.beginOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)).toString(); String begin = DateUtil.beginOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)).toString();
String end = DateUtil.endOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)).toString(); String end = DateUtil.endOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)).toString();
String date = begin.substring(0, 4); String date = begin.substring(0, 4);
List<PmsRunStatisticY> pmsRunStatistic = runStatisticYService.selectListByDate(begin, end,calculatedParam.getDataDate());
Map<String, PmsRunStatisticY> pmsRunStatisticMap = pmsRunStatistic.stream().collect(Collectors.toMap(PmsRunStatisticY::getDeptId,Function.identity()));
List<SysDicTreePO> sysdictreepo = dictTreeFeignClient.queryAll().getData(); List<SysDicTreePO> sysdictreepo = dictTreeFeignClient.queryAll().getData();
@@ -489,7 +532,17 @@ public class PqTypicalSourceCreatePOServiceImpl extends ServiceImpl<PqTypicalSou
Map<String, PvTerminalTreeVO> mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity())); Map<String, PvTerminalTreeVO> mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity()));
for (DeptGetChildrenMoreDTO deptGetChildrenMoreDTO : calculatedParam.getIdList()) { for (DeptGetChildrenMoreDTO deptGetChildrenMoreDTO : calculatedParam.getIdList()) {
List<String> collect1 = deptGetChildrenMoreDTO.getLineBaseList().stream().filter(temp->Objects.equals(temp.getIsUpToGrid(),1)).map(LineDevGetDTO::getPointId).collect(Collectors.toList()); List<String> collect1;
if(pmsRunStatisticMap.containsKey(deptGetChildrenMoreDTO.getUnitId())){
String typicalOnlineIds = pmsRunStatisticMap.get(deptGetChildrenMoreDTO.getUnitId()).getTypicalOnlineIds();
if(StrUtil.isNotBlank(typicalOnlineIds)){
collect1 = CollectionUtil.toList(typicalOnlineIds.split(StrUtil.COMMA));
}else {
collect1 = deptGetChildrenMoreDTO.getLineBaseList().stream().filter(temp->Objects.equals(temp.getIsUpToGrid(),1)).map(LineDevGetDTO::getPointId).collect(Collectors.toList());
}
} else {
collect1 = deptGetChildrenMoreDTO.getLineBaseList().stream().filter(temp->Objects.equals(temp.getIsUpToGrid(),1)).map(LineDevGetDTO::getPointId).collect(Collectors.toList());
}
List<Monitor> monitorList; List<Monitor> monitorList;
if (!CollectionUtils.isEmpty(collect1)) { if (!CollectionUtils.isEmpty(collect1)) {
monitorList = monitorClient.getMonitorList(collect1).getData(); monitorList = monitorClient.getMonitorList(collect1).getData();

View File

@@ -4,9 +4,11 @@ package com.njcn.prepare.harmonic.service.mysql.upload;
import com.github.jeffreyning.mybatisplus.service.IMppService; import com.github.jeffreyning.mybatisplus.service.IMppService;
import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticM; import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticM;
import java.util.List;
/** /**
* <p> * <p>
* 服务类 * 服务类
* </p> * </p>
* *
* @author cdf * @author cdf
@@ -15,15 +17,21 @@ import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticM;
public interface IPmsRunStatisticMService extends IMppService<PmsRunStatisticM> { public interface IPmsRunStatisticMService extends IMppService<PmsRunStatisticM> {
/** /**
* 每日统计每月 * 每日统计每月
*
* @author cdf * @author cdf
* @date 2024/4/17 * @date 2024/4/17
*/ */
void statisticLedgerRunMonth(String date); void statisticLedgerRunMonth(String date);
/**
* @param startTime
* @param endTime
* @Description: 获取每个月中的最新一天数据
* @Author: wr
* @Date: 2024/5/9 14:21
*/
List<PmsRunStatisticM> selectListByDate(String startTime, String endTime, String dataDate);
} }

View File

@@ -4,9 +4,11 @@ package com.njcn.prepare.harmonic.service.mysql.upload;
import com.github.jeffreyning.mybatisplus.service.IMppService; import com.github.jeffreyning.mybatisplus.service.IMppService;
import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticY; import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticY;
import java.util.List;
/** /**
* <p> * <p>
* 服务类 * 服务类
* </p> * </p>
* *
* @author cdf * @author cdf
@@ -15,13 +17,20 @@ import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticY;
public interface IPmsRunStatisticYService extends IMppService<PmsRunStatisticY> { public interface IPmsRunStatisticYService extends IMppService<PmsRunStatisticY> {
/** /**
* 每日统计每年 * 每日统计每年
*
* @author cdf * @author cdf
* @date 2024/4/17 * @date 2024/4/17
*/ */
void statisticLedgerRunYear(String date); void statisticLedgerRunYear(String date);
/**
* @param startTime
* @param endTime
* @Description: 获取每个年中的最新一天数据
* @Author: wr
* @Date: 2024/5/9 14:21
*/
List<PmsRunStatisticY> selectListByDate(String startTime, String endTime, String dataDate);
} }

View File

@@ -7,7 +7,6 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.device.pms.pojo.po.PmsMidLedger;
import com.njcn.prepare.harmonic.mapper.mysql.upload.PmsRunStatisticDMapper; import com.njcn.prepare.harmonic.mapper.mysql.upload.PmsRunStatisticDMapper;
import com.njcn.prepare.harmonic.mapper.mysql.upload.PmsRunStatisticMMapper; import com.njcn.prepare.harmonic.mapper.mysql.upload.PmsRunStatisticMMapper;
import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticD; import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticD;
@@ -23,7 +22,7 @@ import java.util.stream.Collectors;
/** /**
* <p> * <p>
* 服务实现类 * 服务实现类
* </p> * </p>
* *
* @author cdf * @author cdf
@@ -120,5 +119,13 @@ public class PmsRunStatisticMServiceImpl extends MppServiceImpl<PmsRunStatisticM
this.saveOrUpdateBatchByMultiId(poList); this.saveOrUpdateBatchByMultiId(poList);
} }
@Override
public List<PmsRunStatisticM> selectListByDate(String startTime, String endTime, String dataDate) {
return this.list(new LambdaQueryWrapper<PmsRunStatisticM>()
.ge(StrUtil.isNotBlank(startTime), PmsRunStatisticM::getStatisticDate, DateUtil.beginOfDay(DateUtil.parse(startTime)))
.le(StrUtil.isNotBlank(endTime), PmsRunStatisticM::getStatisticDate, DateUtil.endOfDay(DateUtil.parse(endTime)))
.eq(PmsRunStatisticM::getStatDate, dataDate));
}
} }

View File

@@ -122,4 +122,12 @@ public class PmsRunStatisticYServiceImpl extends MppServiceImpl<PmsRunStatisticY
} }
@Override
public List<PmsRunStatisticY> selectListByDate(String startTime, String endTime, String dataDate) {
return this.list(new LambdaQueryWrapper<PmsRunStatisticY>()
.ge(StrUtil.isNotBlank(startTime), PmsRunStatisticY::getStatisticDate, DateUtil.beginOfDay(DateUtil.parse(startTime)))
.le(StrUtil.isNotBlank(endTime), PmsRunStatisticY::getStatisticDate, DateUtil.endOfDay(DateUtil.parse(endTime)))
.eq(PmsRunStatisticY::getStatDate, dataDate));
}
} }

View File

@@ -1,32 +1,37 @@
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.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.DeptGetBase; import com.njcn.device.biz.pojo.dto.*;
import com.njcn.device.biz.pojo.dto.DeptGetBusBarDTO;
import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO;
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.pojo.po.GeneratrixWire; import com.njcn.device.pms.pojo.po.GeneratrixWire;
import com.njcn.device.pms.pojo.po.Monitor; import com.njcn.device.pms.pojo.po.Monitor;
import com.njcn.device.pms.pojo.po.PmsMidLedger; import com.njcn.device.pms.pojo.po.PmsMidLedger;
import com.njcn.harmonic.pojo.dto.LineDataDto; import com.njcn.harmonic.pojo.dto.LineDataDto;
import com.njcn.harmonic.pojo.po.dim.RDimVoltageD; import com.njcn.harmonic.pojo.po.dim.RDimVoltageD;
import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticD;
import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticM;
import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticY;
import com.njcn.harmonic.pojo.po.upload.RUploadEvaluationDataD; import com.njcn.harmonic.pojo.po.upload.RUploadEvaluationDataD;
import com.njcn.prepare.harmonic.enums.UploadEnum; import com.njcn.prepare.harmonic.enums.UploadEnum;
import com.njcn.prepare.harmonic.mapper.mysql.dim.GeneratrixWireMapper; import com.njcn.prepare.harmonic.mapper.mysql.dim.GeneratrixWireMapper;
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.dim.RDimVoltageDMapper; import com.njcn.prepare.harmonic.mapper.mysql.dim.RDimVoltageDMapper;
import com.njcn.prepare.harmonic.mapper.mysql.line.PmsMonitorMapper; import com.njcn.prepare.harmonic.mapper.mysql.line.PmsMonitorMapper;
import com.njcn.prepare.harmonic.mapper.mysql.upload.PmsRunStatisticDMapper;
import com.njcn.prepare.harmonic.mapper.mysql.upload.RUploadEvaluationDataDMapper; import com.njcn.prepare.harmonic.mapper.mysql.upload.RUploadEvaluationDataDMapper;
import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam; import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam;
import com.njcn.prepare.harmonic.pojo.dto.BusBarDto; import com.njcn.prepare.harmonic.pojo.dto.BusBarDto;
import com.njcn.prepare.harmonic.service.mysql.upload.IPmsRunStatisticMService;
import com.njcn.prepare.harmonic.service.mysql.upload.IPmsRunStatisticYService;
import com.njcn.prepare.harmonic.service.mysql.upload.IRUploadEvaluationDataDService; import com.njcn.prepare.harmonic.service.mysql.upload.IRUploadEvaluationDataDService;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum; import com.njcn.system.enums.DicDataEnum;
@@ -65,38 +70,60 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
private final DicDataFeignClient dicDataFeignClient; private final DicDataFeignClient dicDataFeignClient;
private final CommTerminalGeneralClient commTerminalGeneralClient; private final CommTerminalGeneralClient commTerminalGeneralClient;
private final GeneratrixWireMapper generatrixWireMapper; private final GeneratrixWireMapper generatrixWireMapper;
private final PmsRunStatisticDMapper runStatisticDMapper;
private final IPmsRunStatisticMService runStatisticMService;
private final IPmsRunStatisticYService runStatisticYService;
@Override @Override
public void insertEvaluationDataDay(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam) { public void insertEvaluationDataDay(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam) {
List<RUploadEvaluationDataD> result = new ArrayList<>(); List<RUploadEvaluationDataD> result = new ArrayList<>();
final Double defaultValue = 3.1415926; final Double defaultValue = 3.1415926;
//获取监测点信息 //首先获取pms_run_statistic表是否存在执行日期的数据
List<Monitor> list1 = this.getPmsMonitor(); List<PmsRunStatisticD> pmsRunStatisticsListD = runStatisticDMapper.selectList(new LambdaQueryWrapper<PmsRunStatisticD>().eq(PmsRunStatisticD::getStatisticDate, calculatedParam.getDataDate()));
//获取中台母线信息 //获取中台母线信息
List<PmsMidLedger> list2 = this.getBusBarInfo(); List<PmsMidLedger> list2 = this.getBusBarInfo();
//获取灿能母线信息 //获取灿能母线信息
List<GeneratrixWire> list3 = this.getCnBusBarInfo(list1); List<GeneratrixWire> list3;
if (CollUtil.isNotEmpty(pmsRunStatisticsListD)) {
List<String> wireIds = pmsRunStatisticsListD.stream()
.filter(x -> StrUtil.isNotBlank(x.getOnlineBusIds()))
.flatMap(x -> CollectionUtil.toList(x.getOnlineBusIds().split(StrUtil.COMMA)).stream()).distinct().collect(Collectors.toList());
if(CollUtil.isNotEmpty(wireIds)){
LambdaQueryWrapper<GeneratrixWire> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(GeneratrixWire::getStatus, DataStateEnum.ENABLE.getCode())
.in(GeneratrixWire::getId, wireIds);
list3 = generatrixWireMapper.selectList(lambdaQueryWrapper);
}else{
List<Monitor> list1 = this.getPmsMonitor();
list3 = this.getCnBusBarInfo(list1);
}
} else {
//获取监测点信息
List<Monitor> list1 = this.getPmsMonitor();
list3 = this.getCnBusBarInfo(list1);
}
//获取单位下各电压等级数据 //获取单位下各电压等级数据
DeptGetLineParam deptGetLineParam = new DeptGetLineParam(); DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
Dept data = deptFeignClient.getRootDept().getData(); Dept data = deptFeignClient.getRootDept().getData();
deptGetLineParam.setDeptId(data.getId()); deptGetLineParam.setDeptId(data.getId());
List<DeptGetBusBarDTO> barDto = commTerminalGeneralClient.deptBusBar(deptGetLineParam).getData(); List<DeptGetBusBarDTO> barDto = commTerminalGeneralClient.deptBusBar(deptGetLineParam).getData();
List<BusBarDto> busBarList = this.getBusBarNum(list3,list2,barDto); List<BusBarDto> busBarList = this.getBusBarNum(list3, list2, barDto);
List<BusBarDto> allDept = this.getAllDeptLineNum(busBarList,deptGetLineParam); List<BusBarDto> allDept = this.getAllDeptLineNum(busBarList, deptGetLineParam);
//获取省级单位id //获取省级单位id
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();
//获取所有单位 //获取所有单位
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));
List<DeptGetChildrenMoreDTO> list = calculatedParam.getIdList(); List<DeptGetChildrenMoreDTO> list = calculatedParam.getIdList();
list.forEach(item->{ list.forEach(item -> {
if (Objects.equals(Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_1.getCode()),item.getDeptLevel()) if (Objects.equals(Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_1.getCode()), item.getDeptLevel())
//市数据 //市数据
//|| Objects.equals(Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_3.getCode()),item.getDeptLevel()) //|| Objects.equals(Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_3.getCode()),item.getDeptLevel())
//县数据 //县数据
|| Objects.equals(Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_4.getCode()),item.getDeptLevel())){ || Objects.equals(Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_4.getCode()), item.getDeptLevel())) {
return; return;
} }
RUploadEvaluationDataD rUploadEvaluationDataD = new RUploadEvaluationDataD(); RUploadEvaluationDataD rUploadEvaluationDataD = new RUploadEvaluationDataD();
@@ -107,74 +134,75 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
rUploadEvaluationDataD.setComputeDate(calculatedParam.getDataDate()); rUploadEvaluationDataD.setComputeDate(calculatedParam.getDataDate());
rUploadEvaluationDataD.setStatisticalType(UploadEnum.STATISTICAL_TYPE_03.getCode()); rUploadEvaluationDataD.setStatisticalType(UploadEnum.STATISTICAL_TYPE_03.getCode());
rUploadEvaluationDataD.setUploadStatus(Integer.parseInt(UploadEnum.UPLOAD_STATUS_0.getCode())); rUploadEvaluationDataD.setUploadStatus(Integer.parseInt(UploadEnum.UPLOAD_STATUS_0.getCode()));
this.judgeLevel(item.getDeptLevel(),rUploadEvaluationDataD,item.getUnitId(),item.getUnitName(),deptList,deptMap); this.judgeLevel(item.getDeptLevel(), rUploadEvaluationDataD, item.getUnitId(), item.getUnitName(), deptList, deptMap);
BusBarDto busBarDto = allDept.stream().filter(o->Objects.equals(o.getOrgId(),item.getUnitId())).findFirst().orElse(null); BusBarDto busBarDto = allDept.stream().filter(o -> Objects.equals(o.getOrgId(), item.getUnitId())).findFirst().orElse(null);
/*** 计算无电压等级的数据*/ /*** 计算无电压等级的数据*/
RUploadEvaluationDataD dto = this.getLineNum(busBarDto,"0"); RUploadEvaluationDataD dto = this.getLineNum(busBarDto, "0");
//电压 //电压
RUploadEvaluationDataD dto1 = this.channelData(rUploadEvaluationDataD,defaultValue,defaultValue,UploadEnum.INDEX_TYPE_01.getCode(),0,"0",dto); RUploadEvaluationDataD dto1 = this.channelData(rUploadEvaluationDataD, defaultValue, defaultValue, UploadEnum.INDEX_TYPE_01.getCode(), 0, "0", dto);
result.add(dto1); result.add(dto1);
//长时间闪变 //长时间闪变
RUploadEvaluationDataD dto2 = this.channelData(rUploadEvaluationDataD,defaultValue,defaultValue,UploadEnum.INDEX_TYPE_02.getCode(),0,"0",dto); RUploadEvaluationDataD dto2 = this.channelData(rUploadEvaluationDataD, defaultValue, defaultValue, UploadEnum.INDEX_TYPE_02.getCode(), 0, "0", dto);
result.add(dto2); result.add(dto2);
//三相电压不平衡 //三相电压不平衡
RUploadEvaluationDataD dto3 = this.channelData(rUploadEvaluationDataD,defaultValue,defaultValue,UploadEnum.INDEX_TYPE_03.getCode(),0,"0",dto); RUploadEvaluationDataD dto3 = this.channelData(rUploadEvaluationDataD, defaultValue, defaultValue, UploadEnum.INDEX_TYPE_03.getCode(), 0, "0", dto);
result.add(dto3); result.add(dto3);
//电压总谐波畸变率 //电压总谐波畸变率
RUploadEvaluationDataD dto4 = this.channelData(rUploadEvaluationDataD,defaultValue,defaultValue,UploadEnum.INDEX_TYPE_04.getCode(),0,"0",dto); RUploadEvaluationDataD dto4 = this.channelData(rUploadEvaluationDataD, defaultValue, defaultValue, UploadEnum.INDEX_TYPE_04.getCode(), 0, "0", dto);
result.add(dto4); result.add(dto4);
//各次谐波电压 //各次谐波电压
this.channelHarmonicData(rUploadEvaluationDataD,result,null,UploadEnum.INDEX_TYPE_05.getCode(),"0",dto,null); this.channelHarmonicData(rUploadEvaluationDataD, result, null, UploadEnum.INDEX_TYPE_05.getCode(), "0", dto, null);
//负序电流 //负序电流
RUploadEvaluationDataD dto6 = this.channelData(rUploadEvaluationDataD,defaultValue,defaultValue,UploadEnum.INDEX_TYPE_06.getCode(),0,"0",dto); RUploadEvaluationDataD dto6 = this.channelData(rUploadEvaluationDataD, defaultValue, defaultValue, UploadEnum.INDEX_TYPE_06.getCode(), 0, "0", dto);
result.add(dto6); result.add(dto6);
/*** 计算分电压等级的数据*/ /*** 计算分电压等级的数据*/
if (CollUtil.isNotEmpty(busBarDto.getVoltageChild())){ if (CollUtil.isNotEmpty(busBarDto.getVoltageChild())) {
busBarDto.getVoltageChild().forEach(item2->{ busBarDto.getVoltageChild().forEach(item2 -> {
RDimVoltageD rDimVoltageD = this.getDimVoltageData(item.getUnitId(),calculatedParam.getDataDate(),item2.getVoltageLevel()); RDimVoltageD rDimVoltageD = this.getDimVoltageData(item.getUnitId(), calculatedParam.getDataDate(), item2.getVoltageLevel());
RUploadEvaluationDataD dto0 = this.getLineNum(busBarDto,item2.getVoltageLevel()); RUploadEvaluationDataD dto0 = this.getLineNum(busBarDto, item2.getVoltageLevel());
//电压 //电压
double sd1 = this.getDimVoltageDataSd(item2.getVoltageLevel(),Objects.isNull(rDimVoltageD)?defaultValue:rDimVoltageD.getV(),calculatedParam.getDataDate(),item.getLineBaseList(),UploadEnum.INDEX_TYPE_01.getCode(),null); double sd1 = this.getDimVoltageDataSd(item2.getVoltageLevel(), Objects.isNull(rDimVoltageD) ? defaultValue : rDimVoltageD.getV(), calculatedParam.getDataDate(), item.getLineBaseList(), UploadEnum.INDEX_TYPE_01.getCode(), null);
RUploadEvaluationDataD dto11 = this.channelData(rUploadEvaluationDataD,Objects.isNull(rDimVoltageD)?defaultValue:rDimVoltageD.getV(),sd1,UploadEnum.INDEX_TYPE_01.getCode(),0,item2.getVoltageLevel(),dto0); RUploadEvaluationDataD dto11 = this.channelData(rUploadEvaluationDataD, Objects.isNull(rDimVoltageD) ? defaultValue : rDimVoltageD.getV(), sd1, UploadEnum.INDEX_TYPE_01.getCode(), 0, item2.getVoltageLevel(), dto0);
result.add(dto11); result.add(dto11);
//长时间闪变 //长时间闪变
double sd2 = this.getDimVoltageDataSd(item2.getVoltageLevel(),Objects.isNull(rDimVoltageD)?defaultValue:rDimVoltageD.getPst(),calculatedParam.getDataDate(),item.getLineBaseList(),UploadEnum.INDEX_TYPE_02.getCode(),null); double sd2 = this.getDimVoltageDataSd(item2.getVoltageLevel(), Objects.isNull(rDimVoltageD) ? defaultValue : rDimVoltageD.getPst(), calculatedParam.getDataDate(), item.getLineBaseList(), UploadEnum.INDEX_TYPE_02.getCode(), null);
RUploadEvaluationDataD dto22 = this.channelData(rUploadEvaluationDataD,Objects.isNull(rDimVoltageD)?defaultValue:rDimVoltageD.getPst(),sd2,UploadEnum.INDEX_TYPE_02.getCode(),0,item2.getVoltageLevel(),dto0); RUploadEvaluationDataD dto22 = this.channelData(rUploadEvaluationDataD, Objects.isNull(rDimVoltageD) ? defaultValue : rDimVoltageD.getPst(), sd2, UploadEnum.INDEX_TYPE_02.getCode(), 0, item2.getVoltageLevel(), dto0);
result.add(dto22); result.add(dto22);
//三相电压不平衡 //三相电压不平衡
double sd3 = this.getDimVoltageDataSd(item2.getVoltageLevel(),Objects.isNull(rDimVoltageD)?defaultValue:rDimVoltageD.getVUnbalance(),calculatedParam.getDataDate(),item.getLineBaseList(),UploadEnum.INDEX_TYPE_03.getCode(),null); double sd3 = this.getDimVoltageDataSd(item2.getVoltageLevel(), Objects.isNull(rDimVoltageD) ? defaultValue : rDimVoltageD.getVUnbalance(), calculatedParam.getDataDate(), item.getLineBaseList(), UploadEnum.INDEX_TYPE_03.getCode(), null);
RUploadEvaluationDataD dto33 = this.channelData(rUploadEvaluationDataD,Objects.isNull(rDimVoltageD)?defaultValue:rDimVoltageD.getVUnbalance(),sd3,UploadEnum.INDEX_TYPE_03.getCode(),0,item2.getVoltageLevel(),dto0); RUploadEvaluationDataD dto33 = this.channelData(rUploadEvaluationDataD, Objects.isNull(rDimVoltageD) ? defaultValue : rDimVoltageD.getVUnbalance(), sd3, UploadEnum.INDEX_TYPE_03.getCode(), 0, item2.getVoltageLevel(), dto0);
result.add(dto33); result.add(dto33);
//电压总谐波畸变率 //电压总谐波畸变率
double sd4 = this.getDimVoltageDataSd(item2.getVoltageLevel(),Objects.isNull(rDimVoltageD)?defaultValue:rDimVoltageD.getVThd(),calculatedParam.getDataDate(),item.getLineBaseList(),UploadEnum.INDEX_TYPE_04.getCode(),null); double sd4 = this.getDimVoltageDataSd(item2.getVoltageLevel(), Objects.isNull(rDimVoltageD) ? defaultValue : rDimVoltageD.getVThd(), calculatedParam.getDataDate(), item.getLineBaseList(), UploadEnum.INDEX_TYPE_04.getCode(), null);
RUploadEvaluationDataD dto44 = this.channelData(rUploadEvaluationDataD,Objects.isNull(rDimVoltageD)?defaultValue:rDimVoltageD.getVThd(),sd4,UploadEnum.INDEX_TYPE_04.getCode(),0,item2.getVoltageLevel(),dto0); RUploadEvaluationDataD dto44 = this.channelData(rUploadEvaluationDataD, Objects.isNull(rDimVoltageD) ? defaultValue : rDimVoltageD.getVThd(), sd4, UploadEnum.INDEX_TYPE_04.getCode(), 0, item2.getVoltageLevel(), dto0);
result.add(dto44); result.add(dto44);
//各次谐波电压 //各次谐波电压
List<Double> valueList = new ArrayList<>(); List<Double> valueList = new ArrayList<>();
if (!Objects.isNull(rDimVoltageD)){ if (!Objects.isNull(rDimVoltageD)) {
valueList = Arrays.asList(rDimVoltageD.getV2(),rDimVoltageD.getV3(),rDimVoltageD.getV4(),rDimVoltageD.getV5(),rDimVoltageD.getV6(),rDimVoltageD.getV7(),rDimVoltageD.getV8(),rDimVoltageD.getV9(),rDimVoltageD.getV10() valueList = Arrays.asList(rDimVoltageD.getV2(), rDimVoltageD.getV3(), rDimVoltageD.getV4(), rDimVoltageD.getV5(), rDimVoltageD.getV6(), rDimVoltageD.getV7(), rDimVoltageD.getV8(), rDimVoltageD.getV9(), rDimVoltageD.getV10()
,rDimVoltageD.getV11(),rDimVoltageD.getV12(),rDimVoltageD.getV13(),rDimVoltageD.getV14(),rDimVoltageD.getV15(),rDimVoltageD.getV16(),rDimVoltageD.getV17(),rDimVoltageD.getV18(),rDimVoltageD.getV19(),rDimVoltageD.getV20() , rDimVoltageD.getV11(), rDimVoltageD.getV12(), rDimVoltageD.getV13(), rDimVoltageD.getV14(), rDimVoltageD.getV15(), rDimVoltageD.getV16(), rDimVoltageD.getV17(), rDimVoltageD.getV18(), rDimVoltageD.getV19(), rDimVoltageD.getV20()
,rDimVoltageD.getV21(),rDimVoltageD.getV22(),rDimVoltageD.getV23(),rDimVoltageD.getV24(),rDimVoltageD.getV25(),rDimVoltageD.getV26(),rDimVoltageD.getV27(),rDimVoltageD.getV28(),rDimVoltageD.getV29(),rDimVoltageD.getV30() , rDimVoltageD.getV21(), rDimVoltageD.getV22(), rDimVoltageD.getV23(), rDimVoltageD.getV24(), rDimVoltageD.getV25(), rDimVoltageD.getV26(), rDimVoltageD.getV27(), rDimVoltageD.getV28(), rDimVoltageD.getV29(), rDimVoltageD.getV30()
,rDimVoltageD.getV31(),rDimVoltageD.getV32(),rDimVoltageD.getV33(),rDimVoltageD.getV34(),rDimVoltageD.getV35(),rDimVoltageD.getV36(),rDimVoltageD.getV37(),rDimVoltageD.getV38(),rDimVoltageD.getV39(),rDimVoltageD.getV40() , rDimVoltageD.getV31(), rDimVoltageD.getV32(), rDimVoltageD.getV33(), rDimVoltageD.getV34(), rDimVoltageD.getV35(), rDimVoltageD.getV36(), rDimVoltageD.getV37(), rDimVoltageD.getV38(), rDimVoltageD.getV39(), rDimVoltageD.getV40()
,rDimVoltageD.getV41(),rDimVoltageD.getV42(),rDimVoltageD.getV43(),rDimVoltageD.getV44(),rDimVoltageD.getV45(),rDimVoltageD.getV46(),rDimVoltageD.getV47(),rDimVoltageD.getV48(),rDimVoltageD.getV49(),rDimVoltageD.getV50()); , rDimVoltageD.getV41(), rDimVoltageD.getV42(), rDimVoltageD.getV43(), rDimVoltageD.getV44(), rDimVoltageD.getV45(), rDimVoltageD.getV46(), rDimVoltageD.getV47(), rDimVoltageD.getV48(), rDimVoltageD.getV49(), rDimVoltageD.getV50());
} }
this.channelHarmonicData(rUploadEvaluationDataD,result,valueList,UploadEnum.INDEX_TYPE_05.getCode(),item2.getVoltageLevel(),dto0,item.getLineBaseList()); this.channelHarmonicData(rUploadEvaluationDataD, result, valueList, UploadEnum.INDEX_TYPE_05.getCode(), item2.getVoltageLevel(), dto0, item.getLineBaseList());
//负序电流 //负序电流
double sd6 = this.getDimVoltageDataSd(item2.getVoltageLevel(),Objects.isNull(rDimVoltageD)?defaultValue:rDimVoltageD.getINeg(),calculatedParam.getDataDate(),item.getLineBaseList(),UploadEnum.INDEX_TYPE_06.getCode(),null); double sd6 = this.getDimVoltageDataSd(item2.getVoltageLevel(), Objects.isNull(rDimVoltageD) ? defaultValue : rDimVoltageD.getINeg(), calculatedParam.getDataDate(), item.getLineBaseList(), UploadEnum.INDEX_TYPE_06.getCode(), null);
RUploadEvaluationDataD dto66 = this.channelData(rUploadEvaluationDataD,Objects.isNull(rDimVoltageD)?defaultValue:rDimVoltageD.getINeg(),sd6,UploadEnum.INDEX_TYPE_06.getCode(),0,item2.getVoltageLevel(),dto0); RUploadEvaluationDataD dto66 = this.channelData(rUploadEvaluationDataD, Objects.isNull(rDimVoltageD) ? defaultValue : rDimVoltageD.getINeg(), sd6, UploadEnum.INDEX_TYPE_06.getCode(), 0, item2.getVoltageLevel(), dto0);
result.add(dto66); result.add(dto66);
}); });
} }
}); });
if (CollUtil.isNotEmpty(result)){ if (CollUtil.isNotEmpty(result)) {
this.saveOrUpdateBatchByMultiId(result,1000); this.saveOrUpdateBatchByMultiId(result, 1000);
} }
} }
/** /**
* 通过日表取平均值,作为月表数据 * 通过日表取平均值,作为月表数据
*
* @param calculatedParam * @param calculatedParam
*/ */
@Override @Override
@@ -186,14 +214,33 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
//结束时间 //结束时间
String endTime = DateUtil.format(DateUtil.endOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN); String endTime = DateUtil.format(DateUtil.endOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN);
//数据集 //数据集
List<RUploadEvaluationDataD> list = this.baseMapper.evaluationMonthData(beginMonth,startTime,endTime,"02"); List<RUploadEvaluationDataD> list = this.baseMapper.evaluationMonthData(beginMonth, startTime, endTime, "02");
//获取监测点信息 List<PmsRunStatisticM> pmsRunStatisticsList = runStatisticMService.selectListByDate(startTime, endTime,calculatedParam.getDataDate());
List<Monitor> list1 = this.getPmsMonitor();
//获取中台母线信息 //获取中台母线信息
List<PmsMidLedger> list2 = this.getBusBarInfo(); List<PmsMidLedger> list2 = this.getBusBarInfo();
//获取灿能母线信息 //获取灿能母线信息
List<GeneratrixWire> list3 = this.getCnBusBarInfo(list1); List<GeneratrixWire> list3;
if (CollUtil.isNotEmpty(pmsRunStatisticsList)) {
List<String> wireIds = pmsRunStatisticsList.stream()
.filter(x -> StrUtil.isNotBlank(x.getOnlineBusIds()))
.flatMap(x -> CollectionUtil.toList(x.getOnlineBusIds().split(StrUtil.COMMA)).stream()).distinct().collect(Collectors.toList());
if(CollUtil.isNotEmpty(wireIds)){
LambdaQueryWrapper<GeneratrixWire> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(GeneratrixWire::getStatus, DataStateEnum.ENABLE.getCode())
.in(GeneratrixWire::getId, wireIds);
list3 = generatrixWireMapper.selectList(lambdaQueryWrapper);
}else{
List<Monitor> list1 = this.getPmsMonitor();
list3 = this.getCnBusBarInfo(list1);
}
} else {
//获取监测点信息
List<Monitor> list1 = this.getPmsMonitor();
list3 = this.getCnBusBarInfo(list1);
}
//获取单位下各电压等级数据 //获取单位下各电压等级数据
DeptGetLineParam deptGetLineParam = new DeptGetLineParam(); DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
@@ -203,25 +250,25 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
List<BusBarDto> busBarList = new ArrayList<>(); List<BusBarDto> busBarList = new ArrayList<>();
for(DeptGetBusBarDTO deptGetBusBarDTO : barDto){ for (DeptGetBusBarDTO deptGetBusBarDTO : barDto) {
BusBarDto busBarDto = new BusBarDto(); BusBarDto busBarDto = new BusBarDto();
busBarDto.setOrgId(deptGetBusBarDTO.getUnitId()); busBarDto.setOrgId(deptGetBusBarDTO.getUnitId());
Integer online = (int)list3.stream().map(GeneratrixWire::getId).filter(id ->deptGetBusBarDTO.getBusBarIds().contains(id)).distinct().count(); Integer online = (int) list3.stream().map(GeneratrixWire::getId).filter(id -> deptGetBusBarDTO.getBusBarIds().contains(id)).distinct().count();
busBarDto.setAllMonitorBusNum(online); busBarDto.setAllMonitorBusNum(online);
Integer all = (int)list2.stream().filter(item->deptGetBusBarDTO.getUnitChildrenList().contains(item.getSectionId())).count(); Integer all = (int) list2.stream().filter(item -> deptGetBusBarDTO.getUnitChildrenList().contains(item.getSectionId())).count();
busBarDto.setAllOnlineBusNum(all); busBarDto.setAllOnlineBusNum(all);
if(all>0){ if (all > 0) {
busBarDto.setAllMonitorRate(BigDecimal.valueOf((double) online/all).setScale(4,RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)).doubleValue()); busBarDto.setAllMonitorRate(BigDecimal.valueOf((double) online / all).setScale(4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)).doubleValue());
} }
busBarList.add(busBarDto); busBarList.add(busBarDto);
} }
Map<String,BusBarDto> mapBus = busBarList.stream().collect(Collectors.toMap(BusBarDto::getOrgId, Function.identity())); Map<String, BusBarDto> mapBus = busBarList.stream().collect(Collectors.toMap(BusBarDto::getOrgId, Function.identity()));
if (CollUtil.isNotEmpty(list)){ if (CollUtil.isNotEmpty(list)) {
list.forEach(item->{ list.forEach(item -> {
item.setId(IdUtil.simpleUUID()); item.setId(IdUtil.simpleUUID());
item.setComputeDate(calculatedParam.getDataDate()); item.setComputeDate(calculatedParam.getDataDate());
@@ -250,48 +297,17 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
} }
}); });
this.saveOrUpdateBatchByMultiId(list,1000); this.saveOrUpdateBatchByMultiId(list, 1000);
} }
} }
/** /**
* 通过日表取平均值,作为年表数据 * 通过日表取平均值,作为年表数据
*
* @param calculatedParam * @param calculatedParam
*/ */
@Override @Override
public void insertEvaluationDataYear(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam) { public void insertEvaluationDataYear(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam) {
//获取监测点信息
List<Monitor> list1 = this.getPmsMonitor();
//获取中台母线信息
List<PmsMidLedger> list2 = this.getBusBarInfo();
//获取灿能母线信息
List<GeneratrixWire> list3 = this.getCnBusBarInfo(list1);
//获取单位下各电压等级数据
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
Dept data = deptFeignClient.getRootDept().getData();
deptGetLineParam.setDeptId(data.getId());
List<DeptGetBusBarDTO> barDto = commTerminalGeneralClient.deptBusBar(deptGetLineParam).getData();
List<BusBarDto> busBarList = new ArrayList<>();
for(DeptGetBusBarDTO deptGetBusBarDTO : barDto){
BusBarDto busBarDto = new BusBarDto();
busBarDto.setOrgId(deptGetBusBarDTO.getUnitId());
Integer online = (int)list3.stream().map(GeneratrixWire::getId).filter(id ->deptGetBusBarDTO.getBusBarIds().contains(id)).distinct().count();
busBarDto.setAllMonitorBusNum(online);
Integer all = (int)list2.stream().filter(item->deptGetBusBarDTO.getUnitChildrenList().contains(item.getSectionId())).count();
busBarDto.setAllOnlineBusNum(all);
if(all>0){
busBarDto.setAllMonitorRate(BigDecimal.valueOf((double) online/all).setScale(4,RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)).doubleValue());
}
busBarList.add(busBarDto);
}
Map<String,BusBarDto> mapBus = busBarList.stream().collect(Collectors.toMap(BusBarDto::getOrgId, Function.identity()));
//开始年 //开始年
String begin = DateUtil.format(DateUtil.beginOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_YEAR_PATTERN)), DatePattern.NORM_YEAR_PATTERN); String begin = DateUtil.format(DateUtil.beginOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_YEAR_PATTERN)), DatePattern.NORM_YEAR_PATTERN);
//起始时间 //起始时间
@@ -299,9 +315,58 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
//结束时间 //结束时间
String endTime = DateUtil.format(DateUtil.endOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN); String endTime = DateUtil.format(DateUtil.endOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN);
//数据集 //数据集
List<RUploadEvaluationDataD> list = this.baseMapper.evaluationMonthData(begin,startTime,endTime,"01"); List<RUploadEvaluationDataD> list = this.baseMapper.evaluationMonthData(begin, startTime, endTime, "01");
if (CollUtil.isNotEmpty(list)){
list.forEach(item->{ List<PmsRunStatisticY> pmsRunStatisticsList = runStatisticYService.selectListByDate(startTime, endTime,calculatedParam.getDataDate());
//获取中台母线信息
List<PmsMidLedger> list2 = this.getBusBarInfo();
//获取灿能母线信息
List<GeneratrixWire> list3;
if (CollUtil.isNotEmpty(pmsRunStatisticsList)) {
List<String> wireIds = pmsRunStatisticsList.stream()
.filter(x -> StrUtil.isNotBlank(x.getOnlineBusIds()))
.flatMap(x -> CollectionUtil.toList(x.getOnlineBusIds().split(StrUtil.COMMA)).stream()).distinct().collect(Collectors.toList());
if(CollUtil.isNotEmpty(wireIds)){
LambdaQueryWrapper<GeneratrixWire> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(GeneratrixWire::getStatus, DataStateEnum.ENABLE.getCode())
.in(GeneratrixWire::getId, wireIds);
list3 = generatrixWireMapper.selectList(lambdaQueryWrapper);
}else{
List<Monitor> list1 = this.getPmsMonitor();
list3 = this.getCnBusBarInfo(list1);
}
} else {
//获取监测点信息
List<Monitor> list1 = this.getPmsMonitor();
list3 = this.getCnBusBarInfo(list1);
}
//获取单位下各电压等级数据
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
Dept data = deptFeignClient.getRootDept().getData();
deptGetLineParam.setDeptId(data.getId());
List<DeptGetBusBarDTO> barDto = commTerminalGeneralClient.deptBusBar(deptGetLineParam).getData();
List<BusBarDto> busBarList = new ArrayList<>();
for (DeptGetBusBarDTO deptGetBusBarDTO : barDto) {
BusBarDto busBarDto = new BusBarDto();
busBarDto.setOrgId(deptGetBusBarDTO.getUnitId());
Integer online = (int) list3.stream().map(GeneratrixWire::getId).filter(id -> deptGetBusBarDTO.getBusBarIds().contains(id)).distinct().count();
busBarDto.setAllMonitorBusNum(online);
Integer all = (int) list2.stream().filter(item -> deptGetBusBarDTO.getUnitChildrenList().contains(item.getSectionId())).count();
busBarDto.setAllOnlineBusNum(all);
if (all > 0) {
busBarDto.setAllMonitorRate(BigDecimal.valueOf((double) online / all).setScale(4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)).doubleValue());
}
busBarList.add(busBarDto);
}
Map<String, BusBarDto> mapBus = busBarList.stream().collect(Collectors.toMap(BusBarDto::getOrgId, Function.identity()));
if (CollUtil.isNotEmpty(list)) {
list.forEach(item -> {
item.setId(IdUtil.simpleUUID()); item.setId(IdUtil.simpleUUID());
item.setComputeDate(calculatedParam.getDataDate()); item.setComputeDate(calculatedParam.getDataDate());
@@ -329,7 +394,7 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
} }
}); });
this.saveOrUpdateBatchByMultiId(list,1000); this.saveOrUpdateBatchByMultiId(list, 1000);
} }
} }
@@ -338,11 +403,11 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
*/ */
public List<Monitor> getPmsMonitor() { public List<Monitor> getPmsMonitor() {
List<DictData> dicDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.LINE_STATE.getCode()).getData(); List<DictData> dicDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.LINE_STATE.getCode()).getData();
DictData dictData = dicDataList.stream().filter(o->Objects.equals(o.getCode(), DicDataEnum.RUN.getCode())).findFirst().orElse(null); DictData dictData = dicDataList.stream().filter(o -> Objects.equals(o.getCode(), DicDataEnum.RUN.getCode())).findFirst().orElse(null);
LambdaQueryWrapper<Monitor> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Monitor> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(Monitor::getStatus, DataStateEnum.ENABLE.getCode()) lambdaQueryWrapper.eq(Monitor::getStatus, DataStateEnum.ENABLE.getCode())
.eq(Monitor::getIsUpToGrid,DataStateEnum.ENABLE.getCode()) .eq(Monitor::getIsUpToGrid, DataStateEnum.ENABLE.getCode())
.eq(Monitor::getMonitorState,dictData.getId()); .eq(Monitor::getMonitorState, dictData.getId());
return pmsMonitorMapper.selectList(lambdaQueryWrapper); return pmsMonitorMapper.selectList(lambdaQueryWrapper);
} }
@@ -367,7 +432,7 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
List<String> lineList = list.stream().map(Monitor::getLineId).collect(Collectors.toList()); List<String> lineList = list.stream().map(Monitor::getLineId).collect(Collectors.toList());
LambdaQueryWrapper<GeneratrixWire> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GeneratrixWire> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(GeneratrixWire::getStatus, DataStateEnum.ENABLE.getCode()) lambdaQueryWrapper.eq(GeneratrixWire::getStatus, DataStateEnum.ENABLE.getCode())
.in(GeneratrixWire::getId,lineList); .in(GeneratrixWire::getId, lineList);
return generatrixWireMapper.selectList(lambdaQueryWrapper); return generatrixWireMapper.selectList(lambdaQueryWrapper);
} }
@@ -377,7 +442,7 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
public List<BusBarDto> getBusBarNum(List<GeneratrixWire> list1, List<PmsMidLedger> list2, List<DeptGetBusBarDTO> dto) { public List<BusBarDto> getBusBarNum(List<GeneratrixWire> list1, List<PmsMidLedger> list2, List<DeptGetBusBarDTO> dto) {
List<BusBarDto> result = new ArrayList<>(); List<BusBarDto> result = new ArrayList<>();
//中台母线 //中台母线
Map<String,List<PmsMidLedger>> midMap = list2.stream().collect(Collectors.groupingBy(PmsMidLedger::getSectionId)); Map<String, List<PmsMidLedger>> midMap = list2.stream().collect(Collectors.groupingBy(PmsMidLedger::getSectionId));
for (DeptGetBusBarDTO item : dto) { for (DeptGetBusBarDTO item : dto) {
int count = 0; int count = 0;
List<BusBarDto.VoltageChild> childList = new ArrayList<>(); List<BusBarDto.VoltageChild> childList = new ArrayList<>();
@@ -385,31 +450,31 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
dto1.setOrgId(item.getUnitId()); dto1.setOrgId(item.getUnitId());
//处理中台母线 //处理中台母线
List<PmsMidLedger> l1 = midMap.get(item.getUnitId()); List<PmsMidLedger> l1 = midMap.get(item.getUnitId());
if (CollUtil.isNotEmpty(l1)){ if (CollUtil.isNotEmpty(l1)) {
dto1.setAllOnlineBusNum(l1.size()); dto1.setAllOnlineBusNum(l1.size());
Map<String,List<PmsMidLedger>> voltageMap = l1.stream().collect(Collectors.groupingBy(PmsMidLedger::getVoltageLevel)); Map<String, List<PmsMidLedger>> voltageMap = l1.stream().collect(Collectors.groupingBy(PmsMidLedger::getVoltageLevel));
for (String key : voltageMap.keySet()) { for (String key : voltageMap.keySet()) {
BusBarDto.VoltageChild voltageChild = new BusBarDto.VoltageChild(); BusBarDto.VoltageChild voltageChild = new BusBarDto.VoltageChild();
List<String> l2 = voltageMap.get(key).stream().map(PmsMidLedger::getId).collect(Collectors.toList()); List<String> l2 = voltageMap.get(key).stream().map(PmsMidLedger::getId).collect(Collectors.toList());
voltageChild.setVoltageLevel(key); voltageChild.setVoltageLevel(key);
voltageChild.setOnlineBusNum(l2.size()); voltageChild.setOnlineBusNum(l2.size());
//匹配wire母线表数量 //匹配wire母线表数量
if (CollUtil.isNotEmpty(item.getBusBarIds())){ if (CollUtil.isNotEmpty(item.getBusBarIds())) {
List<GeneratrixWire> l3 = list1.stream().filter(o->item.getBusBarIds().contains(o.getId())).collect(Collectors.toList()); List<GeneratrixWire> l3 = list1.stream().filter(o -> item.getBusBarIds().contains(o.getId())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(l3)){ if (CollUtil.isNotEmpty(l3)) {
voltageChild.setMonitorBusNum(l3.size()); voltageChild.setMonitorBusNum(l3.size());
} }
} else { } else {
voltageChild.setMonitorBusNum(0); voltageChild.setMonitorBusNum(0);
} }
voltageChild.setMonitorRate(voltageChild.getMonitorBusNum()*100.0/voltageChild.getOnlineBusNum()); voltageChild.setMonitorRate(voltageChild.getMonitorBusNum() * 100.0 / voltageChild.getOnlineBusNum());
childList.add(voltageChild); childList.add(voltageChild);
// count = count + voltageChild.getMonitorBusNum(); // count = count + voltageChild.getMonitorBusNum();
count = voltageChild.getMonitorBusNum(); count = voltageChild.getMonitorBusNum();
} }
dto1.setAllMonitorBusNum(count); dto1.setAllMonitorBusNum(count);
dto1.setVoltageChild(childList); dto1.setVoltageChild(childList);
dto1.setAllMonitorRate(dto1.getAllMonitorRate()*100/l1.size()); dto1.setAllMonitorRate(dto1.getAllMonitorRate() * 100 / l1.size());
} }
result.add(dto1); result.add(dto1);
} }
@@ -423,35 +488,35 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
List<BusBarDto> result = new ArrayList<>(); List<BusBarDto> result = new ArrayList<>();
//获取所有部门信息 //获取所有部门信息
List<DeptGetBase> deptList = commTerminalGeneralClient.getDeptChildrenByParent(deptGetLineParam).getData(); List<DeptGetBase> deptList = commTerminalGeneralClient.getDeptChildrenByParent(deptGetLineParam).getData();
deptList.forEach(item->{ deptList.forEach(item -> {
int count1 = 0,count2 = 0; int count1 = 0, count2 = 0;
List<BusBarDto.VoltageChild> children = new ArrayList<>(); List<BusBarDto.VoltageChild> children = new ArrayList<>();
List<BusBarDto.VoltageChild> child = new ArrayList<>(); List<BusBarDto.VoltageChild> child = new ArrayList<>();
BusBarDto busBarDto = new BusBarDto(); BusBarDto busBarDto = new BusBarDto();
busBarDto.setOrgId(item.getUnitId()); busBarDto.setOrgId(item.getUnitId());
//获取当前部门下 包含母线数量的部门 //获取当前部门下 包含母线数量的部门
List<BusBarDto> newList = list.stream().filter(o->item.getUnitChildrenList().contains(o.getOrgId())).collect(Collectors.toList()); List<BusBarDto> newList = list.stream().filter(o -> item.getUnitChildrenList().contains(o.getOrgId())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(newList)){ if (CollUtil.isNotEmpty(newList)) {
for (BusBarDto it : newList) { for (BusBarDto it : newList) {
count1 = count1 + it.getAllMonitorBusNum(); count1 = count1 + it.getAllMonitorBusNum();
count2 = count2 + it.getAllOnlineBusNum(); count2 = count2 + it.getAllOnlineBusNum();
if (CollUtil.isNotEmpty(it.getVoltageChild())){ if (CollUtil.isNotEmpty(it.getVoltageChild())) {
child.addAll(it.getVoltageChild()); child.addAll(it.getVoltageChild());
} }
} }
busBarDto.setAllMonitorBusNum(count1); busBarDto.setAllMonitorBusNum(count1);
busBarDto.setAllOnlineBusNum(count2); busBarDto.setAllOnlineBusNum(count2);
busBarDto.setAllMonitorRate(count2==0?0.0:count1*100/count2); busBarDto.setAllMonitorRate(count2 == 0 ? 0.0 : count1 * 100 / count2);
if (CollUtil.isNotEmpty(child)){ if (CollUtil.isNotEmpty(child)) {
Map<String,List<BusBarDto.VoltageChild>> map = child.stream().collect(Collectors.groupingBy(BusBarDto.VoltageChild::getVoltageLevel)); Map<String, List<BusBarDto.VoltageChild>> map = child.stream().collect(Collectors.groupingBy(BusBarDto.VoltageChild::getVoltageLevel));
map.forEach((k,v)->{ map.forEach((k, v) -> {
BusBarDto.VoltageChild c1 = new BusBarDto.VoltageChild(); BusBarDto.VoltageChild c1 = new BusBarDto.VoltageChild();
c1.setVoltageLevel(k); c1.setVoltageLevel(k);
int monitorBusNum = (int) v.stream().mapToDouble(BusBarDto.VoltageChild::getMonitorBusNum).average().getAsDouble(); int monitorBusNum = (int) v.stream().mapToDouble(BusBarDto.VoltageChild::getMonitorBusNum).average().getAsDouble();
c1.setMonitorBusNum(monitorBusNum); c1.setMonitorBusNum(monitorBusNum);
int online = (int) v.stream().mapToDouble(BusBarDto.VoltageChild::getOnlineBusNum).average().getAsDouble(); int online = (int) v.stream().mapToDouble(BusBarDto.VoltageChild::getOnlineBusNum).average().getAsDouble();
c1.setOnlineBusNum(online); c1.setOnlineBusNum(online);
c1.setMonitorRate(online==0.0?0:monitorBusNum*100.0/online); c1.setMonitorRate(online == 0.0 ? 0 : monitorBusNum * 100.0 / online);
children.add(c1); children.add(c1);
}); });
busBarDto.setVoltageChild(children); busBarDto.setVoltageChild(children);
@@ -467,10 +532,10 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
*/ */
public RUploadEvaluationDataD getLineNum(BusBarDto dto2, String voltage) { public RUploadEvaluationDataD getLineNum(BusBarDto dto2, String voltage) {
RUploadEvaluationDataD dto = new RUploadEvaluationDataD(); RUploadEvaluationDataD dto = new RUploadEvaluationDataD();
if (!Objects.isNull(dto2)){ if (!Objects.isNull(dto2)) {
List<BusBarDto.VoltageChild> list = dto2.getVoltageChild(); List<BusBarDto.VoltageChild> list = dto2.getVoltageChild();
if (CollUtil.isNotEmpty(list)){ if (CollUtil.isNotEmpty(list)) {
list.forEach(item->{ list.forEach(item -> {
// if (Objects.equals(item.getVoltageLevel(),voltage)){ // if (Objects.equals(item.getVoltageLevel(),voltage)){
// dto.setMonitorBusNum(item.getMonitorBusNum()); // dto.setMonitorBusNum(item.getMonitorBusNum());
// dto.setOnlineBusNum(item.getOnlineBusNum()); // dto.setOnlineBusNum(item.getOnlineBusNum());
@@ -483,7 +548,7 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
//fixme 基准水平数据上传失败,先将各个电压等级数据调整为不区分电压等级的数据 //fixme 基准水平数据上传失败,先将各个电压等级数据调整为不区分电压等级的数据
dto.setMonitorBusNum(dto2.getAllMonitorBusNum()); dto.setMonitorBusNum(dto2.getAllMonitorBusNum());
dto.setOnlineBusNum(dto2.getAllOnlineBusNum()); dto.setOnlineBusNum(dto2.getAllOnlineBusNum());
dto.setMonitorBusRate(dto2.getAllMonitorBusNum()*100.0d/dto2.getAllOnlineBusNum()); dto.setMonitorBusRate(dto2.getAllMonitorBusNum() * 100.0d / dto2.getAllOnlineBusNum());
}); });
} }
} }
@@ -494,21 +559,21 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
/** /**
* 判断单位层级 * 判断单位层级
*/ */
public void judgeLevel(Integer level, RUploadEvaluationDataD rUploadEvaluationDataD, String id, String name, List<Dept> deptList, Map<String,List<Dept>> map) { public void judgeLevel(Integer level, RUploadEvaluationDataD rUploadEvaluationDataD, String id, String name, List<Dept> deptList, Map<String, List<Dept>> map) {
String result = ""; String result = "";
if (Objects.equals(level,Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_2.getCode()))){ if (Objects.equals(level, Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_2.getCode()))) {
result = UploadEnum.STATISTICAL_LEVEL_3.getCode(); result = UploadEnum.STATISTICAL_LEVEL_3.getCode();
rUploadEvaluationDataD.setCityId(""); rUploadEvaluationDataD.setCityId("");
rUploadEvaluationDataD.setCountyId(""); rUploadEvaluationDataD.setCountyId("");
} else if (Objects.equals(level,Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_3.getCode()))) { } else if (Objects.equals(level, Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_3.getCode()))) {
result = UploadEnum.STATISTICAL_LEVEL_4.getCode(); result = UploadEnum.STATISTICAL_LEVEL_4.getCode();
rUploadEvaluationDataD.setCityId(id); rUploadEvaluationDataD.setCityId(id);
rUploadEvaluationDataD.setCityName(name); rUploadEvaluationDataD.setCityName(name);
rUploadEvaluationDataD.setCountyId(""); rUploadEvaluationDataD.setCountyId("");
} else if (Objects.equals(level,Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_4.getCode()))) { } else if (Objects.equals(level, Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_4.getCode()))) {
result = UploadEnum.STATISTICAL_LEVEL_5.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(Collectors.toList());
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();
rUploadEvaluationDataD.setCityId(parentCode); rUploadEvaluationDataD.setCityId(parentCode);
rUploadEvaluationDataD.setCityName(map.get(parentCode).get(0).getName()); rUploadEvaluationDataD.setCityName(map.get(parentCode).get(0).getName());
rUploadEvaluationDataD.setCountyId(id); rUploadEvaluationDataD.setCountyId(id);
@@ -520,9 +585,9 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
/** /**
* 单个指标数据处理 * 单个指标数据处理
*/ */
public RUploadEvaluationDataD channelData(RUploadEvaluationDataD rUploadEvaluationDataD,Double value, Double sd, String indexType, Integer harmonicNum, String voltage,RUploadEvaluationDataD rUploadEvaluationDataD2) { public RUploadEvaluationDataD channelData(RUploadEvaluationDataD rUploadEvaluationDataD, Double value, Double sd, String indexType, Integer harmonicNum, String voltage, RUploadEvaluationDataD rUploadEvaluationDataD2) {
RUploadEvaluationDataD dto = new RUploadEvaluationDataD(); RUploadEvaluationDataD dto = new RUploadEvaluationDataD();
BeanUtils.copyProperties(rUploadEvaluationDataD,dto); BeanUtils.copyProperties(rUploadEvaluationDataD, dto);
dto.setId(IdUtil.simpleUUID()); dto.setId(IdUtil.simpleUUID());
dto.setAvgValue(value); dto.setAvgValue(value);
dto.setIndexType(indexType); dto.setIndexType(indexType);
@@ -538,25 +603,25 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
/** /**
* 各次谐波电压数据处理 * 各次谐波电压数据处理
*/ */
public void channelHarmonicData(RUploadEvaluationDataD rUploadEvaluationDataD,List<RUploadEvaluationDataD> result,List<Double> valueList, String indexType, String voltage,RUploadEvaluationDataD rUploadEvaluationDataD2,List<LineDevGetDTO> line) { public void channelHarmonicData(RUploadEvaluationDataD rUploadEvaluationDataD, List<RUploadEvaluationDataD> result, List<Double> valueList, String indexType, String voltage, RUploadEvaluationDataD rUploadEvaluationDataD2, List<LineDevGetDTO> line) {
final Double defaultValue = 3.1415926; final Double defaultValue = 3.1415926;
int length; int length;
if (!Objects.isNull(valueList)){ if (!Objects.isNull(valueList)) {
length = valueList.size(); length = valueList.size();
} else { } else {
length = 49; length = 49;
} }
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
RUploadEvaluationDataD dto = new RUploadEvaluationDataD(); RUploadEvaluationDataD dto = new RUploadEvaluationDataD();
BeanUtils.copyProperties(rUploadEvaluationDataD,dto); BeanUtils.copyProperties(rUploadEvaluationDataD, dto);
dto.setId(IdUtil.simpleUUID()); dto.setId(IdUtil.simpleUUID());
dto.setAvgValue(CollUtil.isNotEmpty(valueList)?valueList.get(i):defaultValue); dto.setAvgValue(CollUtil.isNotEmpty(valueList) ? valueList.get(i) : defaultValue);
dto.setIndexType(indexType); dto.setIndexType(indexType);
dto.setHarmonicNum(i+2); dto.setHarmonicNum(i + 2);
if (Objects.equals(voltage, "0")){ if (Objects.equals(voltage, "0")) {
dto.setStandardDeviation(defaultValue); dto.setStandardDeviation(defaultValue);
} else { } else {
double sd = this.getDimVoltageDataSd(voltage,dto.getAvgValue(),dto.getStatisticalDate(),line,indexType,dto.getHarmonicNum()); double sd = this.getDimVoltageDataSd(voltage, dto.getAvgValue(), dto.getStatisticalDate(), line, indexType, dto.getHarmonicNum());
dto.setStandardDeviation(sd); dto.setStandardDeviation(sd);
} }
dto.setVoltageLevel(voltage); dto.setVoltageLevel(voltage);
@@ -573,8 +638,8 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
public RDimVoltageD getDimVoltageData(String orgId, String time, String voltage) { public RDimVoltageD getDimVoltageData(String orgId, String time, String voltage) {
LambdaQueryWrapper<RDimVoltageD> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<RDimVoltageD> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(RDimVoltageD::getOrgId, orgId) lambdaQueryWrapper.eq(RDimVoltageD::getOrgId, orgId)
.eq(RDimVoltageD::getStatisDate,time) .eq(RDimVoltageD::getStatisDate, time)
.eq(RDimVoltageD::getVoltageType,voltage); .eq(RDimVoltageD::getVoltageType, voltage);
return rDimVoltageDMapper.selectOne(lambdaQueryWrapper); return rDimVoltageDMapper.selectOne(lambdaQueryWrapper);
} }
@@ -583,20 +648,20 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
*/ */
public Double getDimVoltageDataSd(String voltage, Double avg, String time, List<LineDevGetDTO> line, String type, Integer times) { public Double getDimVoltageDataSd(String voltage, Double avg, String time, List<LineDevGetDTO> line, String type, Integer times) {
double standardDeviation = 3.1415926; double standardDeviation = 3.1415926;
if (Objects.equals(avg,standardDeviation)){ if (Objects.equals(avg, standardDeviation)) {
return standardDeviation; return standardDeviation;
} }
//获取监测点数据 //获取监测点数据
if (CollUtil.isNotEmpty(line)){ if (CollUtil.isNotEmpty(line)) {
Map<String,List<LineDevGetDTO>> map = line.stream().collect(Collectors.groupingBy(LineDevGetDTO::getVoltageLevel)); Map<String, List<LineDevGetDTO>> map = line.stream().collect(Collectors.groupingBy(LineDevGetDTO::getVoltageLevel));
if (!Objects.isNull(map.get(voltage))){ if (!Objects.isNull(map.get(voltage))) {
Set<String> lineSet = map.get(voltage).stream().map(LineDevGetDTO::getPointId).collect(Collectors.toSet()); Set<String> lineSet = map.get(voltage).stream().map(LineDevGetDTO::getPointId).collect(Collectors.toSet());
List<LineDataDto> dataList = rDimVoltageDMapper.getLineData(time,time,lineSet); List<LineDataDto> dataList = rDimVoltageDMapper.getLineData(time, time, lineSet);
//根据平均值计算每个指标的标准差 //根据平均值计算每个指标的标准差
if (CollUtil.isNotEmpty(dataList)){ if (CollUtil.isNotEmpty(dataList)) {
double total = this.getDataByType(type,avg,dataList,times); double total = this.getDataByType(type, avg, dataList, times);
//计算标准差 //计算标准差
standardDeviation = Math.sqrt(total/dataList.size()); standardDeviation = Math.sqrt(total / dataList.size());
} }
} }

View File

@@ -8,18 +8,23 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl; import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.common.pojo.constant.BizParamConstant;
import com.njcn.device.biz.commApi.CommLineClient; import com.njcn.device.biz.commApi.CommLineClient;
import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO; import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO;
import com.njcn.device.biz.pojo.dto.LineDTO; import com.njcn.device.biz.pojo.dto.LineDTO;
import com.njcn.device.biz.pojo.dto.LineDevGetDTO; import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
import com.njcn.device.pq.pojo.po.RStatIntegrityD; import com.njcn.device.pq.pojo.po.RStatIntegrityD;
import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticM;
import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticY;
import com.njcn.harmonic.pojo.po.upload.RUploadPointStatisticalDataD; import com.njcn.harmonic.pojo.po.upload.RUploadPointStatisticalDataD;
import com.njcn.prepare.harmonic.enums.UploadEnum; import com.njcn.prepare.harmonic.enums.UploadEnum;
import com.njcn.prepare.harmonic.mapper.mysql.day.RStatIntegrityDMapper; 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.PmsRunStatisticDMapper;
import com.njcn.prepare.harmonic.mapper.mysql.upload.RUploadPointStatisticalDataDMapper; import com.njcn.prepare.harmonic.mapper.mysql.upload.RUploadPointStatisticalDataDMapper;
import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam; import com.njcn.prepare.harmonic.pojo.bo.CalculatedParam;
import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticD; import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticD;
import com.njcn.prepare.harmonic.service.mysql.upload.IPmsRunStatisticMService;
import com.njcn.prepare.harmonic.service.mysql.upload.IPmsRunStatisticYService;
import com.njcn.prepare.harmonic.service.mysql.upload.IRUploadPointStatisticalDataDService; import com.njcn.prepare.harmonic.service.mysql.upload.IRUploadPointStatisticalDataDService;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.DictTreeFeignClient; import com.njcn.system.api.DictTreeFeignClient;
@@ -61,9 +66,10 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
private final DicDataFeignClient dicDataFeignClient; private final DicDataFeignClient dicDataFeignClient;
private final PmsRunStatisticMapper pmsRunStatisticMapper;
private final CommLineClient commLineClient; private final CommLineClient commLineClient;
private final PmsRunStatisticDMapper runStatisticDMapper;
private final IPmsRunStatisticMService runStatisticMService;
private final IPmsRunStatisticYService runStatisticYService;
/** /**
* 此算法用于计算底层数据,方便国网数据上送 * 此算法用于计算底层数据,方便国网数据上送
@@ -129,19 +135,23 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
List<RStatIntegrityD> dataList = getStatIntegrityData(calculatedParam.getDataDate()); List<RStatIntegrityD> dataList = getStatIntegrityData(calculatedParam.getDataDate());
//下面先从表里获取在运测点相关数据,当表里没数据时候再从接口获取 //下面先从表里获取在运测点相关数据,当表里没数据时候再从接口获取
//首先获取pms_run_statistic表是否存在执行日期的数据 //首先获取pms_run_statistic表是否存在执行日期的数据
List<PmsRunStatisticD> pmsRunStatisticsListD = pmsRunStatisticMapper.selectList(new LambdaQueryWrapper<PmsRunStatisticD>().eq(PmsRunStatisticD::getStatisticDate,calculatedParam.getDataDate())); List<PmsRunStatisticD> pmsRunStatisticsListD = runStatisticDMapper.selectList(new LambdaQueryWrapper<PmsRunStatisticD>().eq(PmsRunStatisticD::getStatisticDate, calculatedParam.getDataDate()));
//筛选国网上送监测点 //筛选国网上送监测点
List<DeptGetChildrenMoreDTO> deptAll = calculatedParam.getIdList(); List<DeptGetChildrenMoreDTO> deptAll = calculatedParam.getIdList();
Map<String, PmsRunStatisticD> pmsRunStatisticMap = pmsRunStatisticsListD.stream().collect(Collectors.toMap(PmsRunStatisticD::getDeptId,Function.identity())); Map<String, PmsRunStatisticD> pmsRunStatisticMap = pmsRunStatisticsListD.stream().collect(Collectors.toMap(PmsRunStatisticD::getDeptId, Function.identity()));
List<LineDTO> lineDTOList; List<LineDTO> lineDTOList;
if(pmsRunStatisticMap.containsKey(dept.getCode())){ if (pmsRunStatisticMap.containsKey(dept.getCode())) {
List<String> monitorIds = CollectionUtil.toList(pmsRunStatisticMap.get(dept.getCode()).getRunMonitorIds().split(StrUtil.COMMA)); String runMonitorIds = pmsRunStatisticMap.get(dept.getCode()).getRunMonitorIds();
lineDTOList = commLineClient.getLineDetailBatch(monitorIds).getData(); if(StrUtil.isNotBlank(runMonitorIds)){
List<String> monitorIds = CollectionUtil.toList(runMonitorIds.split(StrUtil.COMMA));
lineDTOList = commLineClient.getLineDetailBatch(monitorIds).getData();
}else {
lineDTOList = new ArrayList<>();
}
} else { } else {
lineDTOList = new ArrayList<>(); lineDTOList = new ArrayList<>();
} }
@@ -155,28 +165,51 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
if (Objects.equals(Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_1.getCode()), item.getDeptLevel())) { if (Objects.equals(Integer.parseInt(UploadEnum.NJCN_DEPT_LEVEL_1.getCode()), item.getDeptLevel())) {
return; return;
} }
List<String> upDevIds =new ArrayList<>();
if(CollectionUtil.isEmpty(pmsRunStatisticsListD)){ List<String> onMonitorIds=new ArrayList<>();
if (CollectionUtil.isEmpty(pmsRunStatisticsListD)) {
//正常流程 //正常流程
newBaseList = item.getLineBaseList().stream().filter(o -> Objects.equals(o.getIsUpToGrid(), 1)).collect(toList()); newBaseList = item.getLineBaseList().stream().filter(o -> Objects.equals(o.getIsUpToGrid(), 1)).collect(toList());
}else { upDevIds = newBaseList.stream().map(LineDevGetDTO::getDevId).distinct().collect(toList());
String[] monitorTemIds = pmsRunStatisticMap.get(item.getUnitId()).getRunMonitorIds().split(StrUtil.COMMA); } else {
List<String> temIds = Arrays.stream(monitorTemIds).collect(toList()); if(pmsRunStatisticMap.containsKey(item.getUnitId())){
PmsRunStatisticD pmsRunStatisticD = pmsRunStatisticMap.get(item.getUnitId());
if(StrUtil.isNotBlank(pmsRunStatisticD.getRunMonitorIds())){
List<String> temIds = Arrays.stream(pmsRunStatisticD.getRunMonitorIds().split(StrUtil.COMMA)).collect(toList());
List<LineDevGetDTO> collect = 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(toList());
if(CollUtil.isEmpty(collect)){
newBaseList = item.getLineBaseList().stream().filter(o -> Objects.equals(o.getIsUpToGrid(), 1)).collect(Collectors.toList());
upDevIds = newBaseList.stream().map(LineDevGetDTO::getDevId).distinct().collect(toList());
}else {
newBaseList = collect;
if(StrUtil.isNotBlank(pmsRunStatisticD.getRunDevIds())){
upDevIds = Arrays.stream(pmsRunStatisticD.getRunDevIds().split(StrUtil.COMMA)).collect(toList());
}
if(StrUtil.isNotBlank(pmsRunStatisticD.getOnlineMonitorIds())){
onMonitorIds.addAll(Arrays.stream(pmsRunStatisticD.getOnlineMonitorIds().split(StrUtil.COMMA)).collect(toList()));
}
}
}else{
newBaseList = item.getLineBaseList().stream().filter(o -> Objects.equals(o.getIsUpToGrid(), 1)).collect(toList());
upDevIds = newBaseList.stream().map(LineDevGetDTO::getDevId).distinct().collect(toList());
}
}else{
newBaseList = item.getLineBaseList().stream().filter(o -> Objects.equals(o.getIsUpToGrid(), 1)).collect(toList());
upDevIds = newBaseList.stream().map(LineDevGetDTO::getDevId).distinct().collect(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> upMonitorIds = newBaseList.stream().map(LineDevGetDTO::getPointId).distinct().collect(toList());
List<String> upDevIds = newBaseList.stream().map(LineDevGetDTO::getDevId).distinct().collect(toList());
List<LineDevGetDTO> finalNewBaseList = newBaseList; List<LineDevGetDTO> finalNewBaseList = newBaseList;
List<String> finalUpDevIds = upDevIds;
mapKey.forEach((key, val) -> { mapKey.forEach((key, val) -> {
List<LineDevGetDTO> keyItem = finalNewBaseList.stream().filter(o -> val.contains(o.getObjType())).collect(toList()); List<LineDevGetDTO> keyItem = finalNewBaseList.stream().filter(o -> val.contains(o.getObjType())).collect(toList());
RUploadPointStatisticalDataD rUploadPointStatisticalDataD = new RUploadPointStatisticalDataD(); RUploadPointStatisticalDataD rUploadPointStatisticalDataD = new RUploadPointStatisticalDataD();
@@ -219,18 +252,21 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
long pointCount = keyItem.stream().map(LineDevGetDTO::getPointId).distinct().count(); long pointCount = keyItem.stream().map(LineDevGetDTO::getPointId).distinct().count();
rUploadPointStatisticalDataD.setRunTerminalNum(upDevIds.size()); rUploadPointStatisticalDataD.setRunTerminalNum(finalUpDevIds.size());
rUploadPointStatisticalDataD.setRunMonitorNum(upMonitorIds.size()); rUploadPointStatisticalDataD.setRunMonitorNum(upMonitorIds.size());
List<RStatIntegrityD> l3;
if(CollUtil.isNotEmpty(onMonitorIds)){
List<RStatIntegrityD> l3 = dataList.stream().filter(it -> upMonitorIds.contains(it.getLineIndex())).collect(toList()); l3 = dataList.stream().filter(it -> onMonitorIds.contains(it.getLineIndex())).collect(toList());
}else{
l3 = dataList.stream().filter(it -> upMonitorIds.contains(it.getLineIndex())).collect(toList());
}
int due = l3.stream().mapToInt(RStatIntegrityD::getDueTime).sum(); int due = l3.stream().mapToInt(RStatIntegrityD::getDueTime).sum();
int real = l3.stream().mapToInt(RStatIntegrityD::getRealTime).sum(); int real = l3.stream().mapToInt(RStatIntegrityD::getRealTime).sum();
rUploadPointStatisticalDataD.setExpectCollectNum(due); rUploadPointStatisticalDataD.setExpectCollectNum(due);
rUploadPointStatisticalDataD.setActualCollectNum(real); rUploadPointStatisticalDataD.setActualCollectNum(real);
long onlineCount = l3.stream().filter(me -> me.getRealTime() > 0).count(); long onlineCount = l3.stream().filter(me -> me.getRealTime() > 0).count();
rUploadPointStatisticalDataD.setOnlineMonitorNum((int) onlineCount); rUploadPointStatisticalDataD.setOnlineMonitorNum(onMonitorIds.size() == 0 ? (int) onlineCount : onMonitorIds.size());
rUploadPointStatisticalDataD.setOnlineMonitorRate(upMonitorIds.size() == 0 ? 0d : BigDecimal.valueOf(rUploadPointStatisticalDataD.getOnlineMonitorNum() * 100.0 / rUploadPointStatisticalDataD.getRunMonitorNum()).setScale(4, RoundingMode.HALF_UP).doubleValue()); rUploadPointStatisticalDataD.setOnlineMonitorRate(upMonitorIds.size() == 0 ? 0d : BigDecimal.valueOf(rUploadPointStatisticalDataD.getOnlineMonitorNum() * 100.0 / rUploadPointStatisticalDataD.getRunMonitorNum()).setScale(4, RoundingMode.HALF_UP).doubleValue());
@@ -289,7 +325,6 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
}); });
if (CollectionUtil.isNotEmpty(result)) { if (CollectionUtil.isNotEmpty(result)) {
//查询数据如果有数据,将data_id置为null,这样就保留之前的唯一id //查询数据如果有数据,将data_id置为null,这样就保留之前的唯一id
LambdaQueryWrapper<RUploadPointStatisticalDataD> lambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<RUploadPointStatisticalDataD> lambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -310,9 +345,11 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
String startTime = DateUtil.format(DateUtil.beginOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN); String startTime = DateUtil.format(DateUtil.beginOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN);
//结束时间 //结束时间
String endTime = DateUtil.format(DateUtil.endOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN); String endTime = DateUtil.format(DateUtil.endOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN);
List<PmsRunStatisticM> pmsRunStatistic = runStatisticMService.selectListByDate(startTime, endTime,calculatedParam.getDataDate());
Map<String, PmsRunStatisticM> pmsRunStatisticMap = pmsRunStatistic.stream().collect(Collectors.toMap(PmsRunStatisticM::getDeptId, Function.identity()));
//数据集 //数据集
List<RUploadPointStatisticalDataD> list = this.baseMapper.pointStatisticalMonthData(beginMonth, startTime, endTime, "02"); List<RUploadPointStatisticalDataD> list = this.baseMapper.pointStatisticalMonthData(beginMonth, startTime, endTime, "02");
dataProcessing(calculatedParam, list); dataProcessing(calculatedParam, list, pmsRunStatisticMap, BizParamConstant.STAT_BIZ_MONTH);
} }
@Override @Override
@@ -323,18 +360,19 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
String startTime = DateUtil.format(DateUtil.beginOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN); String startTime = DateUtil.format(DateUtil.beginOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN);
//结束时间 //结束时间
String endTime = DateUtil.format(DateUtil.endOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN); String endTime = DateUtil.format(DateUtil.endOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN);
List<PmsRunStatisticY> pmsRunStatistic = runStatisticYService.selectListByDate(startTime, endTime,calculatedParam.getDataDate());
Map<String, PmsRunStatisticY> pmsRunStatisticMap = pmsRunStatistic.stream().collect(Collectors.toMap(PmsRunStatisticY::getDeptId, Function.identity()));
//数据集 //数据集
List<RUploadPointStatisticalDataD> list = this.baseMapper.pointStatisticalMonthData(beginMonth, startTime, endTime, "01"); List<RUploadPointStatisticalDataD> list = this.baseMapper.pointStatisticalMonthData(beginMonth, startTime, endTime, "01");
dataProcessing(calculatedParam, list); dataProcessing(calculatedParam, list, pmsRunStatisticMap, BizParamConstant.STAT_BIZ_YEAR);
} }
/** /**
* @param calculatedParam * @param calculatedParam
* @param list 数据处理 * @param list 数据处理
*/ */
private void dataProcessing(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam, List<RUploadPointStatisticalDataD> list) { private void dataProcessing(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam, List<RUploadPointStatisticalDataD> list, Map<String, ?> pmsRunStatisticMap, String type) {
//数据分组
/* //数据分组
Map<String, List<RUploadPointStatisticalDataD>> listMap = list.stream().collect(Collectors.groupingBy(x -> x.getProvinceId() + x.getCityId() + x.getCountyId())); Map<String, List<RUploadPointStatisticalDataD>> listMap = list.stream().collect(Collectors.groupingBy(x -> x.getProvinceId() + x.getCityId() + x.getCountyId()));
//获取省级单位id //获取省级单位id
Dept root = deptFeignClient.getRootDept().getData(); Dept root = deptFeignClient.getRootDept().getData();
@@ -378,12 +416,70 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
mapKey.put(sysDicTreePO.getCode(), ids); mapKey.put(sysDicTreePO.getCode(), ids);
otherIds.addAll(ids); otherIds.addAll(ids);
} }
List<LineDTO> lineDTOList=new ArrayList<>();
if (pmsRunStatisticMap.containsKey(dept.getCode())) {
List<String> monitorIds;
String runMonitorIds;
if (BizParamConstant.STAT_BIZ_MONTH.equals(type)) {
runMonitorIds = ((PmsRunStatisticM) pmsRunStatisticMap.get(dept.getCode())).getRunMonitorIds();
} else {
runMonitorIds = ((PmsRunStatisticY) pmsRunStatisticMap.get(dept.getCode())).getRunMonitorIds();
}
if(StrUtil.isNotBlank(runMonitorIds)){
monitorIds = CollectionUtil.toList(runMonitorIds.split(StrUtil.COMMA));
lineDTOList = commLineClient.getLineDetailBatch(monitorIds).getData();
}
}
RUploadPointStatisticalDataD data; RUploadPointStatisticalDataD data;
for (DeptGetChildrenMoreDTO item : calculatedParam.getIdList()) { for (DeptGetChildrenMoreDTO item : calculatedParam.getIdList()) {
//获取国网上送监测点 //获取国网上送监测点
List<LineDevGetDTO> temBaseList = item.getLineBaseList().stream().filter(o -> Objects.equals(o.getIsUpToGrid(), 1)).collect(Collectors.toList()); List<LineDevGetDTO> temBaseList;
long devCount;
if (CollectionUtil.isEmpty(pmsRunStatisticMap)) {
//正常流程
temBaseList = item.getLineBaseList().stream().filter(o -> Objects.equals(o.getIsUpToGrid(), 1)).collect(Collectors.toList());
devCount = temBaseList.stream().map(LineDevGetDTO::getDevId).distinct().count();
} else {
List<String> temIds=new ArrayList<>();
List<String> onDevIds=new ArrayList<>();
String runMonitorIds;
String devIds;
if (BizParamConstant.STAT_BIZ_MONTH.equals(type)) {
runMonitorIds = ((PmsRunStatisticM) pmsRunStatisticMap.get(item.getUnitId())).getRunMonitorIds();
devIds = ((PmsRunStatisticM) pmsRunStatisticMap.get(item.getUnitId())).getRunDevIds();
} else {
runMonitorIds = ((PmsRunStatisticY) pmsRunStatisticMap.get(item.getUnitId())).getRunMonitorIds();
devIds = ((PmsRunStatisticY) pmsRunStatisticMap.get(item.getUnitId())).getRunDevIds();
}
if(StrUtil.isNotBlank(runMonitorIds)){
temIds = CollectionUtil.toList(runMonitorIds.split(StrUtil.COMMA));
}
if(StrUtil.isNotBlank(devIds)){
onDevIds = CollectionUtil.toList(devIds.split(StrUtil.COMMA));
}
List<String> finalTemIds = temIds;
List<LineDevGetDTO> collect = lineDTOList.stream().filter(o -> finalTemIds.contains(o.getLineId())).map(it -> {
LineDevGetDTO lineDevGetDTO = new LineDevGetDTO();
lineDevGetDTO.setPointId(it.getLineId());
lineDevGetDTO.setDevId(it.getDevId());
lineDevGetDTO.setObjType(it.getObjType());
return lineDevGetDTO;
}).collect(toList());
if(CollUtil.isEmpty(collect)){
temBaseList = item.getLineBaseList().stream().filter(o -> Objects.equals(o.getIsUpToGrid(), 1)).collect(Collectors.toList());
devCount = temBaseList.stream().map(LineDevGetDTO::getDevId).distinct().count();
}else {
temBaseList = collect;
if(onDevIds.size()==0){
devCount = temBaseList.stream().map(LineDevGetDTO::getDevId).distinct().count();
}else{
devCount = onDevIds.size();
}
}
}
long monitorCount = temBaseList.stream().map(LineDevGetDTO::getPointId).distinct().count(); long monitorCount = temBaseList.stream().map(LineDevGetDTO::getPointId).distinct().count();
long devCount = temBaseList.stream().map(LineDevGetDTO::getDevId).distinct().count();
//其他类型 //其他类型
data = new RUploadPointStatisticalDataD(); data = new RUploadPointStatisticalDataD();
data.setProvinceId(dept.getCode()); data.setProvinceId(dept.getCode());
@@ -420,10 +516,16 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
stationType = dictDataMap.get(DicDataEnum.Imp_Users.getCode()).getId(); stationType = dictDataMap.get(DicDataEnum.Imp_Users.getCode()).getId();
break; break;
} }
if (stationTypeMap.containsKey(stationType)) { if (stationTypeMap.containsKey(stationType)) {
long pointCount = keyItem.stream().map(LineDevGetDTO::getPointId).distinct().count(); long pointCount = keyItem.stream().map(LineDevGetDTO::getPointId).distinct().count();
RUploadPointStatisticalDataD rUploadPointStatisticalDataD = stationTypeMap.get(stationType); RUploadPointStatisticalDataD rUploadPointStatisticalDataD = stationTypeMap.get(stationType);
rUploadPointStatisticalDataD.setStationMonitorNum((int) pointCount); rUploadPointStatisticalDataD.setStationMonitorNum((int) pointCount);
rUploadPointStatisticalDataD.setRunTerminalNum((int) devCount);
rUploadPointStatisticalDataD.setOnlineMonitorNum((int) monitorCount);
rUploadPointStatisticalDataD.setRunMonitorNum((int) monitorCount);
rUploadPointStatisticalDataD.setOnlineMonitorRate(monitorCount == 0 ? 0d : BigDecimal.valueOf(rUploadPointStatisticalDataD.getOnlineMonitorNum() * 100.0 / rUploadPointStatisticalDataD.getRunMonitorNum()).setScale(4, RoundingMode.HALF_UP).doubleValue());
} }
}); });
@@ -437,15 +539,16 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
rUploadPointStatisticalDataD.setOnlineMonitorNum((int) monitorCount); rUploadPointStatisticalDataD.setOnlineMonitorNum((int) monitorCount);
rUploadPointStatisticalDataD.setRunMonitorNum((int) monitorCount); rUploadPointStatisticalDataD.setRunMonitorNum((int) monitorCount);
rUploadPointStatisticalDataD.setStationMonitorNum((int) pointCount); rUploadPointStatisticalDataD.setStationMonitorNum((int) pointCount);
rUploadPointStatisticalDataD.setOnlineMonitorRate(monitorCount == 0 ? 0d : BigDecimal.valueOf(rUploadPointStatisticalDataD.getOnlineMonitorNum() * 100.0 / rUploadPointStatisticalDataD.getRunMonitorNum()).setScale(4, RoundingMode.HALF_UP).doubleValue());
} }
} }
}*/ }
if (CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
list.forEach(item -> { list.forEach(item -> {
item.setId(IdUtil.simpleUUID()); item.setId(IdUtil.simpleUUID());
item.setComputeDate(calculatedParam.getDataDate()); item.setComputeDate(calculatedParam.getDataDate());
if(item.getOnlineMonitorNum()>item.getRunMonitorNum()){ if (item.getOnlineMonitorNum() > item.getRunMonitorNum()) {
item.setOnlineMonitorRate(100.0); item.setOnlineMonitorRate(100.0);
item.setOnlineMonitorNum(item.getRunMonitorNum()); item.setOnlineMonitorNum(item.getRunMonitorNum());
} }

View File

@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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;
@@ -16,11 +17,15 @@ 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.PmsRunStatisticM;
import com.njcn.harmonic.pojo.po.upload.PmsRunStatisticY;
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.IPmsRunStatisticMService;
import com.njcn.prepare.harmonic.service.mysql.upload.IPmsRunStatisticYService;
import com.njcn.prepare.harmonic.service.mysql.upload.IRUploadSubstationStatisticalDataDService; import com.njcn.prepare.harmonic.service.mysql.upload.IRUploadSubstationStatisticalDataDService;
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;
@@ -29,6 +34,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@@ -49,8 +55,15 @@ public class RUploadSubstationStatisticalDataDServiceImpl extends MppServiceImpl
private final StatationStatClient statationStatClient; private final StatationStatClient statationStatClient;
private final PmsMidLedgerMapper pmsMidLedgerMapper; private final PmsMidLedgerMapper pmsMidLedgerMapper;
private final CommTerminalGeneralClient commTerminalGeneralClient; private final CommTerminalGeneralClient commTerminalGeneralClient;
private final IPmsRunStatisticMService runStatisticMService;
private final IPmsRunStatisticYService runStatisticYService;
@Override @Override
public void insertSubStatisticalDataMonth(CalculatedParam<String> calculatedParam) { public void insertSubStatisticalDataMonth(CalculatedParam<String> calculatedParam) {
//起始时间
String startTime = DateUtil.format(DateUtil.beginOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN);
//结束时间
String endTime = DateUtil.format(DateUtil.endOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN);
List<RUploadSubstationStatisticalDataD> result = new ArrayList<>(); List<RUploadSubstationStatisticalDataD> result = new ArrayList<>();
//获取省级单位id //获取省级单位id
Dept data = deptFeignClient.getRootDept().getData(); Dept data = deptFeignClient.getRootDept().getData();
@@ -63,7 +76,22 @@ public class RUploadSubstationStatisticalDataDServiceImpl extends MppServiceImpl
List<DeptGetChildrenMoreDTO> deptGetChildrenList = commTerminalGeneralClient.deptGetLine(deptGetLineParam).getData(); List<DeptGetChildrenMoreDTO> deptGetChildrenList = commTerminalGeneralClient.deptGetLine(deptGetLineParam).getData();
Map<String,List<DeptGetChildrenMoreDTO>> deptChildren = deptGetChildrenList.stream().collect(Collectors.groupingBy(DeptGetChildrenMoreDTO::getUnitId)); Map<String,List<DeptGetChildrenMoreDTO>> deptChildren = deptGetChildrenList.stream().collect(Collectors.groupingBy(DeptGetChildrenMoreDTO::getUnitId));
//变电站id //变电站id
List<String> subList = calculatedParam.getIdList(); List<String> subList ;
//获取月数据
List<PmsRunStatisticM> pmsRunStatistics = runStatisticMService.selectListByDate(startTime, endTime,calculatedParam.getDataDate());
Map<String, PmsRunStatisticM> pmsRunStatisticMap = pmsRunStatistics.stream().collect(Collectors.toMap(PmsRunStatisticM::getDeptId, Function.identity()));
if (pmsRunStatisticMap.containsKey(dept.getCode())) {
String onlineStationIds = pmsRunStatisticMap.get(dept.getCode()).getOnlineStationIds();
if(StrUtil.isNotBlank(onlineStationIds)){
subList = CollectionUtil.toList(onlineStationIds.split(StrUtil.COMMA));
}else {
subList = calculatedParam.getIdList();
}
} else {
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));
@@ -84,14 +112,26 @@ 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(pmsRunStatisticMap.containsKey(k)){
if (CollUtil.isNotEmpty(l)){ String runMonitorIds = pmsRunStatisticMap.get(dept.getCode()).getRunMonitorIds();
l = l.stream().filter(o->Objects.equals(o.getIsUpToGrid(),1)).collect(Collectors.toList()); if(StrUtil.isNotBlank(runMonitorIds)){
rUploadSubstationStatisticalDataD.setOnlineMonitorNum(l.size()); ArrayList<String> list1 = CollectionUtil.toList(runMonitorIds.split(StrUtil.COMMA));
} else { rUploadSubstationStatisticalDataD.setOnlineMonitorNum(list1.size());
rUploadSubstationStatisticalDataD.setOnlineMonitorNum(0); }else {
rUploadSubstationStatisticalDataD.setOnlineMonitorNum(0);
}
}else{
//计算在线监测点数
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);
}
} }
//处理层级关系 && 处理基础数据 //处理层级关系 && 处理基础数据
this.getDeptLevel(list,rUploadSubstationStatisticalDataD,deptList,deptMap,k,subMap,midSubMap); this.getDeptLevel(list,rUploadSubstationStatisticalDataD,deptList,deptMap,k,subMap,midSubMap);
result.add(rUploadSubstationStatisticalDataD); result.add(rUploadSubstationStatisticalDataD);
@@ -122,6 +162,40 @@ public class RUploadSubstationStatisticalDataDServiceImpl extends MppServiceImpl
String endTime = DateUtil.format(DateUtil.endOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN); String endTime = DateUtil.format(DateUtil.endOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN);
//数据集 //数据集
List<RUploadSubstationStatisticalDataD> list = this.baseMapper.substationStatisticalMonthData(beginMonth,startTime,endTime); List<RUploadSubstationStatisticalDataD> list = this.baseMapper.substationStatisticalMonthData(beginMonth,startTime,endTime);
List<PmsRunStatisticY> pmsRunStatistics = runStatisticYService.selectListByDate(startTime, endTime,calculatedParam.getDataDate());
Map<String, PmsRunStatisticY> pmsRunStatisticMap = pmsRunStatistics.stream().collect(Collectors.toMap(PmsRunStatisticY::getDeptId, Function.identity()));
//数据分组
Map<String, List<RUploadSubstationStatisticalDataD>> listMap = list.stream().collect(Collectors.groupingBy(x ->{
String str = "";
if(StrUtil.isNotBlank(x.getProvinceId())){
str = x.getProvinceId();
}
if(StrUtil.isNotBlank(x.getCityId())){
str = x.getCityId();
}
if(StrUtil.isNotBlank(x.getCountyId())){
str = x.getCountyId();
}
return str;
}
));
listMap.forEach((key,value)->{
if(pmsRunStatisticMap.containsKey(key)){
PmsRunStatisticY pmsRunStatistic = pmsRunStatisticMap.get(key);
String runMonitorIds = pmsRunStatistic.getRunMonitorIds();
if(StrUtil.isNotBlank(runMonitorIds)){
ArrayList<String> list1 = CollectionUtil.toList(runMonitorIds.split(StrUtil.COMMA));
value.forEach(item->{
item.setOnlineMonitorNum(list1.size());
item.setMonitoringRate(Objects.isNull(item.getSubstationCount())?null:list1.size()*1.0/item.getSubstationCount()*100);
});
}
}
});
if (CollUtil.isNotEmpty(list)){ if (CollUtil.isNotEmpty(list)){
list.forEach(item->{ list.forEach(item->{
item.setId(IdUtil.simpleUUID()); item.setId(IdUtil.simpleUUID());
@@ -157,7 +231,13 @@ 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, Map<String,List<PmsMidLedger>> midSubMap) { 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: