|
@@ -1,14 +1,19 @@
|
|
|
package com.ruoyi.web.controller.task;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.ruoyi.common.constant.Constants;
|
|
|
+import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.common.utils.RedisUtils;
|
|
|
+import com.ruoyi.system.service.ISysDeptService;
|
|
|
+import com.ruoyi.system.service.ISysDictDataService;
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
import com.ruoyi.zhdd.domain.IncidentProcess;
|
|
|
import com.ruoyi.zhdd.domain.IncidentUser;
|
|
@@ -57,15 +62,23 @@ public class NoticeInfoListiner {
|
|
|
private final ISmsOutboxService smsOutboxService;
|
|
|
private final ISysUserService sysUserService;
|
|
|
private final IIncidentUserService incidentUserService;
|
|
|
+ private final ISysDictDataService dictDataService;
|
|
|
+ private final ISysDeptService sysDeptService;
|
|
|
|
|
|
@Value("${spring.profiles.active}")
|
|
|
private String env;
|
|
|
|
|
|
+ @Value("${third.incidentUrl}")
|
|
|
+ private String incidentUrl;
|
|
|
+ @Value("${third.resourceUrl}")
|
|
|
+ private String resourceUrl;
|
|
|
+
|
|
|
/**
|
|
|
* 消息发送
|
|
|
* A:事件派发。B:处置方案
|
|
|
*/
|
|
|
@Bean
|
|
|
+
|
|
|
public void sendNotice() {
|
|
|
RedisUtils.subscribe(Constants.NOTICE_PUSH, String.class, msg -> {
|
|
|
try {
|
|
@@ -83,7 +96,7 @@ public class NoticeInfoListiner {
|
|
|
String synopsis = "未知";
|
|
|
String text = "未知";
|
|
|
String messageUser = "";
|
|
|
- String incidentId = "";
|
|
|
+ String incidentId;
|
|
|
String url = "";
|
|
|
IncidentProcess incidentProcess = new IncidentProcess();
|
|
|
boolean sendFlag = true;
|
|
@@ -96,8 +109,9 @@ public class NoticeInfoListiner {
|
|
|
if ("A".equals(type)) {
|
|
|
IncidentVo incidentVo = incidentService.queryById(msg.substring(2));
|
|
|
title = StrUtil.concat(true, "应急事件:", incidentVo.getName());
|
|
|
- synopsis = "系统给您派发了应急事件,请查看";
|
|
|
- text = StrUtil.concat(true, incidentVo.getAddr(), "发生应急事件,请关注消息,做好应急准备");
|
|
|
+ synopsis = "请查看派发应急事件消息";
|
|
|
+ text = getDetail(incidentVo);
|
|
|
+ text = text.replace("#task", "");
|
|
|
incidentProcess.setDes("事件派发");
|
|
|
incidentProcess.setIncidentStatus(2);
|
|
|
incidentProcess.setIncidentId(msg.substring(2));
|
|
@@ -110,9 +124,11 @@ public class NoticeInfoListiner {
|
|
|
incidentId = incidentTaskVo.getIncidentId();
|
|
|
IncidentVo incidentVo = incidentService.queryById(incidentTaskVo.getIncidentId());
|
|
|
title = "应急处置";
|
|
|
- synopsis = "请查看应急处置方案";
|
|
|
- text = StrUtil.concat(true, "请查看", incidentVo.getName(), "事件的", incidentTaskVo.getTaskName(), "方案");
|
|
|
- url = "http://sqmb.xt.wenhq.top:8083/#/status/3/detail?id=" + incidentId + "&taskid=" + incidentTaskVo.getId();
|
|
|
+ synopsis = "请查看应急事件处置指令消息";
|
|
|
+ text = getDetail(incidentVo);
|
|
|
+ String taskName = "<tr><td style=\"color: darkgray;width: 20%;vertical-align: top;\">处置指令</td><td style=\"text-align:left;\">#taskName</td></tr>".replace("#taskName", incidentTaskVo.getTaskName());
|
|
|
+ text = text.replace("#task", taskName);
|
|
|
+ url = incidentUrl.replace("#incidentId", incidentId).replace("#taskId", incidentTaskVo.getId());
|
|
|
incidentProcess.setDes("发送处置方案:" + incidentTaskVo.getTaskName());
|
|
|
incidentProcess.setIncidentStatus(3);
|
|
|
incidentProcess.setIncidentId(incidentTaskVo.getIncidentId());
|
|
@@ -120,7 +136,7 @@ public class NoticeInfoListiner {
|
|
|
if ("3".equals(messageType)) {
|
|
|
title = "应急资源维护";
|
|
|
text = incidentTaskVo.getTaskName();
|
|
|
- url = "http://sqmb.xt.wenhq.top:8083/#/warehouse/detail";
|
|
|
+ url = resourceUrl.replace("#taskId", incidentTaskVo.getId());
|
|
|
}
|
|
|
incidentProcess.setTaskId(incidentTaskVo.getId());
|
|
|
}
|
|
@@ -188,6 +204,40 @@ public class NoticeInfoListiner {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 获取事件详情
|
|
|
+ *
|
|
|
+ * @param incidentVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String getDetail(IncidentVo incidentVo) {
|
|
|
+ // 翻译事件类型、事件等级、事件来源、上报人员、上报单位
|
|
|
+ String type = dictDataService.selectDictLabel("zhdd_incident_type", Convert.toStr(incidentVo.getType()));
|
|
|
+ String level = dictDataService.selectDictLabel("zhdd_incident_level", Convert.toStr(incidentVo.getLevel()));
|
|
|
+ String source = dictDataService.selectDictLabel("zhdd_incident_source", incidentVo.getSource());
|
|
|
+ incidentVo.setTypeText(type);
|
|
|
+ incidentVo.setLevelText(level);
|
|
|
+ incidentVo.setSource(source);
|
|
|
+ SysUser sysUser = sysUserService.selectUserByUserName(incidentVo.getCreateBy());
|
|
|
+ if (sysUser != null) {
|
|
|
+ incidentVo.setCreateBy(sysUser.getNickName());
|
|
|
+ }
|
|
|
+ SysDept sysDept = sysDeptService.selectDeptById(incidentVo.getCreateDept());
|
|
|
+ if (sysDept != null) {
|
|
|
+ incidentVo.setCreateDept(sysDept.getDeptName());
|
|
|
+ }
|
|
|
+ String htmlContent = "<table style=\"font-size: 3vw;\"><tr><td style=\"color: darkgray;width: 20%;vertical-align: top;\">事件类型</td><td style=\"text-align:left;\">#typeText</td></tr><tr><td style=\"color: darkgray;width: 20%;vertical-align: " +
|
|
|
+ "top;\">事件等级</td><td style=\"text-align:left;\">#levelText</td></tr><tr><td style=\"color: darkgray;width: 20%;vertical-align: top;\">事件时间</td><td style=\"text-align:left;\">#createTime</td></tr><tr><td style=\"color: darkgray;width: 20%;vertical-align: top;\">事件地点</td><td style=\"text-align:left;\">#addr</td></tr><tr><td style=\"color: darkgray;width: 20%;vertical-align: top;\">事件来源</td><td style=\"text-align:left;\">#source</td></tr><tr><td style=\"color: darkgray;width: 20%;vertical-align: top;\">上报人员</td><td style=\"text-align:left;\">#createBy</td></tr><tr><td style=\"color: darkgray;width: 20%;vertical-align: top;\">联系电话</td><td style=\"text-align:left;\">#expr1</td></tr><tr><td style=\"color: darkgray;width: 20%;vertical-align: top;\">上报单位</td><td style=\"text-align:left;\">#createDept</td></tr>#task</table>";
|
|
|
+ return htmlContent.replace("#typeText", incidentVo.getTypeText())
|
|
|
+ .replace("#levelText", incidentVo.getLevelText())
|
|
|
+ .replace("#createTime", DateUtil.formatDateTime(incidentVo.getCreateTime()))
|
|
|
+ .replace("#addr", incidentVo.getAddr())
|
|
|
+ .replace("#source", incidentVo.getSource())
|
|
|
+ .replace("#createBy", incidentVo.getCreateBy())
|
|
|
+ .replace("#expr1", incidentVo.getExpr1())
|
|
|
+ .replace("#createDept", incidentVo.getCreateDept());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 指定用户发送
|
|
|
*/
|
|
|
@Bean
|