Merge remote-tracking branch 'mesnac/master'

master
Leon 3 years ago
commit 40fd19d945

@ -46,5 +46,5 @@ public interface AbnormalBillMapper extends BaseMapper<AbnormalBill> {
IPage getAbnormalByConditional(IPage page, @Param("paramMap")Map<String,String> paramMap,@Param("keyword")String keyword);
Map<String,String> findReplaceMessageByAbnoraml(@Param("abnormalBill")AbnormalBill abnormalBill);
Map<String,String> findReplaceMessageByAbnormal(@Param("abnormalBill")AbnormalBill abnormalBill);
}

@ -162,6 +162,11 @@ public interface AbnormalBillService extends IService<AbnormalBill> {
*/
MessageType findMessageTypeByStatusAndUserGroup(Message message, AbnormalBill abnormalBill, AbnormalBillDispose abnormalBillDispose);
void saveDutyMessageAndResolveMessageByNodeIsResponse(Message paramMessage);
/**
*
* @param paramMessage
* @param userGroup
*/
void saveDutyMessageAndResolveMessageByNodeIsResponse(Message paramMessage,String userGroup);
}

@ -1,5 +1,8 @@
package com.foreverwin.mesnac.anomaly.service;
import com.foreverwin.mesnac.anomaly.model.AbnormalBill;
import com.foreverwin.mesnac.common.model.Message;
/**
* @Description TODO
* @Author zhaojiawei
@ -12,4 +15,13 @@ public interface AnomalyJobService {
* @param site
*/
void anomalyJobProcess(String site);
/**
*
* @param abnormalBill
* @param message
* @param site
* @return
*/
String formatMessageJob(AbnormalBill abnormalBill, Message message, String site);
}

@ -187,6 +187,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
private UploadPicturesMapper uploadPicturesMapper;
@Override
public IPage<AbnormalBill> selectPage(FrontPage<AbnormalBill> frontPage, AbnormalBill abnormalBill) {
QueryWrapper<AbnormalBill> queryWrapper = new QueryWrapper<>();
@ -480,7 +481,10 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalBill.setResponseDateTime(now);
abnormalBill.setStatus(Constants.RESPONSE);
this.saveOrUpdate(abnormalBill);
//发送消息
//发送消息.设备异常响应暂时不会发送消息。
if(StringUtils.notBlank(abnormalBill.getType()) && Constants.ABNORMAL_RESRCE.equals(abnormalBill.getType())){
return ;
}
this.anomalyCreatedAndSendMessage(abnormalBillMapper.selectById(abnormalBill.getHandle()),null);
}
@ -1019,6 +1023,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
//得到要发送的消息
abnormalMessage.setContent(message);
List<Message> messages = null;
//设置发送的用户组和异常节点
switch (abnormalBill.getStatus()){
//新建
@ -1034,7 +1039,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalMessage1.setObjectBo(abnormalBill.getHandle());
abnormalMessage1.setNode(Constants.ABNORMAL_MESSAGE_REPORT);
abnormalMessage1.setGrade(Double.parseDouble("1"));
List<Message> messages = messageService.selectList(abnormalMessage1);
messages = messageService.selectList(abnormalMessage1);
// Message _abnormalMessage = messageMapper.selectOne(wrapper);
if(messages.size() > 0) {
abnormalMessage.setUpUserGroup(messages.get(0).getUpUserGroup());
@ -1116,6 +1121,9 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
MessageType messageTypeUp = messageTypeMapper.findMessageTypeByUserGroup(site, abnormalMessage.getUpUserGroup());
//得到升级的消息类型
if(messageTypeUp == null){
throw new BaseException("用户组"+abnormalMessage.getSendUserGroup()+"的升级用户没有维护消息类型");
}
abnormalMessage.setUpMessageType(messageTypeUp.getMessageType());
}
@ -1127,7 +1135,9 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
//如果是响应状态的话,,并且要设置其超时时间和节点和状态,并关闭新建状态的消息
if (Constants.RESPONSE.equals(abnormalBill.getStatus())) {
this.saveDutyMessageAndResolveMessageByNodeIsResponse(abnormalMessage);
if(messages != null && messages.size() > 0) {
this.saveDutyMessageAndResolveMessageByNodeIsResponse(abnormalMessage,messages.get(0).getSendUserGroup());
}
return true;
}
//发送消息
@ -1167,7 +1177,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
throw new BaseException("异常提报时找不到要发送的消息类型");
}
//找到要替换的消息
Map<String, String> replaceMessage = abnormalBillMapper.findReplaceMessageByAbnoraml(abnormalBill);
Map<String, String> replaceMessage = abnormalBillMapper.findReplaceMessageByAbnormal(abnormalBill);
String messageBody = sendMessageType.getBody();
//格式化之后的消息
return StringUtils.format(messageBody, replaceMessage);
@ -1259,8 +1269,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
// messageMap.put("ROUTER",messageContent.getRouterDescription());
// messageMap.put("RESOLVE_SHOP_ORDER",messageContent.getResolveShopOrder());
// }
}
@Override
@ -1399,7 +1407,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
@Override
public void saveDutyMessageAndResolveMessageByNodeIsResponse(Message paramMessage) {
public void saveDutyMessageAndResolveMessageByNodeIsResponse(Message paramMessage,String userGroup) {
Message message = new Message();
String uuid = UUID.randomUUID().toString();
message.setHandle(uuid);
@ -1419,7 +1427,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
message.setCreatedDateTime(paramMessage.getCreatedDateTime());
message.setModifiedUser(paramMessage.getModifiedUser());
message.setModifiedDateTime(paramMessage.getModifiedDateTime());
UserGroup customFieldByGroup = userGroupMapper.getCustomFieldByGroup(message.getSite(), message.getUpUserGroup());
UserGroup customFieldByGroup = userGroupMapper.getCustomFieldByGroup(message.getSite(), userGroup);
message.setUpDateTime(message.getResponseDateTime().plusMinutes(Integer.parseInt(customFieldByGroup.getMessageDutyTime())));
paramMessage.setUpDateTime(message.getResponseDateTime().plusMinutes(Integer.parseInt(customFieldByGroup.getMessageResolveTime())));
message.setNode(Constants.ABNORMAL_MESSAGE_RESPONSE_DUTY);

@ -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);
}
}

