新能源场站高低电压穿越统计

This commit is contained in:
guofeihu
2024-08-20 09:36:35 +08:00
parent c2af7e708c
commit 053183cdd0
15 changed files with 385 additions and 7 deletions

View File

@@ -7,7 +7,6 @@ import com.njcn.device.pq.pojo.po.DeptLine;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -19,7 +18,10 @@ import java.util.Map;
@FeignClient(value = ServerInfo.DEVICE,path = "/deptLine",fallbackFactory = DeptLineFeignClientFallbackFactory.class,contextId = "deptLine") @FeignClient(value = ServerInfo.DEVICE,path = "/deptLine",fallbackFactory = DeptLineFeignClientFallbackFactory.class,contextId = "deptLine")
public interface DeptLineFeignClient { public interface DeptLineFeignClient {
@PostMapping("/getLineByDeptId") @PostMapping("/getLineByDeptId")
HttpResult<List<String>> getLineByDeptId(String id); HttpResult<List<String>> getLineByDeptId(@RequestParam("id")String id);
@PostMapping("/getLineByDeptIdAndNewStation")
HttpResult<List<String>> getLineByDeptIdAndNewStation(@RequestParam("id")String id,@RequestParam("type")String type);
@PostMapping("/selectDeptBindLines") @PostMapping("/selectDeptBindLines")
HttpResult<Boolean> selectDeptBindLines(@RequestParam("ids") List<String> ids); HttpResult<Boolean> selectDeptBindLines(@RequestParam("ids") List<String> ids);

View File

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

View File

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

View File

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

View File

@@ -194,4 +194,10 @@
</if> </if>
</where> </where>
</select> </select>
<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})
</select>
</mapper> </mapper>

View File

