diff --git a/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/api/MonitorSendClient.java b/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/api/MonitorSendClient.java new file mode 100644 index 000000000..a2f098aff --- /dev/null +++ b/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/api/MonitorSendClient.java @@ -0,0 +1,41 @@ +package com.njcn.device.pms.api; + +import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.constant.ServerInfo; +import com.njcn.common.pojo.enums.common.LogEnum; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.device.biz.pojo.po.Overlimit; +import com.njcn.device.pms.api.fallback.MonitorClientFallbackFactory; +import com.njcn.device.pms.pojo.dto.PmsMonitorDTO; +import com.njcn.device.pms.pojo.dto.PmsMonitorInfoDTO; +import com.njcn.device.pms.pojo.param.MonitorParam; +import com.njcn.device.pms.pojo.param.MonitorTerminalParam; +import com.njcn.device.pms.pojo.param.PmsMonitorInfoParam; +import com.njcn.device.pms.pojo.param.PmsMonitorParam; +import com.njcn.device.pms.pojo.po.Monitor; +import com.njcn.device.pms.pojo.vo.MonitorVO; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +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 org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; + +/** + * @author yzh + * @date 2022/10/18 + */ +@FeignClient( + value = ServerInfo.DEVICE, + path = "/monitorSend", + contextId = "monitorSend", + fallbackFactory = MonitorClientFallbackFactory.class) +public interface MonitorSendClient { + + @PostMapping("/sendType") + HttpResult windSend(@RequestBody @Validated MonitorParam.Info param); + +} diff --git a/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/api/fallback/MonitorSendClientFallbackFactory.java b/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/api/fallback/MonitorSendClientFallbackFactory.java new file mode 100644 index 000000000..367d93f98 --- /dev/null +++ b/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/api/fallback/MonitorSendClientFallbackFactory.java @@ -0,0 +1,42 @@ +package com.njcn.device.pms.api.fallback; + +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.device.pms.api.MonitorSendClient; +import com.njcn.device.pms.pojo.param.MonitorParam; +import com.njcn.device.pms.utils.PmsDeviceEnumUtil; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + + +/** + * @author wr + * @description + * @date 2023/12/25 9:17 + */ +@Slf4j +@Component +public class MonitorSendClientFallbackFactory implements FallbackFactory { + + @Override + public MonitorSendClient create(Throwable throwable) { + //判断抛出异常是否为解码器抛出的业务异常 + Enum exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK; + if (throwable.getCause() instanceof BusinessException) { + BusinessException businessException = (BusinessException) throwable.getCause(); + exceptionEnum = PmsDeviceEnumUtil.getExceptionEnum(businessException.getResult()); + } + Enum finalExceptionEnum = exceptionEnum; + return new MonitorSendClient() + { + + @Override + public HttpResult windSend(MonitorParam.Info param) { + log.error("{}异常,降级处理,异常为:{}", "国网五类台账上送接口", throwable.toString()); + throw new BusinessException(finalExceptionEnum); + } + }; + } +} \ No newline at end of file diff --git a/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/pojo/vo/gw/TractionStationDTO.java b/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/pojo/vo/gw/TractionStationDTO.java index 9069042f9..b5168e030 100644 --- a/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/pojo/vo/gw/TractionStationDTO.java +++ b/pqs-device/pms-device/pms-device-api/src/main/java/com/njcn/device/pms/pojo/vo/gw/TractionStationDTO.java @@ -66,6 +66,8 @@ public class TractionStationDTO extends Unit { /*监测点编号 是否必填:否*/ @ExcelProperty(value = "监测点编号") private String monitorNumber; + @ExcelProperty(value = "监测点名称") + private String monitorName; /*第二个监测点编号 是否必填:否*/ @ExcelProperty(value = "第二个监测点编号") private String monitorNumberTwo; diff --git a/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/gwPush/impl/MonitorSendServiceImpl.java b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/gwPush/impl/MonitorSendServiceImpl.java index cd2fad681..e7a4793dc 100644 --- a/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/gwPush/impl/MonitorSendServiceImpl.java +++ b/pqs-device/pms-device/pms-device-boot/src/main/java/com/njcn/device/pms/service/gwPush/impl/MonitorSendServiceImpl.java @@ -2,6 +2,8 @@ package com.njcn.device.pms.service.gwPush.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; +import cn.hutool.core.text.StrBuilder; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.excel.EasyExcel; @@ -18,6 +20,7 @@ import com.njcn.device.pms.service.gwPush.MonitorSendService; import com.njcn.device.pms.service.majornetwork.*; import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DictTreeFeignClient; +import com.njcn.system.enums.DicDataEnum; import com.njcn.system.enums.DicDataTypeEnum; import com.njcn.system.pojo.po.DictData; import com.njcn.system.pojo.po.SysDicTreePO; @@ -67,6 +70,10 @@ public class MonitorSendServiceImpl implements MonitorSendService { throw new BusinessException("请检查监测对象类型是否存在"); } List objType = dictTreeFeignClient.query(param.getObjType()).getData(); + //运行状态 + List lineState = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.LINE_STATE.getCode()).getData(); + List run = lineState.stream().filter(x -> DicDataEnum.RUN.getCode() + .equals(x.getCode())).collect(Collectors.toList()); List objTypeIds=new ArrayList<>(); objTypeIds.add(param.getObjType()); if(CollUtil.isNotEmpty(objType)){ @@ -76,6 +83,8 @@ public class MonitorSendServiceImpl implements MonitorSendService { List monitorList = monitorService.list(new LambdaQueryWrapper() .in(StrUtil.isNotBlank(param.getMonitorTag()),Monitor::getMonitorTag, param.getMonitorTag()) .in(Monitor::getObjType, objTypeIds) + .eq(Monitor::getIsUpToGrid,1) + .eq(Monitor::getMonitorState,run.get(0).getId()) .in(CollUtil.isNotEmpty(param.getIds()),Monitor::getId, param.getIds()) ); List powerIds= monitorList.stream().map(Monitor::getPowerrId).distinct().collect(Collectors.toList()); @@ -93,66 +102,78 @@ public class MonitorSendServiceImpl implements MonitorSendService { } private String monitorType(SysDicTreePO dicTree, List monitorList) { - String msg; + StrBuilder str=new StrBuilder(); switch (dicTree.getCode()) { case "1401": List info = this.windSend(monitorList); sendSize(info); - SendParam sendParam = new SendParam(); - sendParam.setStats(info); - Map send = GwSendUtil.send(sendParam, GWSendEnum.WIND_CREATE); - List wiIds = info.stream().map(WindSourceDto::getId).distinct().collect(Collectors.toList()); - msg = returnInformation(1, wiIds, send); + List> split = ListUtil.split(info, 100); + for (int i = 0; i < split.size(); i++) { + SendParam sendParam = new SendParam(); + sendParam.setStats(split.get(i)); + Map send = GwSendUtil.send(sendParam, GWSendEnum.WIND_CREATE); + List wiIds = info.stream().map(WindSourceDto::getId).distinct().collect(Collectors.toList()); + str.append("第"+(i+1)+"次循环:"+ returnInformation(1, wiIds, send)+";
"); + } break; case "1402": List photovoltaic = this.photovoltaicSend(monitorList); sendSize(photovoltaic); - SendParam phSend = new SendParam(); - phSend.setStats(photovoltaic); - Map phMap = GwSendUtil.send(phSend, GWSendEnum.PHOTOVOLTAIC_CREATE); - List phIds = photovoltaic.stream().map(PhotovoltaicDto::getId).distinct().collect(Collectors.toList()); - msg = returnInformation(1, phIds, phMap); + List> phSplit = ListUtil.split(photovoltaic, 100); + for (int i = 0; i < phSplit.size(); i++) { + SendParam phSend = new SendParam(); + phSend.setStats(phSplit.get(i)); + Map phMap = GwSendUtil.send(phSend, GWSendEnum.PHOTOVOLTAIC_CREATE); + List phIds = photovoltaic.stream().map(PhotovoltaicDto::getId).distinct().collect(Collectors.toList()); + str.append("第"+(i+1)+"次循环:"+ returnInformation(1, phIds, phMap)+";
"); + } break; case "2400": List sensitive = this.sensitiveUserSend(monitorList); sendSize(sensitive); - SendParam seSend = new SendParam(); - seSend.setStats(sensitive); - Map seMap = GwSendUtil.send(seSend, GWSendEnum.SENSITIVE_USER_CREATE); - List seIds = sensitive.stream().map(SensitiveUserDto::getId).distinct().collect(Collectors.toList()); - msg = returnInformation(1, seIds, seMap); + List> seSplit = ListUtil.split(sensitive, 100); + for (int i = 0; i < seSplit.size(); i++) { + SendParam seSend = new SendParam(); + seSend.setStats(seSplit.get(i)); + Map seMap = GwSendUtil.send(seSend, GWSendEnum.SENSITIVE_USER_CREATE); + List seIds = sensitive.stream().map(SensitiveUserDto::getId).distinct().collect(Collectors.toList()); + str.append("第"+(i+1)+"次循环:"+ returnInformation(1, seIds, seMap)+";
"); + } break; case "1300": List traction = this.tractionStationSend(monitorList); sendSize(traction); - SendParam trSend = new SendParam(); - trSend.setStats(traction); - Map trMap = GwSendUtil.send(trSend, GWSendEnum.TRACTION_STATION); - List trIds = traction.stream().map(TractionStationDTO::getId).distinct().collect(Collectors.toList()); - msg = returnInformation(1, trIds, trMap); + List> trSplit = ListUtil.split(traction, 100); + for (int i = 0; i < trSplit.size(); i++) { + SendParam trSend = new SendParam(); + trSend.setStats(trSplit.get(i)); + Map trMap = GwSendUtil.send(trSend, GWSendEnum.TRACTION_STATION); + List trIds = traction.stream().map(TractionStationDTO::getId).distinct().collect(Collectors.toList()); + str.append("第"+(i+1)+"次循环:"+ returnInformation(1, trIds, trMap)+";
"); + } break; case "2300": List other = this.otherUserSend(monitorList); sendSize(other); - SendParam otSend = new SendParam(); - otSend.setStats(other); - Map otMap = GwSendUtil.send(otSend, GWSendEnum.OTHER_USER_CREATE); - List otIds = other.stream().map(OtherUserDto::getId).distinct().collect(Collectors.toList()); - msg = returnInformation(1, otIds, otMap); + List> otSplit = ListUtil.split(other, 100); + for (int i = 0; i < otSplit.size(); i++) { + SendParam otSend = new SendParam(); + otSend.setStats(otSplit.get(i)); + Map otMap = GwSendUtil.send(otSend, GWSendEnum.OTHER_USER_CREATE); + List otIds = other.stream().map(OtherUserDto::getId).distinct().collect(Collectors.toList()); + str.append("第"+(i++)+"循环:"+ returnInformation(1, otIds, otMap)+";
"); + } break; default: throw new BusinessException("请选择国网上送的监测点标签上送"); } - return msg; + return str.toString(); } private void sendSize(List info) { if (CollUtil.isEmpty(info)) { throw new BusinessException("查询数据为空,请查询数据是否存在!"); } - if (info.size() > 100) { - throw new BusinessException("一次最多上送100条数据"); - } } @Override @@ -456,6 +477,7 @@ public class MonitorSendServiceImpl implements MonitorSendService { sendVO.setCreateTime(monitor.getCreateTime()); sendVO.setUpdateTime(monitor.getUpdateTime()); sendVO.setId(monitor.getId()); + sendVO.setMonitorName(monitor.getName()); sendVO.setMonitorNumber(monitor.getMonitorId()); //运行状态 diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/api/EventDetailFeignClient.java b/pqs-event/event-api/src/main/java/com/njcn/event/api/EventDetailFeignClient.java index f0110ad36..45ba0cb27 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/api/EventDetailFeignClient.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/api/EventDetailFeignClient.java @@ -3,6 +3,7 @@ package com.njcn.event.api; import com.njcn.common.pojo.constant.ServerInfo; import com.njcn.common.pojo.response.HttpResult; import com.njcn.event.api.fallback.EventDetailFeignClientFallbackFactory; +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; @@ -56,4 +57,10 @@ public interface EventDetailFeignClient { */ @PostMapping("/getEventDetailByIdsList") HttpResult> getEventDetailByIdsList(@RequestBody List ids); + + /** + * 根据监测点id集合获取暂降列表 + */ + @PostMapping("/getEventDetailByLineCount") + HttpResult getEventDetailByLineCount(@RequestBody EventCountParam param); } diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/EventDetailFeignClientFallbackFactory.java b/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/EventDetailFeignClientFallbackFactory.java index 33770a2ce..193595089 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/EventDetailFeignClientFallbackFactory.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/EventDetailFeignClientFallbackFactory.java @@ -4,6 +4,7 @@ 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.event.api.EventDetailFeignClient; +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; @@ -63,6 +64,12 @@ public class EventDetailFeignClientFallbackFactory implements FallbackFactory getEventDetailByLineCount(EventCountParam param) { + log.error("{}异常,降级处理,异常为:{}", "根据监测点id集合获取暂降列表", throwable.toString()); + throw new BusinessException(finalExceptionEnum); + } + }; } } diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/EventCountParam.java b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/EventCountParam.java new file mode 100644 index 000000000..38b3ae839 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/pojo/param/EventCountParam.java @@ -0,0 +1,25 @@ +package com.njcn.event.pojo.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @author wr + * @description + * @date 2023/12/22 10:38 + */ +@Data +public class EventCountParam implements Serializable { + + @ApiModelProperty(value = "ids") + List ids; + + @ApiModelProperty(name="startTime",value="统计起始日期(yyyy-MM-dd)") + private String startTime; + + @ApiModelProperty(name="endTime",value="统计截止日期(yyyy-MM-dd)") + private String endTime; +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/EventDetailController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/EventDetailController.java index 0be9e252f..463639e32 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/EventDetailController.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/EventDetailController.java @@ -1,5 +1,9 @@ package com.njcn.event.controller.majornetwork; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum; @@ -7,6 +11,7 @@ import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.LogUtil; import com.njcn.event.mapper.majornetwork.EventDetailMapper; +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; @@ -154,4 +159,21 @@ public class EventDetailController extends BaseController { List eventDetailPOS = eventDetailService.listByIds(ids); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, eventDetailPOS, methodDescribe); } + + /** + * 根据监测点集合获取短时终端,电压暂升,电压暂降 + * @return + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getEventDetailByLineCount") + @ApiOperation("根据暂态id集合获取暂降列表") + public HttpResult getEventDetailByLineCount(@RequestBody EventCountParam param) { + String methodDescribe = getMethodDescribe("getEventDetailByLineCount"); + int count = eventDetailService.count(new LambdaQueryWrapper() + .in(CollUtil.isNotEmpty(param.getIds()), RmpEventDetailPO::getLineId, param.getIds()) + .ge(StrUtil.isNotBlank(param.getStartTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime()))) + .le(StrUtil.isNotBlank(param.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime()))) + ); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, count, methodDescribe); + } } diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/MonitorSendTaskRunner.java b/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/MonitorSendTaskRunner.java new file mode 100644 index 000000000..2d7f8e7a7 --- /dev/null +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/MonitorSendTaskRunner.java @@ -0,0 +1,41 @@ +package com.njcn.system.timer.tasks; + +import com.njcn.device.pms.api.MonitorSendClient; +import com.njcn.device.pms.pojo.param.MonitorParam; +import com.njcn.system.service.SysDicTreePOService; +import com.njcn.system.timer.TimerTaskRunner; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + + +/** + * + */ +@Component +@RequiredArgsConstructor +public class MonitorSendTaskRunner implements TimerTaskRunner { + + private final MonitorSendClient monitorSendClient; + private final SysDicTreePOService sysDicTreePOService; + + + @Override + public void action() { + //风电场 + MonitorParam.Info param = new MonitorParam.Info(); + param.setObjType(sysDicTreePOService.queryByCode("1401").getId()); + monitorSendClient.windSend(param); + //光伏电站 + MonitorParam.Info param1 = new MonitorParam.Info(); + param1.setObjType(sysDicTreePOService.queryByCode("1402").getId()); + monitorSendClient.windSend(param1); + //牵引站 + MonitorParam.Info param3 = new MonitorParam.Info(); + param3.setObjType(sysDicTreePOService.queryByCode("1300").getId()); + monitorSendClient.windSend(param3); + //干扰用户 + MonitorParam.Info param4 = new MonitorParam.Info(); + param4.setObjType(sysDicTreePOService.queryByCode("2300").getId()); + monitorSendClient.windSend(param4); + } +} diff --git a/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/MonitorUserSendTaskRunner.java b/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/MonitorUserSendTaskRunner.java new file mode 100644 index 000000000..659445225 --- /dev/null +++ b/pqs-system/system-boot/src/main/java/com/njcn/system/timer/tasks/MonitorUserSendTaskRunner.java @@ -0,0 +1,29 @@ +package com.njcn.system.timer.tasks; + +import com.njcn.device.pms.api.MonitorSendClient; +import com.njcn.device.pms.pojo.param.MonitorParam; +import com.njcn.system.service.SysDicTreePOService; +import com.njcn.system.timer.TimerTaskRunner; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + + +/** + * + */ +@Component +@RequiredArgsConstructor +public class MonitorUserSendTaskRunner implements TimerTaskRunner { + + private final MonitorSendClient monitorSendClient; + private final SysDicTreePOService sysDicTreePOService; + + + @Override + public void action() { + //重要或敏感用户 + MonitorParam.Info param2 = new MonitorParam.Info(); + param2.setObjType(sysDicTreePOService.queryByCode("2400").getId()); + monitorSendClient.windSend(param2); + } +}