Browse Source

1、报警添加微信通知功能,增加模板。

dev_mz
25604 2 days ago
parent
commit
4d696317f2
  1. 48
      mh-quartz/src/main/java/com/mh/quartz/task/PushDataToWechatTask.java
  2. 14
      mh-system/src/main/java/com/mh/system/service/impl/WechatServiceImpl.java

48
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<String, Object> 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

14
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;

Loading…
Cancel
Save