@@ -67,7 +67,13 @@ public interface DeptLineService extends IService<DeptLine> {
*/ */
List<String> getLineByDeptId(String id); List<String> getLineByDeptId(String id);
/**
* 功能描述: 根据部门id获取绑定的监测点且再根据NewStation进行过滤
* @param id,type
* @author guofeihu
* @date 2024/8/19
*/
List<String> getLineByDeptIdAndNewStation(String id,String type);
/** /**
* @Description: 根据部门id获取所有子集部门所包含的部门信息 * @Description: 根据部门id获取所有子集部门所包含的部门信息

View File

@@ -12,6 +12,7 @@ import com.njcn.device.pq.mapper.LineMapper;
import com.njcn.device.pq.pojo.po.DeptLine; import com.njcn.device.pq.pojo.po.DeptLine;
import com.njcn.device.pq.pojo.vo.LineDeviceStateVO; import com.njcn.device.pq.pojo.vo.LineDeviceStateVO;
import com.njcn.device.pq.service.DeptLineService; import com.njcn.device.pq.service.DeptLineService;
import com.njcn.event.pojo.constant.Param;
import com.njcn.user.api.DeptFeignClient; import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.dto.DeptDTO; import com.njcn.user.pojo.dto.DeptDTO;
import com.njcn.web.pojo.param.DeptLineParam; import com.njcn.web.pojo.param.DeptLineParam;
@@ -88,6 +89,13 @@ public class DeptLineServiceImpl extends ServiceImpl<DeptLineMapper, DeptLine> i
return this.lambdaQuery().in(DeptLine::getId, id).list().stream().map(DeptLine::getLineId).distinct().collect(Collectors.toList()); return this.lambdaQuery().in(DeptLine::getId, id).list().stream().map(DeptLine::getLineId).distinct().collect(Collectors.toList());
} }
@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);
}
@Override @Override
public List<String> getLineNodeByDeptId(String id) { public List<String> getLineNodeByDeptId(String id) {
List<DeptDTO> deptInfos = deptFeignClient.getDeptDescendantIndexes(id, WebUtil.filterDeptType()).getData(); List<DeptDTO> deptInfos = deptFeignClient.getDeptDescendantIndexes(id, WebUtil.filterDeptType()).getData();

View File

@@ -501,9 +501,11 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
List<DictData> data = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE_STAND.getCode()).getData(); List<DictData> data = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_VOLTAGE_STAND.getCode()).getData();
Map<String, String> dicMap = data.stream().collect(Collectors.toMap(DictData::getId, DictData::getValue)); Map<String, String> dicMap = data.stream().collect(Collectors.toMap(DictData::getId, DictData::getValue));
LineDTO lineDTO = this.baseMapper.selectLineDetail(id); LineDTO lineDTO = this.baseMapper.selectLineDetail(id);
if(dicMap.containsKey(lineDTO.getVoltageLevel())){ if(lineDTO != null){
lineDTO.setVoltageLevel(dicMap.get(lineDTO.getVoltageLevel())); if(dicMap.containsKey(lineDTO.getVoltageLevel())){
return lineDTO; lineDTO.setVoltageLevel(dicMap.get(lineDTO.getVoltageLevel()));
return lineDTO;
}
} }
return null; return null;
} }

View File

@@ -27,6 +27,14 @@ public interface Param {
String BEGIN =" 00:00:00"; String BEGIN =" 00:00:00";
String END =" 23:59:59"; 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

@@ -0,0 +1,28 @@
package com.njcn.event.pojo.param;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
* 高低电压穿越统计查询实体类
* @author guofeihu
* @since 2024-08-15
*/
@Data
public class VoltageRideThroughQueryParam extends BaseParam {
@ApiModelProperty("区域ID")
@NotBlank(message = "区域ID不能为空")
private String areaId;
@ApiModelProperty("1:风电场,2:光伏电厂")
@NotBlank(message = "新能源场站不能为空")
private String type;
@ApiModelProperty("监测点集合(用于后端使用)")
private List<String> lineIds;
}

View File

@@ -0,0 +1,39 @@
package com.njcn.event.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 高低电压穿越统计 暂降事件列表实体类
* @author guofeihu
* @since 2024-08-15
*/
@Data
public class EventNewStationVo implements Serializable {
@ApiModelProperty(value = "事件ID")
private String eventId;
@ApiModelProperty(value = "监测点ID")
private String lineId;
@ApiModelProperty(value = "电站名称")
private String newStationName;
@ApiModelProperty(value = "开始时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
private LocalDateTime startTime;
@ApiModelProperty(value = "特征幅值")
private Double featureAmplitude;
@ApiModelProperty(value = "暂降原因")
private String advanceReason;
@ApiModelProperty(value = "暂降严重度")
private Double severity;
}

View File

@@ -0,0 +1,34 @@
package com.njcn.event.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 高低电压穿越统计 地图实体类
* @author: guofeihu
* @date: 2024-08-15
*/
@Data
public class VoltageRideThroughVo implements Serializable {
@ApiModelProperty("地区ID")
private String id;
@ApiModelProperty("地区名称")
private String name;
@ApiModelProperty("中心点经度")
private BigDecimal lng;
@ApiModelProperty("中心点纬度")
private BigDecimal lat;
@ApiModelProperty("低压次数")
private String lowPressure;
@ApiModelProperty("高压次数")
private String highPressure;
}

View File

@@ -0,0 +1,60 @@
package com.njcn.event.controller.majornetwork;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
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.common.utils.LogUtil;
import com.njcn.event.pojo.param.VoltageRideThroughQueryParam;
import com.njcn.event.pojo.vo.EventNewStationVo;
import com.njcn.event.pojo.vo.VoltageRideThroughVo;
import com.njcn.event.service.majornetwork.VoltageRideThroughEventService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 高低电压穿越统计 前端控制器
* </p>
* @author guofeihu
* @since 2024-08-14
*/
@Api(tags = "高低电压穿越统计")
@Slf4j
@RestController
@RequestMapping("/voltageRideThrough")
@RequiredArgsConstructor
public class VoltageRideThroughEventController extends BaseController {
private final VoltageRideThroughEventService voltageRideThroughEventService;
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.QUERY)
@PostMapping("/view")
@ApiOperation("查询高低电压穿越视图")
public HttpResult<List<VoltageRideThroughVo>> voltageRideThroughView(@RequestBody @Validated VoltageRideThroughQueryParam voltageRideThroughQueryParam) {
String methodDescribe = getMethodDescribe("voltageRideThroughView");
LogUtil.njcnDebug(log, "{},查询对象为:{}", methodDescribe, voltageRideThroughQueryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, voltageRideThroughEventService.voltageRideThroughView(voltageRideThroughQueryParam), methodDescribe);
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.QUERY)
@PostMapping("/eventQueryPage")
@ApiOperation("高低电压穿越暂态事件分页")
public HttpResult<List<EventNewStationVo>> voltageRideThroughEventQueryPage(@RequestBody @Validated VoltageRideThroughQueryParam voltageRideThroughQueryParam) {
String methodDescribe = getMethodDescribe("voltageRideThroughEventQueryPage");
LogUtil.njcnDebug(log, "{},查询对象为:{}", methodDescribe, voltageRideThroughQueryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, voltageRideThroughEventService.voltageRideThroughEventQueryPage(voltageRideThroughQueryParam), methodDescribe);
}
}

View File

@@ -0,0 +1,136 @@
package com.njcn.event.service.majornetwork.Impl;
import cn.hutool.core.bean.BeanUtil;
import com.njcn.device.biz.commApi.CommLineClient;
import com.njcn.device.biz.pojo.dto.LineDTO;
import com.njcn.device.pq.api.DeptLineFeignClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.api.NewStationClient;
import com.njcn.device.pq.pojo.po.NewStation;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.pojo.constant.Param;
import com.njcn.event.pojo.param.VoltageRideThroughQueryParam;
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.VoltageRideThroughEventService;
import com.njcn.system.api.AreaFeignClient;
import com.njcn.system.pojo.po.Area;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.dto.DeptDTO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
* 高低电压穿越统计 服务类实现类
* </p>
* @author guofeihu
* @since 2024-08-14
*/
@Service
@AllArgsConstructor
@Slf4j
public class VoltageRideThroughEventServiceImpl implements VoltageRideThroughEventService {
private final AreaFeignClient areaFeignClient;
private final DeptFeignClient deptFeignClient;
private final DeptLineFeignClient deptLineFeignClient;
private final CommLineClient commLineClient;
private final LineFeignClient lineFeignClient;
private final EventDetailService eventDetailService;
private final NewStationClient newStationClient;
@Override
public List<VoltageRideThroughVo> voltageRideThroughView(VoltageRideThroughQueryParam voltageRideThroughQueryParam) {
List<VoltageRideThroughVo> voltageRideThroughVos = new ArrayList<>();
//根据当前选择的部门ID获取其下的子部门集合
List<DeptDTO> deptDTOS = deptFeignClient.getDepSonDetailByDeptId(voltageRideThroughQueryParam.getAreaId()).getData();
for(DeptDTO deptDTO : deptDTOS){
//子部门信息
VoltageRideThroughVo voltageRideThroughVo = new VoltageRideThroughVo();
//赋值子部门名称及ID
BeanUtils.copyProperties(deptDTO,voltageRideThroughVo);
//根据子部门的area获取经纬度
Area area = areaFeignClient.selectIdArea(deptDTO.getArea()).getData();
if(area != null){
voltageRideThroughVo.setLat(area.getLat());
voltageRideThroughVo.setLng(area.getLng());
}
//开始计算每个地区高低压穿越次数
//获取当前部门下所有的监测点(当然也会根据选择的新能源场站类型进行过滤)
List<String> lineIds = deptLineFeignClient.getLineByDeptIdAndNewStation(deptDTO.getId(),voltageRideThroughQueryParam.getType()).getData();
for(String lineId : lineIds){
//监测点信息
LineDTO lineDTO = commLineClient.getLineDetail(lineId).getData();
if(lineDTO == null){
continue;
}
//监测点绑定的暂降事件
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(Param.PHOTOVOLTAICPOWER.equals(lineDTO.getStationType())){
//计算 光伏电站 暂升次数
for(EventDetail eventDetail : upperEventDetails){
}
//计算 光伏电站 暂降次数
for(EventDetail eventDetail : lowerEventDetails){
}
}
//当前监测点为:风电场
if(Param.WINDFARM.equals(lineDTO.getStationType())){
//计算 风电场 暂升次数
for(EventDetail eventDetail : upperEventDetails){
}
//计算 风电场 暂降次数
for(EventDetail eventDetail : lowerEventDetails){
}
}
}
voltageRideThroughVos.add(voltageRideThroughVo);
}
return voltageRideThroughVos;
}
@Override
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());
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());
}
}
}
return eventNewStationVos;
}
}

View File

@@ -0,0 +1,32 @@
package com.njcn.event.service.majornetwork;
import com.njcn.event.pojo.param.VoltageRideThroughQueryParam;
import com.njcn.event.pojo.vo.EventNewStationVo;
import com.njcn.event.pojo.vo.VoltageRideThroughVo;
import java.util.List;
/**
* <p>
* 高低电压穿越统计 服务类
* </p>
* @author guofeihu
* @since 2024-08-14
*/
public interface VoltageRideThroughEventService {
/***
* 查询高低电压穿越视图
* @param voltageRideThroughQueryParam
* @return List
*/
List<VoltageRideThroughVo> voltageRideThroughView(VoltageRideThroughQueryParam voltageRideThroughQueryParam);
/***
* 高低电压穿越暂态事件分页
* @param voltageRideThroughQueryParam
* @return Page
*/
List<EventNewStationVo> voltageRideThroughEventQueryPage(VoltageRideThroughQueryParam voltageRideThroughQueryParam);
}