@ -973,7 +973,7 @@
<select id="backLog" resultMap="abnormalBillDto">
SELECT ROW_NUMBER() OVER(ORDER BY ZAB.ABNORMAL_NO ASC) SEQ,ZAB.ABNORMAL_NO ABNORMAL_NO,
CASE WHEN ZAB.CORRECTION = 'true' AND ZAB.PROGRAM = 'true' THEN '纠防确认,方案确认'
CASE WHEN ZAB.CORRECTION = 'true' AND ZAB.PROGRAM = 'true' AND ZAB.STATUS != 'G' THEN '纠防确认,方案确认'
ELSE ZAB.STATUS
END STATUS ,
IT.DESCRIPTION ITEM_DESCRIPTION, ZAB.CREATED_DATE_TIME CREATED_DATE_TIME,
@ -1253,7 +1253,7 @@
ORDER BY zab.CREATED_DATE_TIME DESC
</select>
<select id="findReplaceMessageByAbnoraml" resultType="java.util.HashMap">
<select id="findReplaceMessageByAbnormal" resultType="java.util.HashMap">
SELECT wct.DESCRIPTION WORKCENTER,so.SHOP_ORDER SHOPORDER ,
it.DESCRIPTION ITEM,zab.WORK_ORDER WORK_ORDER,zab.ITEM_NUMBER PROJECT,
LISTAGG(nct.DESCRIPTION , ',') WITHIN GROUP(ORDER BY zab.ABNORMAL_NO) NC,
@ -1267,7 +1267,8 @@
WHEN zabd.ABNORMAL_METHOD = 'FW' THEN '返修(外协)'
WHEN zabd.ABNORMAL_METHOD = 'FB' THEN '返修(不返回原工艺)'
ELSE ''
END ABNORMAL_METHOD,
END METHOD,
zab.ABNORMAL_NO ABNORMAL_NO
FROM Z_ABNORMAL_BILL zab
INNER JOIN ITEM i ON i.HANDLE = zab.ITEM_BO
LEFT JOIN RESRCE r ON r.RESRCE = zab.RESRCE AND r.SITE = zab.SITE
@ -1293,7 +1294,7 @@
</if>
</where>
GROUP BY wct.DESCRIPTION ,so.SHOP_ORDER ,it.DESCRIPTION,r.DESCRIPTION,r2.DESCRIPTION,
zab.WORK_ORDER,zab.ITEM_NUMBER,zabd.ABNORMAL_METHOD
zab.WORK_ORDER,zab.ITEM_NUMBER,zabd.ABNORMAL_METHOD,zab.ABNORMAL_NO
</select>
</mapper>

@ -6,6 +6,8 @@ import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.DecimalFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created by Administrator on 2018/8/20.
@ -203,18 +205,18 @@ public class StringUtils {
String key = map.getKey();
String value = map.getValue();
String keyStr = '#' + key + '#';
if (message.contains(keyStr)) {
if(StringUtils.isEmpty(value)){
message = message.replace(keyStr, "");
message = message.replace(keyStr, "[空]");
}else {
message = message.replace(keyStr, value);
message = message.replace(keyStr, "["+value+"]");
}
}
}
Pattern pattern = Pattern.compile("#.*#");
Matcher matcher = pattern.matcher(message);
message = matcher.replaceAll("[空]");
return message;
}

@ -572,7 +572,7 @@
</delete>
<!-- BaseMapper标准查询/修改/删除 -->
<select id="selectAllByUserGroups" resultMap="BaseResultMap">
SELECT ZNU.USER_NAME USER_NAME,ZNU.FULL_NAME FULL_NAME
SELECT ZNU.USER_NAME USER_NAME,ZNU.FULL_NAME FULL_NAME,ZNU.PHONE PHONE
FROM USER_GROUP UG
INNER JOIN USER_GROUP_MEMBER UGM ON UG.HANDLE = UGM.USER_GROUP_BO
INNER JOIN USR ON UGM.USER_OR_GROUP_GBO = USR.HANDLE

Loading…
Cancel
Save