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

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

@@ -35,6 +35,6 @@ public class LineDTO {
@ApiModelProperty(name = "objType",value = "对象类型")
private String objType;
@ApiModelProperty(name = "stationType",value = "新能源场站类型")
private String stationType;
@ApiModelProperty(name = "新能源场站信息ID")
private String newStationId;
}

View File

@@ -21,7 +21,7 @@ public interface DeptLineFeignClient {
HttpResult<List<String>> getLineByDeptId(@RequestParam("id")String id);
@PostMapping("/getLineByDeptIdAndNewStation")
HttpResult<List<String>> getLineByDeptIdAndNewStation(@RequestParam("id")String id,@RequestParam("type")String type);
HttpResult<List<String>> getLineByDeptIdAndNewStation(@RequestParam("id")String id);
@PostMapping("/selectDeptBindLines")
HttpResult<Boolean> selectDeptBindLines(@RequestParam("ids") List<String> ids);

View File

@@ -40,7 +40,7 @@ public class DeptLineFeignClientFallbackFactory implements FallbackFactory<DeptL
}
@Override
public HttpResult<List<String>> getLineByDeptIdAndNewStation(String id, String type) {
public HttpResult<List<String>> getLineByDeptIdAndNewStation(String id) {
log.error("{}异常,降级处理,异常为:{}", "根据部门id获取绑定的监测点且再根据NewStation进行过滤", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}

View File

@@ -30,7 +30,7 @@ public class NewStationClientFallbackFactory implements FallbackFactory<NewStati
return new NewStationClient() {
@Override
public HttpResult<NewStation> selectById(String id) {
log.error("{}异常,降级处理,异常为:{}", "获取终获取告警策略列表", throwable.toString());
log.error("{}异常,降级处理,异常为:{}", "根据ID获取新能源场站高低电压穿越表信息", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};

View File

@@ -21,4 +21,14 @@ public interface Param {
Integer WEEK = 4;
Integer DAY = 5;
//以下四个固定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

@@ -115,9 +115,9 @@ public class DeptLineController extends BaseController {
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@PostMapping("/getLineByDeptIdAndNewStation")
@ApiOperation("根据部门id获取绑定的监测点且再根据NewStation进行过滤")
public HttpResult<List<String>> getLineByDeptIdAndNewStation(@RequestParam("id") String id,@RequestParam("type")String type) {
public HttpResult<List<String>> getLineByDeptIdAndNewStation(@RequestParam("id") String id) {
String methodDescribe = getMethodDescribe("getLineByDeptIdAndNewStation");
List<String> list = deptLineService.getLineByDeptIdAndNewStation(id,type);
List<String> list = deptLineService.getLineByDeptIdAndNewStation(id);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}

View File

@@ -83,5 +83,5 @@ public interface DeptLineMapper extends BaseMapper<DeptLine> {
List<SubGetBase> selectSubStationList(@Param("param") SubstationParam substationParam);
List<String> getLineByDeptIdAndNewStation(@Param("id") String id,@Param("stationType") String stationType);
List<String> getLineByDeptIdAndNewStation(@Param("id") String id);
}

View File

@@ -198,6 +198,7 @@
<select id="getLineByDeptIdAndNewStation" resultType="string">
select pdl.Line_Id from pq_dept_line pdl
inner join pq_line_detail pld on pdl.Line_Id = pld.Id
where pdl.Id = #{id} and pld.New_Station_Id in (select pns.id from pq_new_station pns where pns.station_type = #{stationType} and pns.state = 1)
where pdl.Id = #{id}
and exists (select 1 from pq_new_station pns where pns.id = pld.New_Station_Id and pns.state = 1)
</select>
</mapper>

View File

@@ -1432,7 +1432,7 @@
pqd.Run_Flag as runFlag,
detail.PT_Type AS ptType,
detail.PT_Phase_Type AS ptPhaseType,
detail.New_Station_Id AS stationType
detail.New_Station_Id AS newStationId
FROM
pq_line line,
pq_line_detail detail,

View File

@@ -73,7 +73,7 @@ public interface DeptLineService extends IService<DeptLine> {
* @author guofeihu
* @date 2024/8/19
*/
List<String> getLineByDeptIdAndNewStation(String id,String type);
List<String> getLineByDeptIdAndNewStation(String id);
/**
* @Description: 根据部门id获取所有子集部门所包含的部门信息

View File

@@ -12,7 +12,7 @@ import com.njcn.device.pq.mapper.LineMapper;
import com.njcn.device.pq.pojo.po.DeptLine;
import com.njcn.device.pq.pojo.vo.LineDeviceStateVO;
import com.njcn.device.pq.service.DeptLineService;
import com.njcn.event.pojo.constant.Param;
import com.njcn.device.pq.constant.Param;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.dto.DeptDTO;
import com.njcn.web.pojo.param.DeptLineParam;
@@ -90,10 +90,8 @@ public class DeptLineServiceImpl extends ServiceImpl<DeptLineMapper, DeptLine> i
}
@Override
public List<String> getLineByDeptIdAndNewStation(String id, String type) {
if("1".equals(type)) type = Param.WINDFARM;
if("2".equals(type)) type = Param.PHOTOVOLTAICPOWER;
return this.baseMapper.getLineByDeptIdAndNewStation(id,type);
public List<String> getLineByDeptIdAndNewStation(String id) {
return this.baseMapper.getLineByDeptIdAndNewStation(id);
}
@Override

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,11 +92,17 @@ 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);
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();
@@ -128,6 +112,7 @@ public class VoltageRideThroughEventServiceImpl implements VoltageRideThroughEve
}
}
}
}
return eventNewStationVos;
}
}

View File

@@ -0,0 +1,31 @@
package com.njcn.harmonic.pojo.param;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.time.LocalDate;
/**
* 有功功率趋势实分页查询类
* @author guofeihu
* @date 2024-08-20
*/
@Data
public class RActivePowerRangeQueryParam extends BaseParam {
@Data
public static class RActivePowerRangeEdit{
@ApiModelProperty("id")
private String id;
@NotBlank(message = "监测点ID不能为空")
@ApiModelProperty("监测点(*)")
private String lineId;
@NotBlank(message = "日期不能为空")
@ApiModelProperty("日期(*)")
private LocalDate timeId;
}
}

View File

@@ -0,0 +1,25 @@
package com.njcn.harmonic.controller.powerstatistics;
import com.njcn.harmonic.service.activepowerrange.PowerStatisticsService;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import com.njcn.web.controller.BaseController;
/**
* 有功功率趋势统计 前端控制器
* @author guofeihu
* @since 2024-08-20
*/
@Slf4j
@RestController
@RequestMapping("/powerStatistics")
@Api(tags = "有功功率趋势")
@AllArgsConstructor
public class PowerStatisticsController extends BaseController {
private final PowerStatisticsService powerStatisticsService;
}

View File

@@ -0,0 +1,10 @@
package com.njcn.harmonic.service.activepowerrange;
/**
* 有功功率趋势统计 服务类
* @author guofeihu
* @since 2024-08-20
*/
public interface PowerStatisticsService {
}

View File

@@ -0,0 +1,14 @@
package com.njcn.harmonic.service.activepowerrange.impl;
import com.njcn.harmonic.service.activepowerrange.PowerStatisticsService;
import org.springframework.stereotype.Service;
/**
* 有功功率趋势统计 服务实现类
* @author guofeihu
* @since 2024-08-20
*/
@Service
public class PowerStatisticsServiceImpl implements PowerStatisticsService {
}

View File

@@ -3,8 +3,13 @@ package com.njcn.prepare.harmonic.api.event;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.prepare.harmonic.api.event.fallback.SpThroughFeignClientFallbackFactory;
import com.njcn.prepare.harmonic.pojo.param.SpThroughParam;
import com.njcn.prepare.harmonic.pojo.vo.SpThroughVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* 高低电压穿越Feign客户端
@@ -20,4 +25,10 @@ public interface SpThroughFeignClient {
@PostMapping("/record")
HttpResult<Boolean> record();
@PostMapping("/getDataByEventIds")
HttpResult<SpThroughVO> getDataByEventIds(@RequestBody @Validated SpThroughParam spThroughParam);
@PostMapping("/formatEventIds")
HttpResult<List<String>> formatEventIds(@RequestBody @Validated SpThroughParam spThroughParam);
}

View File

@@ -4,10 +4,13 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.prepare.harmonic.api.event.SpThroughFeignClient;
import com.njcn.prepare.harmonic.pojo.param.SpThroughParam;
import com.njcn.prepare.harmonic.pojo.vo.SpThroughVO;
import com.njcn.prepare.harmonic.utils.PrepareEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 高低电压穿越熔断降级
@@ -33,6 +36,18 @@ public class SpThroughFeignClientFallbackFactory implements FallbackFactory<SpTh
log.error("{}异常,降级处理,异常为:{}", "高低电压穿越记录: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<SpThroughVO> getDataByEventIds(SpThroughParam spThroughParam) {
log.error("{}异常,降级处理,异常为:{}", "根据事件ID集合及能源站类型获取高低电压穿越次数: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<String>> formatEventIds(SpThroughParam spThroughParam) {
log.error("{}异常,降级处理,异常为:{}", "根据原有的事件集合进行过滤: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,27 @@
package com.njcn.prepare.harmonic.pojo.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author guofeihu
* @since 2024-08-14
*/
@Data
public class SpThroughParam {
@ApiModelProperty(name = "eventIds",value = "事件ID集合")
private List<String> eventIds;
@ApiModelProperty(name = "lineType",value = "监测点类别(1:风电场、2:光伏电站)")
private String stationType;
public SpThroughParam(List<String> eventIds, String stationType) {
this.eventIds = eventIds;
this.stationType = stationType;
}
public SpThroughParam() {
}
}

View File

@@ -0,0 +1,19 @@
package com.njcn.prepare.harmonic.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;
}

View File

@@ -6,7 +6,8 @@ import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.prepare.harmonic.pojo.po.SpThroughPO;
import com.njcn.prepare.harmonic.pojo.param.SpThroughParam;
import com.njcn.prepare.harmonic.pojo.vo.SpThroughVO;
import com.njcn.prepare.harmonic.service.mysql.event.SpThroughService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
@@ -45,11 +46,19 @@ public class SpThroughController extends BaseController {
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.QUERY)
@PostMapping("/getDataByLineIds")
@ApiOperation("根据监测点ID集合获取高低电压穿越信息")
public HttpResult<List<SpThroughPO>> getDataByLineIds(@RequestBody List<String> lineIds) {
String methodDescribe = getMethodDescribe("getDataByLineIds");
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, spThroughService.getDataByLineIds(lineIds), methodDescribe);
@PostMapping("/getDataByEventIds")
@ApiOperation("根据事件ID集合及能源站类型获取高低电压穿越次数")
public HttpResult<SpThroughVO> getDataByEventIds(@RequestBody SpThroughParam spThroughParam) {
String methodDescribe = getMethodDescribe("getDataByEventIds");
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, spThroughService.getDataByEventIds(spThroughParam), methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.QUERY)
@PostMapping("/formatEventIds")
@ApiOperation("根据原有的事件集合进行过滤")
public HttpResult<List<String>> formatEventIds(@RequestBody SpThroughParam spThroughParam) {
String methodDescribe = getMethodDescribe("formatEventIds");
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, spThroughService.formatEventIds(spThroughParam), methodDescribe);
}
}

View File

@@ -1,11 +1,25 @@
package com.njcn.prepare.harmonic.service.mysql.Impl.event;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.device.biz.commApi.CommLineClient;
import com.njcn.device.biz.pojo.dto.LineDTO;
import com.njcn.device.pq.api.NewStationClient;
import com.njcn.device.pq.constant.Param;
import com.njcn.device.pq.pojo.po.NewStation;
import com.njcn.event.api.EventDetailFeignClient;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.prepare.harmonic.mapper.mysql.event.SpThroughMapper;
import com.njcn.prepare.harmonic.pojo.param.SpThroughParam;
import com.njcn.prepare.harmonic.pojo.po.SpThroughPO;
import com.njcn.prepare.harmonic.pojo.vo.SpThroughVO;
import com.njcn.prepare.harmonic.service.mysql.event.SpThroughService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
/**
* 高低电压穿越 服务实现类
@@ -13,15 +27,105 @@ import java.util.List;
* @since 2024-08-22
*/
@Service
@RequiredArgsConstructor
public class SpThroughServiceImpl extends MppServiceImpl<SpThroughMapper, SpThroughPO> implements SpThroughService {
private final EventDetailFeignClient eventDetailFeignClient;
private final CommLineClient commLineClient;
private final NewStationClient newStationClient;
@Override
public void record() {
LocalDateTime currentTime = LocalDateTime.now();
//获取最新的暂态事件信息(截至目前为止)
List<RmpEventDetailPO> evenStDetailPOS = eventDetailFeignClient.getNewEventDetailByTime(getLastTime(),currentTime).getData();
for(RmpEventDetailPO rmpEventDetailPO : evenStDetailPOS){
//获取监测点
LineDTO lineDTO = commLineClient.getLineDetail(rmpEventDetailPO.getMeasurementPointId()).getData();
if(lineDTO != null && lineDTO.getNewStationId() != null){
NewStation newStation = newStationClient.selectById(lineDTO.getNewStationId()).getData();
if(newStation != null){
//暂升事件
if(Param.UPPEREVENT.equals(rmpEventDetailPO.getEventType())){
//风电场
if(Param.WINDFARM.equals(newStation.getStationType())){
}
//光伏电站
if(Param.PHOTOVOLTAICPOWER.equals(newStation.getStationType())){
}
}
//暂降事件
if(Param.LOWEREVENT.equals(rmpEventDetailPO.getEventType())){
//风电场
if(Param.WINDFARM.equals(newStation.getStationType())){
}
//光伏电站
if(Param.PHOTOVOLTAICPOWER.equals(newStation.getStationType())){
}
}
}
}
}
}
//拿到最近一次插入高低电压穿越表信息的时间
private LocalDateTime getLastTime(){
LambdaQueryWrapper<SpThroughPO> lambdaQueryWrapper = new LambdaQueryWrapper();
lambdaQueryWrapper.orderByDesc(SpThroughPO::getCreateTime);
Page<SpThroughPO> page = new Page<>(1, 1);
List<SpThroughPO> spThroughPOS = this.baseMapper.selectPage(page,lambdaQueryWrapper).getRecords();
if(!spThroughPOS.isEmpty()){
return spThroughPOS.get(0).getCreateTime();
}
return null;
}
@Override
public List<SpThroughPO> getDataByLineIds(List<String> lineIds) {
return null;
public SpThroughVO getDataByEventIds(SpThroughParam spThroughParam) {
SpThroughVO spThroughVO = new SpThroughVO();
LambdaQueryWrapper<SpThroughPO> upperLambdaQueryWrapper = new LambdaQueryWrapper();
upperLambdaQueryWrapper.in(SpThroughPO::getEventId,spThroughParam.getEventIds())
.eq(SpThroughPO::getIsOrNot,1)
.eq(SpThroughPO::getStationType,spThroughParam.getStationType().equals("1")?Param.WINDFARM:Param.PHOTOVOLTAICPOWER)
.eq(SpThroughPO::getState,1)
.eq(SpThroughPO::getEventType,Param.UPPEREVENT);
Integer upperCount = this.baseMapper.selectCount(upperLambdaQueryWrapper);
spThroughVO.setHighPressure(upperCount == 0?null:upperCount.toString());
LambdaQueryWrapper<SpThroughPO> lowLambdaQueryWrapper = new LambdaQueryWrapper();
lowLambdaQueryWrapper.in(SpThroughPO::getEventId,spThroughParam.getEventIds())
.eq(SpThroughPO::getIsOrNot,1)
.eq(SpThroughPO::getStationType,spThroughParam.getStationType().equals("1")?Param.WINDFARM:Param.PHOTOVOLTAICPOWER)
.eq(SpThroughPO::getState,1)
.eq(SpThroughPO::getEventType,Param.LOWEREVENT);
Integer lowCount = this.baseMapper.selectCount(lowLambdaQueryWrapper);
spThroughVO.setLowPressure(lowCount == 0?null:lowCount.toString());
return spThroughVO;
}
/**
* 说明:
* 此方法是专门提供给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,spThroughParam.getStationType().equals("1")?Param.WINDFARM:Param.PHOTOVOLTAICPOWER)
.eq(SpThroughPO::getState,1);
List<SpThroughPO> spThroughPOS = this.baseMapper.selectList(lambdaQueryWrapper);
return spThroughPOS.stream().map(SpThroughPO::getEventId).collect(Collectors.toList());
}
}

View File

@@ -1,7 +1,9 @@
package com.njcn.prepare.harmonic.service.mysql.event;
import com.github.jeffreyning.mybatisplus.service.IMppService;
import com.njcn.prepare.harmonic.pojo.param.SpThroughParam;
import com.njcn.prepare.harmonic.pojo.po.SpThroughPO;
import com.njcn.prepare.harmonic.pojo.vo.SpThroughVO;
import java.util.List;
/**
@@ -17,8 +19,13 @@ public interface SpThroughService extends IMppService<SpThroughPO> {
void record();
/**
* 根据监测点ID集合获取高低电压穿越信息
* 根据事件ID集合及能源站类型获取高低电压穿越次数
*/
List<SpThroughPO> getDataByLineIds(List<String> lineIds);
SpThroughVO getDataByEventIds(SpThroughParam spThroughParam);
/**
* 根据原有的事件集合进行过滤
*/
List<String> formatEventIds(SpThroughParam spThroughParam);
}