From ebabe3d17a1b2b1840186c6889822685370c7ba3 Mon Sep 17 00:00:00 2001 From: 25604 Date: Mon, 30 Jun 2025 17:05:05 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=8A=A5=E8=AD=A6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E9=80=9A=E7=9F=A5=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A8=A1=E6=9D=BF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mh/quartz/task/PushDataToWechatTask.java | 48 +++++++++++++++++-- .../service/impl/WechatServiceImpl.java | 14 +++++- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/mh-quartz/src/main/java/com/mh/quartz/task/PushDataToWechatTask.java b/mh-quartz/src/main/java/com/mh/quartz/task/PushDataToWechatTask.java index c28a22e..a8438f0 100644 --- a/mh-quartz/src/main/java/com/mh/quartz/task/PushDataToWechatTask.java +++ b/mh-quartz/src/main/java/com/mh/quartz/task/PushDataToWechatTask.java @@ -5,7 +5,9 @@ import com.mh.common.core.domain.entity.AlarmRecords; import com.mh.common.core.domain.wechat.*; import com.mh.common.utils.DateUtils; import com.mh.common.utils.DictUtils; +import com.mh.system.service.ISysParamsService; import com.mh.system.service.IWechatService; +import com.mh.system.service.impl.SysParamsServiceImpl; import com.mh.system.service.operation.IAlarmRecordsService; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; @@ -33,6 +35,9 @@ public class PushDataToWechatTask { @Resource private IWechatService wechatService; + @Resource + private ISysParamsService sysParamsService; + public void pushDataToWechat() { // 查询报警内容 AlarmRecords alarmRecords = new AlarmRecords(); @@ -62,9 +67,9 @@ public class PushDataToWechatTask { // 设备异常告警提醒 pushDeviceExceptionParams(map, pushMsgEntity, alarmRecords2); break; - case "qG3Odr74o4BRx8QigZuoil3l3ZC2aAdDeO49robRLC8": - // 推送用电量、用冷量、EER数据 - // pushAllParams(projectInfoEntity, map, pushMsgEntity, energyDataEntity); + case "SiyBtZeZuF0Qo8V3NlvGwhc95-vX-a6wsvIxpAq3d_Y": + // 设备告警通知 + pushDeviceArmParams(map, pushMsgEntity, alarmRecords2); break; default: break; @@ -84,6 +89,43 @@ public class PushDataToWechatTask { }); } + private void pushDeviceArmParams(Map map, PushMsgEntity pushMsgEntity, AlarmRecords alarmRecords2) { + pushMsgEntity.setTouser(map.get("open_id").toString()); + pushMsgEntity.setTemplateId(map.get("template_id").toString()); + pushMsgEntity.setUrl("http://jnd2.mhwsh.net:8765/"); + First first = new First(); + first.setValue("设备告警通知"); + pushMsgEntity.setFirst(first); + + // 项目名称 + Key1 key1 = new Key1(); + key1.setValue(sysParamsService.queryList().get(0).getProName()); + pushMsgEntity.setKey1(key1); + + // 设备名称 + Key2 key2 = new Key2(); + key2.setValue(alarmRecords2.getDeviceName()); + pushMsgEntity.setKey2(key2); + + // 告警等级 + Key3 key3 = new Key3(); + // 通过告警等级id得到value值 + String alarmLevel = alarmRecords2.getAlarmLevel(); + String alarmLevel1 = DictUtils.getDictLabel("alarm_level", alarmLevel); + key3.setValue(alarmLevel1); + pushMsgEntity.setKey3(key3); + + // 异常原因 + Key4 key4 = new Key4(); + key4.setValue(alarmRecords2.getContent().substring(0, 20)); + pushMsgEntity.setKey4(key4); + + // 发生时间 + Key5 key5 = new Key5(); + key5.setValue(DateUtils.dateToString(alarmRecords2.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + pushMsgEntity.setKey5(key5); + } + /** * 推送设备异常告警提醒 * @param map diff --git a/mh-system/src/main/java/com/mh/system/service/impl/WechatServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/impl/WechatServiceImpl.java index c95f32f..f4e5834 100644 --- a/mh-system/src/main/java/com/mh/system/service/impl/WechatServiceImpl.java +++ b/mh-system/src/main/java/com/mh/system/service/impl/WechatServiceImpl.java @@ -104,13 +104,23 @@ public class WechatServiceImpl implements IWechatService { data.put("thing11", pushMsgEntity.getKey1()); // 告警等级 data.put("thing4", pushMsgEntity.getKey2()); -// // 告警类型 -// data.put("thing3", pushMsgEntity.getKey3()); // 告警明细 data.put("thing6", pushMsgEntity.getKey4()); // 告警时间 data.put("time5", pushMsgEntity.getKey5()); break; + case "SiyBtZeZuF0Qo8V3NlvGwhc95-vX-a6wsvIxpAq3d_Y": + // 项目名称 + data.put("thing95", pushMsgEntity.getKey1()); + // 设备名称 + data.put("thing23", pushMsgEntity.getKey2()); + // 告警等级 + data.put("phrase20", pushMsgEntity.getKey3()); + // 异常原因 + data.put("thing25", pushMsgEntity.getKey4()); + // 发生时间 + data.put("time51", pushMsgEntity.getKey5()); + break; default: break;