|
|
|
@ -12,9 +12,12 @@ import com.foreverwin.mesnac.common.service.MessageService;
|
|
|
|
|
import com.foreverwin.mesnac.common.util.ActiveMQUtil;
|
|
|
|
|
import com.foreverwin.mesnac.common.util.StringUtil;
|
|
|
|
|
import com.foreverwin.mesnac.listener.mapper.UsrMapper;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.mapper.MessageTypeMapper;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.mapper.UserGroupMapper;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.model.MessageType;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.model.NwaUser;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.service.NwaUserService;
|
|
|
|
|
import com.foreverwin.mesnac.meapi.util.StringUtils;
|
|
|
|
|
import com.foreverwin.modular.core.util.CommonMethods;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
@ -24,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
@ -59,6 +63,9 @@ public class AnomalyJobServiceImpl implements AnomalyJobService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private UsrMapper usrMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MessageTypeMapper messageTypeMapper;
|
|
|
|
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(AnomalyJobServiceImpl.class);
|
|
|
|
|
|
|
|
|
@ -110,20 +117,9 @@ public class AnomalyJobServiceImpl implements AnomalyJobService {
|
|
|
|
|
abnormalMessage.setNode(_abnormalMessage.getNode());
|
|
|
|
|
abnormalMessage.setStatus("Y");
|
|
|
|
|
_abnormalMessage.setStatus("Y");
|
|
|
|
|
|
|
|
|
|
String message = abnormalBillService.formatMessage(abnormalBill,abnormalMessage.getMessageType(),site);
|
|
|
|
|
|
|
|
|
|
//格式化消息
|
|
|
|
|
String message = this.formatMessageJob(abnormalBill,abnormalMessage,site);
|
|
|
|
|
abnormalMessage.setContent(message);
|
|
|
|
|
//根据异常消息的节点来判断所处的状态
|
|
|
|
|
if(Constants.ABNORMAL_MESSAGE_REPORT.equals(abnormalMessage.getNode())){
|
|
|
|
|
abnormalMessage.setContent(message+",现已超时未响应");
|
|
|
|
|
}else if(Constants.ABNORMAL_MESSAGE_RESPONSE_DUTY.equals(abnormalMessage.getNode())){
|
|
|
|
|
//走判责提交
|
|
|
|
|
abnormalMessage.setContent(message+",现已响应超时未判责提交(责任划分)");
|
|
|
|
|
}else if(Constants.ABNORMAL_MESSAGE_RESPONSE_RESOLVE.equals(abnormalMessage.getNode())){
|
|
|
|
|
//走解决方案
|
|
|
|
|
abnormalMessage.setContent(message+",现已响应超时未方案确认");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//设置时间
|
|
|
|
|
abnormalMessage.setCreatedUser(user);
|
|
|
|
@ -135,24 +131,65 @@ public class AnomalyJobServiceImpl implements AnomalyJobService {
|
|
|
|
|
List<NwaUser> nwaUsers = nwaUserService.checkUserGroup(site,abnormalMessage.getSendUserGroup());
|
|
|
|
|
if(nwaUsers != null && nwaUsers.size() <= 0){
|
|
|
|
|
logger.info("消息发送失败,发送的用户组下面没有用户") ;
|
|
|
|
|
}
|
|
|
|
|
List<String> customFieldByUserId = usrMapper.findCustomFieldByUserId(site, nwaUsers);
|
|
|
|
|
if(customFieldByUserId != null && customFieldByUserId.size() <= 0){
|
|
|
|
|
logger.info("消息发送失败,发送的用户组下面的用户的自定义数据没有维护");
|
|
|
|
|
}
|
|
|
|
|
StringBuilder sendUsers = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < Objects.requireNonNull(customFieldByUserId).size(); i++) {
|
|
|
|
|
if(i == (customFieldByUserId.size() - 1)){
|
|
|
|
|
sendUsers.append(customFieldByUserId.get(i));
|
|
|
|
|
}else{
|
|
|
|
|
sendUsers.append(customFieldByUserId.get(i)).append("|");
|
|
|
|
|
}else{
|
|
|
|
|
List<String> customFieldByUserId = usrMapper.findCustomFieldByUserId(site, nwaUsers);
|
|
|
|
|
if(customFieldByUserId != null && customFieldByUserId.size() <= 0){
|
|
|
|
|
logger.info("消息发送失败,发送的用户组下面的用户的自定义数据没有维护");
|
|
|
|
|
}else {
|
|
|
|
|
StringBuilder sendUsers = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < Objects.requireNonNull(customFieldByUserId).size(); i++) {
|
|
|
|
|
if(i == (customFieldByUserId.size() - 1)){
|
|
|
|
|
sendUsers.append(customFieldByUserId.get(i));
|
|
|
|
|
}else{
|
|
|
|
|
sendUsers.append(customFieldByUserId.get(i)).append("|");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
activeMQUtil.wechatSendMessage(sendUsers.toString(),abnormalMessage.getContent());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
activeMQUtil.wechatSendMessage(sendUsers.toString(),abnormalMessage.getContent());
|
|
|
|
|
//保存升级的消息类型
|
|
|
|
|
messageService.saveOrUpdate(abnormalMessage);
|
|
|
|
|
//保存原先的消息类型,让原先的消息类型的stauts改为Y
|
|
|
|
|
messageService.saveOrUpdate(_abnormalMessage);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String formatMessageJob(AbnormalBill abnormalBill, Message message, String site) {
|
|
|
|
|
//找到消息内容
|
|
|
|
|
MessageType messageTypeEntity = new MessageType();
|
|
|
|
|
messageTypeEntity.setSite(site);
|
|
|
|
|
messageTypeEntity.setMessageType(message.getMessageType());
|
|
|
|
|
QueryWrapper<MessageType> messageTypeQueryWrapper = new QueryWrapper<MessageType>();
|
|
|
|
|
messageTypeQueryWrapper.setEntity(messageTypeEntity);
|
|
|
|
|
MessageType sendMessageType = messageTypeMapper.selectOne(messageTypeQueryWrapper);
|
|
|
|
|
if(sendMessageType == null){
|
|
|
|
|
return "消息类型:"+message.getMessageType()+"找不到,异常单为:"+abnormalBill.getAbnormalNo()+",状态为:"+abnormalBill.getStatus();
|
|
|
|
|
}
|
|
|
|
|
//找到要替换的消息
|
|
|
|
|
Map<String, String> replaceMessage = abnormalBillMapper.findReplaceMessageByAbnormal(abnormalBill);
|
|
|
|
|
//找到用户组下的所有用户
|
|
|
|
|
List<NwaUser> nwaUsers = nwaUserService.checkUserGroup(site, message.getSendUserGroup());
|
|
|
|
|
String user = "";
|
|
|
|
|
for (int i = 0; i < nwaUsers.size(); i++) {
|
|
|
|
|
user += nwaUsers.get(i).getFullName()+"、";
|
|
|
|
|
if(i == (nwaUsers.size() - 1)){
|
|
|
|
|
user += nwaUsers.get(i).getFullName()+",";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//根据异常消息的节点来判断所处的状态
|
|
|
|
|
if(Constants.ABNORMAL_MESSAGE_REPORT.equals(message.getNode())){
|
|
|
|
|
user += "现已超时未响应。";
|
|
|
|
|
}else if(Constants.ABNORMAL_MESSAGE_RESPONSE_DUTY.equals(message.getNode())){
|
|
|
|
|
//走判责提交
|
|
|
|
|
user += "现已判责提交(责任划分)超时。";
|
|
|
|
|
}else if(Constants.ABNORMAL_MESSAGE_RESPONSE_RESOLVE.equals(message.getNode())){
|
|
|
|
|
//走解决方案
|
|
|
|
|
user += "现已方案确认超时。";
|
|
|
|
|
}
|
|
|
|
|
replaceMessage.put("USER",user);
|
|
|
|
|
String messageBody = sendMessageType.getBody();
|
|
|
|
|
//格式化之后的消息
|
|
|
|
|
return StringUtils.format(messageBody, replaceMessage);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|