1.河北两级贯通接口新增台账运行详情统计

This commit is contained in:
cdf
2024-05-08 09:57:27 +08:00
parent 4e14fb5a3b
commit 3fecc56f93
5 changed files with 210 additions and 10 deletions

View File

@@ -1,12 +1,20 @@
package com.njcn.device.pms.pojo.po;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import com.njcn.db.bo.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* pqs
@@ -14,15 +22,13 @@ import java.time.LocalDate;
* @author cdf
* @date 2024/4/17
*/
@TableName(value = "pms_run_statistic")
@TableName(value = "pms_run_statistic_d")
@Data
@EqualsAndHashCode(callSuper = true)
public class PmsRunStatistic extends BaseEntity {
public class PmsRunStatistic{
/**
*
*/
@MppMultiId
private LocalDate statisticDate;
@@ -31,6 +37,39 @@ public class PmsRunStatistic extends BaseEntity {
private String runMonitorIds;
private String onlineMonitorIds;
private String runBusIds;
private Integer runBusNum;
private String onlineBusIds;
private String runDevIds;
private String runStationIds;
private Integer runStationNum;
private String onlineStationIds;
private String typicalTractionIds;
private String typicalWindIds;
private String typicalSunIds;
private String typicalOtherIds;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime createTime;
}

View File

@@ -451,4 +451,7 @@ public class CommTerminalController extends BaseController {
}

View File

@@ -0,0 +1,21 @@
package com.njcn.device.pms.mapper.majornetwork;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.device.pms.pojo.po.PmsCountLedger;
import java.util.List;
/**
* <p>
* 每日变电站-母线数据总条目表 Mapper 接口
* </p>
*
* @author hongawen
* @since 2023-11-15
*/
public interface PmsCountLedgerMapper extends BaseMapper<PmsCountLedger> {
}

View File

@@ -24,4 +24,20 @@ public interface IPmsRunStatisticService extends IMppService<PmsRunStatistic> {
*/
void statisticLedgerRunDay(String date);
/**
* 每日统计每月
* @author cdf
* @date 2024/4/17
*/
void statisticLedgerRunMonth(String date);
/**
* 每日统计每年
* @author cdf
* @date 2024/4/17
*/
void statisticLedgerRunYear(String date);
}

View File

@@ -2,17 +2,31 @@ package com.njcn.device.pms.service.ledgerManger.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum;
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.pms.mapper.majornetwork.PmsRunStatisticMapper;
import com.njcn.device.pms.pojo.po.Monitor;
import com.njcn.device.pms.pojo.po.PmsRunStatistic;
import com.njcn.device.pms.mapper.majornetwork.*;
import com.njcn.device.pms.pojo.po.*;
import com.njcn.device.pms.service.ledgerManger.CommTerminalService;
import com.njcn.device.pms.service.ledgerManger.IPmsRunStatisticService;
import com.njcn.device.pms.service.majornetwork.IMonitorService;
import com.njcn.device.pq.pojo.po.RStatIntegrityD;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.DictTreeFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.enums.DicTreeEnum;
import com.njcn.system.pojo.po.Dic;
import com.njcn.system.pojo.po.DictData;
import com.njcn.system.pojo.po.SysDicTreePO;
import com.njcn.system.pojo.vo.DictTreeVO;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.po.Dept;
import lombok.RequiredArgsConstructor;
@@ -22,6 +36,7 @@ import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* <p>
@@ -39,24 +54,130 @@ public class PmsRunStatisticServiceImpl extends MppServiceImpl<PmsRunStatisticMa
private final DeptFeignClient deptFeignClient;
private final RStatIntegrityDMapper rStatIntegrityDMapper;
private final PmsMidLedgerMapper pmsMidLedgerMapper;
private final DicDataFeignClient dicDataFeignClient;
private final MonitorMapper monitorMapper;
private final DictTreeFeignClient dictTreeFeignClient;
private final StatationStatMapper statationStatMapper;
@Override
public void statisticLedgerRunDay(String date) {
Dept dept = deptFeignClient.getRootDept().getData();
LocalDate localDate = LocalDate.parse(date);
DeptGetLineParam deptGetLineParam = new DeptGetLineParam();
deptGetLineParam.setDeptId(dept.getId());
deptGetLineParam.setIsUpToGrid(1);
List<DeptGetChildrenMoreDTO> deptGetChildrenMoreDTOList = commTerminalService.deptGetLine(deptGetLineParam);
List<PmsRunStatistic> poList = new ArrayList<>();
//获取在运母线,在运电站数量
List<PmsMidLedger> midLedgerStationList = this.getBusBarAndStationInfo(0);
List<PmsMidLedger> midLedgerBusBarList = this.getBusBarAndStationInfo(1);
//获取在运,符合上送国网的测点,用于过滤监测母线,监测电站
DictData dictData = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.RUN.getCode(),DicDataTypeEnum.LINE_STATE.getCode()).getData();
List<Monitor> monitorList = monitorMapper.selectList(new LambdaQueryWrapper<Monitor>().eq(Monitor::getMonitorState,dictData.getId()).eq(Monitor::getIsUpToGrid,DataStateEnum.ENABLE.getCode()));
List<StatationStat> statationStatList = statationStatMapper.selectList(new LambdaQueryWrapper<StatationStat>().isNotNull(StatationStat::getMidStationId));
//数据完整性
List<String> rStatIntegrityIds = rStatIntegrityDMapper.selectList(new LambdaQueryWrapper<RStatIntegrityD>().eq(RStatIntegrityD::getTimeId,localDate).gt(RStatIntegrityD::getRealTime,0)).stream().map(RStatIntegrityD::getLineIndex).distinct().collect(Collectors.toList());
//对象类型
List<SysDicTreePO> sysdictreepo = dictTreeFeignClient.queryAll().getData();
List<String> windfarm_user = Stream.of(DicDataEnum.WINDPOWER_STATION.getCode()).collect(Collectors.toList());
List<String> photovoltaicsit_eusers = Stream.of(DicDataEnum.PHOTOVOLTAIC_POWER_STATION.getCode()).collect(Collectors.toList());
List<String> tractionstation = Stream.of(DicDataEnum.ELECTRIFIED_RAILWAY.getCode()).collect(Collectors.toList());
DictTreeVO dictTreeVO = dictTreeFeignClient.queryByCode(DicTreeEnum.Imp_Users.getCode()).getData();
List<DictTreeVO> dictTreeVOList = dictTreeFeignClient.query(dictTreeVO.getId()).getData();
List<String> importUser = dictTreeVOList.stream().map(DictTreeVO::getCode).distinct().collect(Collectors.toList());
importUser.add(dictTreeVO.getCode());
List<String> windfarm_user_dict = sysdictreepo.stream().filter(temp -> windfarm_user.contains(temp.getCode())).map(SysDicTreePO::getId).collect(Collectors.toList());
List<String> photovoltaicsit_eusers_dict = sysdictreepo.stream().filter(temp -> photovoltaicsit_eusers.contains(temp.getCode())).map(SysDicTreePO::getId).collect(Collectors.toList());
List<String> tractionstation_dict = sysdictreepo.stream().filter(temp -> tractionstation.contains(temp.getCode())).map(SysDicTreePO::getId).collect(Collectors.toList());
List<String> import_dict = sysdictreepo.stream().filter(temp -> importUser.contains(temp.getCode())).map(SysDicTreePO::getId).collect(Collectors.toList());
List<String> un_other_interferencesource_users_dict = new ArrayList<>();
un_other_interferencesource_users_dict.addAll(photovoltaicsit_eusers_dict);
un_other_interferencesource_users_dict.addAll(tractionstation_dict);
un_other_interferencesource_users_dict.addAll(windfarm_user_dict);
un_other_interferencesource_users_dict.addAll(import_dict);
//遍历每个部门
for(DeptGetChildrenMoreDTO dto : deptGetChildrenMoreDTOList){
List<String> childrenDept = dto.getUnitChildrenList();
List<String> temPointIds = dto.getLineBaseList().stream().map(LineDevGetDTO::getPointId).distinct().collect(Collectors.toList());
List<String> onlinePointIds = temPointIds.stream().filter(rStatIntegrityIds::contains).collect(Collectors.toList());
PmsRunStatistic pmsRunStatistic = new PmsRunStatistic();
pmsRunStatistic.setStatisticDate(LocalDate.parse(date));
pmsRunStatistic.setStatisticDate(localDate);
pmsRunStatistic.setDeptId(dto.getUnitId());
pmsRunStatistic.setRunMonitorIds(dto.getLineBaseList().stream().map(LineDevGetDTO::getPointId).distinct().collect(Collectors.joining(StrUtil.COMMA)));
pmsRunStatistic.setRunMonitorIds(String.join(StrUtil.COMMA, temPointIds));
pmsRunStatistic.setOnlineMonitorIds(String.join(StrUtil.COMMA, onlinePointIds));
pmsRunStatistic.setRunDevIds(dto.getLineBaseList().stream().map(LineDevGetDTO::getDevId).distinct().collect(Collectors.joining(StrUtil.COMMA)));
long stationCount = midLedgerStationList.stream().filter(it->childrenDept.contains(it.getSectionId())).map(PmsMidLedger::getId).distinct().count();
pmsRunStatistic.setRunStationNum((int) stationCount);
long busBarCount = midLedgerBusBarList.stream().filter(it->childrenDept.contains(it.getSectionId())).map(PmsMidLedger::getId).distinct().count();
pmsRunStatistic.setRunBusNum((int) busBarCount);
List<String> runBusIds = monitorList.stream().filter(it->childrenDept.contains(it.getOrgId())).map(Monitor::getLineId).distinct().collect(Collectors.toList());
pmsRunStatistic.setOnlineBusIds(String.join(StrUtil.COMMA, runBusIds));
List<String> runStationIds = statationStatList.stream().filter(it->childrenDept.contains(it.getOrgId())).map(StatationStat::getPowerId).distinct().collect(Collectors.toList());
pmsRunStatistic.setOnlineStationIds(String.join(StrUtil.COMMA, runStationIds));
//典型统计
List<String> windPointIds = dto.getLineBaseList().stream().filter(it->windfarm_user_dict.contains(it.getObjType())).map(LineDevGetDTO::getPointId).collect(Collectors.toList());
List<String> sunPointIds = dto.getLineBaseList().stream().filter(it->photovoltaicsit_eusers_dict.contains(it.getObjType())).map(LineDevGetDTO::getPointId).collect(Collectors.toList());
List<String> tractionPointIds = dto.getLineBaseList().stream().filter(it->tractionstation_dict.contains(it.getObjType())).map(LineDevGetDTO::getPointId).collect(Collectors.toList());
List<String> otherPointIds = dto.getLineBaseList().stream().filter(it->!un_other_interferencesource_users_dict.contains(it.getObjType())).map(LineDevGetDTO::getPointId).collect(Collectors.toList());
pmsRunStatistic.setTypicalWindIds(String.join(StrUtil.COMMA, windPointIds));
pmsRunStatistic.setTypicalSunIds(String.join(StrUtil.COMMA, sunPointIds));
pmsRunStatistic.setTypicalTractionIds(String.join(StrUtil.COMMA, tractionPointIds));
pmsRunStatistic.setTypicalOtherIds(String.join(StrUtil.COMMA, otherPointIds));
poList.add(pmsRunStatistic);
}
this.saveBatch(poList);
}
@Override
public void statisticLedgerRunMonth(String date) {
DateTime begin = DateUtil.beginOfMonth(DateUtil.parse(date));
DateTime end = DateUtil.endOfMonth(DateUtil.parse(date));
}
@Override
public void statisticLedgerRunYear(String date) {
}
/**
* 获取中台母线电站信息
*/
public List<PmsMidLedger> getBusBarAndStationInfo(Integer type) {
LambdaQueryWrapper<PmsMidLedger> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(PmsMidLedger::getLevel,type)
.eq(PmsMidLedger::getState, DataStateEnum.ENABLE.getCode());
return pmsMidLedgerMapper.selectList(lambdaQueryWrapper);
}
}