|
|
|
@ -7,8 +7,10 @@ import com.foreverwin.mesnac.anomaly.dto.AbnormalBillDisposeDto;
|
|
|
|
|
import com.foreverwin.mesnac.anomaly.dto.AbnormalBillDto;
|
|
|
|
|
import com.foreverwin.mesnac.anomaly.mapper.AbnormalBillDisposeMapper;
|
|
|
|
|
import com.foreverwin.mesnac.anomaly.mapper.AbnormalBillMapper;
|
|
|
|
|
import com.foreverwin.mesnac.anomaly.mapper.AbnormalMessageMapper;
|
|
|
|
|
import com.foreverwin.mesnac.anomaly.model.*;
|
|
|
|
|
import com.foreverwin.mesnac.anomaly.service.*;
|
|
|
|
|
import com.foreverwin.mesnac.anomaly.util.ActiveMQUtil;
|
|
|
|
|
import com.foreverwin.mesnac.common.constant.Constants;
|
|
|
|
|
import com.foreverwin.mesnac.common.enums.HandleEnum;
|
|
|
|
|
import com.foreverwin.mesnac.common.helper.NextNumberHelper;
|
|
|
|
@ -119,6 +121,15 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
@Autowired
|
|
|
|
|
private UserGroupMapper userGroupMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ActiveMQUtil activeMQUtil;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private AbnormalMessageMapper abnormalMessageMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private AbnormalMessageService abnormalMessageService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public IPage<AbnormalBill> selectPage(FrontPage<AbnormalBill> frontPage, AbnormalBill abnormalBill) {
|
|
|
|
|
QueryWrapper<AbnormalBill> queryWrapper = new QueryWrapper<>();
|
|
|
|
@ -142,6 +153,8 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
String message = this.generateAbnormalBill(abnormalBill, abnormalBillDispose, dutyCauseType, dutyType);
|
|
|
|
|
this.saveOrUpdate(abnormalBill);
|
|
|
|
|
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
|
|
|
|
|
//发送消息
|
|
|
|
|
this.anomalyCreatedAndSendMessage(abnormalBill,null);
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -196,6 +209,8 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
}
|
|
|
|
|
this.saveOrUpdate(abnormalBill);
|
|
|
|
|
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
|
|
|
|
|
//发送消息
|
|
|
|
|
this.anomalyCreatedAndSendMessage(abnormalBill,null);
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -203,21 +218,21 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
@Override
|
|
|
|
|
public String anomalyReportDevice(AbnormalBill abnormalBill,AbnormalBillDispose abnormalBillDispose) {
|
|
|
|
|
String message = this.generateAbnormalBill(abnormalBill, abnormalBillDispose, null, null);
|
|
|
|
|
this.saveOrUpdate(abnormalBill);
|
|
|
|
|
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
|
|
|
|
|
//判断设备异常是否有为处理完成的sfc
|
|
|
|
|
if(!StringUtil.isBlank(abnormalBill.getSfc()) ){
|
|
|
|
|
List<String> status = new ArrayList<>();
|
|
|
|
|
status.add(Constants.PROGRAM_CONFIRM);
|
|
|
|
|
status.add(Constants.CANCEL);
|
|
|
|
|
status.add(Constants.SHUT_DOWN);
|
|
|
|
|
List<AbnormalBill> abnormalBillList = abnormalBillMapper.findCountBySfc(abnormalBill.getSite(), abnormalBill.getType(), abnormalBill.getSfc(), status);
|
|
|
|
|
|
|
|
|
|
if(abnormalBillList.size() > 1 && !"更新成功".equals(message)){
|
|
|
|
|
throw BusinessException.build("设备异常有未处理完成的sfc");
|
|
|
|
|
}else if(abnormalBillList.size() > 1 ){
|
|
|
|
|
if(abnormalBillList.size() >= 1 ){
|
|
|
|
|
throw BusinessException.build("设备异常有未处理完成的sfc");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
|
|
|
|
|
this.saveOrUpdate(abnormalBill);
|
|
|
|
|
//发送消息
|
|
|
|
|
this.anomalyCreatedAndSendMessage(abnormalBill,null);
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -311,6 +326,8 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
abnormalBill.setResponseDateTime(now);
|
|
|
|
|
abnormalBill.setStatus(Constants.RESPONSE);
|
|
|
|
|
this.saveOrUpdate(abnormalBill);
|
|
|
|
|
//发送消息
|
|
|
|
|
this.anomalyCreatedAndSendMessage(abnormalBillMapper.selectById(abnormalBill.getHandle()),null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -354,9 +371,12 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
abnormalBillDispose.setResolveDateTime(now);
|
|
|
|
|
abnormalBillDispose.setResolveUser(user);
|
|
|
|
|
abnormalBill.setStatus(Constants.PROGRAM_CONFIRM);
|
|
|
|
|
|
|
|
|
|
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
|
|
|
|
|
this.saveOrUpdate(abnormalBill);
|
|
|
|
|
|
|
|
|
|
this.anomalyCreatedAndSendMessage(abnormalBillMapper.selectById(abnormalBill.getHandle()),abnormalBillDispose);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -378,6 +398,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
|
|
|
|
|
nwaUserService.checkUserGroup(abnormalBillDispose.getDutySendUserGroup());
|
|
|
|
|
this.saveOrUpdate(abnormalBill);
|
|
|
|
|
this.anomalyCreatedAndSendMessage(abnormalBillMapper.selectById(abnormalBill.getHandle()),abnormalBillDispose);
|
|
|
|
|
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -399,43 +420,56 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
abnormalBill.setStatus(Constants.SHUT_DOWN);
|
|
|
|
|
abnormalBillDispose.setClosedUser(user);
|
|
|
|
|
abnormalBillDispose.setClosedDateTime(now);
|
|
|
|
|
this.anomalyCreatedAndSendMessage(abnormalBill,abnormalBillDispose);
|
|
|
|
|
this.saveOrUpdate(abnormalBill);
|
|
|
|
|
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String generateAbnormalBill(AbnormalBill abnormalBill, AbnormalBillDispose abnormalBillDispose,List<String> dutyCauseType,List<String> dutyType) {
|
|
|
|
|
String site = CommonMethods.getSite();
|
|
|
|
|
String message = null;
|
|
|
|
|
//返回的消息
|
|
|
|
|
String message = "保存成功";
|
|
|
|
|
LocalDateTime currentTime = LocalDateTime.now();
|
|
|
|
|
String user = CommonMethods.getUser();
|
|
|
|
|
//如果前台传过来的异常单为空的话,则抛出一个异常
|
|
|
|
|
if(StringUtil.isBlank(abnormalBill.getAbnormalNo())) {
|
|
|
|
|
throw BusinessException.build("异常单号不存在");
|
|
|
|
|
}
|
|
|
|
|
//设置异常单的handle
|
|
|
|
|
abnormalBill.setHandle(HandleEnum.Z_ABNORMAL_BILL.getHandle(site,abnormalBill.getAbnormalNo()));
|
|
|
|
|
//更新的时候,判断该异常单的状态是否为新建
|
|
|
|
|
AbnormalBill abnormalBill1 = abnormalBillMapper.selectById(abnormalBill.getHandle());
|
|
|
|
|
if(abnormalBill1 != null){
|
|
|
|
|
if(!"N".equals(abnormalBill1.getStatus()) && StringUtil.isBlank(abnormalBillDispose.getClosedUser())){
|
|
|
|
|
throw BusinessException.build("该异常单已经被人处理,不能进行更新");
|
|
|
|
|
}
|
|
|
|
|
message = "更新成功";
|
|
|
|
|
}else{
|
|
|
|
|
message = "保存成功";
|
|
|
|
|
if(abnormalBillMapper.selectById(abnormalBill.getHandle()) != null &&
|
|
|
|
|
!Constants.SHUT_DOWN.equals(abnormalBill.getStatus())){
|
|
|
|
|
throw BusinessException.build("该异常单已经提交,请清空后提交");
|
|
|
|
|
}
|
|
|
|
|
abnormalBillDispose.setClosedUser(null);
|
|
|
|
|
/**
|
|
|
|
|
* 取消异常提报的更新
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//更新的时候,判断该异常单的状态是否为新建,如果为新建,则可以修改,否则就不能进行修改
|
|
|
|
|
// AbnormalBill abnormalBill1 = abnormalBillMapper.selectById(abnormalBill.getHandle());
|
|
|
|
|
// if(abnormalBill1 != null){
|
|
|
|
|
// if(!"N".equals(abnormalBill1.getStatus()) && StringUtil.isBlank(abnormalBillDispose.getClosedUser())){
|
|
|
|
|
// throw BusinessException.build("该异常单已经被人处理,不能进行更新");
|
|
|
|
|
// }
|
|
|
|
|
// message = "更新成功";
|
|
|
|
|
// }else{
|
|
|
|
|
// message = "保存成功";
|
|
|
|
|
// }
|
|
|
|
|
// abnormalBillDispose.setClosedUser(null);
|
|
|
|
|
//设置异常单详细表的handle和abnormalBillBo
|
|
|
|
|
abnormalBillDispose.setAbnormalBillBo(abnormalBill.getHandle());
|
|
|
|
|
abnormalBillDispose.setHandle(HandleEnum.Z_ABNORMAL_BILL_DISPOSE.getHandle(site,abnormalBill.getAbnormalNo()));
|
|
|
|
|
|
|
|
|
|
//设置责任划分填报人和填报时间
|
|
|
|
|
if(StringUtil.isBlank(abnormalBillDispose.getDutyUser())){
|
|
|
|
|
abnormalBillDispose.setDutyUser(user);
|
|
|
|
|
abnormalBillDispose.setDutyDateTime(currentTime);
|
|
|
|
|
}
|
|
|
|
|
ArrayList<AbnormalCause> causeTypes = new ArrayList<>();
|
|
|
|
|
abnormalBillDispose.setDutyUser(user);
|
|
|
|
|
abnormalBillDispose.setDutyDateTime(currentTime);
|
|
|
|
|
|
|
|
|
|
//判断原因分类是否为空,如果不为空,把它放进Z_ABNORMAL_CAUSE表里面
|
|
|
|
|
ArrayList<AbnormalCause> causeTypes = new ArrayList<>();
|
|
|
|
|
if(dutyCauseType != null && dutyCauseType.size() >= 1){
|
|
|
|
|
for(String cause:dutyCauseType){
|
|
|
|
|
AbnormalCause abnormalCause = new AbnormalCause();
|
|
|
|
@ -458,9 +492,8 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
causeTypes.add(abnormalCause);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 判断工序编码是否传递错误
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//判断工序编码是否传递错误
|
|
|
|
|
if(!StringUtil.isBlank(abnormalBill.getOperation())){
|
|
|
|
|
QueryWrapper<Operation> operationQueryWrapper = new QueryWrapper<Operation>();
|
|
|
|
|
operationQueryWrapper.eq("OPERATION",abnormalBill.getOperation())
|
|
|
|
@ -471,9 +504,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断设备传递的不良代码是否有误
|
|
|
|
|
*/
|
|
|
|
|
//判断设备传递的不良代码是否有误
|
|
|
|
|
if(!StringUtil.isBlank(abnormalBill.getNcCode()) && Constants.ABNORMAL_RESRCE.equals(abnormalBill.getType())){
|
|
|
|
|
List<String> ncCodes = Arrays.asList(abnormalBill.getNcCode().split(","));
|
|
|
|
|
Integer length = ncCodeMapper.checkNcCode(ncCodes,site,"FAILURE");
|
|
|
|
@ -528,6 +559,10 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
if(StringUtil.isBlank(abnormalBill.getSfc()) && !Constants.ABNORMAL_RESRCE.equals(abnormalBill.getType())) {
|
|
|
|
|
throw BusinessException.build("产品条码不能为空");
|
|
|
|
|
}
|
|
|
|
|
//异常提报的时候,提报用户不可以为空
|
|
|
|
|
if(StringUtil.isBlank(abnormalBill.getReportSendUserGroup()) ) {
|
|
|
|
|
throw BusinessException.build("提报用户组不能为空");
|
|
|
|
|
}
|
|
|
|
|
// }else if(!StringUtil.isBlank(abnormalBill.getSfc()) && Constants.ABNORMAL_RESRCE.equals(abnormalBill.getType())){
|
|
|
|
|
// AbnormalBill abnormalBill2 = new AbnormalBill();
|
|
|
|
|
// abnormalBill2.setType(abnormalBill.getType());
|
|
|
|
@ -568,7 +603,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
throw BusinessException.build("问题数量或不良品数量必须为一个正整数");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//判断输入的用户组是否正确,并返回对应的用户
|
|
|
|
|
//判断输入的责任划分用户组是否正确,并返回对应的用户
|
|
|
|
|
nwaUserService.checkUserGroup(abnormalBillDispose.getDutySendUserGroup());
|
|
|
|
|
//插入原因分类和责任分类
|
|
|
|
|
if(dutyTypes.size() > 0){
|
|
|
|
@ -582,10 +617,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
this.fileUpload(abnormalBill);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.anomalyReportSendMessage(abnormalBill);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// this.anomalyCreatedAndSendMessage(abnormalBill,null);
|
|
|
|
|
return message;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -604,6 +636,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
}
|
|
|
|
|
abnormalBill.setCancelUser(CommonMethods.getUser());
|
|
|
|
|
abnormalBill.setCancelDateTime(now);
|
|
|
|
|
this.anomalyCreatedAndSendMessage(abnormalBill,null);
|
|
|
|
|
this.saveOrUpdate(abnormalBill);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
@ -678,9 +711,11 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
if(!Constants.RESPONSE.equals(abnormalBill.getStatus())){
|
|
|
|
|
throw BusinessException.build("该异常单的状态必须是响应中才能转维修");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(StringUtil.isBlank(abnormalBillDispose.getAbnormalMethod())){
|
|
|
|
|
throw BusinessException.build("转维修时方案分类必须填写");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
abnormalBill.setHandle(HandleEnum.Z_ABNORMAL_BILL.getHandle(site,abnormalBill.getAbnormalNo()));
|
|
|
|
|
abnormalBill.setStatus(Constants.SHUT_DOWN);
|
|
|
|
|
abnormalBillDispose.setResolveUser(user);
|
|
|
|
@ -739,18 +774,19 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
if(!HandleEnum.SHOP_ORDER.getHandle(site,shopOrder).equals(sfc1.getShopOrderBo())){
|
|
|
|
|
throw new BaseException("工单传递有误");
|
|
|
|
|
}
|
|
|
|
|
// Resrce resrce = resrceMapper.selectById(HandleEnum.RESOURCE.getHandle(site, resource));
|
|
|
|
|
// if(resrce == null){
|
|
|
|
|
// throw new BaseException("资源传递有误");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
this.anomalyReportDevice(abnormalBill,abnormalBillDispose);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 异常消息的发送
|
|
|
|
|
* @param abnormalBill
|
|
|
|
|
* @param abnormalBillDispose
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public boolean anomalyReportSendMessage(AbnormalBill abnormalBill){
|
|
|
|
|
//得到异常提报用户组下面的用户
|
|
|
|
|
List<NwaUser> sendUsersList = nwaUserService.checkUserGroup(abnormalBill.getReportSendUserGroup());
|
|
|
|
|
public boolean anomalyCreatedAndSendMessage(AbnormalBill abnormalBill,AbnormalBillDispose abnormalBillDispose){
|
|
|
|
|
String site = CommonMethods.getSite();
|
|
|
|
|
String user = CommonMethods.getUser();
|
|
|
|
|
String locale = LocaleContextHolder.getLocale().getLanguage();
|
|
|
|
@ -770,37 +806,123 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
case "Z"://质量异常
|
|
|
|
|
abnormalMessage.setMessageType(Constants.ABNORMAL_MESSAGE_QUALITY);
|
|
|
|
|
break;
|
|
|
|
|
case "Q":
|
|
|
|
|
case "Q"://其他异常
|
|
|
|
|
abnormalMessage.setMessageType(Constants.ABNORMAL_MESSAGE_OTHER);
|
|
|
|
|
break;
|
|
|
|
|
case "S":
|
|
|
|
|
case "S"://设备异常
|
|
|
|
|
abnormalMessage.setMessageType(Constants.ABNORMAL_MESSAGE_RESOURCE);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
//设置发送的用户组
|
|
|
|
|
abnormalMessage.setSendUserGroup(abnormalBill.getReportSendUserGroup());
|
|
|
|
|
//设置发送用户,响应时设置
|
|
|
|
|
// StringBuilder sendUser = new StringBuilder();
|
|
|
|
|
// for (int i = 0; i < sendUsersList.size(); i++) {
|
|
|
|
|
// if(i == (sendUsersList.size() - 1)){
|
|
|
|
|
// sendUser.append(sendUsersList.get(i));
|
|
|
|
|
// }else{
|
|
|
|
|
// sendUser.append(sendUsersList.get(i)).append(",");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// abnormalMessage.setSendUser(sendUser.toString());
|
|
|
|
|
switch (abnormalBill.getStatus()){
|
|
|
|
|
case Constants.NEW://新建
|
|
|
|
|
abnormalMessage.setSendUserGroup(abnormalBill.getReportSendUserGroup());
|
|
|
|
|
abnormalMessage.setAbnormalNode(Constants.ABNORMAL_MESSAGE_REPORT);
|
|
|
|
|
break;
|
|
|
|
|
case Constants.RESPONSE://响应中,设置响应超时的用户的发送的用户组为提报时要升级的用户组
|
|
|
|
|
QueryWrapper<AbnormalMessage> wrapper = new QueryWrapper<>();
|
|
|
|
|
AbnormalMessage abnormalMessage1 = new AbnormalMessage();
|
|
|
|
|
abnormalMessage1.setSite(site);
|
|
|
|
|
abnormalMessage1.setAbnormalBillBo(abnormalBill.getHandle());
|
|
|
|
|
abnormalMessage1.setAbnormalNode(Constants.ABNORMAL_MESSAGE_REPORT);
|
|
|
|
|
wrapper.setEntity(abnormalMessage1);
|
|
|
|
|
AbnormalMessage _abnormalMessage = abnormalMessageMapper.selectOne(wrapper);
|
|
|
|
|
abnormalMessage.setUpUserGroup(_abnormalMessage.getUpUserGroup());
|
|
|
|
|
abnormalMessage.setGrade(_abnormalMessage.getGrade());
|
|
|
|
|
abnormalMessage.setUpDateTime(_abnormalMessage.getUpDateTime());
|
|
|
|
|
abnormalMessage.setAbnormalNode(Constants.ABNORMAL_MESSAGE_RESPONSE);
|
|
|
|
|
break;
|
|
|
|
|
case Constants.CORRECTION_CONFIRM://纠纷确认
|
|
|
|
|
abnormalMessage.setSendUserGroup(abnormalBillDispose.getDutySendUserGroup());
|
|
|
|
|
abnormalMessage.setAbnormalNode(Constants.ABNORMAL_MESSAGE_CORRECTION_CONFIRM);
|
|
|
|
|
break;
|
|
|
|
|
case Constants.PROGRAM_CONFIRM://方案确认
|
|
|
|
|
abnormalMessage.setSendUser(abnormalBillDispose.getResolveSendUser());
|
|
|
|
|
abnormalMessage.setAbnormalNode(Constants.ABNORMAL_MESSAGE_PROGRAM_CONFIRM);
|
|
|
|
|
break;
|
|
|
|
|
case Constants.CANCEL://取消
|
|
|
|
|
abnormalMessage.setSendUserGroup(abnormalBill.getCancelSendUserGroup());
|
|
|
|
|
abnormalMessage.setAbnormalNode(Constants.ABNORMAL_MESSAGE_CANCEL);
|
|
|
|
|
break;
|
|
|
|
|
case Constants.SHUT_DOWN:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String message = this.formatMessage(abnormalBill, abnormalMessage.getMessageType(), site);
|
|
|
|
|
//得到消息触发的时间
|
|
|
|
|
abnormalMessage.setResponseDateTime(now);
|
|
|
|
|
//得到要发送的消息
|
|
|
|
|
abnormalMessage.setContent(message);
|
|
|
|
|
//得到升级的用户组
|
|
|
|
|
//新建有、响应没有、纠防确认有、方案确认没有、取消没有、关闭没有
|
|
|
|
|
if(Constants.NEW.equals(abnormalBill.getStatus()) || Constants.CORRECTION_CONFIRM.equals(abnormalBill.getStatus())){
|
|
|
|
|
abnormalMessage.setUpUserGroup(abnormalMessage.getSendUserGroup()+"_UP");
|
|
|
|
|
//得到升级的时间和等级
|
|
|
|
|
|
|
|
|
|
UserGroup customFieldByGroup = userGroupMapper.getCustomFieldByGroup(site, abnormalMessage.getSendUserGroup());
|
|
|
|
|
abnormalMessage.setUpDateTime(abnormalMessage.getResponseDateTime().plusMinutes(Integer.parseInt(customFieldByGroup.getMessageNoticeTime())));
|
|
|
|
|
abnormalMessage.setGrade(customFieldByGroup.getMessageNoticeLevel());
|
|
|
|
|
//得到升级的消息类型
|
|
|
|
|
abnormalMessage.setUpMessageType(abnormalMessage.getMessageType());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//得到异常节点
|
|
|
|
|
|
|
|
|
|
//abnormalMessage.setAbnormalNode(Constants.ABNORMAL_MESSAGE_REPORT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//设置状态,新建是Y,响应为N,纠防确认是N,方案确认是Y,
|
|
|
|
|
if(Constants.ABNORMAL_MESSAGE_RESPONSE.equals(abnormalMessage.getAbnormalNode()) ||
|
|
|
|
|
Constants.ABNORMAL_MESSAGE_CORRECTION_CONFIRM.equals(abnormalMessage.getAbnormalNode())){
|
|
|
|
|
abnormalMessage.setStatus("N");
|
|
|
|
|
}else{
|
|
|
|
|
abnormalMessage.setStatus("Y");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abnormalMessage.setCreatedUser(user);
|
|
|
|
|
abnormalMessage.setCreatedDateTime(now);
|
|
|
|
|
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(abnormalMessage.getSendUserGroup());
|
|
|
|
|
StringBuilder sendUsers = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < nwaUsers.size(); i++) {
|
|
|
|
|
if(i == (nwaUsers.size() - 1)){
|
|
|
|
|
sendUsers.append(nwaUsers.get(i));
|
|
|
|
|
}else{
|
|
|
|
|
sendUsers.append(nwaUsers.get(i)).append("|");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
activeMQUtil.wechatSendMessage(sendUsers.toString(),abnormalMessage.getContent());
|
|
|
|
|
}
|
|
|
|
|
abnormalMessageService.saveOrUpdate(abnormalMessage);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String formatMessage(AbnormalBill abnormalBill,String messageType, String site) {
|
|
|
|
|
//找到消息内容
|
|
|
|
|
String locale = LocaleContextHolder.getLocale().getLanguage();
|
|
|
|
|
MessageType messageTypeEntity = new MessageType();
|
|
|
|
|
messageTypeEntity.setSite(site);
|
|
|
|
|
messageTypeEntity.setMessageType(abnormalMessage.getMessageType());
|
|
|
|
|
messageTypeEntity.setMessageType(messageType);
|
|
|
|
|
QueryWrapper<MessageType> messageTypeQueryWrapper = new QueryWrapper<MessageType>();
|
|
|
|
|
messageTypeQueryWrapper.setEntity(messageTypeEntity);
|
|
|
|
|
MessageType messageType = messageTypeMapper.selectOne(messageTypeQueryWrapper);
|
|
|
|
|
MessageType sendMessageType = messageTypeMapper.selectOne(messageTypeQueryWrapper);
|
|
|
|
|
if(messageType == null){
|
|
|
|
|
throw new BaseException("异常提报时找不到要发送的消息类型");
|
|
|
|
|
}
|
|
|
|
|
//格式化消息
|
|
|
|
|
String body = messageType.getBody();
|
|
|
|
|
String body = sendMessageType.getBody();
|
|
|
|
|
//替换消息类型中的参数
|
|
|
|
|
Map<String, String> messageMap = new HashMap<>();
|
|
|
|
|
//根据车间找到对应车间的描述
|
|
|
|
@ -813,49 +935,19 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
Item _item = itemMapper.selectById(locale, abnormalBill.getItemBo());
|
|
|
|
|
String item = _item.getItem() + "/" + _item.getDescription();
|
|
|
|
|
|
|
|
|
|
messageMap.put("WORKCENTER",workCenter.getDescription());
|
|
|
|
|
messageMap.put("WORKCENTER_LIN",line.getDescription());
|
|
|
|
|
messageMap.put("PROJECT",projectNo.getItemNumber());
|
|
|
|
|
if(workCenter != null){
|
|
|
|
|
messageMap.put("WORKCENTER",workCenter.getDescription());
|
|
|
|
|
}
|
|
|
|
|
if(line != null){
|
|
|
|
|
messageMap.put("WORKCENTER_LIN",line.getDescription());
|
|
|
|
|
}
|
|
|
|
|
if(projectNo != null){
|
|
|
|
|
messageMap.put("PROJECT",projectNo.getItemNumber());
|
|
|
|
|
}
|
|
|
|
|
messageMap.put("SHOPORDER",abnormalBill.getWorkCenter());
|
|
|
|
|
messageMap.put("ITEM",item);
|
|
|
|
|
String message = StringUtils.format(body, messageMap);
|
|
|
|
|
//得到要发送的消息
|
|
|
|
|
abnormalMessage.setContent(message);
|
|
|
|
|
//得到升级的用户组
|
|
|
|
|
// List<String> _upSendUserGroups = Arrays.asList(abnormalMessage.getSendUserGroup().split(","));
|
|
|
|
|
// for(int i = 0; i < _upSendUserGroups.size(); i++){
|
|
|
|
|
// _upSendUserGroups.set(i,_upSendUserGroups.get(i)+"_UP");
|
|
|
|
|
// }
|
|
|
|
|
// List<UserGroup> upSendUserGroups = userGroupMapper.getUserGroupListByGroups(site, _upSendUserGroups);
|
|
|
|
|
// if(upSendUserGroups != null && upSendUserGroups.size() > 0){
|
|
|
|
|
// abnormalMessage.setUpUserGroup(upSendUserGroups.get(0).getUserGroup());
|
|
|
|
|
// }
|
|
|
|
|
//得到升级的用户组
|
|
|
|
|
abnormalMessage.setUpUserGroup(abnormalMessage.getSendUserGroup()+"_UP");
|
|
|
|
|
//得到升级的消息类型
|
|
|
|
|
abnormalMessage.setUpMessageType(abnormalMessage.getMessageType());
|
|
|
|
|
//得到消息触发的时间
|
|
|
|
|
abnormalMessage.setResponseDateTime(now);
|
|
|
|
|
//得到升级的时间和等级
|
|
|
|
|
UserGroup customFieldByGroup = userGroupMapper.getCustomFieldByGroup(site, abnormalMessage.getSendUserGroup());
|
|
|
|
|
abnormalMessage.setUpDateTime(abnormalMessage.getResponseDateTime().plusMinutes(Integer.parseInt(customFieldByGroup.getMessageNoticeTime())));
|
|
|
|
|
abnormalMessage.setGrade(customFieldByGroup.getMessageNoticeLevel());
|
|
|
|
|
//得到异常节点
|
|
|
|
|
abnormalMessage.setAbnormalNode(Constants.ABNORMAL_MESSAGE_REPORT);
|
|
|
|
|
//设置状态
|
|
|
|
|
if(Constants.ABNORMAL_MESSAGE_REPORT.equals(abnormalMessage.getAbnormalNode())){
|
|
|
|
|
abnormalMessage.setStatus("Y");
|
|
|
|
|
}else{
|
|
|
|
|
abnormalMessage.setStatus("N");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
abnormalMessage.setCreatedUser(user);
|
|
|
|
|
abnormalMessage.setCreatedDateTime(now);
|
|
|
|
|
abnormalMessage.setModifiedUser(user);
|
|
|
|
|
abnormalMessage.setModifiedDateTime(now);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
//格式化之后的消息
|
|
|
|
|
return StringUtils.format(body, messageMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|