From bbde9859994488dafc91846241410b007bc0aba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=98=89=E4=BC=9F?= <1724121454@qq.com> Date: Thu, 16 Sep 2021 14:49:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=8F=91=E9=80=81=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../anomaly/service/AbnormalBillService.java | 2 + .../service/impl/AbnormalBillServiceImpl.java | 86 ++++++++++++++++--- .../service/impl/AnomalyJobServiceImpl.java | 38 +++----- .../resources/mapper/AbnormalBillMapper.xml | 14 +-- .../mesnac/common/constant/Constants.java | 2 + .../mesnac/common/util/ActiveMQUtil.java | 12 ++- .../mesnac/meapi/model/UserGroup.java | 20 +++++ .../main/resources/mapper/UserGroupMapper.xml | 7 +- 8 files changed, 131 insertions(+), 50 deletions(-) diff --git a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/AbnormalBillService.java b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/AbnormalBillService.java index 12f2f620..9c70fbb1 100644 --- a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/AbnormalBillService.java +++ b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/AbnormalBillService.java @@ -162,4 +162,6 @@ public interface AbnormalBillService extends IService { */ MessageType findMessageTypeByStatusAndUserGroup(Message message, AbnormalBill abnormalBill, AbnormalBillDispose abnormalBillDispose); + void saveDutyMessageAndResolveMessageByNodeIsResponse(Message paramMessage); + } \ No newline at end of file diff --git a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AbnormalBillServiceImpl.java b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AbnormalBillServiceImpl.java index ac4a2bca..4378cd00 100644 --- a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AbnormalBillServiceImpl.java +++ b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/AbnormalBillServiceImpl.java @@ -1029,38 +1029,46 @@ public class AbnormalBillServiceImpl extends ServiceImpl wrapper = new QueryWrapper<>(); -// wrapper.setEntity(abnormalMessage1); List messages = messageService.selectList(abnormalMessage1); // Message _abnormalMessage = messageMapper.selectOne(wrapper); if(messages.size() > 0) { abnormalMessage.setUpUserGroup(messages.get(0).getUpUserGroup()); abnormalMessage.setUpMessageType(messages.get(0).getUpMessageType()); abnormalMessage.setGrade(messages.get(0).getGrade()); - abnormalMessage.setUpDateTime(messages.get(0).getUpDateTime()); - abnormalMessage.setNode(Constants.ABNORMAL_MESSAGE_RESPONSE); } -// }else{ -// throw new BaseException("发送消息时,异常响应报错"); -// } break; //纠纷确认 case Constants.CORRECTION_CONFIRM: abnormalMessage.setSendUserGroup(abnormalBillDispose.getDutySendUserGroup()); abnormalMessage.setNode(Constants.ABNORMAL_MESSAGE_CORRECTION_CONFIRM); + //找到责任划分超时的,并关闭 + UpdateWrapper dutyWrapper = new UpdateWrapper<>(); + Message dutyMessage = new Message(); + dutyMessage.setStatus("Y"); + dutyWrapper.eq("STATUS","N"); + dutyWrapper.eq("OBJECT_BO",abnormalMessage.getObjectBo()); + dutyWrapper.eq("NODE",Constants.ABNORMAL_MESSAGE_RESPONSE_DUTY); + messageService.update(dutyMessage,dutyWrapper); break; //方案确认 case Constants.PROGRAM_CONFIRM: abnormalMessage.setSendUserGroup(abnormalBillDispose.getResolveSendUserGroup()); abnormalMessage.setNode(Constants.ABNORMAL_MESSAGE_PROGRAM_CONFIRM); + //找到方案确认超时的,并关闭 + UpdateWrapper resolveWrapper = new UpdateWrapper<>(); + Message resolveMessage = new Message(); + resolveMessage.setStatus("Y"); + resolveWrapper.eq("STATUS","N"); + resolveWrapper.eq("OBJECT_BO",abnormalMessage.getObjectBo()); + resolveWrapper.eq("NODE",Constants.ABNORMAL_MESSAGE_RESPONSE_RESOLVE); + messageService.update(resolveMessage,resolveWrapper); break; //取消 @@ -1081,14 +1089,14 @@ public class AbnormalBillServiceImpl extends ServiceImpl nwaUsers = nwaUserService.checkUserGroup(site,abnormalMessage.getSendUserGroup()); @@ -1136,6 +1150,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl messages = new ArrayList<>(); + messages.add(message); + messages.add(paramMessage); + //关闭新建状态的消息 + + //找到新建状态的,并关闭 + UpdateWrapper resolveWrapper = new UpdateWrapper<>(); + Message resolveMessage = new Message(); + resolveMessage.setStatus("Y"); + resolveWrapper.eq("STATUS","N"); + resolveWrapper.eq("OBJECT_BO",paramMessage.getObjectBo()); + resolveWrapper.eq("NODE",Constants.ABNORMAL_MESSAGE_REPORT); + messageService.update(resolveMessage,resolveWrapper); + + messageService.saveOrUpdateBatch(messages); + } @Override public Map jgProductionIsScrap(String abnormalNo, String site, String sfc) { @@ -1513,5 +1574,4 @@ public class AbnormalBillServiceImpl extends ServiceImpl nwaUsers = nwaUserService.checkUserGroup(site,abnormalMessage.getSendUserGroup()); -// StringBuilder sendUsers = new StringBuilder(); -// for (int i = 0; i < nwaUsers.size(); i++) { -// if(i == (nwaUsers.size() - 1)){ -// sendUsers.append(nwaUsers.get(i).getUserName()); -// }else{ -// sendUsers.append(nwaUsers.get(i).getUserName()).append("|"); -// } -// } -// activeMQUtil.wechatSendMessage(sendUsers.toString(),abnormalMessage.getContent()); -// -// -// -// //发送消息 List nwaUsers = nwaUserService.checkUserGroup(site,abnormalMessage.getSendUserGroup()); if(nwaUsers != null && nwaUsers.size() <= 0){ - throw new BaseException("消息发送失败,发送的用户组下面没有用户"); + logger.info("消息发送失败,发送的用户组下面没有用户") ; } List customFieldByUserId = usrMapper.findCustomFieldByUserId(site, nwaUsers); if(customFieldByUserId != null && customFieldByUserId.size() <= 0){ - throw new BaseException("消息发送失败,发送的用户组下面的自定义数据没有维护"); + logger.info("消息发送失败,发送的用户组下面的用户的自定义数据没有维护"); } StringBuilder sendUsers = new StringBuilder(); for (int i = 0; i < Objects.requireNonNull(customFieldByUserId).size(); i++) { diff --git a/anomaly/src/main/resources/mapper/AbnormalBillMapper.xml b/anomaly/src/main/resources/mapper/AbnormalBillMapper.xml index 504722d2..6d672f3e 100644 --- a/anomaly/src/main/resources/mapper/AbnormalBillMapper.xml +++ b/anomaly/src/main/resources/mapper/AbnormalBillMapper.xml @@ -1254,9 +1254,11 @@ diff --git a/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java b/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java index 4d29163a..ac0f6521 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java @@ -166,6 +166,8 @@ public interface Constants { String ABNORMAL_MESSAGE_PROGRAM_CONFIRM = "PROGRAM_CONFIRM";//方案确认 String ABNORMAL_MESSAGE_CORRECTION_CONFIRM = "CORRECTION_CONFIRM";//纠防确认 String ABNORMAL_MESSAGE_CANCEL = "CANCEL";//取消 + String ABNORMAL_MESSAGE_RESPONSE_DUTY ="RESPONSE_DUTY";//责任划分超时 + String ABNORMAL_MESSAGE_RESPONSE_RESOLVE = "RESPONSE_RESOLVE";//方案确认超时 /** * 打印类型 diff --git a/common/src/main/java/com/foreverwin/mesnac/common/util/ActiveMQUtil.java b/common/src/main/java/com/foreverwin/mesnac/common/util/ActiveMQUtil.java index 6c266f28..379ed643 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/util/ActiveMQUtil.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/util/ActiveMQUtil.java @@ -1,11 +1,15 @@ package com.foreverwin.mesnac.common.util; import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.jms.core.JmsMessagingTemplate; import org.springframework.stereotype.Component; +import java.time.LocalDateTime; + /** * @Description TODO * @Author zhaojiawei @@ -19,18 +23,18 @@ public class ActiveMQUtil { @Qualifier("mesJmsTemplate") private JmsMessagingTemplate mesJmsTemplate; + private static Logger logger = LoggerFactory.getLogger(ActiveMQUtil.class); + public void wechatSendMessage(String user, String text) { String queue = "send.weChat.notice"; JSONObject jsonObject = new JSONObject(); try{ jsonObject.put("TO_USER", user); jsonObject.put("CONTENT",text); - // defaultJmsTemplate.getJmsTemplate().setReceiveTimeout(TimeUnit.SECONDS.toMillis(3)); mesJmsTemplate.convertAndSend(queue, jsonObject.toString()); -// if (StringUtil.isBlank(message)) { -// //记日志 -// } }catch (Exception ignored){ + LocalDateTime now = LocalDateTime.now(); + logger.info("消息发送失败。日期:" + now + "消息内容:"+text) ; // throw new BaseException("消息发送失败"); } } diff --git a/meapi/src/main/java/com/foreverwin/mesnac/meapi/model/UserGroup.java b/meapi/src/main/java/com/foreverwin/mesnac/meapi/model/UserGroup.java index 67c4e320..51dff96f 100644 --- a/meapi/src/main/java/com/foreverwin/mesnac/meapi/model/UserGroup.java +++ b/meapi/src/main/java/com/foreverwin/mesnac/meapi/model/UserGroup.java @@ -44,6 +44,10 @@ public class UserGroup extends Model { private String messageNoticeLevel; @TableField(exist = false) private String messageNoticeTime; + @TableField(exist = false) + private String messageDutyTime; + @TableField(exist = false) + private String messageResolveTime; public String getHandle() { @@ -126,6 +130,22 @@ public class UserGroup extends Model { this.messageNoticeTime = messageNoticeTime; } + public String getMessageDutyTime() { + return messageDutyTime; + } + + public void setMessageDutyTime(String messageDutyTime) { + this.messageDutyTime = messageDutyTime; + } + + public String getMessageResolveTime() { + return messageResolveTime; + } + + public void setMessageResolveTime(String messageResolveTime) { + this.messageResolveTime = messageResolveTime; + } + public static final String HANDLE = "HANDLE"; public static final String CHANGE_STAMP = "CHANGE_STAMP"; diff --git a/meapi/src/main/resources/mapper/UserGroupMapper.xml b/meapi/src/main/resources/mapper/UserGroupMapper.xml index ec64be23..0ce9dbbe 100644 --- a/meapi/src/main/resources/mapper/UserGroupMapper.xml +++ b/meapi/src/main/resources/mapper/UserGroupMapper.xml @@ -14,6 +14,8 @@ + + @@ -352,10 +354,13 @@