|
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -23,6 +24,7 @@ import com.ruoyi.system.service.ISysUserService;
|
|
|
import com.ruoyi.zhdd.domain.Incident;
|
|
|
import com.ruoyi.zhdd.domain.IncidentProcess;
|
|
|
import com.ruoyi.zhdd.domain.IncidentTask;
|
|
|
+import com.ruoyi.zhdd.domain.IncidentUser;
|
|
|
import com.ruoyi.zhdd.domain.bo.BacklogMessageUpdateBo;
|
|
|
import com.ruoyi.zhdd.domain.bo.IncidentBo;
|
|
|
import com.ruoyi.zhdd.domain.bo.MessagePushUser;
|
|
@@ -43,7 +45,6 @@ import java.util.Arrays;
|
|
|
import java.util.Collection;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -122,7 +123,7 @@ public class IncidentServiceImpl extends ServicePlusImpl<IncidentMapper, Inciden
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.set("des", "事件接报");
|
|
|
jsonObject.set("incidentId", add.getId());
|
|
|
- jsonObject.set("incidentStatus", 1);
|
|
|
+ jsonObject.set("incidentStatus", 2);
|
|
|
RedisUtils.publish(Constants.PROCESS_RECORD, jsonObject, msg -> {
|
|
|
log.info("事件处置详情消息 => " + msg);
|
|
|
});
|
|
@@ -136,7 +137,7 @@ public class IncidentServiceImpl extends ServicePlusImpl<IncidentMapper, Inciden
|
|
|
bo.setCreateDept(null);
|
|
|
// 是否为状态变更
|
|
|
boolean flag;
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
+
|
|
|
// 查询变更前信息
|
|
|
IncidentVo beforeInfo = getVoById(bo.getId());
|
|
|
if (beforeInfo != null) {
|
|
@@ -145,48 +146,148 @@ public class IncidentServiceImpl extends ServicePlusImpl<IncidentMapper, Inciden
|
|
|
throw new ServiceException("事件不存在!");
|
|
|
}
|
|
|
Incident update = BeanUtil.toBean(bo, Incident.class);
|
|
|
+ // 待删除事件用户关系的array
|
|
|
+ JSONArray removeJsonArray = new JSONArray();
|
|
|
+ // 待新增事件用户关系的array
|
|
|
+ JSONArray saveJsonArray = new JSONArray();
|
|
|
+ // 待发送消息的jsonObject
|
|
|
+ JSONObject sendJsonObject = new JSONObject();
|
|
|
if (flag && bo.getStatus() == 3) {
|
|
|
- // 第一次派发
|
|
|
+ // 第一次派发(只派发给主办人员)
|
|
|
// 待处置状态
|
|
|
if (StrUtil.isBlank(bo.getMadinDept())) {
|
|
|
throw new ServiceException("请选择主办单位!");
|
|
|
}
|
|
|
+ if (StrUtil.isBlank(bo.getMadinTaskUser())) {
|
|
|
+ throw new ServiceException("请选择主办单位处置人员!");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 冗余主办
|
|
|
+ SysDept sysDept = sysDeptService.selectDeptById(bo.getMadinDept());
|
|
|
+ if (sysDept != null) {
|
|
|
+ update.setMadinDeptText(sysDept.getDeptName());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 组装人员数据
|
|
|
+ // 主办单位处置人员
|
|
|
+ for (MessagePushUser messagePushUser : JSONUtil.toList(bo.getMadinTaskUser(), MessagePushUser.class)) {
|
|
|
+ IncidentUser save = new IncidentUser();
|
|
|
+ save.setIncidentId(bo.getId());
|
|
|
+ save.setUserId(messagePushUser.getUserId());
|
|
|
+ save.setSource("2");
|
|
|
+ saveJsonArray.add(save);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 主办单位通知人员
|
|
|
+ if (StrUtil.isNotBlank(bo.getMadinDeptUser())) {
|
|
|
+ for (MessagePushUser messagePushUser : JSONUtil.toList(bo.getMadinDeptUser(), MessagePushUser.class)) {
|
|
|
+ IncidentUser save = new IncidentUser();
|
|
|
+ save.setIncidentId(bo.getId());
|
|
|
+ save.setUserId(messagePushUser.getUserId());
|
|
|
+ save.setSource("6");
|
|
|
+ saveJsonArray.add(save);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (!flag
|
|
|
+ && bo.getStatus() == 3
|
|
|
+ && (!StrUtil.equals(bo.getAssistDept(), beforeInfo.getAssistDept())
|
|
|
+ || !StrUtil.equals(bo.getCommander(), beforeInfo.getCommander())
|
|
|
+ || !StrUtil.equals(bo.getAssistTaskUser(), beforeInfo.getAssistTaskUser())
|
|
|
+ || !StrUtil.equals(bo.getAssistDeptUser(), beforeInfo.getAssistDeptUser()))) {
|
|
|
+ // 协办部门派发或再次对协办修改
|
|
|
+ // 重新冗余协办部门、总指挥
|
|
|
if (StrUtil.isBlank(bo.getCommander())) {
|
|
|
throw new ServiceException("请选择总指挥!");
|
|
|
}
|
|
|
- jsonObject.set("des", "事件派发");
|
|
|
- // 冗余总指挥、主办、协办部门数据
|
|
|
- if (StrUtil.isNotBlank(bo.getCommander())) {
|
|
|
- SysUser commanderText = sysUserService.selectUserById(bo.getCommander());
|
|
|
- if (commanderText != null) {
|
|
|
- update.setCommanderText(commanderText.getNickName());
|
|
|
- }
|
|
|
+ SysUser commanderText = sysUserService.selectUserById(bo.getCommander());
|
|
|
+ if (commanderText != null) {
|
|
|
+ update.setCommanderText(commanderText.getNickName());
|
|
|
}
|
|
|
- if (StrUtil.isNotBlank(bo.getMadinDept())) {
|
|
|
- SysDept sysDept = sysDeptService.selectDeptById(bo.getMadinDept());
|
|
|
- if (sysDept != null) {
|
|
|
- update.setMadinDeptText(sysDept.getDeptName());
|
|
|
+ if (StrUtil.isBlank(bo.getAssistDept())) {
|
|
|
+ update.setAssistDeptText("");
|
|
|
+ } else {
|
|
|
+ // 增加了协办单位后,协办的处置人员非空
|
|
|
+ if (StrUtil.isBlank(bo.getAssistTaskUser())) {
|
|
|
+ throw new ServiceException("请选择协办单位处置人员!");
|
|
|
}
|
|
|
- }
|
|
|
- if (StrUtil.isNotBlank(bo.getAssistDept())) {
|
|
|
- List<SysDept> sysDepts = sysDeptService.listByIds(Arrays.asList(bo.getAssistDept().split(",")));
|
|
|
- if (sysDepts != null && sysDepts.size() > 0) {
|
|
|
- update.setAssistDeptText(sysDepts.stream().map(SysDept::getDeptName).collect(Collectors.joining(",")));
|
|
|
+ if (!StrUtil.equals(beforeInfo.getAssistDept(), bo.getAssistDept())) {
|
|
|
+ List<SysDept> sysDepts = sysDeptService.listByIds(Arrays.asList(bo.getAssistDept().split(",")));
|
|
|
+ if (sysDepts != null && sysDepts.size() > 0) {
|
|
|
+ update.setAssistDeptText(sysDepts.stream().map(SysDept::getDeptName).collect(Collectors.joining(",")));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ // 分析变更的派发对象
|
|
|
+ // 变更的总指挥
|
|
|
+ String oldCommander = beforeInfo.getCommander();
|
|
|
+ String newCommander = bo.getCommander();
|
|
|
+ if (StrUtil.isNotBlank(oldCommander) && !StrUtil.equals(oldCommander, newCommander)) {
|
|
|
+ // 删除关系
|
|
|
+ IncidentUser remove = new IncidentUser();
|
|
|
+ remove.setIncidentId(bo.getId());
|
|
|
+ remove.setUserId(oldCommander);
|
|
|
+ remove.setSource("5");
|
|
|
+ removeJsonArray.add(remove);
|
|
|
+ }
|
|
|
+ // 将总指挥加入到关系
|
|
|
+ if (!StrUtil.equals(oldCommander, newCommander)) {
|
|
|
+ IncidentUser save = new IncidentUser();
|
|
|
+ save.setIncidentId(bo.getId());
|
|
|
+ save.setUserId(newCommander);
|
|
|
+ save.setSource("5");
|
|
|
+ saveJsonArray.add(save);
|
|
|
+ }
|
|
|
|
|
|
- //保存派发的人员和事件关系数据
|
|
|
- JSONObject incidentUser = new JSONObject();
|
|
|
- // 组装人员数据
|
|
|
- Set<MessagePushUser> messagePushUsers = CollUtil.unionDistinct(JSONUtil.toList(bo.getCommanderUser(), MessagePushUser.class), JSONUtil.toList(bo.getMadinDeptUser(), MessagePushUser.class),
|
|
|
- StrUtil.isNotBlank(bo.getAssistDeptUser()) ? JSONUtil.toList(bo.getAssistDeptUser(), MessagePushUser.class) : new ArrayList<>());
|
|
|
- String userId = messagePushUsers.stream().map(MessagePushUser::getUserId).collect(Collectors.joining(","));
|
|
|
- incidentUser.set("incidentId", bo.getId());
|
|
|
- incidentUser.set("userId", userId);
|
|
|
- incidentUser.set("source", "2");
|
|
|
- RedisUtils.publish(Constants.INCIDENT_USER, incidentUser, msg -> {
|
|
|
- log.info("保存事件人员关系 => " + msg);
|
|
|
- });
|
|
|
+ // 变更的协办处置人员
|
|
|
+ List<MessagePushUser> oldAssistTaskUser = JSONUtil.toList(StrUtil.blankToDefault(beforeInfo.getAssistTaskUser(), "[]"), MessagePushUser.class);
|
|
|
+ List<MessagePushUser> newAssistTaskUser = JSONUtil.toList(StrUtil.blankToDefault(bo.getAssistTaskUser(), "[]"), MessagePushUser.class);
|
|
|
+ List<MessagePushUser> removeAssistTaskUser = CollUtil.subtractToList(oldAssistTaskUser, newAssistTaskUser);
|
|
|
+ List<MessagePushUser> addAssistTaskUser = CollUtil.subtractToList(newAssistTaskUser, oldAssistTaskUser);
|
|
|
+ for (MessagePushUser messagePushUser : removeAssistTaskUser) {
|
|
|
+ // 删除关系
|
|
|
+ IncidentUser remove = new IncidentUser();
|
|
|
+ remove.setIncidentId(bo.getId());
|
|
|
+ remove.setUserId(messagePushUser.getUserId());
|
|
|
+ remove.setSource("4");
|
|
|
+ removeJsonArray.add(remove);
|
|
|
+ }
|
|
|
+ for (MessagePushUser messagePushUser : addAssistTaskUser) {
|
|
|
+ IncidentUser save = new IncidentUser();
|
|
|
+ save.setIncidentId(bo.getId());
|
|
|
+ save.setUserId(messagePushUser.getUserId());
|
|
|
+ save.setSource("4");
|
|
|
+ saveJsonArray.add(save);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 变更的协办通知人员
|
|
|
+ List<MessagePushUser> oldAssistDeptUser = JSONUtil.toList(StrUtil.blankToDefault(beforeInfo.getAssistDeptUser(), "[]"), MessagePushUser.class);
|
|
|
+ List<MessagePushUser> newAssistDeptUser = JSONUtil.toList(StrUtil.blankToDefault(bo.getAssistDeptUser(), "[]"), MessagePushUser.class);
|
|
|
+ List<MessagePushUser> removeAssistDeptUser = CollUtil.subtractToList(oldAssistDeptUser, newAssistDeptUser);
|
|
|
+ List<MessagePushUser> addAssistDeptUser = CollUtil.subtractToList(newAssistDeptUser, oldAssistDeptUser);
|
|
|
+ for (MessagePushUser messagePushUser : removeAssistDeptUser) {
|
|
|
+ // 删除关系
|
|
|
+ IncidentUser remove = new IncidentUser();
|
|
|
+ remove.setIncidentId(bo.getId());
|
|
|
+ remove.setUserId(messagePushUser.getUserId());
|
|
|
+ remove.setSource("6");
|
|
|
+ removeJsonArray.add(remove);
|
|
|
+ }
|
|
|
+ for (MessagePushUser messagePushUser : addAssistDeptUser) {
|
|
|
+ IncidentUser save = new IncidentUser();
|
|
|
+ save.setIncidentId(bo.getId());
|
|
|
+ save.setUserId(messagePushUser.getUserId());
|
|
|
+ save.setSource("6");
|
|
|
+ saveJsonArray.add(save);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (addAssistDeptUser.size() > 0 || addAssistTaskUser.size() > 0) {
|
|
|
+ sendJsonObject.set("des", "再次派发总指挥及协办部门");
|
|
|
+ sendJsonObject.set("incidentStatus", bo.getStatus());
|
|
|
+ sendJsonObject.set("incidentId", bo.getId());
|
|
|
+ sendJsonObject.set("messagePushUsers", CollUtil.unionDistinct(addAssistDeptUser, addAssistTaskUser));
|
|
|
+ RedisUtils.publish(Constants.NOTICE_PUSH_SINGLE, sendJsonObject);
|
|
|
+ }
|
|
|
|
|
|
} else if (flag && bo.getStatus() == 4) {
|
|
|
// 将待办变成已办
|
|
@@ -222,55 +323,27 @@ public class IncidentServiceImpl extends ServicePlusImpl<IncidentMapper, Inciden
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- } else if (!flag && bo.getStatus() == 3 && !StrUtil.equals(bo.getAssistDept(), beforeInfo.getAssistDept())) {
|
|
|
- // 第二次对协办部门派发
|
|
|
- // 重新冗余协办部门
|
|
|
- if (StrUtil.isBlank(bo.getAssistDept())) {
|
|
|
- update.setAssistDeptText("");
|
|
|
- } else {
|
|
|
- List<SysDept> sysDepts = sysDeptService.listByIds(Arrays.asList(bo.getAssistDept().split(",")));
|
|
|
- if (sysDepts != null && sysDepts.size() > 0) {
|
|
|
- update.setAssistDeptText(sysDepts.stream().map(SysDept::getDeptName).collect(Collectors.joining(",")));
|
|
|
- }
|
|
|
- }
|
|
|
- // 查询新增的部门数据。此处需要单独发送消息给相关的人
|
|
|
- List<MessagePushUser> oldAssistDeptUser = JSONUtil.toList(beforeInfo.getAssistDeptUser(), MessagePushUser.class);
|
|
|
- List<MessagePushUser> newAssistDeptUser = JSONUtil.toList(bo.getAssistDeptUser(), MessagePushUser.class);
|
|
|
- List<MessagePushUser> messagePushUsers = CollUtil.subtractToList(newAssistDeptUser, oldAssistDeptUser);
|
|
|
-
|
|
|
- jsonObject.set("des", "再次派发协办部门");
|
|
|
- jsonObject.set("incidentStatus", bo.getStatus());
|
|
|
- jsonObject.set("incidentId", bo.getId());
|
|
|
- jsonObject.set("messagePushUsers", messagePushUsers);
|
|
|
-
|
|
|
- RedisUtils.publish(Constants.NOTICE_PUSH_SINGLE, jsonObject);
|
|
|
-
|
|
|
- //对第二次修改的人员再保存事件人员关系
|
|
|
- String userId = messagePushUsers.stream().map(MessagePushUser::getUserId).collect(Collectors.joining(","));
|
|
|
- JSONObject incidentUser = new JSONObject();
|
|
|
- incidentUser.set("incidentId", bo.getId());
|
|
|
- incidentUser.set("userId", userId);
|
|
|
- incidentUser.set("source", "2");
|
|
|
- RedisUtils.publish(Constants.INCIDENT_USER, incidentUser, msg -> {
|
|
|
- log.info("保存事件人员关系 => " + msg);
|
|
|
- });
|
|
|
}
|
|
|
// 更新事件信息
|
|
|
boolean b = updateById(update);
|
|
|
|
|
|
+ if (removeJsonArray.size() > 0) {
|
|
|
+ RedisUtils.publish(Constants.INCIDENT_USER_DELETE, removeJsonArray);
|
|
|
+ }
|
|
|
+ if (saveJsonArray.size() > 0) {
|
|
|
+ RedisUtils.publish(Constants.INCIDENT_USER_BATCH, saveJsonArray);
|
|
|
+ }
|
|
|
+
|
|
|
if (flag) {
|
|
|
if (bo.getStatus() == 3) {
|
|
|
- // 推送到派发的待办消息中
|
|
|
- RedisUtils.publish(Constants.NOTICE_PUSH, 1 + "A" + update.getId(), msg -> {
|
|
|
- log.info("事件派发消息 => " + msg);
|
|
|
- });
|
|
|
+ // 第一次派发给主办部门时
|
|
|
+ RedisUtils.publish(Constants.NOTICE_PUSH, 1 + "A" + update.getId());
|
|
|
return b;
|
|
|
}
|
|
|
- jsonObject.set("incidentId", update.getId());
|
|
|
- jsonObject.set("incidentStatus", update.getStatus());
|
|
|
- RedisUtils.publish(Constants.PROCESS_RECORD, jsonObject, msg -> {
|
|
|
- log.info("事件处置详情消息 => " + msg);
|
|
|
- });
|
|
|
+ // 事件状态的变更,将发送到处置日志中
|
|
|
+ sendJsonObject.set("incidentId", update.getId());
|
|
|
+ sendJsonObject.set("incidentStatus", update.getStatus());
|
|
|
+ RedisUtils.publish(Constants.PROCESS_RECORD, sendJsonObject);
|
|
|
}
|
|
|
return b;
|
|
|
}
|
|
@@ -282,4 +355,10 @@ public class IncidentServiceImpl extends ServicePlusImpl<IncidentMapper, Inciden
|
|
|
}
|
|
|
return removeByIds(ids);
|
|
|
}
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|