Merge remote-tracking branch 'origin/master'

master
philip 3 years ago
commit 7c14b9ab98

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

@ -1029,38 +1029,46 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
//响应中,设置响应超时的用户的发送的用户组为提报时要升级的用户组
case Constants.RESPONSE:
Message abnormalMessage1 = new Message();
abnormalMessage1.setSite(site);
abnormalMessage1.setObjectBo(abnormalBill.getHandle());
abnormalMessage1.setNode(Constants.ABNORMAL_MESSAGE_REPORT);
abnormalMessage1.setGrade(Double.parseDouble("1"));
// QueryWrapper<Message> wrapper = new QueryWrapper<>();
// wrapper.setEntity(abnormalMessage1);
List<Message> 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<Message> 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<Message> 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<AbnormalBillMapper, Abn
//设置状态新建是N响应为N纠防确认是N方案确认是Y取消是Y,N为可以升级Y为不可以升级
if(Constants.ABNORMAL_MESSAGE_RESPONSE.equals(abnormalMessage.getNode()) ||
Constants.ABNORMAL_MESSAGE_REPORT.equals(abnormalMessage.getNode())){
//设置状态新建是N,响应比较特殊,在下面设置
if(Constants.ABNORMAL_MESSAGE_REPORT.equals(abnormalMessage.getNode())){
abnormalMessage.setStatus("N");
}else{
abnormalMessage.setStatus("Y");
}
//得到升级的用户组、升级的时间和等级、升级的消息
//新建有、响应没有、纠防确认没有、方案确认没有、取消没有、关闭没有
if(Constants.NEW.equals(abnormalBill.getStatus()) ){
@ -1116,6 +1124,12 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalMessage.setModifiedUser(user);
abnormalMessage.setModifiedDateTime(now);
//如果是响应状态的话,,并且要设置其超时时间和节点和状态,并关闭新建状态的消息
if (Constants.RESPONSE.equals(abnormalBill.getStatus())) {
this.saveDutyMessageAndResolveMessageByNodeIsResponse(abnormalMessage);
return true;
}
//发送消息
if(!Constants.ABNORMAL_MESSAGE_RESPONSE.equals(abnormalMessage.getNode())){
List<NwaUser> nwaUsers = nwaUserService.checkUserGroup(site,abnormalMessage.getSendUserGroup());
@ -1136,6 +1150,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
activeMQUtil.wechatSendMessage(sendUsers.toString(),abnormalMessage.getContent());
}
messageService.saveOrUpdate(abnormalMessage);
return true;
}
@ -1291,6 +1306,9 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
//查询质量异常记录数量 处置工艺路线及不良代码
SplitSfcDto splitSfcDto=splitSfcMapper.getAbnormalQty(site,sfc,operation, abnormalNo);
if(splitSfcDto == null){
throw new BaseException("没有找到报废的信息");
}
String routerBo = splitSfcDto.getRouterBo();
String ncCode = splitSfcDto.getNcCode();
@ -1380,7 +1398,50 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
}
@Override
public void saveDutyMessageAndResolveMessageByNodeIsResponse(Message paramMessage) {
Message message = new Message();
String uuid = UUID.randomUUID().toString();
message.setHandle(uuid);
message.setSite(paramMessage.getSite());
message.setObjectBo(paramMessage.getObjectBo());
message.setType(paramMessage.getType());
message.setMessageType(paramMessage.getMessageType());
message.setSendUserGroup(paramMessage.getSendUserGroup());
message.setSendUser(paramMessage.getSendUser());
message.setContent(paramMessage.getContent());
message.setUpUserGroup(paramMessage.getUpUserGroup());
message.setUpUser(paramMessage.getUpUser());
message.setUpMessageType(paramMessage.getUpMessageType());
message.setResponseDateTime(paramMessage.getResponseDateTime());
message.setGrade(paramMessage.getGrade());
message.setCreatedUser(paramMessage.getCreatedUser());
message.setCreatedDateTime(paramMessage.getCreatedDateTime());
message.setModifiedUser(paramMessage.getModifiedUser());
message.setModifiedDateTime(paramMessage.getModifiedDateTime());
UserGroup customFieldByGroup = userGroupMapper.getCustomFieldByGroup(message.getSite(), message.getUpUserGroup());
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);
paramMessage.setNode(Constants.ABNORMAL_MESSAGE_RESPONSE_RESOLVE);
paramMessage.setStatus("N");
message.setStatus("N");
List<Message> messages = new ArrayList<>();
messages.add(message);
messages.add(paramMessage);
//关闭新建状态的消息
//找到新建状态的,并关闭
UpdateWrapper<Message> 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<String, String> jgProductionIsScrap(String abnormalNo, String site, String sfc) {
@ -1513,5 +1574,4 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
inspectionTaskService.save(newInspectionTask);
}
}

