1.新能源专项分析代码优化
2.迁移相关代码算法
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package com.njcn.event.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 高低电压穿越 实体类
|
||||
* @author guofeihu
|
||||
* @since 2024-08-22
|
||||
*/
|
||||
@Data
|
||||
@TableName("sp_through")
|
||||
public class SpThroughPO extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 暂降事件ID
|
||||
*/
|
||||
private String eventId;
|
||||
|
||||
/**
|
||||
* 暂降类型(暂升、暂降)
|
||||
*/
|
||||
private String eventType;
|
||||
|
||||
/**
|
||||
* (关联PQS_Dictionary表)变电站类型(风电场、光伏电站)
|
||||
*/
|
||||
private String stationType;
|
||||
|
||||
/**
|
||||
* 是否穿越
|
||||
*/
|
||||
private Integer isOrNot;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Boolean state;
|
||||
|
||||
/**
|
||||
* 创建时间(自定义)
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.event.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author guofeihu
|
||||
* @since 2024-08-14
|
||||
*/
|
||||
@Data
|
||||
public class SpThroughVO {
|
||||
|
||||
@ApiModelProperty("低压次数")
|
||||
private String lowPressure;
|
||||
|
||||
@ApiModelProperty("高压次数")
|
||||
private String highPressure;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.event.mapper.majornetwork;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.event.pojo.po.SpThroughPO;
|
||||
|
||||
/**
|
||||
* 高低电压穿越 Mapper 接口
|
||||
* @author guofeihu
|
||||
* @since 2024-08-22
|
||||
*/
|
||||
public interface SpThroughMapper extends MppBaseMapper<SpThroughPO> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.event.mapper.majornetwork.SpThroughMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.njcn.event.service.majornetwork.Impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.event.mapper.majornetwork.SpThroughMapper;
|
||||
import com.njcn.event.pojo.po.SpThroughPO;
|
||||
import com.njcn.event.pojo.vo.SpThroughVO;
|
||||
import com.njcn.event.service.majornetwork.SpThroughService;
|
||||
import com.njcn.prepare.harmonic.pojo.param.SpThroughParam;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicTreeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.system.pojo.vo.DictTreeVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 高低电压穿越 服务实现类
|
||||
*
|
||||
* @author guofeihu
|
||||
* @since 2024-08-22
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SpThroughServiceImpl extends MppServiceImpl<SpThroughMapper, SpThroughPO> implements SpThroughService {
|
||||
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
|
||||
@Override
|
||||
public SpThroughVO getDataByEventIds(SpThroughParam spThroughParam) {
|
||||
SpThroughVO spThroughVO = new SpThroughVO();
|
||||
spThroughVO.setLowPressure("0");
|
||||
spThroughVO.setHighPressure("0");
|
||||
String treeId = dicTreeId(spThroughParam);
|
||||
DictData dip = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
|
||||
if (ObjectUtil.isNotNull(dip)) {
|
||||
spThroughVO.setHighPressure(eventCount(spThroughParam, treeId, dip) + "");
|
||||
}
|
||||
DictData rise = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_RISE.getCode()).getData();
|
||||
if (ObjectUtil.isNotNull(rise)) {
|
||||
spThroughVO.setLowPressure(eventCount(spThroughParam, treeId, rise) + "");
|
||||
}
|
||||
return spThroughVO;
|
||||
}
|
||||
|
||||
private Integer eventCount(SpThroughParam spThroughParam, String dictTreeId, DictData rise) {
|
||||
LambdaQueryWrapper<SpThroughPO> lowLambdaQueryWrapper = new LambdaQueryWrapper();
|
||||
lowLambdaQueryWrapper.in(SpThroughPO::getEventId, spThroughParam.getEventIds())
|
||||
.eq(SpThroughPO::getIsOrNot, 1)
|
||||
.eq(SpThroughPO::getStationType, dictTreeId)
|
||||
.eq(SpThroughPO::getState, 1)
|
||||
.eq(SpThroughPO::getEventType, rise.getId());
|
||||
return this.baseMapper.selectCount(lowLambdaQueryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 说明:
|
||||
* 此方法是专门提供给event模块-高低压穿越模块中-根据区域获取暂态事件列表使用
|
||||
* 根据区域获取各个子区域高低电压穿越次数是基于sp_through表中记录来的 那么在根据区域获取暂态事件列表数据也应该基于sp_through表中记录来
|
||||
* 因为如果不基于sp_through表中记录来 那么根据区域获取暂态事件可能数据非常多且可能一部分的事件数据并没有被定时任务(record方法)所执行
|
||||
*
|
||||
* @param spThroughParam
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<String> formatEventIds(SpThroughParam spThroughParam) {
|
||||
LambdaQueryWrapper<SpThroughPO> lambdaQueryWrapper = new LambdaQueryWrapper();
|
||||
lambdaQueryWrapper.in(SpThroughPO::getEventId, spThroughParam.getEventIds())
|
||||
.eq(SpThroughPO::getIsOrNot, 1)
|
||||
.eq(SpThroughPO::getStationType, dicTreeId(spThroughParam))
|
||||
.eq(SpThroughPO::getState, 1);
|
||||
List<SpThroughPO> spThroughPOS = this.baseMapper.selectList(lambdaQueryWrapper);
|
||||
return spThroughPOS.stream().map(SpThroughPO::getEventId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private String dicTreeId(SpThroughParam spThroughParam) {
|
||||
String dictTreeId = "";
|
||||
if ("1".equals(spThroughParam.getStationType())) {
|
||||
DictTreeVO windFarms = dictTreeFeignClient.queryByCode(DicTreeEnum.Wind_Farms.getCode()).getData();
|
||||
if (ObjectUtil.isNotNull(windFarms)) {
|
||||
dictTreeId = windFarms.getId();
|
||||
}
|
||||
} else {
|
||||
DictTreeVO powerStation = dictTreeFeignClient.queryByCode(DicTreeEnum.Power_Station.getCode()).getData();
|
||||
if (ObjectUtil.isNotNull(powerStation)) {
|
||||
dictTreeId = powerStation.getId();
|
||||
}
|
||||
}
|
||||
return dictTreeId;
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.vo.EventNewStationVo;
|
||||
import com.njcn.event.pojo.vo.VoltageRideThroughVo;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.service.majornetwork.SpThroughService;
|
||||
import com.njcn.event.service.majornetwork.VoltageRideThroughEventService;
|
||||
import com.njcn.prepare.harmonic.api.event.SpThroughFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.param.SpThroughParam;
|
||||
import com.njcn.supervision.api.UserLedgerFeignClient;
|
||||
import com.njcn.supervision.pojo.vo.user.NewUserReportVO;
|
||||
@@ -46,7 +46,7 @@ public class VoltageRideThroughEventServiceImpl implements VoltageRideThroughEve
|
||||
private final DeptLineFeignClient deptLineFeignClient;
|
||||
private final LineFeignClient lineFeignClient;
|
||||
private final EventDetailService eventDetailService;
|
||||
private final SpThroughFeignClient spThroughFeignClient;
|
||||
private final SpThroughService spThroughService;
|
||||
private final UserLedgerFeignClient userLedgerFeignClient;
|
||||
|
||||
@Override
|
||||
@@ -76,10 +76,10 @@ public class VoltageRideThroughEventServiceImpl implements VoltageRideThroughEve
|
||||
if(CollUtil.isNotEmpty(eventDetails)){
|
||||
List<String> eventDetailIds = eventDetails.stream().map(EventDetail::getEventId).collect(Collectors.toList());
|
||||
SpThroughParam spThroughParam = new SpThroughParam(eventDetailIds,param.getType());
|
||||
List<String> eventIds = spThroughFeignClient.formatEventIds(spThroughParam).getData();
|
||||
List<String> eventIds = spThroughService.formatEventIds(spThroughParam);
|
||||
spThroughParam.setEventIds(eventIds);
|
||||
//赋值子部门高低电压穿越次数
|
||||
BeanUtils.copyProperties(spThroughFeignClient.getDataByEventIds(spThroughParam).getData(),voltageRideThroughVo);
|
||||
BeanUtils.copyProperties(spThroughService.getDataByEventIds(spThroughParam),voltageRideThroughVo);
|
||||
}
|
||||
}
|
||||
voltageRideThroughVos.add(voltageRideThroughVo);
|
||||
@@ -103,7 +103,7 @@ public class VoltageRideThroughEventServiceImpl implements VoltageRideThroughEve
|
||||
List<String> eventDetailIds = eventNewStationVos.stream().map(EventNewStationVo::getEventId).collect(Collectors.toList());
|
||||
SpThroughParam spThroughParam = new SpThroughParam(eventDetailIds,param.getType());
|
||||
//eventNewStationVos:事件集合中是包含了所有符合条件的事件,可能有部分事件并没有被高低电压穿越记录定时任务所执行 所以需要过滤下 具体逻辑说请看spThroughFeignClient.formatEventIds
|
||||
List<String> eventIds = spThroughFeignClient.formatEventIds(spThroughParam).getData();
|
||||
List<String> eventIds = spThroughService.formatEventIds(spThroughParam);
|
||||
//过滤掉不符合的事件(eventIds为有效事件ID)
|
||||
eventNewStationVos = eventNewStationVos.stream().filter(item->eventIds.contains(item.getEventId())).collect(Collectors.toList());
|
||||
List<LineDetailDataVO> lineDetailDataVOS = lineFeignClient.getLineDetailList(lineIds).getData();
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.event.service.majornetwork;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.IMppService;
|
||||
import com.njcn.event.pojo.po.SpThroughPO;
|
||||
import com.njcn.event.pojo.vo.SpThroughVO;
|
||||
import com.njcn.prepare.harmonic.pojo.param.SpThroughParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 高低电压穿越 服务类
|
||||
* @author guofeihu
|
||||
* @since 2024-08-22
|
||||
*/
|
||||
public interface SpThroughService extends IMppService<SpThroughPO> {
|
||||
|
||||
/**
|
||||
* 根据事件ID集合及能源站类型获取高低电压穿越次数
|
||||
*/
|
||||
SpThroughVO getDataByEventIds(SpThroughParam spThroughParam);
|
||||
|
||||
/**
|
||||
* 根据原有的事件集合进行过滤
|
||||
*/
|
||||
List<String> formatEventIds(SpThroughParam spThroughParam);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user