高低电压穿越相关接口走算法模块

This commit is contained in:
guofeihu
2024-08-23 11:15:41 +08:00
parent 043b8f9a71
commit 21f4466580
29 changed files with 378 additions and 84 deletions

View File

@@ -7,12 +7,11 @@ import com.njcn.event.pojo.param.EventCountParam;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.GeneralVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
@@ -76,4 +75,10 @@ public interface EventDetailFeignClient {
*/
@PostMapping("/getEventDetailByEventType")
HttpResult<List<RmpEventDetailPO>> getEventDetailByEventType(@RequestBody EventCountParam param);
/**
* 根据开始时间及结束时间获取暂态事件信息
*/
@PostMapping("/getNewEventDetailByTime")
HttpResult<List<RmpEventDetailPO>> getNewEventDetailByTime(@RequestParam(name = "lastTime",required = false)LocalDateTime lastTime,@RequestParam("currentTime")LocalDateTime currentTime);
}

View File

@@ -12,7 +12,7 @@ import com.njcn.event.utils.EventlEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
@@ -82,6 +82,11 @@ public class EventDetailFeignClientFallbackFactory implements FallbackFactory<Ev
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<RmpEventDetailPO>> getNewEventDetailByTime(LocalDateTime lastTime, LocalDateTime currentTime) {
log.error("{}异常,降级处理,异常为:{}", "根据开始时间及结束时间获取暂态事件信息", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -27,14 +27,4 @@ public interface Param {
String BEGIN =" 00:00:00";
String END =" 23:59:59";
//以下四个固定ID用于某些业务判断
//字典(sys_dict_data):电压暂升的ID
String UPPEREVENT = "c5ce588cb76fba90c4519ab250c962d0";
//字典(sys_dict_data):电升暂升的ID
String LOWEREVENT = "c37861896dafab0883321e1d508caa51";
//字典(sys_dict_data):光伏电站的ID
String PHOTOVOLTAICPOWER = "45615057cb88650ffc4779b0629bac7e";
//字典(sys_dict_data):风电场的ID
String WINDFARM = "f9145acb79cbf136b9ee89fd38d72583";
}

View File

@@ -36,4 +36,7 @@ public class EventNewStationVo implements Serializable {
@ApiModelProperty(value = "暂降严重度")
private Double severity;
@ApiModelProperty(value = "波形路径")
private String wavePath;
}

View File

@@ -78,6 +78,12 @@
<artifactId>harmonic-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>prepare-api</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@@ -26,6 +26,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -212,4 +213,22 @@ public class EventDetailController extends BaseController {
);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
/**
* 根据开始时间及结束时间获取暂态事件信息
* @return
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getNewEventDetailByTime")
@ApiOperation("根据开始时间及结束时间获取暂态事件信息")
public HttpResult<List<RmpEventDetailPO>> getNewEventDetailByTime(@RequestParam(name = "lastTime",required = false) LocalDateTime lastTime, @RequestParam("currentTime")LocalDateTime currentTime) {
String methodDescribe = getMethodDescribe("getNewEventDetailByTime");
LambdaQueryWrapper<RmpEventDetailPO> lambdaQueryWrapper = new LambdaQueryWrapper();
lambdaQueryWrapper.le(RmpEventDetailPO::getStartTime,currentTime);
if(lastTime != null){
lambdaQueryWrapper.gt(RmpEventDetailPO::getStartTime,lastTime);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventDetailService.list(lambdaQueryWrapper), methodDescribe);
}
}

View File

@@ -1,7 +1,6 @@
package com.njcn.event.service.majornetwork.Impl;
import cn.hutool.core.bean.BeanUtil;
import com.njcn.device.biz.commApi.CommLineClient;
import com.njcn.device.pq.api.DeptLineFeignClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.api.NewStationClient;
@@ -14,6 +13,8 @@ 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.VoltageRideThroughEventService;
import com.njcn.prepare.harmonic.api.event.SpThroughFeignClient;
import com.njcn.prepare.harmonic.pojo.param.SpThroughParam;
import com.njcn.system.api.AreaFeignClient;
import com.njcn.system.pojo.po.Area;
import com.njcn.user.api.DeptFeignClient;
@@ -25,7 +26,6 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
/**
@@ -46,14 +46,14 @@ public class VoltageRideThroughEventServiceImpl implements VoltageRideThroughEve
private final DeptLineFeignClient deptLineFeignClient;
private final CommLineClient commLineClient;
private final LineFeignClient lineFeignClient;
private final EventDetailService eventDetailService;
private final NewStationClient newStationClient;
private final SpThroughFeignClient spThroughFeignClient;
@Override
public List<VoltageRideThroughVo> voltageRideThroughView(VoltageRideThroughQueryParam voltageRideThroughQueryParam) {
List<VoltageRideThroughVo> voltageRideThroughVos = new ArrayList<>();
@@ -70,39 +70,17 @@ public class VoltageRideThroughEventServiceImpl implements VoltageRideThroughEve
voltageRideThroughVo.setLat(area.getLat());
voltageRideThroughVo.setLng(area.getLng());
}
voltageRideThroughVo.setHighPressure((int) (Math.random() * 100 + 1)+"");
voltageRideThroughVo.setLowPressure((int) (Math.random() * 100 + 1)+"");
//开始计算每个地区高低压穿越次数
//获取当前部门下所有的监测点(当然也会根据选择的新能源场站类型进行过滤)
List<String> lineIds = deptLineFeignClient.getLineByDeptIdAndNewStation(deptDTO.getId(),voltageRideThroughQueryParam.getType()).getData();
for(String lineId : lineIds){
//监测点绑定的暂降事件
List<EventDetail> eventDetails = eventDetailService.getEventDetailData(lineId,voltageRideThroughQueryParam.getSearchBeginTime()+Param.BEGIN,voltageRideThroughQueryParam.getSearchEndTime()+Param.END);
//取出事件类型为:暂升
List<EventDetail> upperEventDetails = eventDetails.stream().filter(e -> e.getEventType().equals(Param.UPPEREVENT)).collect(Collectors.toList());
//取出事件类型为:暂降
List<EventDetail> lowerEventDetails = eventDetails.stream().filter(e -> e.getEventType().equals(Param.LOWEREVENT)).collect(Collectors.toList());
//当前监测点为:风电场
if("1".equals(voltageRideThroughQueryParam.getType())){
//计算 风电场 暂升次数
for(EventDetail eventDetail : upperEventDetails){
}
//计算 风电场 暂降次数
for(EventDetail eventDetail : lowerEventDetails){
}
}
//当前监测点为:光伏电站
if("2".equals(voltageRideThroughQueryParam.getType())){
//计算 光伏电站 暂升次数
for(EventDetail eventDetail : upperEventDetails){
}
//计算 光伏电站 暂降次数
for(EventDetail eventDetail : lowerEventDetails){
}
//开始计算当前地区高低压穿越次数
//获取当前部门下所有的已绑定能源站的监测点
List<String> lineIds = deptLineFeignClient.getLineByDeptIdAndNewStation(deptDTO.getId()).getData();
if(!lineIds.isEmpty()){
//根据已绑定能源站的监测点获取关联的暂态事件
List<EventDetail> eventDetails = eventDetailService.getEventDetail(lineIds,voltageRideThroughQueryParam.getSearchBeginTime()+Param.BEGIN,voltageRideThroughQueryParam.getSearchEndTime()+Param.END,null);
List<String> eventIds = eventDetails.stream().map(EventDetail::getEventId).collect(Collectors.toList());
if(!eventIds.isEmpty()){
SpThroughParam spThroughParam = new SpThroughParam(eventIds,voltageRideThroughQueryParam.getType());
//赋值子部门高低电压穿越次数
BeanUtils.copyProperties(spThroughFeignClient.getDataByEventIds(spThroughParam).getData(),voltageRideThroughVo);
}
}
voltageRideThroughVos.add(voltageRideThroughVo);
@@ -114,17 +92,24 @@ public class VoltageRideThroughEventServiceImpl implements VoltageRideThroughEve
public List<EventNewStationVo> voltageRideThroughEventQueryPage(VoltageRideThroughQueryParam voltageRideThroughQueryParam) {
List<EventNewStationVo> eventNewStationVos = new ArrayList<>();
List<String> lineIds = new ArrayList<>();
//获取当前选择的部门下所有的监测点(当然也会根据选择的新能源场站类型进行过滤)
lineIds.addAll(deptLineFeignClient.getLineByDeptIdAndNewStation(voltageRideThroughQueryParam.getAreaId(),voltageRideThroughQueryParam.getType()).getData());
//获取当前部门下所有的已绑定能源站的监测点
lineIds.addAll(deptLineFeignClient.getLineByDeptIdAndNewStation(voltageRideThroughQueryParam.getAreaId()).getData());
if(!lineIds.isEmpty()){
//根据监测点获取监测点下所有的事件集合
eventNewStationVos = BeanUtil.copyToList(eventDetailService.getEventDetail(lineIds,voltageRideThroughQueryParam.getSearchBeginTime()+Param.BEGIN,voltageRideThroughQueryParam.getSearchEndTime()+Param.END,null), EventNewStationVo.class);
//特殊处理事件集合中新能源场站名称
for(EventNewStationVo eventNewStationVo : eventNewStationVos){
List<LineDetailDataVO> lineDetailDataVOS = lineFeignClient.getLineDetailList(Arrays.asList(eventNewStationVo.getLineId())).getData();
if(!lineDetailDataVOS.isEmpty()){
NewStation newStation = newStationClient.selectById(lineDetailDataVOS.get(0).getNewStationId()).getData();
eventNewStationVo.setNewStationName(newStation.getName());
if(!eventNewStationVos.isEmpty()){
SpThroughParam spThroughParam = new SpThroughParam(eventNewStationVos.stream().map(EventNewStationVo::getEventId).collect(Collectors.toList()),voltageRideThroughQueryParam.getType());
//eventNewStationVos:事件集合中是包含了所有符合条件的事件,可能有部分事件并没有被高低电压穿越记录定时任务所执行 所以需要过滤下 具体逻辑说请看spThroughFeignClient.formatEventIds
List<String> eventIds = spThroughFeignClient.formatEventIds(spThroughParam).getData();
//过滤掉不符合的事件(eventIds为有效事件ID)
eventNewStationVos = eventNewStationVos.stream().filter(item->eventIds.contains(item.getEventId())).collect(Collectors.toList());
//特殊处理事件集合中新能源场站名称
for(EventNewStationVo eventNewStationVo : eventNewStationVos){
List<LineDetailDataVO> lineDetailDataVOS = lineFeignClient.getLineDetailList(Arrays.asList(eventNewStationVo.getLineId())).getData();
if(!lineDetailDataVOS.isEmpty()){
NewStation newStation = newStationClient.selectById(lineDetailDataVOS.get(0).getNewStationId()).getData();
eventNewStationVo.setNewStationName(newStation.getName());
}
}
}
}