From d214b181d005115f1a820bdea29dfb28104b23c6 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 29 Jul 2024 10:22:45 +0800 Subject: [PATCH 01/11] =?UTF-8?q?#=E9=9B=86=E4=B8=AD=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=BE=E5=A4=87=E8=A3=85=E6=9C=BA=E5=AE=B9?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/operational/main/vo/RealDeviceVo.java | 3 ++ .../operation/monitor/impl/MonitorServiceImpl.java | 29 ++++++++------ .../main/service/impl/HydropowerServiceImpl.java | 44 +++++++++++++++++++++- 3 files changed, 63 insertions(+), 13 deletions(-) diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealDeviceVo.java index 0107d84..c3c066b 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealDeviceVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/vo/RealDeviceVo.java @@ -18,6 +18,9 @@ public class RealDeviceVo implements Serializable { @ApiModelProperty("设备名称") private String deviceName; + @ApiModelProperty("装机容量") + private Double installedCapacity; + @ApiModelProperty("设备状态") private Integer state; diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java index 279ef93..ad170fa 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java @@ -291,6 +291,8 @@ public class MonitorServiceImpl implements MonitorService { List aborts = interruptionAlarmService.aborts(operations); // 设备状态分类 Map> deviceClassifyMap = (Map>) redisTemplate.opsForValue().get(device_classify_cache_final); + // 设备信息 + List deviceParms = JSONObject.parseObject(redisTemplate.opsForValue().get(device_cache_final).toString(),new TypeReference>() {}); // 按10个站点一组分割属性配置 List>> limit = this.limitMapChunk(attributes); // 线程执行次数 @@ -305,8 +307,8 @@ public class MonitorServiceImpl implements MonitorService { RealStationVo realStation = new RealStationVo(); // 设备信息 List devices = this.monitorRealDevice(value,realTimeData); - // 设备状态 - this.deviceStatus(devices,deviceClassifyMap); + // 设备状态、装机容量 + this.deviceParam(devices,deviceClassifyMap,deviceParms); realStation.setDeviceList(devices.stream().sorted(Comparator.comparing(RealDeviceVo::getDeviceName)).collect(Collectors.toList())); // 站点基础信息: 编码、名称、限制水位、服务类型、机构、排序 this.stationBaseInfo(stations.stream().filter(station->key.equals(station.getCode())).findFirst(),sorts,realStation); @@ -330,30 +332,33 @@ public class MonitorServiceImpl implements MonitorService { } /** - * 设置设备状态 + * 设置设备状态、装机容量 * @param devices * @param deviceClassifyMap */ - private void deviceStatus(List devices, Map> deviceClassifyMap) { + private void deviceParam(List devices, Map> deviceClassifyMap,List deviceParams) { if (CollectionUtil.isEmpty(devices) || MapUtils.isEmpty(deviceClassifyMap)) { return; } List faults = deviceClassifyMap.get(HomePageConstant.FAULT); List overhaults = deviceClassifyMap.get(HomePageConstant.OVERHAUL); devices.forEach(device -> { - int state = -1; + device.setState(-1); if(StringUtil.isNotBlank(device.getDeviceCode())){ - // 故障 + // 设备装机容量 + if(CollectionUtil.isNotEmpty(deviceParams)){ + Optional optional = deviceParams.stream().filter(param->param.getEmCode().equals(device.getDeviceCode())).findFirst(); + optional.ifPresent(eminfoAndEmParamVo -> device.setInstalledCapacity(eminfoAndEmParamVo.getInstalledCapacity())); + } + // 设备状态 : 故障、检修 if (CollectionUtil.isNotEmpty(faults) && faults.contains(device.getDeviceCode())) { - state = 4; - // 检修 + device.setState(4); } else if (CollectionUtil.isNotEmpty(overhaults) && overhaults.contains(device.getDeviceCode())) { - state = 0; + device.setState(0); } } - if(state >= 0){ - device.setState(state); - }else{ + // 根据有功进行判断设备状态 + if(device.getState() < 0){ List attbts = device.getAttbtList(); // 功率属性记录 List powers = attbts.stream().filter(att-> HomePageConstant.powerList.contains(att.getName())).collect(Collectors.toList()); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java index 60de174..37e52f1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/HydropowerServiceImpl.java @@ -17,6 +17,7 @@ import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; import com.hnac.hzims.operational.duty.service.IImsDutyMainService; import com.hnac.hzims.operational.duty.vo.DutyMainInfoVo; +import com.hnac.hzims.operational.fill.entity.GenerateEntity; import com.hnac.hzims.operational.main.constant.HomePageConstant; import com.hnac.hzims.operational.main.entity.UserDeptEntity; import com.hnac.hzims.operational.main.service.*; @@ -800,7 +801,7 @@ public class HydropowerServiceImpl implements HydropowerService { private List generateThreeYear(List stations,Map> map) { List> filter = map.entrySet().stream().filter(entry -> stations.contains(entry.getKey())).map(Map.Entry::getValue).collect(Collectors.toList()); if (CollectionUtil.isEmpty(filter)) { - return new ArrayList<>(); + return this.defaultThreeYear(); } // 根据月份分组 List powerMonthVos = new ArrayList<>(); @@ -837,6 +838,47 @@ public class HydropowerServiceImpl implements HydropowerService { } + /** + * 默认结构 + * @return + */ + private List defaultThreeYear() { + List mons = this.mons(2,12,false); + // 返回结果 + // 根据月份分组 + List powerMonthVos = new ArrayList<>(); + mons.forEach(item -> { + PowerMonthVo powerMonthVo = new PowerMonthVo(); + powerMonthVo.setStrMonth(item); + powerMonthVo.setPower(0f); + powerMonthVos.add(powerMonthVo); + }); + Map> months = powerMonthVos.stream().collect(Collectors.groupingBy(PowerMonthVo::getStrMonth)); + // 总和所有相同月份的发电量 + List powerMonthVoList = months.entrySet().stream().map(entry -> { + PowerMonthVo powerMonth = new PowerMonthVo(); + powerMonth.setStrMonth(entry.getKey()); + LocalDate localDate = LocalDate.parse(DateUtil.format(new Date(), entry.getKey()), DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATE)); + powerMonth.setYear(localDate.getYear()); + powerMonth.setMonth(localDate.getMonthValue()); + powerMonth.setPower((float) entry.getValue().stream().mapToDouble(PowerMonthVo::getPower).sum()); + return powerMonth; + }).collect(Collectors.toList()); + // 根据年份分组 + Map> year = powerMonthVoList.stream().collect(Collectors.groupingBy(PowerMonthVo::getYear)); + // 返回结果集 + return year.entrySet().stream().map(entry -> { + PowerYearVo powerYearVo = new PowerYearVo(); + powerYearVo.setYear(entry.getKey()); + List sortValue = entry.getValue().stream().sorted(Comparator.comparing(PowerMonthVo::getMonth)).collect(Collectors.toList()); + powerYearVo.setPowerMonthVoList(sortValue); + return powerYearVo; + }).collect(Collectors.toList()); + + + } + + /*=====================================================app=====================================================*/ /** From dcba22e179675ec0072cd5cef41f60c78cdd416f Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Mon, 29 Jul 2024 11:20:49 +0800 Subject: [PATCH 02/11] =?UTF-8?q?#=E9=9B=86=E4=B8=AD=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=BE=E5=A4=87=E8=A3=85=E6=9C=BA=E5=AE=B9?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/operation/monitor/impl/MonitorServiceImpl.java | 6 +++++- .../hzims/operational/station/service/impl/StationServiceImpl.java | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java index ad170fa..d4a5b1d 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/monitor/impl/MonitorServiceImpl.java @@ -348,7 +348,11 @@ public class MonitorServiceImpl implements MonitorService { // 设备装机容量 if(CollectionUtil.isNotEmpty(deviceParams)){ Optional optional = deviceParams.stream().filter(param->param.getEmCode().equals(device.getDeviceCode())).findFirst(); - optional.ifPresent(eminfoAndEmParamVo -> device.setInstalledCapacity(eminfoAndEmParamVo.getInstalledCapacity())); + if(optional.isPresent()){ + device.setInstalledCapacity(optional.get().getInstalledCapacity()); + }else{ + device.setInstalledCapacity(0.0); + } } // 设备状态 : 故障、检修 if (CollectionUtil.isNotEmpty(faults) && faults.contains(device.getDeviceCode())) { diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java index 89d40ad..681e73f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationServiceImpl.java @@ -113,14 +113,14 @@ public class StationServiceImpl extends ServiceImpl deptResult = sysClient.getDept(stationEntity.getRefDept()); if (deptResult.isSuccess() && ObjectUtil.isNotEmpty(deptResult.getData())) { R projectResult = deptClient.deleteDeptById(stationEntity.getRefDept()); if (!projectResult.isSuccess()) { - log.info("hzims-operational:station:removeStation", stationEntity.getRefDept() + "所属机构删除失败,报错信息为:" + projectResult.getMsg()); + log.info("hzims-operational:station:removeStation : {}", stationEntity.getRefDept() + "所属机构删除失败,报错信息为:" + projectResult.getMsg()); } } } @@ -144,6 +144,9 @@ public class StationServiceImpl extends ServiceImpl Date: Tue, 30 Jul 2024 10:11:57 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=9A=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=91=8A=E8=AD=A6=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../target/classes/META-INF/build-info.properties | 5 ----- .../com/hnac/hzims/alarm/monitor/listener/AlarmListener.java | 10 +++++----- target/classes/META-INF/build-info.properties | 5 ----- 3 files changed, 5 insertions(+), 15 deletions(-) delete mode 100644 hzims-service-api/target/classes/META-INF/build-info.properties delete mode 100644 target/classes/META-INF/build-info.properties diff --git a/hzims-service-api/target/classes/META-INF/build-info.properties b/hzims-service-api/target/classes/META-INF/build-info.properties deleted file mode 100644 index 8fd2af4..0000000 --- a/hzims-service-api/target/classes/META-INF/build-info.properties +++ /dev/null @@ -1,5 +0,0 @@ -build.artifact=hzims-service-api -build.group=com.hnac.hzims -build.name=hzims-service-api -build.time=2024-07-22T06\:45\:56.469Z -build.version=4.0.0-SNAPSHOT diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java index cff87ff..f69399e 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java @@ -39,14 +39,14 @@ public class AlarmListener implements IQueueConsume { messageService.webAppMessage(alarm); } - // 步骤3.短信推送 - if(ObjectUtil.isNotEmpty(alarm.getIsShortMessage()) && alarm.getIsShortMessage() == 0){ - messageService.shortMessage(alarm); - } - // 步骤4.微信公众号发送 if(ObjectUtil.isNotEmpty(alarm.getIsWxMessage()) && alarm.getIsWxMessage() == 0){ messageService.weChatMessage(alarm); } + + // 步骤3.短信推送 + if(ObjectUtil.isNotEmpty(alarm.getIsShortMessage()) && alarm.getIsShortMessage() == 0){ + messageService.shortMessage(alarm); + } } } \ No newline at end of file diff --git a/target/classes/META-INF/build-info.properties b/target/classes/META-INF/build-info.properties deleted file mode 100644 index 92baf95..0000000 --- a/target/classes/META-INF/build-info.properties +++ /dev/null @@ -1,5 +0,0 @@ -build.artifact=hzims-back -build.group=com.hnac.hzims -build.name=hzims-back -build.time=2024-07-22T06\:45\:56.469Z -build.version=4.0.0-SNAPSHOT From f84d172c23fbc3824b9503082cf5420110de971c Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 30 Jul 2024 10:15:45 +0800 Subject: [PATCH 04/11] =?UTF-8?q?#=E6=96=B0=E7=89=88=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hnac/hzims/alarm/monitor/listener/AlarmListener.java | 11 ++++++++--- .../hzims/alarm/show/service/impl/AlarmServiceImpl.java | 6 ++++++ .../java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java | 6 +++--- .../com/hnac/hzims/alarm/ws/alart/AlarmSessionManager.java | 1 - .../com/hnac/hzims/alarm/ws/alart/AlarmSocketConfig.java | 4 ++-- .../java/com/hnac/hzims/alarm/ws/alart/AlarmSocketPool.java | 13 ------------- .../hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java | 1 + .../scheduled/service/alarm/impl/AlarmServiceImpl.java | 5 +++-- 8 files changed, 23 insertions(+), 24 deletions(-) delete mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketPool.java diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java index cff87ff..e8393f4 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java @@ -34,17 +34,22 @@ public class AlarmListener implements IQueueConsume { // 步骤1.消息对象转换 AlarmEntity alarm = JSONObject.parseObject(message,AlarmEntity.class); - // 步骤2.WEB/APP消息推送 + // 步骤2.websocket消息推送 + if(ObjectUtil.isNotEmpty(alarm.getIsRightTabulation()) && alarm.getIsRightTabulation() == 0){ + + } + + // 步骤3.WEB/APP消息推送 if(ObjectUtil.isNotEmpty(alarm.getIsPlatformMessage()) && alarm.getIsPlatformMessage() == 0){ messageService.webAppMessage(alarm); } - // 步骤3.短信推送 + // 步骤4.短信推送 if(ObjectUtil.isNotEmpty(alarm.getIsShortMessage()) && alarm.getIsShortMessage() == 0){ messageService.shortMessage(alarm); } - // 步骤4.微信公众号发送 + // 步骤5.微信公众号发送 if(ObjectUtil.isNotEmpty(alarm.getIsWxMessage()) && alarm.getIsWxMessage() == 0){ messageService.weChatMessage(alarm); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index d976531..be038f1 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -106,6 +106,9 @@ public class AlarmServiceImpl extends ServiceImpl impl if(!StringUtil.isEmpty(showQuery.getAlarmType())){ wrapper.eq("ALARM_TYPE",showQuery.getAlarmType()); } + if(!StringUtil.isEmpty(showQuery.getContent())){ + wrapper.like("alarmContext",showQuery.getContent()); + } // 处理告警过滤 :当天处理告警 List handles = alarmHandleService.handles(); @@ -186,6 +189,9 @@ public class AlarmServiceImpl extends ServiceImpl impl }).collect(Collectors.toList()); } + + + /** * 播报告警 * @param startTime diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java index f6052a0..668a4b8 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java @@ -6,6 +6,9 @@ import com.hnac.hzims.business.ws.alart.vo.AlartParamVo; import lombok.extern.slf4j.Slf4j; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; +import org.springblade.system.feign.IDeptClient; +import org.springblade.system.feign.ISysClient; +import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.TextMessage; @@ -31,13 +34,11 @@ public class AlarmHandler extends TextWebSocketHandler { session.getAttributes().put("userId", uid); log.info("sessionId: " + session.getId()); log.info("session connection successful!"); - AlarmSocketPool.pool.put(session.getId(), this); } @Override public void afterConnectionClosed(WebSocketSession session, CloseStatus status) { AlarmSessionManager.removeAndClose(session.getId()); - AlarmSocketPool.pool.remove(session.getId()); log.info("sessionId: " + session.getId()); log.info("uri: " + session.getUri()); log.info("session closed successful!"); @@ -46,7 +47,6 @@ public class AlarmHandler extends TextWebSocketHandler { @Override public void handleTransportError(WebSocketSession session, Throwable exception) { AlarmSessionManager.removeAndClose(session.getId()); - AlarmSocketPool.pool.remove(session.getId()); } @Override diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSessionManager.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSessionManager.java index b54e6b2..d2227b9 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSessionManager.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSessionManager.java @@ -55,7 +55,6 @@ public class AlarmSessionManager { throw new RuntimeException("关闭ws会话失败!", ex); } } - SESSION_POOL.remove(uid); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketConfig.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketConfig.java index bbceab3..051da5a 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketConfig.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketConfig.java @@ -18,11 +18,11 @@ public class AlarmSocketConfig implements WebSocketConfigurer{ @Override public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { // 集中监控弹框处理器 - registry.addHandler(monitorHandler(), "/alarm/alart/{uid}").setAllowedOrigins("*"); + registry.addHandler(alarmHandler(), "/alarm/alart/{uid}").setAllowedOrigins("*"); } @Bean - public WebSocketHandler monitorHandler() { + public WebSocketHandler alarmHandler() { return new AlarmHandler(); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketPool.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketPool.java deleted file mode 100644 index c7bc6cc..0000000 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmSocketPool.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.hnac.hzims.alarm.ws.alart; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * @author ysj - */ -public class AlarmSocketPool { - - public static Map pool = new ConcurrentHashMap<>(); - -} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java index 8d89a72..4e502cc 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/AlarmScheduledTask.java @@ -62,6 +62,7 @@ public class AlarmScheduledTask { */ @XxlJob(INTERRUPT_ALARM) //@Scheduled(cron = "0/40 * * * * ? ") + public ReturnT interruption(String param) { if (Func.isBlank(param)) { param = DateUtil.format(new Date(), "yyyy-MM"); diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java index 486a396..6d92b14 100644 --- a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/alarm/impl/AlarmServiceImpl.java @@ -27,6 +27,7 @@ import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.mqtt.producer.IMqttSender; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -55,7 +56,7 @@ public class AlarmServiceImpl implements AlarmService { private final RedisTemplate redisTemplate; - //private final IMqttSender mqttSender; + private final IMqttSender mqttSender; private final static String start_stop_cache_final = "hzims:operation:start:stop:key"; private final static String load_hydropower_unit_real_key = "hzims:operation:loadhydropowerunit:real:key"; @@ -279,7 +280,7 @@ public class AlarmServiceImpl implements AlarmService { alarm.setContext(entity.getSoeExplain()); alarm.setState(entity.getStatus()); log.error("send_interruption_msg : {}",JsonUtil.toJson(alarm)); - //mqttSender.sendToMqtt(InterruptionConstants.HZ3000_TOPIC_PREFIX + entity.getStationId(), JsonUtil.toJson(alarm)); + mqttSender.sendToMqtt(InterruptionConstants.HZ3000_TOPIC_PREFIX + entity.getStationId(), JsonUtil.toJson(alarm)); }); } From 63b310d47d0d3ed57b5e92b29e365346f26ae83f Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 30 Jul 2024 10:16:33 +0800 Subject: [PATCH 05/11] =?UTF-8?q?#=E6=96=B0=E7=89=88=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java index bee063e..cc0629b 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/show/vo/ShowQueryVo.java @@ -24,5 +24,8 @@ public class ShowQueryVo { @ApiModelProperty(value = "告警子类") private Integer alarmType; + + @ApiModelProperty(value = "告警内容") + private String content; } From 2c881e0417c3469471d44fe8302d73df486399ca Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Tue, 30 Jul 2024 10:20:16 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=9A=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E5=91=8A=E8=AD=A6=E6=B6=88=E6=81=AF=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/alarm/monitor/listener/AlarmListener.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java index f69399e..cff87ff 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java @@ -39,14 +39,14 @@ public class AlarmListener implements IQueueConsume { messageService.webAppMessage(alarm); } - // 步骤4.微信公众号发送 - if(ObjectUtil.isNotEmpty(alarm.getIsWxMessage()) && alarm.getIsWxMessage() == 0){ - messageService.weChatMessage(alarm); - } - // 步骤3.短信推送 if(ObjectUtil.isNotEmpty(alarm.getIsShortMessage()) && alarm.getIsShortMessage() == 0){ messageService.shortMessage(alarm); } + + // 步骤4.微信公众号发送 + if(ObjectUtil.isNotEmpty(alarm.getIsWxMessage()) && alarm.getIsWxMessage() == 0){ + messageService.weChatMessage(alarm); + } } } \ No newline at end of file From e8e720800da4a4405f35893b9b8264c717c7eb65 Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 30 Jul 2024 15:12:03 +0800 Subject: [PATCH 07/11] =?UTF-8?q?#=E6=96=B0=E7=89=88=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/business/ws/alart/vo/AlartParamVo.java | 9 ++-- .../alarm/monitor/listener/AlarmListener.java | 26 ++++++++--- .../alarm/monitor/listener/AlarmPoolManager.java | 34 ++++++++++++++ .../hzims/alarm/show/service/AlarmService.java | 2 +- .../alarm/show/service/impl/AlarmServiceImpl.java | 38 ++++++++++------ .../hzims/alarm/source/service/MessageService.java | 2 + .../source/service/impl/MessageServiceImpl.java | 52 ++++++++++++++++++---- .../hnac/hzims/alarm/ws/alart/AlarmHandler.java | 14 +++--- 8 files changed, 136 insertions(+), 41 deletions(-) create mode 100644 hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmPoolManager.java diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java index 06123de..4c5a13b 100644 --- a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/ws/alart/vo/AlartParamVo.java @@ -10,12 +10,9 @@ import java.util.List; * @author ysj */ @Data -@ApiModel(value = "告警弹框参数", description = "") +@ApiModel(value = "告警websocket参数", description = "") public class AlartParamVo { - @ApiModelProperty("站点类型: 2-云服务 1-代运维") - private Integer serveType; - - @ApiModelProperty("用户权限机构集合") - private List depts; + @ApiModelProperty("站点集合") + private List codes; } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java index e8393f4..b7a2e08 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmListener.java @@ -12,6 +12,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ThreadPoolExecutor; + /** * @author ysj */ @@ -21,6 +24,9 @@ import org.springframework.stereotype.Service; public class AlarmListener implements IQueueConsume { @Autowired + private ThreadPoolExecutor pool; + + @Autowired private MessageService messageService; @Autowired @@ -36,22 +42,30 @@ public class AlarmListener implements IQueueConsume { // 步骤2.websocket消息推送 if(ObjectUtil.isNotEmpty(alarm.getIsRightTabulation()) && alarm.getIsRightTabulation() == 0){ - + CompletableFuture.runAsync(() -> { + messageService.webRightMessage(alarm); + },pool); } // 步骤3.WEB/APP消息推送 if(ObjectUtil.isNotEmpty(alarm.getIsPlatformMessage()) && alarm.getIsPlatformMessage() == 0){ - messageService.webAppMessage(alarm); + CompletableFuture.runAsync(() -> { + messageService.webAppMessage(alarm); + },pool); } // 步骤4.短信推送 - if(ObjectUtil.isNotEmpty(alarm.getIsShortMessage()) && alarm.getIsShortMessage() == 0){ - messageService.shortMessage(alarm); + if (ObjectUtil.isNotEmpty(alarm.getIsShortMessage()) && alarm.getIsShortMessage() == 0) { + CompletableFuture.runAsync(() -> { + messageService.shortMessage(alarm); + },pool); } // 步骤5.微信公众号发送 - if(ObjectUtil.isNotEmpty(alarm.getIsWxMessage()) && alarm.getIsWxMessage() == 0){ - messageService.weChatMessage(alarm); + if (ObjectUtil.isNotEmpty(alarm.getIsWxMessage()) && alarm.getIsWxMessage() == 0) { + CompletableFuture.runAsync(() -> { + messageService.weChatMessage(alarm); + },pool); } } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmPoolManager.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmPoolManager.java new file mode 100644 index 0000000..3fd1e35 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/monitor/listener/AlarmPoolManager.java @@ -0,0 +1,34 @@ + +package com.hnac.hzims.alarm.monitor.listener; + +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +import java.util.concurrent.*; + +/** + * @author: ysj + */ +@Component +public class AlarmPoolManager { + + @Bean + public ThreadPoolExecutor threadPoolExecutor() { + // 核心线程数 + int corePoolSize = 8; + // 最大线程数 + int maximumPoolSize = 16; + // 线程空闲时的存活时间 + long keepAliveTime = 60L; + // 时间单位 + TimeUnit unit = TimeUnit.SECONDS; + // 任务队列 + BlockingQueue workQueue = new LinkedBlockingQueue<>(100); + // 线程工厂 + ThreadFactory threadFactory = Executors.defaultThreadFactory(); + // 等待策略 + RejectedExecutionHandler handler = new ThreadPoolExecutor.CallerRunsPolicy(); + return new ThreadPoolExecutor(corePoolSize,maximumPoolSize,keepAliveTime,unit,workQueue,threadFactory,handler); + } + +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java index b114c17..2d142a7 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/AlarmService.java @@ -22,7 +22,7 @@ public interface AlarmService extends IService { List broadcast(String startTime, String endTime,Integer serveType); - TextMessage majorAlarm(AlartParamVo param); + TextMessage majorAlarm(List stations); List alarmVideos(String stationCode, String deviceCode, String realId,Integer alarmType); } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java index be038f1..e4c4169 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/show/service/impl/AlarmServiceImpl.java @@ -36,6 +36,7 @@ import org.apache.commons.collections4.MapUtils; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; import org.springblade.message.fegin.IMessageClient; @@ -138,6 +139,18 @@ public class AlarmServiceImpl extends ServiceImpl impl } /** + * 获取权限站点 + * @return + */ + private List stationsByCodes(List stations) { + R> result = stationClient.querySatationByCodes(stations); + if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ + return new ArrayList<>(); + } + return result.getData(); + } + + /** * 查询告警数量 * @return */ @@ -219,26 +232,25 @@ public class AlarmServiceImpl extends ServiceImpl impl /** * 弹框告警 - * @param param + * @param codes * @return */ @Override - public TextMessage majorAlarm(AlartParamVo param) { + public TextMessage majorAlarm(List codes) { // 站点查询 - List stations = this.stations(param.getServeType()); - if(CollectionUtil.isEmpty(stations) || CollectionUtil.isEmpty(param.getDepts())){ - return new TextMessage(new ArrayList().toString()); - } - List effectives = stations.stream().filter(station->param.getDepts().contains(station.getRefDept())).map(StationEntity::getCode).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(effectives)){ + List stations = this.stationsByCodes(codes); + if(CollectionUtil.isEmpty(stations)){ return new TextMessage(new ArrayList().toString()); } // 条件过滤 QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().in(AlarmEntity::getStationId,effectives); - queryWrapper.lambda().in(AlarmEntity::getAlarmType, Arrays.asList(AlarmConstants.FAULT,AlarmConstants.EARLY)); - queryWrapper.lambda().eq(AlarmEntity::getIsShowAlert,0); - queryWrapper.lambda().eq(AlarmEntity::getStatus,0); + queryWrapper.lambda().in(AlarmEntity::getStationId,stations.stream().map(StationEntity::getCode).collect(Collectors.toList())); + queryWrapper.lambda().in(AlarmEntity::getAlarmType, Arrays.asList(AlarmConstants.WARNING,AlarmConstants.FAULT,AlarmConstants.OFFSIDE,AlarmConstants.INTERRUPT,AlarmConstants.ABNORMAL,AlarmConstants.EARLY,AlarmConstants.START,AlarmConstants.STOP)); + queryWrapper.lambda().eq(AlarmEntity::getIsRightTabulation,0); + queryWrapper.lambda().ge(AlarmEntity::getAlarmTime, DateUtil.format(new Date(),DateUtil.PATTERN_DATE) + " 00:00:00"); + queryWrapper.lambda().le(AlarmEntity::getAlarmTime,DateUtil.format(new Date(),DateUtil.PATTERN_DATETIME)); + queryWrapper.lambda().orderByDesc(AlarmEntity::getAlarmTime); + //queryWrapper.lambda().eq(AlarmEntity::getStatus,0); // 处理告警过滤 :当天处理告警 List handles = alarmHandleService.handles(); if(!CollectionUtil.isEmpty(handles)){ @@ -248,7 +260,7 @@ public class AlarmServiceImpl extends ServiceImpl impl if(CollectionUtil.isEmpty(alarms)){ return new TextMessage(new ArrayList().toString()); } - return new TextMessage(JSONObject.toJSONString(alarms.stream().sorted(Comparator.comparing(AlarmEntity::getAlarmTime).reversed()).collect(Collectors.toList()))); + return new TextMessage(JSONObject.toJSONString(alarms.stream().skip(0).limit(1000).collect(Collectors.toList()))); } /** diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/MessageService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/MessageService.java index 71b8661..87b2426 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/MessageService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/MessageService.java @@ -7,6 +7,8 @@ import com.hnac.hzims.alarm.config.entity.AlarmEntity; */ public interface MessageService { + void webRightMessage(AlarmEntity alarm); + void webAppMessage(AlarmEntity entity); void shortMessage(AlarmEntity entity); diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java index 21a8d5d..f881882 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/source/service/impl/MessageServiceImpl.java @@ -1,8 +1,10 @@ package com.hnac.hzims.alarm.source.service.impl; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.hnac.hzims.alarm.config.entity.AlarmEntity; import com.hnac.hzims.alarm.source.service.MessageService; +import com.hnac.hzims.alarm.ws.alart.AlarmSessionManager; import com.hnac.hzims.common.constant.CommonConstant; import com.hnac.hzims.operational.station.entity.StationEntity; import com.hnac.hzims.operational.station.feign.IStationClient; @@ -17,13 +19,16 @@ import org.springblade.message.dto.SmsImmediatelyPushDTO; import org.springblade.message.dto.WxMessageDTO; import org.springblade.message.fegin.IMessageClient; import org.springblade.system.cache.DictCache; +import org.springblade.system.feign.IDeptClient; import org.springblade.system.feign.ISysClient; import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.UserInfo; import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.web.socket.TextMessage; +import java.io.IOException; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -44,6 +49,8 @@ public class MessageServiceImpl implements MessageService { private final IUserClient userClient; + private final IDeptClient deptClient; + private final IMessageClient messageClient; private final IStationClient stationClient; @@ -56,6 +63,34 @@ public class MessageServiceImpl implements MessageService { private String wxPushTemplate; @Value("${hzims.wxPush.enabled}") private Boolean wxPushEnabled; + + /** + * web告警展示消息推送 + * @param alarm + */ + @Override + public void webRightMessage(AlarmEntity alarm) { + if(CollectionUtil.isEmpty(AlarmSessionManager.SESSION_POOL)){ + return; + } + // 遍历websocket链接,拥有告警站点权限进行推送消息 + AlarmSessionManager.SESSION_POOL.forEach((key, session) -> { + if(!session.getAttributes().containsKey("codes")){ + return; + } + List codes = (List) session.getAttributes().get("codes"); + if(CollectionUtil.isEmpty(codes) || !codes.contains(alarm.getStationId())){ + return; + } + try { + session.sendMessage(new TextMessage(JSONObject.toJSONString(Collections.singletonList(alarm)))); + } catch (IOException e) { + throw new RuntimeException(e); + } + }); + } + + /** * web/app消息推送 * @param entity : 告警对象 @@ -161,8 +196,6 @@ public class MessageServiceImpl implements MessageService { return; } userList.addAll(result.getData()); - log.info("短信发送用户列表:{}",userList); - log.info("短信发送用户列表,{}",userList); }else { //内测只推给对应的3个用户 List phoneList = Arrays.asList("18351807087", "18163793336", "18285121497"); @@ -172,9 +205,9 @@ public class MessageServiceImpl implements MessageService { userList.add(userByPhone.getData().getUser()); } } - log.info("短信发送用户列表:{}",userList); - log.info("短信发送用户列表,{}",userList); } + log.info("短信发送用户列表:{}",userList); + log.info("短信发送用户列表,{}",userList); String userIds = userList.stream().map(o -> String.valueOf(o.getId())).distinct().collect(Collectors.joining(",")); WxMessageDTO message = new WxMessageDTO(); // 模板Id @@ -191,8 +224,8 @@ public class MessageServiceImpl implements MessageService { message.setTaskId(entity.getId()); // 微信参数键值对 HashMap map = new HashMap<>(); - map.put("thing18",getTruncateString(entity.getStationName(), 20)); - map.put("thing11",getTruncateString(entity.getAlarmContext(), 20)); + map.put("thing18",getTruncateString(entity.getStationName())); + map.put("thing11",getTruncateString(entity.getAlarmContext())); map.put("time2",entity.getAlarmTime()); map.put("thing14", DictCache.getValue("alarm_type", String.valueOf(entity.getAlarmType()))); DateTimeFormatter format = DateTimeFormatter.ofPattern(DateUtil.PATTERN_DATETIME); @@ -211,11 +244,12 @@ public class MessageServiceImpl implements MessageService { message.setTenantId(station.getData().getTenantId()); messageClient.sendWxMessage(message); } - private String getTruncateString(String ruleDefName, int maxSize) { - if (ruleDefName.length()<= maxSize){ + + private String getTruncateString(String ruleDefName) { + if (ruleDefName.length()<= 20){ return ruleDefName; }else { - return ruleDefName.substring(0, maxSize - 3) + "..."; + return ruleDefName.substring(0, 20 - 3) + "..."; } } } \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java index 668a4b8..34d6196 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/ws/alart/AlarmHandler.java @@ -4,11 +4,9 @@ import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.alarm.show.service.AlarmService; import com.hnac.hzims.business.ws.alart.vo.AlartParamVo; import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.core.tool.utils.StringUtil; -import org.springblade.system.feign.IDeptClient; -import org.springblade.system.feign.ISysClient; -import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.TextMessage; @@ -16,6 +14,8 @@ import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.handler.TextWebSocketHandler; import java.io.IOException; +import java.util.Collections; +import java.util.List; /** * @author ysj @@ -56,11 +56,13 @@ public class AlarmHandler extends TextWebSocketHandler { if(StringUtil.isBlank(message)){ return; } - AlartParamVo param = JSONObject.parseObject(message,AlartParamVo.class); - if(ObjectUtil.isEmpty(param)){ + AlartParamVo param = JSONObject.parseObject(textMessage.getPayload(), AlartParamVo.class); + if(ObjectUtil.isEmpty(param) || CollectionUtil.isEmpty(param.getCodes())){ return; } - TextMessage sendMessage = alarmService.majorAlarm(param); + session.getAttributes().put("codes", param.getCodes()); + AlarmSessionManager.SESSION_POOL.put(userId,session); + TextMessage sendMessage = alarmService.majorAlarm(param.getCodes()); session.sendMessage(sendMessage); } } From dbe9b41b6da87b0c8c8a711b0dcab8ec79c41ed3 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Tue, 30 Jul 2024 16:24:03 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E8=A1=A5?= =?UTF-8?q?=E5=81=BF=E5=B7=A5=E4=BD=9C=E6=B5=81=E7=9A=84params=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java index f0660df..6ba975b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java @@ -144,7 +144,7 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service, StartProces if (StringUtils.isNotBlank(param)){ variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class); }else { - variables = JSONObject.parseObject(entity); + variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class); } variables.put("creator", TaskUtil.getTaskUser(String.valueOf(AuthUtil.getUserId()))); R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(), From ccad4b1d74636dd0e31bed4b900e6ec4157fc35f Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Tue, 30 Jul 2024 16:28:19 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E8=A1=A5?= =?UTF-8?q?=E5=81=BF=E5=B7=A5=E4=BD=9C=E6=B5=81=E7=9A=84params=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java index 6ba975b..aa68cc7 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java @@ -144,7 +144,7 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service, StartProces if (StringUtils.isNotBlank(param)){ variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class); }else { - variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class); + variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity,DateUtil.PATTERN_DATETIME), Map.class); } variables.put("creator", TaskUtil.getTaskUser(String.valueOf(AuthUtil.getUserId()))); R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(), From d89794d31ab69c07f54a5a1e00daf88b98fdec52 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Tue, 30 Jul 2024 19:22:57 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=97=A5=E5=BF=97=E6=8A=A5=E9=94=99=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/duty/service/impl/ImsAnalyseExampleServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsAnalyseExampleServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsAnalyseExampleServiceImpl.java index dffc84e..5cec3ce 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsAnalyseExampleServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/duty/service/impl/ImsAnalyseExampleServiceImpl.java @@ -70,7 +70,8 @@ public class ImsAnalyseExampleServiceImpl extends ServiceImpl Date: Tue, 30 Jul 2024 22:00:57 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E8=A1=A5?= =?UTF-8?q?=E5=81=BF=E6=B5=81=E7=A8=8B=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/access/service/impl/AccessPlanV4ServiceImpl.java | 2 +- .../operational/access/service/impl/AccessTaskV4ServiceImpl.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java index aa68cc7..029d156 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java @@ -144,7 +144,7 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service, StartProces if (StringUtils.isNotBlank(param)){ variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class); }else { - variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity,DateUtil.PATTERN_DATETIME), Map.class); + variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(accessPlanV4DTO,DateUtil.PATTERN_DATETIME), Map.class); } variables.put("creator", TaskUtil.getTaskUser(String.valueOf(AuthUtil.getUserId()))); R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(), diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java index 2c49021..675064c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessTaskV4ServiceImpl.java @@ -120,13 +120,13 @@ public class AccessTaskV4ServiceImpl implements AccessTaskV4Service, StartProces if (StringUtils.isNotBlank(param)){ variables=JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(param,DateUtil.PATTERN_DATETIME), Map.class); }else { - variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(entity, DateUtil.PATTERN_DATETIME), Map.class); + variables = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(accessTaskV4DTO, DateUtil.PATTERN_DATETIME), Map.class); } if(ObjectUtil.isNotEmpty(accessTaskV4DTO.getCreateUser())){ variables.put("startFlowUserId",accessTaskV4DTO.getCreateUser().toString()); } variables.put("solve",TaskUtil.getTaskUser(accessTaskV4DTO.getHandler().toString())); - R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),dictValue, + R result = compensateProcessClient.startFlow(AuthUtil.getUserId().toString(),dictValue, FlowUtil.getBusinessKey("access_task_v4", String.valueOf(accessTaskV4DTO.getId())), accessTaskV4DTO.getName(),variables); log.error("开启检修任务流程失败{}" + result);