异常bug修改,异常逻辑修改

master
赵嘉伟 3 years ago
parent 55afd862f7
commit 48388b41f7

@ -38,4 +38,6 @@ public interface AbnormalPlanService extends IService<AbnormalPlan> {
List<AbnormalPlanDto> findAbnormalPlan(AbnormalPlanDto abnormalPlanDto);
void processes(List<AbnormalPlan> abnormalPlanList);
void sendMessage(AbnormalBill abnormalBill,AbnormalPlan abnormalPlan);
}

@ -273,6 +273,18 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalNcCodeService.saveOrUpdateBatch(abnormalNcCodes);
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
this.saveOrUpdate(abnormalBill);
/**
* XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX
* XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX
* XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX
* XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX
* XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX
* XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX
* XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX
* XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXX
*/
//发送消息
if(Constants.NEW.equals(abnormalBill.getStatus())){
this.anomalyCreatedAndSendMessage(abnormalBill,null);
@ -585,13 +597,19 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
/**
* SFC sfc
* SFC sfcsfc
*
*
*/
if(StringUtil.isBlank(abnormalBill.getSfc()) && !Constants.ABNORMAL_RESRCE.equals(abnormalBill.getType())) {
if(Constants.ABNORMAL_QUALITY.equals(abnormalBill.getType())){
if(StringUtil.isBlank(abnormalBill.getItemBo())){
throw BusinessException.build("物料编号不能为空");
}
}else{
throw BusinessException.build("产品条码不能为空");
}
}
//异常提报的时候,提报用户组不可以为空
@ -659,12 +677,14 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
status.add(Constants.PROGRAM_CONFIRM);
status.add(Constants.CANCEL);
status.add(Constants.SHUT_DOWN);
if(!StringUtil.isBlank(abnormalBill.getSfc())) {
List<AbnormalBill> abnormalBillList = abnormalBillMapper.findCountBySfc(abnormalBill.getSite(), abnormalBill.getType(), abnormalBill.getSfc(), status);
String abnormalType = abnormalBill.getType().equals(Constants.ABNORMAL_QUALITY) ? "质量异常" :
abnormalBill.getType().equals(Constants.ABNORMAL_OTHER) ? "其他异常" : "设备异常";
if (abnormalBillList.size() >= 1) {
throw BusinessException.build(abnormalType + "有未处理完成的产品条码SFC");
}
}
//设置创建时间和更新时间
@ -779,18 +799,33 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
if(StringUtil.isBlank(abnormalBillDispose.getAbnormalMethod())){
throw BusinessException.build("转维修时方案分类必须填写");
}
abnormalBill.setHandle(HandleEnum.ABNORMAL_BILL.getHandle(site,abnormalBill.getAbnormalNo()));
abnormalBillDispose.setHandle(HandleEnum.ABNORMAL_BILL_DISPOSE.getHandle(site,abnormalBill.getAbnormalNo()));
this.saveOrUpdate(abnormalBill);
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("abnormalBill",abnormalBillMapper.selectById(abnormalBill.getHandle()));
hashMap.put("abnormalBillDispose",abnormalBillDisposeMapper.selectById(HandleEnum.ABNORMAL_BILL_DISPOSE.getHandle(site,abnormalBill.getAbnormalNo())));
return hashMap;
}
@Override
public void anomalyReveseRepairShutDown(String abnormalNo){
String site = CommonMethods.getSite();
String user = CommonMethods.getUser();
LocalDateTime now = LocalDateTime.now();
AbnormalBill abnormalBill = getById(HandleEnum.ABNORMAL_BILL.getHandle(site, abnormalNo));
if(!Constants.RESPONSE.equals(abnormalBill.getStatus())){
throw new BaseException("状态不在响应中,请重新检索");
}
abnormalBill.setHandle(HandleEnum.ABNORMAL_BILL.getHandle(site,abnormalBill.getAbnormalNo()));
abnormalBill.setStatus(Constants.SHUT_DOWN);
AbnormalBillDispose abnormalBillDispose = abnormalBillDisposeMapper.selectById(HandleEnum.ABNORMAL_BILL_DISPOSE.getHandle(site, abnormalBill.getAbnormalNo()));
abnormalBillDispose.setResolveUser(user);
abnormalBillDispose.setResolveDateTime(now);
abnormalBillDispose.setHandle(HandleEnum.ABNORMAL_BILL_DISPOSE.getHandle(site,abnormalBill.getAbnormalNo()));
this.saveOrUpdate(abnormalBill);
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("abnormalBill",abnormalBillMapper.selectById(abnormalBill.getHandle()));
hashMap.put("abnormalBillDispose",abnormalBillDisposeMapper.selectById(abnormalBillDispose.getHandle()));
return hashMap;
}
@Override
@ -980,9 +1015,10 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
//发送消息
if(!Constants.ABNORMAL_MESSAGE_RESPONSE.equals(abnormalMessage.getNode())){
List<NwaUser> nwaUsers = nwaUserService.checkUserGroup(site,abnormalMessage.getSendUserGroup());
if(nwaUsers != null && nwaUsers.size() <= 0){
throw new BaseException("消息发送失败,发送的用户组下面没有用户");
}
StringBuilder sendUsers = new StringBuilder();
for (int i = 0; i < nwaUsers.size(); i++) {
if(i == (nwaUsers.size() - 1)){
sendUsers.append(nwaUsers.get(i).getUserName());
@ -1050,7 +1086,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
messageMap.put("shutDown",AnomalyConstant.ShutDown.msg(messageContent.getShutDown()));
//判断该异常单的状态是否是纠防确认
if(Constants.CORRECTION_CONFIRM.equals(messageContent.getStatus())){
if(Constants.CORRECTION_CONFIRM.equals(messageContent.getStatus()) || Constants.SHUT_DOWN.equals(messageContent.getStatus())){
DataField dataField = new DataField();
dataField.setSite(site);
@ -1091,7 +1127,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
messageMap.put("dutyCauseDescription",messageContent.getDutyCauseDescription());
}
if(Constants.PROGRAM_CONFIRM.equals(messageContent.getStatus())){
if(Constants.PROGRAM_CONFIRM.equals(messageContent.getStatus()) || Constants.SHUT_DOWN.equals(messageContent.getStatus())){
messageMap.put("abnormalMethod",AnomalyConstant.AnomalyMethod.msg(messageContent.getAbnormalMethod()));
messageMap.put("resolveRemark",messageContent.getResolveRemark());
messageMap.put("router",messageContent.getRouterDescription());
@ -1120,7 +1156,8 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
if(this.jgProductionIsScrap(site,sfc)){
throw new BaseException("该产品条码的异常方案不是报废");
}
return abnormalBillMapper.findScrapDtoBySfc(site, sfc);
List<ScrapDto> scrapDtoBySfc = abnormalBillMapper.findScrapDtoBySfc(site, sfc);
return scrapDtoBySfc;
}

@ -16,8 +16,13 @@ import com.foreverwin.mesnac.anomaly.service.AbnormalPlanService;
import com.foreverwin.mesnac.common.constant.Constants;
import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.common.mapper.MessageMapper;
import com.foreverwin.mesnac.common.model.Message;
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.meapi.mapper.UserGroupMapper;
import com.foreverwin.mesnac.meapi.model.NwaUser;
import com.foreverwin.mesnac.meapi.model.UserGroup;
import com.foreverwin.mesnac.meapi.service.NwaUserService;
import com.foreverwin.modular.core.exception.BaseException;
import com.foreverwin.modular.core.util.CommonMethods;
@ -28,7 +33,10 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
/**
* <p>
@ -67,6 +75,9 @@ public class AbnormalPlanServiceImpl extends ServiceImpl<AbnormalPlanMapper, Abn
@Autowired
private AbnormalBillDisposeMapper abnormalBillDisposeMapper;
@Autowired
private UserGroupMapper userGroupMapper;
@Override
public IPage<AbnormalPlan> selectPage(FrontPage<AbnormalPlan> frontPage, AbnormalPlan abnormalPlan) {
@ -98,7 +109,9 @@ public class AbnormalPlanServiceImpl extends ServiceImpl<AbnormalPlanMapper, Abn
abnormalPlan.setShopOrder(abnormalBillDisposeDto.getShopOrder());
abnormalPlan.setResrce(abnormalBillDisposeDto.getResrce());
abnormalPlan.setItemBo(abnormalBillDisposeDto.getItemBo());
if(!StringUtil.isBlank(abnormalBillDisposeDto.getNcQty())){
abnormalPlan.setQty(Long.parseLong(abnormalBillDisposeDto.getNcQty()));
}
//没有处理人和处理时间
// abnormalPlan.setProcessor();
abnormalPlan.setClosedUser(user);
@ -138,11 +151,14 @@ public class AbnormalPlanServiceImpl extends ServiceImpl<AbnormalPlanMapper, Abn
String site = CommonMethods.getSite();
LocalDateTime now = LocalDateTime.now();
String user = CommonMethods.getUser();
List<AbnormalPlan> abnormalPlans = new ArrayList<>();
List<AbnormalBill> abnormalBills = new ArrayList<>();
for (AbnormalPlan abnormalPlan : abnormalPlanList){
AbnormalBill abnormalBill = abnormalBillMapper.selectById(HandleEnum.ABNORMAL_BILL.getHandle(site, abnormalPlan.getAbnormalNo()));
AbnormalBillDispose abnormalBillDispose = abnormalBillDisposeMapper.selectById(HandleEnum.ABNORMAL_BILL_DISPOSE.getHandle(site, abnormalPlan.getAbnormalNo()));
//发送消息
// abnormalBillService.anomalyCreatedAndSendMessage(abnormalBill,abnormalBillDispose);
//设置handle
abnormalPlan.setHandle(HandleEnum.ABNORMAL_PLAN.getHandle(site,abnormalPlan.getAbnormalNo()));
if(Constants.PROCESSED.equals(abnormalPlan.getStatus())){
throw new BaseException("异常单:"+abnormalPlan.getAbnormalNo()+"已经处理,不能再次处理");
}
@ -152,11 +168,66 @@ public class AbnormalPlanServiceImpl extends ServiceImpl<AbnormalPlanMapper, Abn
abnormalPlan.setProcessor(user);
//设置发送时间
abnormalPlan.setSendDateTime(now);
//设置handle
abnormalPlan.setHandle(HandleEnum.ABNORMAL_PLAN.getHandle(site,abnormalPlan.getAbnormalNo()));
abnormalPlans.add(abnormalPlan);
abnormalBills.add(abnormalBill);
}
//发送消息
for(int i = 0; i < abnormalBills.size() && i < abnormalPlans.size(); i++) {
this.sendMessage(abnormalBills.get(i),abnormalPlans.get(i));
}
//更新
this.saveOrUpdate(abnormalPlan);
this.saveOrUpdateBatch(abnormalPlans);
}
@Override
public void sendMessage(AbnormalBill abnormalBill, AbnormalPlan abnormalPlan) {
//创建一个消息记录表
String site = CommonMethods.getSite();
String user = CommonMethods.getUser();
LocalDateTime now = LocalDateTime.now();
Message message = new Message();
message.setHandle(UUID.randomUUID().toString());
message.setSite(site);
message.setObjectBo(abnormalPlan.getHandle());
message.setType(Constants.ABNORMAL_PLAN);
message.setMessageType(Constants.ABNORMAL_MESSAGE_PLAN);
message.setSendUserGroup(abnormalPlan.getSendUserGroup());
//格式化消息内容
String messageContent = abnormalBillService.formatMessage(abnormalBill, message.getMessageType(), site);
message.setContent(messageContent);
message.setResponseDateTime(now);
UserGroup customFieldByGroup = userGroupMapper.getCustomFieldByGroup(site, message.getSendUserGroup());
//得到升级的时间和等级
if(customFieldByGroup != null && !StringUtil.isBlank(customFieldByGroup.getMessageNoticeTime())){
message.setUpDateTime(message.getResponseDateTime().plusMinutes(Integer.parseInt(customFieldByGroup.getMessageNoticeTime())));
}
if(customFieldByGroup != null && !StringUtil.isBlank(customFieldByGroup.getMessageNoticeLevel())) {
message.setGrade(Double.parseDouble(customFieldByGroup.getMessageNoticeLevel()));
}
message.setStatus("Y");
message.setCreatedUser(user);
message.setCreatedDateTime(now);
message.setModifiedUser(user);
message.setModifiedDateTime(now);
//发送消息
List<NwaUser> nwaUsers = nwaUserService.checkUserGroup(site,message.getSendUserGroup());
if(nwaUsers != null && nwaUsers.size() <= 0){
throw new BaseException("消息发送失败,发送的用户组下面没有用户");
}
StringBuilder sendUsers = new StringBuilder();
for (int i = 0; i < Objects.requireNonNull(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(),message.getContent());
messageService.saveOrUpdate(message);
}
}

@ -1091,7 +1091,7 @@
SELECT S.SFC SFC,
S2.STATUS STATUS,
SUBSTR(SS.OPERATION_BO ,INSTR(SS.OPERATION_BO ,',',1)+1,(INSTR(SS.OPERATION_BO ,'#',1)-1)-(INSTR(SS.OPERATION_BO ,',',1)+1)) || '/' || SS.STEP_ID OPERATION,
ZSD2.RESRCE RESRCE,ZSD.SHOP_ORDER SHOP_ORDER,
ZSD2.RESRCE RESRCE,ZSD2.SHOP_ORDER SHOP_ORDER,
CASE WHEN I.ITEM != 'NULL' THEN I.ITEM || '/' || I.REVISION END ITEM,
CASE WHEN R.ROUTER != 'NULL' THEN R.ROUTER || '/' || R.REVISION END ROUTER ,
CASE WHEN B.BOM != 'NULL' THEN B.BOM || '/' || B.REVISION END BOM,
@ -1102,14 +1102,13 @@
FROM SFC S
INNER JOIN SFC_ROUTING SR ON SR.SFC_BO = S.HANDLE
INNER JOIN SFC_ROUTER ST ON ST.SFC_ROUTING_BO = SR.HANDLE
INNER JOIN SFC_STEP SS ON SS.SFC_ROUTER_BO = ST.HANDLE AND (SS.QTY_IN_QUEUE > 0 OR SS.QTY_IN_WORK > 0)
INNER JOIN SFC_STEP SS ON SS.SFC_ROUTER_BO = ST.HANDLE/* AND (SS.QTY_IN_QUEUE > 0 OR SS.QTY_IN_WORK > 0)*/
INNER JOIN STATUS S2 ON S2.HANDLE = S.STATUS_BO
INNER JOIN Z_SFC_DISPATCH ZSD ON ZSD.DISPATCH_NO = S.SFC || '-' || SS.STEP_ID
LEFT JOIN Z_SFC_DISPATCH ZSD2 ON ZSD2.DISPATCH_NO = S.SFC || '-' || SS.STEP_ID
AND ZSD2.DISPATCH_STATUS IN ('START','COMPLETE')
LEFT JOIN SHOP_ORDER SO ON SO.SHOP_ORDER = ZSD.SHOP_ORDER AND SO.SITE = S.SITE
LEFT JOIN SHOP_ORDER SO ON SO.SHOP_ORDER = ZSD2.SHOP_ORDER AND SO.SITE = S.SITE
LEFT JOIN ITEM I ON I.HANDLE = SO.PLANNED_ITEM_BO
LEFT JOIN ROUTER R ON R.HANDLE = ZSD.ROUTER_BO
LEFT JOIN ROUTER R ON R.HANDLE = ZSD2.ROUTER_BO
LEFT JOIN Z_SFC_SCRAP ZSS ON ZSS.SFC = S.SFC AND ZSS.SITE = S.SITE
LEFT JOIN BOM B ON B.HANDLE = SO.PLANNED_BOM_BO
INNER JOIN ( SELECT * FROM Z_ABNORMAL_BILL_VIEW ZABV WHERE ZABV.HANDLE = (SELECT MAX(HANDLE) FROM Z_ABNORMAL_BILL_VIEW ZABV2

@ -124,6 +124,7 @@ public interface Constants {
String ABNORMAL_QUALITY = "Z";
String ABNORMAL_OTHER = "Q";
String ABNORMAL_RESRCE = "S";
String ABNORMAL_PLAN = "P";
/**
*

@ -37,4 +37,6 @@ public interface AnomalyService {
*/
List<ScrapDto> getScrapDtoBysfc(String site, String sfc);
void anomalyReveseRepairShutDown(String abnormalNo);
}

@ -1,10 +1,17 @@
package com.foreverwin.mesnac.equip.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.mesnac.common.constant.Constants;
import com.foreverwin.mesnac.common.enums.HandleEnum;
import com.foreverwin.mesnac.common.helper.NextNumberHelper;
import com.foreverwin.mesnac.common.service.AnomalyService;
import com.foreverwin.mesnac.equip.mapper.ResourceRepairTaskMapper;
import com.foreverwin.mesnac.equip.model.ResourceInspectTaskSpare;
import com.foreverwin.mesnac.equip.model.ResourceRepairTask;
import com.foreverwin.mesnac.equip.service.ResourceInspectTaskSpareService;
import com.foreverwin.mesnac.equip.service.ResourceRepairTaskService;
import com.foreverwin.mesnac.meapi.dto.NcCodeDto;
import com.foreverwin.mesnac.meapi.mapper.NwaUserMapper;
import com.foreverwin.mesnac.meapi.model.DataField;
@ -16,19 +23,16 @@ import com.foreverwin.mesnac.meapi.service.ResrceService;
import com.foreverwin.modular.core.exception.BusinessException;
import com.foreverwin.modular.core.util.CommonMethods;
import com.foreverwin.modular.core.util.FrontPage;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.foreverwin.mesnac.equip.model.ResourceRepairTask;
import com.foreverwin.mesnac.equip.mapper.ResourceRepairTaskMapper;
import com.foreverwin.mesnac.equip.service.ResourceRepairTaskService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
/**
* <p>
@ -60,6 +64,8 @@ public class ResourceRepairTaskServiceImpl extends ServiceImpl<ResourceRepairTas
private NwaUserMapper nwaUserMapper;
@Autowired
private DataFieldListService dataFieldListService;
@Autowired
private AnomalyService anomalyService;
@Override
public HashMap<String, Object> init() {
@ -133,6 +139,10 @@ public class ResourceRepairTaskServiceImpl extends ServiceImpl<ResourceRepairTas
if (reportUser == null){
throw BusinessException.build("提报人不能为空!!!");
}
//调用方法,关闭异常单的状态
anomalyService.anomalyReveseRepairShutDown(resourceRepairTask.getObjectBo());
resourceRepairTask.setCreateUser(reportUser);
resourceRepairTask.setCreatedDateTime(LocalDateTime.now());
resourceRepairTaskService.save(resourceRepairTask);

@ -455,7 +455,7 @@
</select>
<select id="selectPage" resultMap="BaseResultMap">
SELECT item,IT.description,revision
SELECT I.HANDLE,item,IT.description,revision
FROM ITEM I
LEFT JOIN ITEM_T IT ON I.HANDLE = IT.ITEM_BO AND IT.LOCALE = 'zh'
<where>

@ -669,7 +669,8 @@
SELECT PREZSD.EMPLOYEE_DESCRIPTION,CASE WHEN TO_NUMBER(zsd.DISPATCH_SEQ)=1 THEN NULL
WHEN SS.STEP_SEQUENCE>TO_NUMBER(zsd.DISPATCH_SEQ)-1 THEN '完成'
ELSE '未完成' END LAST_OPERATION_STATUS,
S.SFC,S.QTY,IT.DESCRIPTION ITEM_DESCRIPTION FROM SFC S
S.SFC,S.QTY,IT.DESCRIPTION ITEM_DESCRIPTION,S.ITEM_BO,S.SHOP_ORDER_BO
FROM SFC S
LEFT JOIN ITEM_T IT ON S.ITEM_BO=IT.ITEM_BO AND IT.LOCALE=#{locale}
JOIN Z_SFC_DISPATCH zsd ON S.SFC=zsd.SFC AND S.SITE=zsd.SITE
LEFT JOIN Z_SFC_DISPATCH PREZSD ON zsd.SFC=PREZSD.SFC AND PREZSD.DISPATCH_SEQ=TO_NUMBER(zsd.DISPATCH_SEQ)-1

Loading…
Cancel
Save