|
|
|
@ -4,10 +4,8 @@ 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.anomaly.mapper.AbnormalBillMapper;
|
|
|
|
|
import com.foreverwin.mesnac.anomaly.model.AbnormalBill;
|
|
|
|
|
import com.foreverwin.mesnac.anomaly.model.AbnormalBillDispose;
|
|
|
|
|
import com.foreverwin.mesnac.anomaly.service.AbnormalBillDisposeService;
|
|
|
|
|
import com.foreverwin.mesnac.anomaly.service.AbnormalBillService;
|
|
|
|
|
import com.foreverwin.mesnac.anomaly.model.*;
|
|
|
|
|
import com.foreverwin.mesnac.anomaly.service.*;
|
|
|
|
|
import com.foreverwin.mesnac.common.enums.HandleEnum;
|
|
|
|
|
import com.foreverwin.mesnac.common.helper.NextNumberHelper;
|
|
|
|
|
import com.foreverwin.mesnac.common.util.StringUtil;
|
|
|
|
@ -24,7 +22,8 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <p>
|
|
|
|
|
* 异常单 服务实现类
|
|
|
|
@ -56,6 +55,15 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
@Autowired
|
|
|
|
|
private NwaUserService nwaUserService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private AbnormalNcCodeService abnormalNcCodeService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private AbnormalCauseService abnormalCauseService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private AbnormalDutyService abnormalDutyService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public IPage<AbnormalBill> selectPage(FrontPage<AbnormalBill> frontPage, AbnormalBill abnormalBill) {
|
|
|
|
@ -72,40 +80,147 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String anomalyReportOther(AbnormalBill abnormalBill, AbnormalBillDispose abnormalBillDispose) {
|
|
|
|
|
this.generateAbnormalBill(abnormalBill,abnormalBillDispose);
|
|
|
|
|
public String anomalyReportOther(AbnormalBill abnormalBill,
|
|
|
|
|
AbnormalBillDispose abnormalBillDispose,
|
|
|
|
|
List<String> dutyCauseType,
|
|
|
|
|
List<String> dutyType) {
|
|
|
|
|
this.generateAbnormalBill(abnormalBill,abnormalBillDispose,dutyCauseType,dutyType);
|
|
|
|
|
this.saveOrUpdate(abnormalBill);
|
|
|
|
|
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
|
|
|
|
|
return abnormalBill.getAbnormalNo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void generateAbnormalBill(AbnormalBill abnormalBill, AbnormalBillDispose abnormalBillDispose) {
|
|
|
|
|
public String anomalyReport(AbnormalBill abnormalBill,
|
|
|
|
|
AbnormalBillDispose abnormalBillDispose,
|
|
|
|
|
List<String> ncGroupAndNcCodes,
|
|
|
|
|
List<String> dutyCauseType,
|
|
|
|
|
List<String> dutyType) {
|
|
|
|
|
this.generateAbnormalBill(abnormalBill,abnormalBillDispose,dutyCauseType,dutyType);
|
|
|
|
|
//获取当前时间
|
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
//生成不良代码和不良代码组,并把它放到hashMap里面,ncCode是存放在异常单里面的ncCode
|
|
|
|
|
|
|
|
|
|
List<String> ncCode = new ArrayList<>();
|
|
|
|
|
List<String> ncGroup = new ArrayList<>();
|
|
|
|
|
StringBuilder ncCodes = new StringBuilder();
|
|
|
|
|
for(String ncGroupAndNcCode:ncGroupAndNcCodes){
|
|
|
|
|
String[] split = ncGroupAndNcCode.split("/");
|
|
|
|
|
ncGroup.add(split[0]);
|
|
|
|
|
ncCode.add(split[1]);
|
|
|
|
|
ncCodes.append(split[1]).append(",");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ArrayList<AbnormalNcCode> abnormalNcCodes = new ArrayList<>();
|
|
|
|
|
for(int i = 0; i < ncGroup.size(); i ++){
|
|
|
|
|
AbnormalNcCode abnormalNcCode = new AbnormalNcCode();
|
|
|
|
|
//设置异常单BO
|
|
|
|
|
abnormalNcCode.setAbnormalBillBo(abnormalBill.getHandle());
|
|
|
|
|
List<AbnormalNcCode> abnormalNcCodes1 = abnormalNcCodeService.selectList(abnormalNcCode);
|
|
|
|
|
if(abnormalNcCodes1.size() != 0){
|
|
|
|
|
QueryWrapper<AbnormalNcCode> abnormalNcCodeQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
abnormalNcCodeQueryWrapper.setEntity(abnormalNcCode);
|
|
|
|
|
abnormalNcCodeService.remove(abnormalNcCodeQueryWrapper);
|
|
|
|
|
}
|
|
|
|
|
abnormalNcCode.setModifiedUser(CommonMethods.getUser());
|
|
|
|
|
abnormalNcCode.setModifiedDateTime(now);
|
|
|
|
|
abnormalNcCode.setCreatedUser(CommonMethods.getUser());
|
|
|
|
|
abnormalNcCode.setCreatedDateTime(now);
|
|
|
|
|
//设置HANDLE
|
|
|
|
|
abnormalNcCode.setHandle(UUID.randomUUID().toString());
|
|
|
|
|
//设置站点
|
|
|
|
|
abnormalNcCode.setSite(CommonMethods.getSite());
|
|
|
|
|
//设置不合格代码组
|
|
|
|
|
abnormalNcCode.setNcCodeGroup(ncGroup.get(i));
|
|
|
|
|
abnormalNcCode.setNcCode(ncCode.get(i));
|
|
|
|
|
abnormalNcCodes.add(abnormalNcCode);
|
|
|
|
|
}
|
|
|
|
|
abnormalNcCodeService.saveOrUpdateBatch(abnormalNcCodes);
|
|
|
|
|
abnormalBill.setNcCode(ncCodes.substring(0,ncCodes.length() - 1));
|
|
|
|
|
this.saveOrUpdate(abnormalBill);
|
|
|
|
|
abnormalBillDisposeService.saveOrUpdate(abnormalBillDispose);
|
|
|
|
|
return abnormalBill.getAbnormalNo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void generateAbnormalBill(AbnormalBill abnormalBill, AbnormalBillDispose abnormalBillDispose,List<String> dutyCauseType,List<String> dutyType) {
|
|
|
|
|
String site = CommonMethods.getSite();
|
|
|
|
|
LocalDateTime currentTime = LocalDateTime.now();
|
|
|
|
|
String user = CommonMethods.getUser();
|
|
|
|
|
if(StringUtil.isBlank(abnormalBill.getAbnormalNo())){
|
|
|
|
|
String abnormalNo = null;
|
|
|
|
|
//生成异常单号
|
|
|
|
|
if("Q".equals(abnormalBill.getType())){//其他异常
|
|
|
|
|
abnormalNo = nextNumberHelper.getNextNumber(abnormalBill.getSite(), "ABNORMAL_OTHER", 1, null).get(0);
|
|
|
|
|
abnormalNo = nextNumberHelper.getNextNumber(site, "ABNORMAL_OTHER", 1, null).get(0);
|
|
|
|
|
}else if("Z".equals(abnormalBill.getType())){//质量异常
|
|
|
|
|
abnormalNo = nextNumberHelper.getNextNumber(abnormalBill.getSite(), "ABNORMAL_QUALITY", 1, null).get(0);
|
|
|
|
|
abnormalNo = nextNumberHelper.getNextNumber(site, "ABNORMAL_QUALITY", 1, null).get(0);
|
|
|
|
|
}else if("S".equals(abnormalBill.getType())){//设备异常
|
|
|
|
|
abnormalNo = nextNumberHelper.getNextNumber(abnormalBill.getSite(), "ABNORMAL_DEVICE", 1, null).get(0);
|
|
|
|
|
abnormalNo = nextNumberHelper.getNextNumber(site, "ABNORMAL_DEVICE", 1, null).get(0);
|
|
|
|
|
}
|
|
|
|
|
abnormalBill.setAbnormalNo(abnormalNo);
|
|
|
|
|
}
|
|
|
|
|
abnormalBill.setHandle(HandleEnum.Z_ABNORMAL_BILL.getHandle(abnormalBill.getSite(),abnormalBill.getAbnormalNo()));
|
|
|
|
|
abnormalBill.setHandle(HandleEnum.Z_ABNORMAL_BILL.getHandle(site,abnormalBill.getAbnormalNo()));
|
|
|
|
|
abnormalBillDispose.setAbnormalBillBo(abnormalBill.getHandle());
|
|
|
|
|
abnormalBillDispose.setHandle(HandleEnum.Z_ABNORMAL_BILL_DISPOSE.getHandle(abnormalBill.getSite(),abnormalBill.getAbnormalNo()));
|
|
|
|
|
abnormalBillDispose.setHandle(HandleEnum.Z_ABNORMAL_BILL_DISPOSE.getHandle(site,abnormalBill.getAbnormalNo()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LocalDateTime currentTime = LocalDateTime.now();
|
|
|
|
|
String user = CommonMethods.getUser();
|
|
|
|
|
//设置责任划分填报人和填报时间
|
|
|
|
|
abnormalBillDispose.setDutyUser(user);
|
|
|
|
|
abnormalBillDispose.setDutyDateTime(currentTime);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList<AbnormalCause> causeTypes = new ArrayList<>();
|
|
|
|
|
//判断原因分类是否为空
|
|
|
|
|
if(dutyCauseType.size() >= 1){
|
|
|
|
|
for(String cause:dutyCauseType){
|
|
|
|
|
AbnormalCause abnormalCause = new AbnormalCause();
|
|
|
|
|
String uuid = UUID.randomUUID().toString();
|
|
|
|
|
abnormalCause.setSite(site);
|
|
|
|
|
abnormalCause.setAbnormalBillBo(abnormalBill.getHandle());
|
|
|
|
|
abnormalCause.setAbnormalBillDisposeBo(abnormalBillDispose.getHandle());
|
|
|
|
|
List<AbnormalCause> abnormalCauses = abnormalCauseService.selectList(abnormalCause);
|
|
|
|
|
if(abnormalCauses.size() != 0){
|
|
|
|
|
QueryWrapper<AbnormalCause> abnormalCauseQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
abnormalCauseQueryWrapper.setEntity(abnormalCause);
|
|
|
|
|
abnormalCauseService.remove(abnormalCauseQueryWrapper);
|
|
|
|
|
}
|
|
|
|
|
abnormalCause.setHandle(uuid);
|
|
|
|
|
abnormalCause.setAbnormalCauseNo(cause);
|
|
|
|
|
abnormalCause.setCreatedDateTime(currentTime);
|
|
|
|
|
abnormalCause.setCreatedUser(user);
|
|
|
|
|
abnormalCause.setModifiedUser(user);
|
|
|
|
|
abnormalCause.setModifiedDateTime(currentTime);
|
|
|
|
|
causeTypes.add(abnormalCause);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ArrayList<AbnormalDuty> dutyTypes = new ArrayList<>();
|
|
|
|
|
//判断责任分类是否为空
|
|
|
|
|
if(dutyType.size() >= 1){
|
|
|
|
|
for(String duty:dutyType){
|
|
|
|
|
AbnormalDuty abnormalDuty = new AbnormalDuty();
|
|
|
|
|
String uuid = UUID.randomUUID().toString();
|
|
|
|
|
abnormalDuty.setSite(site);
|
|
|
|
|
abnormalDuty.setAbnormalBillBo(abnormalBill.getHandle());
|
|
|
|
|
abnormalDuty.setAbnormalBillDisposeBo(abnormalBillDispose.getHandle());
|
|
|
|
|
List<AbnormalDuty> abnormalDuties = abnormalDutyService.selectList(abnormalDuty);
|
|
|
|
|
if(abnormalDuties.size() != 0){
|
|
|
|
|
QueryWrapper<AbnormalDuty> abnormalDutyQueryWrapper = new QueryWrapper<>();
|
|
|
|
|
abnormalDutyQueryWrapper.setEntity(abnormalDuty);
|
|
|
|
|
abnormalDutyService.remove(abnormalDutyQueryWrapper);
|
|
|
|
|
}
|
|
|
|
|
abnormalDuty.setHandle(uuid);
|
|
|
|
|
abnormalDuty.setAbnormalDutyNo(duty);
|
|
|
|
|
abnormalDuty.setModifiedUser(user);
|
|
|
|
|
abnormalDuty.setModifiedDateTime(currentTime);
|
|
|
|
|
abnormalDuty.setCreatedDateTime(currentTime);
|
|
|
|
|
abnormalDuty.setCreatedUser(user);
|
|
|
|
|
dutyTypes.add(abnormalDuty);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//设置创建时间和更新时间
|
|
|
|
|
if(abnormalBillMapper.selectById(abnormalBill.getHandle()) == null){
|
|
|
|
|
abnormalBill.setCreatedDataTime(currentTime);
|
|
|
|
@ -126,17 +241,37 @@ public class AbnormalBillServiceImpl extends ServiceImpl<AbnormalBillMapper, Abn
|
|
|
|
|
throw BusinessException.build("设备编号不能为空");
|
|
|
|
|
}
|
|
|
|
|
if(!StringUtil.isBlank(abnormalBill.getMessageType())){
|
|
|
|
|
NcGroup messageType = ncGroupMapper.selectById(HandleEnum.NC_GROUP.getHandle(abnormalBill.getSite(), abnormalBill.getMessageType()));
|
|
|
|
|
NcGroup messageType = ncGroupMapper.selectById(HandleEnum.NC_GROUP.getHandle(site, abnormalBill.getMessageType()));
|
|
|
|
|
if(messageType == null){
|
|
|
|
|
throw BusinessException.build("该消息类型不存在");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Resrce resrce = resrceMapper.selectById(HandleEnum.RESOURCE.getHandle(abnormalBill.getSite(), abnormalBill.getResrce()));
|
|
|
|
|
Resrce resrce = resrceMapper.selectById(HandleEnum.RESOURCE.getHandle(site, abnormalBill.getResrce()));
|
|
|
|
|
if(resrce == null){
|
|
|
|
|
throw BusinessException.build("该设备编号不存在");
|
|
|
|
|
}
|
|
|
|
|
//判断不良品数量和问题数量是否为正整数
|
|
|
|
|
try {
|
|
|
|
|
if(Integer.parseInt(abnormalBill.getNcQty()) < 0) {
|
|
|
|
|
throw BusinessException.build("不良品数量必须大于0");
|
|
|
|
|
}
|
|
|
|
|
if(Integer.parseInt(abnormalBill.getPbQty()) < 0){
|
|
|
|
|
throw BusinessException.build("问题数量必须大于0");
|
|
|
|
|
}
|
|
|
|
|
}catch (NumberFormatException num){
|
|
|
|
|
throw BusinessException.build("问题数量或不良品数量必须为一个正整数");
|
|
|
|
|
}
|
|
|
|
|
//判断输入的用户组是否正确,并返回对应的用户
|
|
|
|
|
nwaUserService.checkUserGroup(abnormalBillDispose.getDutySendUserGroup());
|
|
|
|
|
|
|
|
|
|
//插入原因分类和责任分类
|
|
|
|
|
if(dutyTypes.size() > 0){
|
|
|
|
|
abnormalDutyService.saveOrUpdateBatch(dutyTypes);
|
|
|
|
|
}
|
|
|
|
|
if(causeTypes.size() > 0){
|
|
|
|
|
abnormalCauseService.saveOrUpdateBatch(causeTypes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|