@ -15,8 +15,9 @@ import com.foreverwin.mesnac.listener.mapper.UsrMapper;
import com.foreverwin.mesnac.meapi.mapper.UserGroupMapper;
import com.foreverwin.mesnac.meapi.model.NwaUser;
import com.foreverwin.mesnac.meapi.service.NwaUserService;
import com.foreverwin.modular.core.exception.BaseException;
import com.foreverwin.modular.core.util.CommonMethods;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -59,6 +60,7 @@ public class AnomalyJobServiceImpl implements AnomalyJobService {
@Autowired
private UsrMapper usrMapper;
private static Logger logger = LoggerFactory.getLogger(AnomalyJobServiceImpl.class);
@Override
public void anomalyJobProcess(String site) {
@ -99,7 +101,6 @@ public class AnomalyJobServiceImpl implements AnomalyJobService {
AbnormalBill abnormalBill = abnormalBillMapper.selectById(abnormalMessage.getObjectBo());
//设置UP_DATE_TIME、UP_MESSAGE_TYPE、GRADE、RESPONSE_DATE_TIME、ABNORMAL_NODE、STATUS
abnormalMessage.setUpMessageType(null);
abnormalMessage.setUpDateTime(null);
@ -116,10 +117,13 @@ public class AnomalyJobServiceImpl implements AnomalyJobService {
//根据异常消息的节点来判断所处的状态
if(Constants.ABNORMAL_MESSAGE_REPORT.equals(abnormalMessage.getNode())){
abnormalMessage.setContent(message+",现已超时未响应");
}else if(Constants.ABNORMAL_MESSAGE_RESPONSE.equals(abnormalMessage.getNode())){
//走判责提交和方案确认
}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);
@ -127,34 +131,14 @@ public class AnomalyJobServiceImpl implements AnomalyJobService {
abnormalMessage.setModifiedUser(user);
abnormalMessage.setModifiedDateTime(now);
// if(Constants.ABNORMAL_MESSAGE_PROGRAM_CONFIRM.equals(abnormalMessage.getAbnormalNode())){
// String sendUsers = abnormalMessage.getSendUser().replace(',', '|');
// activeMQUtil.wechatSendMessage(sendUsers,abnormalMessage.getContent());
// }else if(!Constants.ABNORMAL_MESSAGE_RESPONSE.equals(abnormalMessage.getAbnormalNode())){
// 判断是否有该用户组
// List<NwaUser> 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<NwaUser> nwaUsers = nwaUserService.checkUserGroup(site,abnormalMessage.getSendUserGroup());
if(nwaUsers != null && nwaUsers.size() <= 0){
throw new BaseException("消息发送失败,发送的用户组下面没有用户");
logger.info("消息发送失败,发送的用户组下面没有用户") ;
}
List<String> 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++) {

@ -1254,9 +1254,11 @@
</select>
<select id="findReplaceMessageByAbnoraml" resultType="java.util.HashMap">
SELECT wct.DESCRIPTION WORKCENTER,so.SHOP_ORDER SHOPORDER ,item.VALUE PROJECT,it.DESCRIPTION ITEM,
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,
r.DESCRIPTION "RESOURCE",r2.DESCRIPTION WORKCENTER_LIN
r.DESCRIPTION "RESOURCE",r2.DESCRIPTION WORKCENTER_LIN,
zabd.ABNORMAL_METHOD METHOD
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
@ -1267,7 +1269,8 @@
LEFT JOIN WORK_CENTER wc ON wc.WORK_CENTER = zab.WORK_CENTER AND wc.SITE = zab.SITE
LEFT JOIN WORK_CENTER_T wct ON wct.WORK_CENTER_BO = wc.HANDLE AND wct.LOCALE = 'zh'
LEFT JOIN SHOP_ORDER so ON so.SHOP_ORDER = zab.SHOP_ORDER AND so.SITE = zab.SITE
LEFT JOIN CUSTOM_FIELDS item ON item.HANDLE = so.HANDLE AND item."ATTRIBUTE" = 'ITEM_NUMBER'
-- LEFT JOIN CUSTOM_FIELDS item ON item.HANDLE = so.HANDLE AND item."ATTRIBUTE" = 'ITEM_NUMBER'
-- LEFT JOIN CUSTOM_FIELDS workOrder on workOrder.HANDLE = so.HANDLE AND workOrder."ATTRIBUTE" = 'WORK_ORDER'
LEFT JOIN ROUTER r2 ON r2.HANDLE = so.PLANNED_ROUTER_BO
<where>
<if test="abnormalBill != null">
@ -1280,7 +1283,8 @@
</if>
</if>
</where>
GROUP BY wct.DESCRIPTION ,so.SHOP_ORDER ,item.VALUE ,it.DESCRIPTION,r.DESCRIPTION,r2.DESCRIPTION
GROUP BY wct.DESCRIPTION ,so.SHOP_ORDER ,it.DESCRIPTION,r.DESCRIPTION,r2.DESCRIPTION,
zab.WORK_ORDER,zab.ITEM_NUMBER,zabd.ABNORMAL_METHOD
</select>
</mapper>

@ -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";//方案确认超时
/**
*

@ -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("消息发送失败");
}
}

@ -44,6 +44,10 @@ public class UserGroup extends Model<UserGroup> {
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<UserGroup> {
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";

@ -14,6 +14,8 @@
<result column="MODIFIED_DATE_TIME" property="modifiedDateTime" />
<result column="MESSAGE_NOTICE_LEVEL" property="messageNoticeLevel"/>
<result column="MESSAGE_NOTICE_TIME" property="messageNoticeTime"/>
<result column="MESSAGE_DUTY_TIME" property="messageDutyTime"/>
<result column="MESSAGE_RESOLVE_TIME" property="messageResolveTime"/>
</resultMap>
<!-- 通用查询结果列 -->
@ -352,10 +354,13 @@
</if>
</select>
<select id="getCustomFieldByGroup" resultMap="BaseResultMap">
SELECT CF.VALUE MESSAGE_NOTICE_LEVEL, CF2.VALUE MESSAGE_NOTICE_TIME
SELECT CF.VALUE MESSAGE_NOTICE_LEVEL, CF2.VALUE MESSAGE_NOTICE_TIME,
CF3.VALUE MESSAGE_DUTY_TIME,CF4.VALUE MESSAGE_RESOLVE_TIME
FROM USER_GROUP UG
LEFT JOIN CUSTOM_FIELDS CF ON CF.HANDLE = UG.HANDLE AND CF."ATTRIBUTE" = 'MESSAGE_NOTICE_LEVEL'
LEFT JOIN CUSTOM_FIELDS CF2 ON CF2.HANDLE = UG.HANDLE AND CF2."ATTRIBUTE" = 'MESSAGE_NOTICE_TIME'
LEFT JOIN CUSTOM_FIELDS CF3 ON CF3.HANDLE = UG.HANDLE AND CF3."ATTRIBUTE" = 'MESSAGE_DUTY_TIME'
LEFT JOIN CUSTOM_FIELDS CF4 ON CF4.HANDLE = UG.HANDLE AND CF4."ATTRIBUTE" = 'MESSAGE_RESOLVE_TIME'
WHERE UG.USER_GROUP = #{userGroup} AND UG.SITE = #{site}
</select>

Loading…
Cancel
Save