质量异常提报时校验当前产品&工序是否有未完成的异常,如果有不能进行创建

master
赵嘉伟 4 years ago
parent d9d97a4d9c
commit e61e462b4f

@ -246,16 +246,16 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
public String anomalyReportDevice(AbnormalBill abnormalBill,AbnormalBillDispose abnormalBillDispose) {
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");
}
}
// 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);
this.saveOrUpdate(abnormalBill);
//发送消息
@ -463,20 +463,29 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
@Override
public String generateAbnormalBill(AbnormalBill abnormalBill, AbnormalBillDispose abnormalBillDispose,List<String> dutyCauseType,List<String> dutyType) {
String site = CommonMethods.getSite();
//返回的消息
String message = "提报成功";
LocalDateTime currentTime = LocalDateTime.now();
String user = CommonMethods.getUser();
//return 返回的消息
String message = "提报成功";
//如果前台传过来的异常单为空的话,则抛出一个异常
if(StringUtil.isBlank(abnormalBill.getAbnormalNo())) {
throw BusinessException.build("异常单号不存在");
}
//设置异常单的handle
abnormalBill.setHandle(HandleEnum.ABNORMAL_BILL.getHandle(site,abnormalBill.getAbnormalNo()));
//判断该异常单是否已经提交
if(abnormalBillMapper.selectById(abnormalBill.getHandle()) != null &&
!Constants.SHUT_DOWN.equals(abnormalBill.getStatus())){
throw BusinessException.build("该异常单已经提交,请清空后提交");
}
/**
*
*/
@ -492,14 +501,18 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
// message = "保存成功";
// }
// abnormalBillDispose.setClosedUser(null);
//设置异常单详细表的handle和abnormalBillBo
abnormalBillDispose.setAbnormalBillBo(abnormalBill.getHandle());
abnormalBillDispose.setHandle(HandleEnum.ABNORMAL_BILL_DISPOSE.getHandle(site,abnormalBill.getAbnormalNo()));
//设置责任划分填报人和填报时间
abnormalBillDispose.setDutyUser(user);
abnormalBillDispose.setDutyDateTime(currentTime);
//判断原因分类是否为空,如果不为空把它放进Z_ABNORMAL_CAUSE表里面
ArrayList<AbnormalCause> causeTypes = new ArrayList<>();
if(dutyCauseType != null && dutyCauseType.size() >= 1){
@ -525,6 +538,7 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
}
//判断工序编码是否传递错误
if(!StringUtil.isBlank(abnormalBill.getOperation())){
QueryWrapper<Operation> operationQueryWrapper = new QueryWrapper<Operation>();
@ -536,7 +550,8 @@ 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");
@ -571,17 +586,6 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
}
}
//设置创建时间和更新时间
if(abnormalBillMapper.selectById(abnormalBill.getHandle()) == null){
abnormalBill.setCreatedDateTime(currentTime);
abnormalBill.setCreatedUser(user);
abnormalBillDispose.setCreatedDataTime(currentTime);
abnormalBillDispose.setCreatedUser(user);
}
abnormalBill.setModifiedDateTime(currentTime);
abnormalBill.setModifiedUser(user);
abnormalBillDispose.setModifiedDateTime(currentTime);
abnormalBillDispose.setModifiedUser(user);
/**
* SFC sfc
@ -591,10 +595,14 @@ 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());
@ -617,12 +625,16 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
// }
// }
//判断设备异常提交的设备是否正确
if(!StringUtil.isBlank(abnormalBill.getResrce()) && Constants.ABNORMAL_RESRCE.equals(abnormalBill.getType())){
Resrce resrce = resrceMapper.selectById(HandleEnum.RESOURCE.getHandle(site, abnormalBill.getResrce()));
if(resrce == null){
throw BusinessException.build("该设备编号不存在");
}
}
//判断不良品数量和问题数量是否为正整数
try {
if(!StringUtil.isBlank(abnormalBill.getNcQty()) && Integer.parseInt(abnormalBill.getNcQty()) < 0) {
@ -635,8 +647,11 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
throw BusinessException.build("问题数量或不良品数量必须为一个正整数");
}
//判断输入的责任划分用户组是否正确,并返回对应的用户
//判断输入的责任划分用户组是否正确,并返回对应的用户组下的用户
nwaUserService.checkUserGroup(site,abnormalBillDispose.getDutySendUserGroup());
//插入原因分类和责任分类
if(dutyTypes.size() > 0){
abnormalDutyService.saveOrUpdateBatch(dutyTypes);
@ -649,6 +664,33 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
this.fileUpload(abnormalBill);
}
//判断该sfc是否已经提交过一个异常如果已经提交且状态不是方案确认、取消、闭环关闭则报错
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);
String abnormalType = abnormalBill.getType().equals(Constants.ABNORMAL_QUALITY) ? "质量异常" :
abnormalBill.getType().equals(Constants.ABNORMAL_OTHER) ? "其他异常" : "设备异常" ;
if(abnormalBillList.size() >= 1 ){
throw BusinessException.build(abnormalType + "有未处理完成的产品条码SFC");
}
//设置创建时间和更新时间
if(abnormalBillMapper.selectById(abnormalBill.getHandle()) == null){
abnormalBill.setCreatedDateTime(currentTime);
abnormalBill.setCreatedUser(user);
abnormalBillDispose.setCreatedDataTime(currentTime);
abnormalBillDispose.setCreatedUser(user);
}
abnormalBill.setModifiedDateTime(currentTime);
abnormalBill.setModifiedUser(user);
abnormalBillDispose.setModifiedDateTime(currentTime);
abnormalBillDispose.setModifiedUser(user);
// this.anomalyCreatedAndSendMessage(abnormalBill,null);
return message;

Loading…
Cancel
Save