@ -12,19 +12,23 @@ import com.foreverwin.mesnac.anomaly.model.*;
import com.foreverwin.mesnac.anomaly.service.* ;
import com.foreverwin.mesnac.anomaly.service.* ;
import com.foreverwin.mesnac.common.constant.Constants ;
import com.foreverwin.mesnac.common.constant.Constants ;
import com.foreverwin.mesnac.common.dto.ScrapDto ;
import com.foreverwin.mesnac.common.dto.ScrapDto ;
import com.foreverwin.mesnac.common.dto.UsrDto ;
import com.foreverwin.mesnac.common.enums.HandleEnum ;
import com.foreverwin.mesnac.common.enums.HandleEnum ;
import com.foreverwin.mesnac.common.helper.NextNumberHelper ;
import com.foreverwin.mesnac.common.helper.NextNumberHelper ;
import com.foreverwin.mesnac.common.mapper.MessageMapper ;
import com.foreverwin.mesnac.common.mapper.MessageMapper ;
import com.foreverwin.mesnac.common.model.Message ;
import com.foreverwin.mesnac.common.model.Message ;
import com.foreverwin.mesnac.common.service.AnomalyService ;
import com.foreverwin.mesnac.common.service.AnomalyService ;
import com.foreverwin.mesnac.common.service.MessageService ;
import com.foreverwin.mesnac.common.service.MessageService ;
import com.foreverwin.mesnac.common.service.UserService ;
import com.foreverwin.mesnac.common.util.ActiveMQUtil ;
import com.foreverwin.mesnac.common.util.ActiveMQUtil ;
import com.foreverwin.mesnac.common.util.StringUtil ;
import com.foreverwin.mesnac.common.util.StringUtil ;
import com.foreverwin.mesnac.meapi.mapper.* ;
import com.foreverwin.mesnac.meapi.mapper.* ;
import com.foreverwin.mesnac.meapi.model.* ;
import com.foreverwin.mesnac.meapi.model.* ;
import com.foreverwin.mesnac.meapi.service.* ;
import com.foreverwin.mesnac.meapi.service.DataFieldListService ;
import com.foreverwin.mesnac.meapi.service.NwaUserService ;
import com.foreverwin.mesnac.meapi.service.RouterService ;
import com.foreverwin.mesnac.meapi.service.WorkCenterService ;
import com.foreverwin.mesnac.meapi.util.StringUtils ;
import com.foreverwin.mesnac.meapi.util.StringUtils ;
import com.foreverwin.mesnac.production.mapper.SfcScrapMapper ;
import com.foreverwin.mesnac.quality.service.SelfReportService ;
import com.foreverwin.mesnac.quality.service.SelfReportService ;
import com.foreverwin.modular.core.exception.BaseException ;
import com.foreverwin.modular.core.exception.BaseException ;
import com.foreverwin.modular.core.exception.BusinessException ;
import com.foreverwin.modular.core.exception.BusinessException ;
@ -43,8 +47,8 @@ import java.util.*;
* 异 常 单 服 务 实 现 类
* 异 常 单 服 务 实 现 类
* < / p >
* < / p >
*
*
* @author 赵 嘉 伟
* @author zjw
* @since 2021 - 07 - 22
* @since 2021 - 0 8 - 16
* /
* /
@Service
@Service
@Transactional ( rollbackFor = Exception . class )
@Transactional ( rollbackFor = Exception . class )
@ -57,9 +61,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
@Autowired
@Autowired
private NextNumberHelper nextNumberHelper ;
private NextNumberHelper nextNumberHelper ;
@Autowired
private NcGroupMapper ncGroupMapper ;
@Autowired
@Autowired
private AbnormalBillDisposeService abnormalBillDisposeService ;
private AbnormalBillDisposeService abnormalBillDisposeService ;
@ -69,9 +70,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
@Autowired
@Autowired
private NwaUserService nwaUserService ;
private NwaUserService nwaUserService ;
@Autowired
private NcCodeService ncCodeService ;
@Autowired
@Autowired
private AbnormalNcCodeService abnormalNcCodeService ;
private AbnormalNcCodeService abnormalNcCodeService ;
@ -87,9 +85,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
@Autowired
@Autowired
private ShopOrderMapper shopOrderMapper ;
private ShopOrderMapper shopOrderMapper ;
@Autowired
private NwaUserMapper nwaUserMapper ;
@Autowired
@Autowired
private RouterService routerService ;
private RouterService routerService ;
@ -111,18 +106,9 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
@Autowired
@Autowired
private OperationMapper operationMapper ;
private OperationMapper operationMapper ;
@Autowired
private MessageTypeService messageTypeService ;
@Autowired
@Autowired
private MessageTypeMapper messageTypeMapper ;
private MessageTypeMapper messageTypeMapper ;
@Autowired
private WorkCenterMapper workCenterMapper ;
@Autowired
private ItemMapper itemMapper ;
@Autowired
@Autowired
private UserGroupMapper userGroupMapper ;
private UserGroupMapper userGroupMapper ;
@ -139,10 +125,11 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
private SelfReportService selfReportService ;
private SelfReportService selfReportService ;
@Autowired
@Autowired
private SfcScrapMapper sfcScrapMapper ;
private AbnormalPlanService abnormalPlanService ;
@Autowired
@Autowired
private AbnormalPlanService abnormalPlanService ;
private UserService userService ;
@Override
@Override
@ -184,8 +171,9 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
String message = this . generateAbnormalBill ( abnormalBill , abnormalBillDispose , dutyCauseType , dutyType ) ;
String message = this . generateAbnormalBill ( abnormalBill , abnormalBillDispose , dutyCauseType , dutyType ) ;
//获取当前时间
//获取当前时间
LocalDateTime now = LocalDateTime . now ( ) ;
LocalDateTime now = LocalDateTime . now ( ) ;
//生成不良代码和不良代码组,并把它放到hashMap里面, ncCode是存放在异常单里面的ncCode
//生成不良代码和不良代码组,并把它放到hashMap里面, ncCode是存放在异常单里面的ncCode
List < String > ncCode = new ArrayList < > ( ) ;
List < String > ncCode = new ArrayList < > ( ) ;
List < String > ncGroup = new ArrayList < > ( ) ;
List < String > ncGroup = new ArrayList < > ( ) ;
StringBuilder ncCodes = new StringBuilder ( ) ;
StringBuilder ncCodes = new StringBuilder ( ) ;
@ -202,7 +190,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
//设置异常单BO
//设置异常单BO
abnormalNcCode . setAbnormalBillBo ( abnormalBill . getHandle ( ) ) ;
abnormalNcCode . setAbnormalBillBo ( abnormalBill . getHandle ( ) ) ;
List < AbnormalNcCode > abnormalNcCodes1 = abnormalNcCodeService . selectList ( abnormalNcCode ) ;
List < AbnormalNcCode > abnormalNcCodes1 = abnormalNcCodeService . selectList ( abnormalNcCode ) ;
if ( abnormalNcCodes1 . size ( ) != 0 ) {
if ( abnormalNcCodes1 . size ( ) > 0 ) {
QueryWrapper < AbnormalNcCode > abnormalNcCodeQueryWrapper = new QueryWrapper < > ( ) ;
QueryWrapper < AbnormalNcCode > abnormalNcCodeQueryWrapper = new QueryWrapper < > ( ) ;
abnormalNcCodeQueryWrapper . setEntity ( abnormalNcCode ) ;
abnormalNcCodeQueryWrapper . setEntity ( abnormalNcCode ) ;
abnormalNcCodeService . remove ( abnormalNcCodeQueryWrapper ) ;
abnormalNcCodeService . remove ( abnormalNcCodeQueryWrapper ) ;
@ -224,15 +212,19 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalNcCodeService . saveOrUpdateBatch ( abnormalNcCodes ) ;
abnormalNcCodeService . saveOrUpdateBatch ( abnormalNcCodes ) ;
abnormalBill . setNcCode ( ncCodes . substring ( 0 , ncCodes . length ( ) - 1 ) ) ;
abnormalBill . setNcCode ( ncCodes . substring ( 0 , ncCodes . length ( ) - 1 ) ) ;
}
}
//判断是否是用户自报
//判断是否是用户自报,如果是自报的话,调用孙豪的方法
if ( ! StringUtil . isBlank ( abnormalBill . getInspector ( ) ) & & Constants . NEW . equals ( abnormalBill . getStatus ( ) ) ) {
if ( ! StringUtil . isBlank ( abnormalBill . getInspector ( ) ) & & Constants . NEW . equals ( abnormalBill . getStatus ( ) ) ) {
abnormalBill . setObjectBo ( HandleEnum . SELF_REPORT . getHandle ( abnormalBill . getSite ( ) , abnormalBill . getObjectBo ( ) ) ) ;
abnormalBill . setObjectBo ( HandleEnum . SELF_REPORT . getHandle ( abnormalBill . getSite ( ) , abnormalBill . getObjectBo ( ) ) ) ;
selfReportService . updateState ( abnormalBill . getObjectBo ( ) , Constants . STATE_CONFIRM ) ;
selfReportService . updateState ( abnormalBill . getObjectBo ( ) , Constants . STATE_CONFIRM ) ;
}
}
this . saveOrUpdate ( abnormalBill ) ;
this . saveOrUpdate ( abnormalBill ) ;
abnormalBillDisposeService . saveOrUpdate ( abnormalBillDispose ) ;
abnormalBillDisposeService . saveOrUpdate ( abnormalBillDispose ) ;
//发送消息
//发送消息
if ( Constants . NEW . equals ( abnormalBill . getStatus ( ) ) ) {
if ( Constants . NEW . equals ( abnormalBill . getStatus ( ) ) ) {
this . anomalyCreatedAndSendMessage ( abnormalBill , null ) ;
this . anomalyCreatedAndSendMessage ( abnormalBill , null ) ;
@ -245,67 +237,61 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
@Override
@Override
public String anomalyReportDevice ( AbnormalBill abnormalBill , AbnormalBillDispose abnormalBillDispose ) {
public String anomalyReportDevice ( AbnormalBill abnormalBill , AbnormalBillDispose abnormalBillDispose ) {
String message = this . generateAbnormalBill ( abnormalBill , abnormalBillDispose , null , null ) ;
String message = this . generateAbnormalBill ( abnormalBill , abnormalBillDispose , null , null ) ;
//判断设备异常是否有为处理完成的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 ){
// throw BusinessException.build("设备异常有未处理完成的sfc");
// }
// }
abnormalBillDisposeService . saveOrUpdate ( abnormalBillDispose ) ;
abnormalBillDisposeService . saveOrUpdate ( abnormalBillDispose ) ;
this . saveOrUpdate ( abnormalBill ) ;
this . saveOrUpdate ( abnormalBill ) ;
//发送消息
//发送消息
this . anomalyCreatedAndSendMessage ( abnormalBill , null ) ;
if ( Constants . NEW . equals ( abnormalBill . getStatus ( ) ) ) {
this . anomalyCreatedAndSendMessage ( abnormalBill , null ) ;
}
return message ;
return message ;
}
}
@Override
@Override
public HashMap < String , Object > init ( String messageType, String type) {
public HashMap < String , Object > init ( String type ) {
HashMap < String , Object > hashMap = new HashMap < > ( ) ;
HashMap < String , Object > hashMap = new HashMap < > ( ) ;
String site = CommonMethods . getSite ( ) ;
String site = CommonMethods . getSite ( ) ;
//消息类型
// if("Z".equals(type)){
// List<NcCode> category = ncCodeService.findNcByCategory(messageType,null);
// hashMap.put("ncByNG",category);
// }
//工作中心
//工作中心
WorkCenter workCenter = new WorkCenter ( ) ;
WorkCenter workCenter = new WorkCenter ( ) ;
workCenter . setWcCategory ( "LEVEL4" ) ;
workCenter . setWcCategory ( "LEVEL4" ) ;
workCenter . setSite ( site ) ;
workCenter . setSite ( site ) ;
List < WorkCenter > workCenterList = workCenterService . selectList ( workCenter ) ;
List < WorkCenter > workCenterList = workCenterService . selectList ( workCenter ) ;
hashMap . put ( "workCenter" , workCenterList ) ;
hashMap . put ( "workCenter" , workCenterList ) ;
//原因分类
//原因分类
DataField ncCode = new DataField ( ) ;
DataField ncCode = new DataField ( ) ;
ncCode . setSite ( site ) ;
ncCode . setSite ( site ) ;
ncCode . setDataField ( "REASON_CATEGORY" ) ;
ncCode . setDataField ( "REASON_CATEGORY" ) ;
List < DataField > ncCodeList = dataFieldListService . findDataFieldListById ( ncCode ) ;
List < DataField > ncCodeList = dataFieldListService . findDataFieldListById ( ncCode ) ;
hashMap . put ( "causeType" , ncCodeList ) ;
hashMap . put ( "causeType" , ncCodeList ) ;
//责任部门
//责任部门
DataField dataField = new DataField ( ) ;
DataField dataField = new DataField ( ) ;
dataField . setSite ( site ) ;
dataField . setSite ( site ) ;
dataField . setDataField ( "RESPONSIBILITY_DEPARTMENT" ) ;
dataField . setDataField ( "RESPONSIBILITY_DEPARTMENT" ) ;
List < DataField > dutyDepartList = dataFieldListService . findDataFieldListById ( dataField ) ;
List < DataField > dutyDepartList = dataFieldListService . findDataFieldListById ( dataField ) ;
hashMap . put ( "dutyDepart" , dutyDepartList ) ;
hashMap . put ( "dutyDepart" , dutyDepartList ) ;
//责任分类
//责任分类
dataField . setDataField ( "RESPONSIBILITY_TYPE" ) ;
dataField . setDataField ( "RESPONSIBILITY_TYPE" ) ;
List < DataField > dutyTypeList = dataFieldListService . findDataFieldListById ( dataField ) ;
List < DataField > dutyTypeList = dataFieldListService . findDataFieldListById ( dataField ) ;
hashMap . put ( "dutyType" , dutyTypeList ) ;
hashMap . put ( "dutyType" , dutyTypeList ) ;
//当前登录用户的fullName
//当前登录用户的fullName
NwaUser nwaUser = new NwaUser ( ) ;
List < UsrDto > list = userService . findList ( CommonMethods . getUser ( ) ) ;
nwaUser . setSite ( site ) ;
if ( list ! = null & & list . size ( ) > 0 ) {
nwaUser . setUserName ( CommonMethods . getUser ( ) ) ;
hashMap . put ( "currentUser" , list . get ( 0 ) . getFullName ( ) ) ;
List < NwaUser > nwaUsers = nwaUserService . selectList ( nwaUser ) ;
if ( nwaUsers ! = null & & nwaUsers . size ( ) > 0 ) {
hashMap . put ( "currentUser" , nwaUsers . get ( 0 ) . getFullName ( ) ) ;
}
}
//初始化异常单号
//初始化异常单号
if ( ! StringUtil . isBlank ( type ) ) {
if ( ! StringUtil . isBlank ( type ) ) {
hashMap . put ( "abnormalNo" , this . getNextNumber ( type ) ) ;
hashMap . put ( "abnormalNo" , this . getNextNumber ( type ) ) ;
}
}
return hashMap ;
return hashMap ;
}
}
@ -363,6 +349,11 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
LocalDateTime now = LocalDateTime . now ( ) ;
LocalDateTime now = LocalDateTime . now ( ) ;
abnormalBillDispose . setHandle ( HandleEnum . ABNORMAL_BILL_DISPOSE . getHandle ( site , abnormalBill . getAbnormalNo ( ) ) ) ;
abnormalBillDispose . setHandle ( HandleEnum . ABNORMAL_BILL_DISPOSE . getHandle ( site , abnormalBill . getAbnormalNo ( ) ) ) ;
AbnormalBill abnormalBill1 = abnormalBillMapper . selectById ( HandleEnum . ABNORMAL_BILL . getHandle ( site , abnormalBill . getAbnormalNo ( ) ) ) ;
if ( "true" . equals ( abnormalBill1 . getProgram ( ) ) ) {
throw BusinessException . build ( "该异常单已经方案确认" ) ;
}
if ( ! StringUtil . isBlank ( abnormalBillDispose . getRouterBo ( ) ) ) {
if ( ! StringUtil . isBlank ( abnormalBillDispose . getRouterBo ( ) ) ) {
//分割该工艺路线
//分割该工艺路线
String [ ] routerSplit = abnormalBillDispose . getRouterBo ( ) . split ( "," ) ;
String [ ] routerSplit = abnormalBillDispose . getRouterBo ( ) . split ( "," ) ;
@ -396,6 +387,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalBillDispose . setResolveDateTime ( now ) ;
abnormalBillDispose . setResolveDateTime ( now ) ;
abnormalBillDispose . setResolveUser ( user ) ;
abnormalBillDispose . setResolveUser ( user ) ;
abnormalBill . setStatus ( Constants . PROGRAM_CONFIRM ) ;
abnormalBill . setStatus ( Constants . PROGRAM_CONFIRM ) ;
abnormalBill . setProgram ( "true" ) ;
abnormalBillDisposeService . saveOrUpdate ( abnormalBillDispose ) ;
abnormalBillDisposeService . saveOrUpdate ( abnormalBillDispose ) ;
this . saveOrUpdate ( abnormalBill ) ;
this . saveOrUpdate ( abnormalBill ) ;
@ -414,10 +406,11 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
//判断判责提交是否已经填写
//判断判责提交是否已经填写
//AbnormalBillDispose abnormalBillDispose1 = abnormalBillDisposeMapper.selectById(abnormalBillDispose.getHandle());
//AbnormalBillDispose abnormalBillDispose1 = abnormalBillDisposeMapper.selectById(abnormalBillDispose.getHandle());
AbnormalBill abnormalBill1 = abnormalBillMapper . selectById ( abnormalBill . getHandle ( ) ) ;
AbnormalBill abnormalBill1 = abnormalBillMapper . selectById ( abnormalBill . getHandle ( ) ) ;
if ( ! "N" . equals ( abnormalBill1 . getStatus ( ) ) & & ! "X" . equals ( abnormalBill1 . getStatus ( ) ) ) {
if ( "true" . equals ( abnormalBill1 . getCorrection ( ) ) ) {
throw BusinessException . build ( "该异常单已经判责提交" ) ;
throw BusinessException . build ( "该异常单已经判责提交" ) ;
}
}
abnormalBill . setStatus ( Constants . CORRECTION_CONFIRM ) ;
abnormalBill . setStatus ( Constants . CORRECTION_CONFIRM ) ;
abnormalBill . setCorrection ( "true" ) ;
abnormalBillDispose . setDutyDateTime ( now ) ;
abnormalBillDispose . setDutyDateTime ( now ) ;
abnormalBillDispose . setDutyUser ( user ) ;
abnormalBillDispose . setDutyUser ( user ) ;
@ -436,19 +429,11 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
String local = LocaleContextHolder . getLocale ( ) . getLanguage ( ) ;
String local = LocaleContextHolder . getLocale ( ) . getLanguage ( ) ;
abnormalBillDispose . setHandle ( HandleEnum . ABNORMAL_BILL_DISPOSE . getHandle ( site , abnormalBill . getAbnormalNo ( ) ) ) ;
abnormalBillDispose . setHandle ( HandleEnum . ABNORMAL_BILL_DISPOSE . getHandle ( site , abnormalBill . getAbnormalNo ( ) ) ) ;
//判断判责提交是否还没有进行填写
AbnormalBillDispose abnormalBillDispose1 = abnormalBillDisposeMapper . selectById ( abnormalBillDispose . getHandle ( ) ) ;
if ( abnormalBillDispose1 ! = null ) {
if ( StringUtil . isBlank ( abnormalBillDispose1 . getDutyCauseType ( ) ) ) {
throw BusinessException . build ( "该异常单还没有进行判责提交" ) ;
}
}
abnormalBill . setStatus ( Constants . SHUT_DOWN ) ;
abnormalBill . setStatus ( Constants . SHUT_DOWN ) ;
abnormalBillDispose . setClosedUser ( user ) ;
abnormalBillDispose . setClosedUser ( user ) ;
abnormalBillDispose . setClosedDateTime ( now ) ;
abnormalBillDispose . setClosedDateTime ( now ) ;
// this.anomalyCreatedAndSendMessage(abnormalBill,abnormalBillDispose);
// this.anomalyCreatedAndSendMessage(abnormalBill,abnormalBillDispose);
//保存到异常计划表
//保存到异常计划表
AbnormalBillDisposeDto abnormalBillDisposeDto = abnormalBillDisposeMapper . findAllByAbnormalNo ( abnormalBill , local ) ;
AbnormalBillDisposeDto abnormalBillDisposeDto = abnormalBillDisposeMapper . findAllByAbnormalNo ( abnormalBill , local ) ;
if ( Constants . ABNORMAL_QUALITY . equals ( abnormalBill . getType ( ) ) ) {
if ( Constants . ABNORMAL_QUALITY . equals ( abnormalBill . getType ( ) ) ) {
@ -466,17 +451,24 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
LocalDateTime currentTime = LocalDateTime . now ( ) ;
LocalDateTime currentTime = LocalDateTime . now ( ) ;
String user = CommonMethods . getUser ( ) ;
String user = CommonMethods . getUser ( ) ;
//return 返回的消息
//return 返回的消息
String message = "提报成功" ;
String message = "提报成功" ;
//设置消息类型
if ( Constants . ABNORMAL_QUALITY . equals ( abnormalBill . getType ( ) ) ) {
abnormalBill . setMessageType ( Constants . ABNORMAL_MESSAGE_QUALITY ) ;
} else if ( Constants . ABNORMAL_RESRCE . equals ( abnormalBill . getType ( ) ) ) {
abnormalBill . setMessageType ( Constants . ABNORMAL_MESSAGE_RESOURCE ) ;
} else if ( Constants . ABNORMAL_OTHER . equals ( abnormalBill . getType ( ) ) ) {
abnormalBill . setMessageType ( Constants . ABNORMAL_MESSAGE_OTHER ) ;
}
//如果前台传过来的异常单为空的话,则抛出一个异常
//如果前台传过来的异常单为空的话,则抛出一个异常
if ( StringUtil . isBlank ( abnormalBill . getAbnormalNo ( ) ) ) {
if ( StringUtil . isBlank ( abnormalBill . getAbnormalNo ( ) ) ) {
throw BusinessException . build ( "异常单号不存在" ) ;
throw BusinessException . build ( "异常单号不存在" ) ;
}
}
//设置异常单的handle
//设置异常单的handle
abnormalBill . setHandle ( HandleEnum . ABNORMAL_BILL . getHandle ( site , abnormalBill . getAbnormalNo ( ) ) ) ;
abnormalBill . setHandle ( HandleEnum . ABNORMAL_BILL . getHandle ( site , abnormalBill . getAbnormalNo ( ) ) ) ;
//判断该异常单是否已经提交
//判断该异常单是否已经提交
@ -539,7 +531,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
}
//判断工序编 码 是否传递错误
//判断工序编 号 是否传递错误
if ( ! StringUtil . isBlank ( abnormalBill . getOperation ( ) ) ) {
if ( ! StringUtil . isBlank ( abnormalBill . getOperation ( ) ) ) {
QueryWrapper < Operation > operationQueryWrapper = new QueryWrapper < Operation > ( ) ;
QueryWrapper < Operation > operationQueryWrapper = new QueryWrapper < Operation > ( ) ;
operationQueryWrapper . eq ( "OPERATION" , abnormalBill . getOperation ( ) )
operationQueryWrapper . eq ( "OPERATION" , abnormalBill . getOperation ( ) )
@ -554,7 +546,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
//判断设备异常提报传递的不良代码是否有误
//判断设备异常提报传递的不良代码是否有误
if ( ! StringUtil . isBlank ( abnormalBill . getNcCode ( ) ) & & Constants . ABNORMAL_RESRCE . equals ( abnormalBill . getType ( ) ) ) {
if ( ! StringUtil . isBlank ( abnormalBill . getNcCode ( ) ) & & Constants . ABNORMAL_RESRCE . equals ( abnormalBill . getType ( ) ) ) {
List < String > ncCodes = Arrays . asList ( abnormalBill . getNcCode ( ) . split ( "," ) ) ;
List < String > ncCodes = Arrays . asList ( abnormalBill . getNcCode ( ) . split ( "," ) ) ;
Integer length = ncCodeMapper . checkNcCode ( ncCodes , site ,"FAILURE" );
Integer length = ncCodeMapper . checkNcCode ( ncCodes , site );
if ( ncCodes . size ( ) ! = length ) {
if ( ncCodes . size ( ) ! = length ) {
throw BusinessException . build ( "不良代码传递有误" ) ;
throw BusinessException . build ( "不良代码传递有误" ) ;
}
}
@ -672,7 +664,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
status . add ( Constants . SHUT_DOWN ) ;
status . add ( Constants . SHUT_DOWN ) ;
List < AbnormalBill > abnormalBillList = abnormalBillMapper . findCountBySfc ( abnormalBill . getSite ( ) , abnormalBill . getType ( ) , abnormalBill . getSfc ( ) , status ) ;
List < AbnormalBill > abnormalBillList = abnormalBillMapper . findCountBySfc ( abnormalBill . getSite ( ) , abnormalBill . getType ( ) , abnormalBill . getSfc ( ) , status ) ;
String abnormalType = abnormalBill . getType ( ) . equals ( Constants . ABNORMAL_QUALITY ) ? "质量异常" :
String abnormalType = abnormalBill . getType ( ) . equals ( Constants . ABNORMAL_QUALITY ) ? "质量异常" :
abnormalBill . getType ( ) . equals ( Constants . ABNORMAL_OTHER ) ? "其他异常" : "设备异常" ;
abnormalBill . getType ( ) . equals ( Constants . ABNORMAL_OTHER ) ? "其他异常" : "设备异常" ;
if ( abnormalBillList . size ( ) > = 1 ) {
if ( abnormalBillList . size ( ) > = 1 ) {
throw BusinessException . build ( abnormalType + "有未处理完成的产品条码( SFC) " ) ;
throw BusinessException . build ( abnormalType + "有未处理完成的产品条码( SFC) " ) ;
}
}
@ -876,7 +868,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
public boolean anomalyCreatedAndSendMessage ( AbnormalBill abnormalBill , AbnormalBillDispose abnormalBillDispose ) {
public boolean anomalyCreatedAndSendMessage ( AbnormalBill abnormalBill , AbnormalBillDispose abnormalBillDispose ) {
String site = CommonMethods . getSite ( ) ;
String site = CommonMethods . getSite ( ) ;
String user = CommonMethods . getUser ( ) ;
String user = CommonMethods . getUser ( ) ;
String locale = LocaleContextHolder . getLocale ( ) . getLanguage ( ) ;
LocalDateTime now = LocalDateTime . now ( ) ;
LocalDateTime now = LocalDateTime . now ( ) ;
Message abnormalMessage = new Message ( ) ;
Message abnormalMessage = new Message ( ) ;
//发送消息的主键
//发送消息的主键
@ -888,25 +879,33 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalMessage . setObjectBo ( abnormalBill . getHandle ( ) ) ;
abnormalMessage . setObjectBo ( abnormalBill . getHandle ( ) ) ;
//异常类型
//异常类型
abnormalMessage . setType ( abnormalBill . getType ( ) ) ;
abnormalMessage . setType ( abnormalBill . getType ( ) ) ;
//根据异常的类型找到消息的类型
switch ( abnormalMessage . getType ( ) ) {
case "Z" : //质量异常
abnormalMessage . setMessageType ( abnormalBill . getMessageType ( ) ) ;
abnormalMessage . setMessageType ( Constants . ABNORMAL_MESSAGE_QUALITY ) ;
// //根据异常的类型找到消息的类型
break ;
// switch (abnormalMessage.getType()){
case "Q" : //其他异常
// case "Z"://质量异常
abnormalMessage . setMessageType ( Constants . ABNORMAL_MESSAGE_OTHER ) ;
// abnormalMessage.setMessageType(Constants.ABNORMAL_MESSAGE_QUALITY);
break ;
// break;
case "S" : //设备异常
// case "Q"://其他异常
abnormalMessage . setMessageType ( Constants . ABNORMAL_MESSAGE_RESOURCE ) ;
// abnormalMessage.setMessageType(Constants.ABNORMAL_MESSAGE_OTHER);
break ;
// break;
}
// case "S"://设备异常
// abnormalMessage.setMessageType(Constants.ABNORMAL_MESSAGE_RESOURCE);
// break;
// }
//设置发送的用户组
//设置发送的用户组
switch ( abnormalBill . getStatus ( ) ) {
switch ( abnormalBill . getStatus ( ) ) {
case Constants . NEW : //新建
//新建
case Constants . NEW :
abnormalMessage . setSendUserGroup ( abnormalBill . getReportSendUserGroup ( ) ) ;
abnormalMessage . setSendUserGroup ( abnormalBill . getReportSendUserGroup ( ) ) ;
abnormalMessage . setNode ( Constants . ABNORMAL_MESSAGE_REPORT ) ;
abnormalMessage . setNode ( Constants . ABNORMAL_MESSAGE_REPORT ) ;
break ;
break ;
case Constants . RESPONSE : //响应中,设置响应超时的用户的发送的用户组为提报时要升级的用户组
//响应中,设置响应超时的用户的发送的用户组为提报时要升级的用户组
case Constants . RESPONSE :
QueryWrapper < Message > wrapper = new QueryWrapper < > ( ) ;
QueryWrapper < Message > wrapper = new QueryWrapper < > ( ) ;
Message abnormalMessage1 = new Message ( ) ;
Message abnormalMessage1 = new Message ( ) ;
abnormalMessage1 . setSite ( site ) ;
abnormalMessage1 . setSite ( site ) ;
@ -920,39 +919,47 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalMessage . setUpDateTime ( _abnormalMessage . getUpDateTime ( ) ) ;
abnormalMessage . setUpDateTime ( _abnormalMessage . getUpDateTime ( ) ) ;
abnormalMessage . setNode ( Constants . ABNORMAL_MESSAGE_RESPONSE ) ;
abnormalMessage . setNode ( Constants . ABNORMAL_MESSAGE_RESPONSE ) ;
break ;
break ;
case Constants . CORRECTION_CONFIRM : //纠纷确认
//纠纷确认
case Constants . CORRECTION_CONFIRM :
abnormalMessage . setSendUserGroup ( abnormalBillDispose . getDutySendUserGroup ( ) ) ;
abnormalMessage . setSendUserGroup ( abnormalBillDispose . getDutySendUserGroup ( ) ) ;
abnormalMessage . setNode ( Constants . ABNORMAL_MESSAGE_CORRECTION_CONFIRM ) ;
abnormalMessage . setNode ( Constants . ABNORMAL_MESSAGE_CORRECTION_CONFIRM ) ;
break ;
break ;
case Constants . PROGRAM_CONFIRM : //方案确认
abnormalMessage . setSendUser ( abnormalBillDispose . getResolveSendUserGroup ( ) ) ;
//方案确认
case Constants . PROGRAM_CONFIRM :
abnormalMessage . setSendUserGroup ( abnormalBillDispose . getResolveSendUserGroup ( ) ) ;
abnormalMessage . setNode ( Constants . ABNORMAL_MESSAGE_PROGRAM_CONFIRM ) ;
abnormalMessage . setNode ( Constants . ABNORMAL_MESSAGE_PROGRAM_CONFIRM ) ;
break ;
break ;
case Constants . CANCEL : //取消
//取消
case Constants . CANCEL :
abnormalMessage . setSendUserGroup ( abnormalBill . getCancelSendUserGroup ( ) ) ;
abnormalMessage . setSendUserGroup ( abnormalBill . getCancelSendUserGroup ( ) ) ;
abnormalMessage . setNode ( Constants . ABNORMAL_MESSAGE_CANCEL ) ;
abnormalMessage . setNode ( Constants . ABNORMAL_MESSAGE_CANCEL ) ;
//异常取消的时候要关闭当前异常单下所有的异常信息
//异常取消的时候要关闭当前异常单下所有的异常信息
UpdateWrapper < Message > messageTypeUpdateWrapper = new UpdateWrapper < > ( ) ;
UpdateWrapper < Message > messageTypeUpdateWrapper = new UpdateWrapper < > ( ) ;
// messageTypeUpdateWrapper.eq("SITE",site);
// messageTypeUpdateWrapper.eq("ABNORMAL_BILL_BO",abnormalMessage.getAbnormalBillBo());
Message abnormalMessage2 = new Message ( ) ;
Message abnormalMessage2 = new Message ( ) ;
// abnormalMessage2.setAbnormalBillBo(abnormalMessage.getAbnormalBillBo());
abnormalMessage2 . setStatus ( "Y" ) ;
abnormalMessage2 . setStatus ( "Y" ) ;
messageTypeUpdateWrapper . eq ( "STATUS" , "N" ) ;
messageTypeUpdateWrapper . eq ( "STATUS" , "N" ) ;
messageTypeUpdateWrapper . eq ( "OBJECT_BO" , abnormalMessage . getObjectBo ( ) ) ;
messageTypeUpdateWrapper . eq ( "OBJECT_BO" , abnormalMessage . getObjectBo ( ) ) ;
messageService . update ( abnormalMessage2 , messageTypeUpdateWrapper ) ;
messageService . update ( abnormalMessage2 , messageTypeUpdateWrapper ) ;
break ;
break ;
default :
default :
abnormalMessage . setSendUser ( abnormalBillDispose . getResolveSendUserGroup ( ) ) ;
abnormalMessage . setSendUser ( abnormalBillDispose . getResolveSendUserGroup ( ) ) ;
abnormalMessage . setNode ( Constants . ABNORMAL_MESSAGE_CANCEL ) ;
abnormalMessage . setNode ( Constants . ABNORMAL_MESSAGE_CANCEL ) ;
break ;
break ;
}
}
//格式化消息
String message = this . formatMessage ( abnormalBill , abnormalMessage . getMessageType ( ) , site ) ;
String message = this . formatMessage ( abnormalBill , abnormalMessage . getMessageType ( ) , site ) ;
//得到消息触发的时间
//得到消息触发的时间
abnormalMessage . setResponseDateTime ( now ) ;
abnormalMessage . setResponseDateTime ( now ) ;
//得到要发送的消息
//得到要发送的消息
abnormalMessage . setContent ( message ) ;
abnormalMessage . setContent ( message ) ;
//得到升级的用户组
//得到升级的用户组
//新建有、响应没有、纠防确认有、方案确认没有、取消没有、关闭没有
//新建有、响应没有、纠防确认有、方案确认没有、取消没有、关闭没有
if ( Constants . NEW . equals ( abnormalBill . getStatus ( ) ) | | Constants . CORRECTION_CONFIRM . equals ( abnormalBill . getStatus ( ) ) ) {
if ( Constants . NEW . equals ( abnormalBill . getStatus ( ) ) | | Constants . CORRECTION_CONFIRM . equals ( abnormalBill . getStatus ( ) ) ) {
@ -971,13 +978,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalMessage . setUpMessageType ( abnormalMessage . getMessageType ( ) ) ;
abnormalMessage . setUpMessageType ( abnormalMessage . getMessageType ( ) ) ;
}
}
//设置状态, 新建是Y, 响应为N, 纠防确认是N, 方案确认是Y, 取消是Y
//得到异常节点
//abnormalMessage.setAbnormalNode(Constants.ABNORMAL_MESSAGE_REPORT);
//设置状态, 新建是Y, 响应为N, 纠防确认是N, 方案确认是Y,
if ( Constants . ABNORMAL_MESSAGE_RESPONSE . equals ( abnormalMessage . getNode ( ) ) | |
if ( Constants . ABNORMAL_MESSAGE_RESPONSE . equals ( abnormalMessage . getNode ( ) ) | |
Constants . ABNORMAL_MESSAGE_CORRECTION_CONFIRM . equals ( abnormalMessage . getNode ( ) ) ) {
Constants . ABNORMAL_MESSAGE_CORRECTION_CONFIRM . equals ( abnormalMessage . getNode ( ) ) ) {
abnormalMessage . setStatus ( "N" ) ;
abnormalMessage . setStatus ( "N" ) ;
@ -990,13 +991,12 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
abnormalMessage . setModifiedDateTime ( now ) ;
abnormalMessage . setModifiedDateTime ( now ) ;
//判断,如果是方案确认,则发送用户,否则,除了节点是响应之外,则发送用户组
//发送消息
if ( Constants . ABNORMAL_MESSAGE_PROGRAM_CONFIRM . equals ( abnormalMessage . getNode ( ) ) ) {
if ( ! Constants . ABNORMAL_MESSAGE_RESPONSE . equals ( abnormalMessage . getNode ( ) ) ) {
String sendUsers = abnormalMessage . getSendUser ( ) . replace ( ',' , '|' ) ;
activeMQUtil . wechatSendMessage ( sendUsers , abnormalMessage . getContent ( ) ) ;
} else if ( ! Constants . ABNORMAL_MESSAGE_RESPONSE . equals ( abnormalMessage . getNode ( ) ) ) {
List < NwaUser > nwaUsers = nwaUserService . checkUserGroup ( site , abnormalMessage . getSendUserGroup ( ) ) ;
List < NwaUser > nwaUsers = nwaUserService . checkUserGroup ( site , abnormalMessage . getSendUserGroup ( ) ) ;
StringBuilder sendUsers = new StringBuilder ( ) ;
StringBuilder sendUsers = new StringBuilder ( ) ;
for ( int i = 0 ; i < nwaUsers . size ( ) ; i + + ) {
for ( int i = 0 ; i < nwaUsers . size ( ) ; i + + ) {
if ( i = = ( nwaUsers . size ( ) - 1 ) ) {
if ( i = = ( nwaUsers . size ( ) - 1 ) ) {
sendUsers . append ( nwaUsers . get ( i ) ) ;
sendUsers . append ( nwaUsers . get ( i ) ) ;
@ -1009,7 +1009,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
messageService . saveOrUpdate ( abnormalMessage ) ;
messageService . saveOrUpdate ( abnormalMessage ) ;
return true ;
return true ;
}
}
@Override
@Override
public String formatMessage ( AbnormalBill abnormalBill , String messageType , String site ) {
public String formatMessage ( AbnormalBill abnormalBill , String messageType , String site ) {
//找到消息内容
//找到消息内容
@ -1085,4 +1084,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
}
return abnormalBillMapper . findScrapDtoBySfc ( site , sfc ) ;
return abnormalBillMapper . findScrapDtoBySfc ( site , sfc ) ;
}
}
}
}