高低电压穿越功能优化
This commit is contained in:
@@ -80,5 +80,5 @@ public interface EventDetailFeignClient {
|
||||
* 根据开始时间及结束时间获取暂态事件信息
|
||||
*/
|
||||
@PostMapping("/getNewEventDetailByTime")
|
||||
HttpResult<List<RmpEventDetailPO>> getNewEventDetailByTime(@RequestParam(name = "lastTime",required = false)LocalDateTime lastTime,@RequestParam("currentTime")LocalDateTime currentTime);
|
||||
HttpResult<List<RmpEventDetailPO>> getNewEventDetailByTime(@RequestBody EventCountParam param);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ 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;
|
||||
|
||||
@@ -83,7 +82,7 @@ public class EventDetailFeignClientFallbackFactory implements FallbackFactory<Ev
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<RmpEventDetailPO>> getNewEventDetailByTime(LocalDateTime lastTime, LocalDateTime currentTime) {
|
||||
public HttpResult<List<RmpEventDetailPO>> getNewEventDetailByTime(EventCountParam param) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "根据开始时间及结束时间获取暂态事件信息", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@@ -84,6 +84,11 @@
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>supervision-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -27,7 +27,6 @@ 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;
|
||||
@@ -108,7 +107,7 @@ public class EventDetailController extends BaseController {
|
||||
public HttpResult<List<EventDetail>> getEventDetail(@RequestBody List<String> lineIndexes, @RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime) {
|
||||
String methodDescribe = getMethodDescribe("getEventDetail");
|
||||
LogUtil.njcnDebug(log, "{},监测点id为:{}", methodDescribe, lineIndexes);
|
||||
List<EventDetail> result = eventDetailService.getEventDetail(lineIndexes, startTime, endTime, new ArrayList<>());
|
||||
List<EventDetail> result = eventDetailService.getEventDetail(lineIndexes, startTime, endTime);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@@ -222,12 +221,13 @@ public class EventDetailController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getNewEventDetailByTime")
|
||||
@ApiOperation("根据开始时间及结束时间获取暂态事件信息")
|
||||
public HttpResult<List<RmpEventDetailPO>> getNewEventDetailByTime(@RequestParam(name = "lastTime",required = false) LocalDateTime lastTime, @RequestParam("currentTime")LocalDateTime currentTime) {
|
||||
public HttpResult<List<RmpEventDetailPO>> getNewEventDetailByTime(@RequestBody EventCountParam param) {
|
||||
String methodDescribe = getMethodDescribe("getNewEventDetailByTime");
|
||||
LambdaQueryWrapper<RmpEventDetailPO> lambdaQueryWrapper = new LambdaQueryWrapper();
|
||||
lambdaQueryWrapper.le(RmpEventDetailPO::getStartTime,currentTime);
|
||||
if(lastTime != null){
|
||||
lambdaQueryWrapper.gt(RmpEventDetailPO::getStartTime,lastTime);
|
||||
lambdaQueryWrapper.in(RmpEventDetailPO::getMeasurementPointId,param.getIds());
|
||||
lambdaQueryWrapper.le(RmpEventDetailPO::getStartTime,param.getEndTime());
|
||||
if(param.getStartTime() != null){
|
||||
lambdaQueryWrapper.gt(RmpEventDetailPO::getStartTime,param.getStartTime());
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventDetailService.list(lambdaQueryWrapper), methodDescribe);
|
||||
}
|
||||
|
||||
@@ -21,12 +21,14 @@ 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
|
||||
*/
|
||||
@@ -39,22 +41,24 @@ public class VoltageRideThroughEventController extends BaseController {
|
||||
|
||||
private final VoltageRideThroughEventService voltageRideThroughEventService;
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.QUERY)
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@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);
|
||||
List<VoltageRideThroughVo> voltageRideThroughVos = voltageRideThroughEventService.voltageRideThroughView(voltageRideThroughQueryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, voltageRideThroughVos, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.QUERY)
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/voltageRideThroughEventQueryPage")
|
||||
@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);
|
||||
List<EventNewStationVo> eventNewStationVos = voltageRideThroughEventService.voltageRideThroughEventQueryPage(voltageRideThroughQueryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventNewStationVos, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public interface EventDetailService extends IService<RmpEventDetailPO> {
|
||||
/**
|
||||
* 根据监测点集合获取暂态列表
|
||||
*/
|
||||
List<EventDetail> getEventDetail(List<String> lineIndexes, String startTime, String endTime, List<Integer> waveType);
|
||||
List<EventDetail> getEventDetail(List<String> lineIndexes, String startTime, String endTime);
|
||||
|
||||
/**
|
||||
* 根据监测点集合以及分页信息获取暂降事件
|
||||
|
||||
@@ -75,7 +75,7 @@ public class EventDetailServiceImpl extends ServiceImpl<EventDetailMapper, RmpEv
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EventDetail> getEventDetail(List<String> lineIndexes, String startTime, String endTime, List<Integer> waveType) {
|
||||
public List<EventDetail> getEventDetail(List<String> lineIndexes, String startTime, String endTime) {
|
||||
List<RmpEventDetailPO> info = this.list(new LambdaQueryWrapper<RmpEventDetailPO>()
|
||||
.in(RmpEventDetailPO::getMeasurementPointId, lineIndexes)
|
||||
.ge(StrUtil.isNotBlank(startTime), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(startTime)))
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package com.njcn.event.service.majornetwork.Impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
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;
|
||||
@@ -15,6 +14,8 @@ 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.supervision.api.UserLedgerFeignClient;
|
||||
import com.njcn.supervision.pojo.vo.user.NewUserReportVO;
|
||||
import com.njcn.system.api.AreaFeignClient;
|
||||
import com.njcn.system.pojo.po.Area;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
@@ -24,8 +25,8 @@ 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.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -41,24 +42,18 @@ import java.util.stream.Collectors;
|
||||
public class VoltageRideThroughEventServiceImpl implements VoltageRideThroughEventService {
|
||||
|
||||
private final AreaFeignClient areaFeignClient;
|
||||
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
|
||||
private final DeptLineFeignClient deptLineFeignClient;
|
||||
|
||||
private final LineFeignClient lineFeignClient;
|
||||
|
||||
private final EventDetailService eventDetailService;
|
||||
|
||||
private final NewStationClient newStationClient;
|
||||
|
||||
private final SpThroughFeignClient spThroughFeignClient;
|
||||
private final UserLedgerFeignClient userLedgerFeignClient;
|
||||
|
||||
@Override
|
||||
public List<VoltageRideThroughVo> voltageRideThroughView(VoltageRideThroughQueryParam voltageRideThroughQueryParam) {
|
||||
public List<VoltageRideThroughVo> voltageRideThroughView(VoltageRideThroughQueryParam param) {
|
||||
List<VoltageRideThroughVo> voltageRideThroughVos = new ArrayList<>();
|
||||
//根据当前选择的部门ID获取其下的子部门集合
|
||||
List<DeptDTO> deptDTOS = deptFeignClient.getDepSonDetailByDeptId(voltageRideThroughQueryParam.getAreaId()).getData();
|
||||
List<DeptDTO> deptDTOS = deptFeignClient.getDepSonDetailByDeptId(param.getAreaId()).getData();
|
||||
for(DeptDTO deptDTO : deptDTOS){
|
||||
//子部门信息
|
||||
VoltageRideThroughVo voltageRideThroughVo = new VoltageRideThroughVo();
|
||||
@@ -75,10 +70,14 @@ public class VoltageRideThroughEventServiceImpl implements VoltageRideThroughEve
|
||||
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());
|
||||
List<EventDetail> eventDetails = eventDetailService.getEventDetail(lineIds,
|
||||
DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())).toString(),
|
||||
DateUtil.beginOfDay(DateUtil.parse(param.getSearchEndTime())).toString());
|
||||
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();
|
||||
spThroughParam.setEventIds(eventIds);
|
||||
//赋值子部门高低电压穿越次数
|
||||
BeanUtils.copyProperties(spThroughFeignClient.getDataByEventIds(spThroughParam).getData(),voltageRideThroughVo);
|
||||
}
|
||||
@@ -89,26 +88,35 @@ public class VoltageRideThroughEventServiceImpl implements VoltageRideThroughEve
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EventNewStationVo> voltageRideThroughEventQueryPage(VoltageRideThroughQueryParam voltageRideThroughQueryParam) {
|
||||
public List<EventNewStationVo> voltageRideThroughEventQueryPage(VoltageRideThroughQueryParam param) {
|
||||
List<EventNewStationVo> eventNewStationVos = new ArrayList<>();
|
||||
List<String> lineIds = new ArrayList<>();
|
||||
//获取当前部门下所有的已绑定能源站的监测点
|
||||
lineIds.addAll(deptLineFeignClient.getLineByDeptIdAndNewStation(voltageRideThroughQueryParam.getAreaId()).getData());
|
||||
lineIds.addAll(deptLineFeignClient.getLineByDeptIdAndNewStation(param.getAreaId()).getData());
|
||||
if(!lineIds.isEmpty()){
|
||||
//根据监测点获取监测点下所有的事件集合
|
||||
eventNewStationVos = BeanUtil.copyToList(eventDetailService.getEventDetail(lineIds,voltageRideThroughQueryParam.getSearchBeginTime()+Param.BEGIN,voltageRideThroughQueryParam.getSearchEndTime()+Param.END,null), EventNewStationVo.class);
|
||||
List<EventDetail> eventDetail = eventDetailService.getEventDetail(lineIds,
|
||||
DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())).toString(),
|
||||
DateUtil.beginOfDay(DateUtil.parse(param.getSearchEndTime())).toString());
|
||||
eventNewStationVos = BeanUtil.copyToList(eventDetail, EventNewStationVo.class);
|
||||
if(!eventNewStationVos.isEmpty()){
|
||||
SpThroughParam spThroughParam = new SpThroughParam(eventNewStationVos.stream().map(EventNewStationVo::getEventId).collect(Collectors.toList()),voltageRideThroughQueryParam.getType());
|
||||
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();
|
||||
//过滤掉不符合的事件(eventIds为有效事件ID)
|
||||
eventNewStationVos = eventNewStationVos.stream().filter(item->eventIds.contains(item.getEventId())).collect(Collectors.toList());
|
||||
List<LineDetailDataVO> lineDetailDataVOS = lineFeignClient.getLineDetailList(lineIds).getData();
|
||||
Map<String, String> lineDetailDataMap = lineDetailDataVOS.stream().collect(Collectors.toMap(LineDetailDataVO::getLineId, LineDetailDataVO::getObyId));
|
||||
//特殊处理事件集合中新能源场站名称
|
||||
List<NewUserReportVO> userReportVOS = userLedgerFeignClient.getUserReportByIds(new ArrayList<>(lineDetailDataMap.values())).getData();
|
||||
Map<String, String> userReportMap = userReportVOS.stream().collect(Collectors.toMap(NewUserReportVO::getId, NewUserReportVO::getProjectName));
|
||||
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(lineDetailDataMap.containsKey(eventNewStationVo.getLineId())){
|
||||
String lineID = lineDetailDataMap.get(eventNewStationVo.getLineId());
|
||||
if(userReportMap.containsKey(lineID)){
|
||||
eventNewStationVo.setNewStationName(userReportMap.get(lineID));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user