|
|
|
@ -2,19 +2,26 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesConfigService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesInputDefectRecordService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesInputDefectRecordModel;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionInputModel;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionViewModel;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.*;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionDetail;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.rework.MesReworkTask;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.*;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@ -23,6 +30,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
@ -56,13 +64,15 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesPartTypeDefectRepository partTypeDefectRepository;
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesDefectRecordRepository defectRecordRepository;
|
|
|
|
|
private MesMoveRepository moveRepository;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesDefectRecordService defectRecordService;
|
|
|
|
|
private MesPartInspectionRepository partInspectionRepository;
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesPartInspectionDetailRepository partInspectionDetailRepository;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesMoveRepository moveRepository;
|
|
|
|
|
private MesReworkTaskRepository reworkTaskRepository;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesConfigService configService;
|
|
|
|
@ -71,38 +81,63 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
private ISyncFuncService syncFuncService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public MesInputDefectRecordModel queryProduceSn(String serialNumber, Integer frontBack, String org) {
|
|
|
|
|
|
|
|
|
|
//检查条码
|
|
|
|
|
MesProduceSn produceSn = checkProduceSn(serialNumber, org);
|
|
|
|
|
public MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel inputModel, String org) {
|
|
|
|
|
|
|
|
|
|
//检查物料
|
|
|
|
|
MesPart part = checkPart(produceSn, org);
|
|
|
|
|
MesPart part;
|
|
|
|
|
//获取NC-零件检测-单据
|
|
|
|
|
MesPartInspection partInspection;
|
|
|
|
|
Integer sourceType = null;
|
|
|
|
|
if (!StringUtils.isEmpty(inputModel.getSerialNumber())) {
|
|
|
|
|
// 数据校验
|
|
|
|
|
ValidatorBean.checkNotNull(inputModel.getFrontBack(), "正反面不能为空");
|
|
|
|
|
//检查条码
|
|
|
|
|
MesProduceSn produceSn = checkProduceSn(inputModel.getSerialNumber(), org);
|
|
|
|
|
|
|
|
|
|
//检查零件类型与图片对应关系
|
|
|
|
|
MesPartTypePicture partTypePicture = checkPartTypePicture(part, org);
|
|
|
|
|
//获取NC-零件检测-单据
|
|
|
|
|
partInspection = getPartInspection(inputModel, org);
|
|
|
|
|
|
|
|
|
|
//构造返回信息
|
|
|
|
|
MesInputDefectRecordModel model = getModel(part, partTypePicture, frontBack, org);
|
|
|
|
|
//检查物料
|
|
|
|
|
part = checkPart(produceSn, org);
|
|
|
|
|
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public MesInputDefectRecordModel queryPartAndLot(String partNo, String lot, Integer frontBack, String org) {
|
|
|
|
|
} else {
|
|
|
|
|
// 数据校验
|
|
|
|
|
ValidatorBean.checkNotNull(inputModel.getPartNo(), "物料不能为空");
|
|
|
|
|
ValidatorBean.checkNotNull(inputModel.getLot(), "批次不能为空");
|
|
|
|
|
ValidatorBean.checkNotNull(inputModel.getFrontBack(), "正反面不能为空");
|
|
|
|
|
ValidatorBean.checkNotNull(inputModel.getQty(), "数量不能为空");
|
|
|
|
|
|
|
|
|
|
//检查物料
|
|
|
|
|
MesPart part = checkPartByPartNo(partNo, org);
|
|
|
|
|
//检查物料
|
|
|
|
|
part = checkPartByPartNo(inputModel.getPartNo(), org);
|
|
|
|
|
|
|
|
|
|
//获取NC-零件检测-单据
|
|
|
|
|
partInspection = getPartInspectionByPartAndLot(inputModel, org);
|
|
|
|
|
|
|
|
|
|
sourceType = MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.LOT.getValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//检查零件类型与图片对应关系
|
|
|
|
|
MesPartTypePicture partTypePicture = checkPartTypePicture(part, org);
|
|
|
|
|
|
|
|
|
|
//构造返回信息
|
|
|
|
|
MesInputDefectRecordModel model = getModel(part, partTypePicture, frontBack, org);
|
|
|
|
|
MesPartInspectionViewModel model = getModel(partInspection, part, partTypePicture, inputModel.getFrontBack(), org);
|
|
|
|
|
model.setSourceType(sourceType);
|
|
|
|
|
model.setTransferFlg(inputModel.isTransferFlg());
|
|
|
|
|
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询零件类型缺陷类型对应关系
|
|
|
|
|
*
|
|
|
|
|
* @param partNo
|
|
|
|
|
* @param defectLocation
|
|
|
|
|
* @param flg
|
|
|
|
|
* @param frontBack
|
|
|
|
|
* @param org
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<MesPartTypeDefect> queryPartTypeDefect(String partNo, String defectLocation, boolean flg, Integer frontBack, String org) {
|
|
|
|
|
|
|
|
|
@ -143,45 +178,240 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
return partTypeDefectList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 完成质检-保存不良记录
|
|
|
|
|
*
|
|
|
|
|
* @param model
|
|
|
|
|
* @param org
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void saveDefectRecord(List<MesDefectRecord> defectRecordList, String org) {
|
|
|
|
|
public void savePartInspection(MesPartInspectionInputModel model, String org) {
|
|
|
|
|
|
|
|
|
|
//通过条码判断是单件还是批次,
|
|
|
|
|
//扫描条码则是单件 没有条码是批次
|
|
|
|
|
if (!StringUtils.isEmpty(defectRecordList.get(0).getSerialNumber())) {
|
|
|
|
|
|
|
|
|
|
// 数据校验
|
|
|
|
|
ValidatorBean.checkNotNull(defectRecordList.get(0).getSerialNumber(), "条码不能为空");
|
|
|
|
|
//检查条码
|
|
|
|
|
MesProduceSn produceSn = checkProduceSn(defectRecordList.get(0).getSerialNumber(), org);
|
|
|
|
|
//零件检测详情为空,则代表本次校验为合格。
|
|
|
|
|
if (CollectionUtils.isEmpty(model.getPartInspectionDetailList())) {
|
|
|
|
|
|
|
|
|
|
produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue());
|
|
|
|
|
|
|
|
|
|
//检查物料
|
|
|
|
|
MesPart part = checkPartByPartNo(produceSn.getPartNo(), org);
|
|
|
|
|
MesPartInspection partInspection;
|
|
|
|
|
//返工单返修完成,需可疑品移正常库
|
|
|
|
|
if (model.isTransferFlg()) {
|
|
|
|
|
//移库
|
|
|
|
|
MesMove move = createMove(model, configService.getCfgValue(org, "UMLGO"), configService.getCfgValue(org, "LGORT"), org);
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//保存数据
|
|
|
|
|
saveDate(defectRecordList, part, org);
|
|
|
|
|
//判断首次合格还是 多次检验最终为合格品
|
|
|
|
|
//若返修单返修完成,则会生成一个新的检验单并合格
|
|
|
|
|
//若检验单为空,则生成新的单据并合格
|
|
|
|
|
if (StringUtils.isEmpty(model.getPartInspection())) {
|
|
|
|
|
|
|
|
|
|
partInspection = createPartInspection(model, MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), org);
|
|
|
|
|
partInspectionRepository.save(partInspection);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
//原单据不合格 现合格
|
|
|
|
|
if (model.getPartInspection().getInspectionStatus() == MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue()) {
|
|
|
|
|
model.getPartInspection().setInspectionStatus(MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue());
|
|
|
|
|
ConvertBean.serviceModelUpdate(model.getPartInspection(), AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
partInspectionRepository.save(model.getPartInspection());
|
|
|
|
|
|
|
|
|
|
//查询当前单据明细
|
|
|
|
|
List<MesPartInspectionDetail> resultDetailList = queryResultDetailList(model, org);
|
|
|
|
|
|
|
|
|
|
model.getPartInspectionDetailList().forEach(k -> {
|
|
|
|
|
k.setId(null);
|
|
|
|
|
k.setOrganizeCode(org);
|
|
|
|
|
k.setPid(model.getPartInspection().getId());
|
|
|
|
|
ConvertBean.serviceModelInitialize(k, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
});
|
|
|
|
|
partInspectionDetailRepository.saveAll(resultDetailList);
|
|
|
|
|
partInspectionDetailRepository.saveAll(model.getPartInspectionDetailList());
|
|
|
|
|
|
|
|
|
|
//移库
|
|
|
|
|
MesMove move = createMove(model, configService.getCfgValue(org, "UMLGO"), configService.getCfgValue(org, "LGORT"), org);
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//单件需要修改条码状态 批量则不需要
|
|
|
|
|
ConvertBean.serviceModelUpdate(produceSn, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
produceSnRepository.save(produceSn);
|
|
|
|
|
} else {
|
|
|
|
|
//零件检测详情不为空,则代表本次校验为不合格。
|
|
|
|
|
|
|
|
|
|
// 数据校验
|
|
|
|
|
ValidatorBean.checkNotNull(defectRecordList.get(0).getPartNo(), "零件号不能为空");
|
|
|
|
|
ValidatorBean.checkNotNull(defectRecordList.get(0).getLot(), "批次不能为空");
|
|
|
|
|
//零件检测-单据为空,则是首次不合格
|
|
|
|
|
MesPartInspection partInspection;
|
|
|
|
|
if (StringUtils.isEmpty(model.getPartInspection())) {
|
|
|
|
|
|
|
|
|
|
//检查物料
|
|
|
|
|
MesPart part = checkPartByPartNo(defectRecordList.get(0).getPartNo(), org);
|
|
|
|
|
partInspection = createPartInspection(model, MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), org);
|
|
|
|
|
partInspectionRepository.save(partInspection);
|
|
|
|
|
|
|
|
|
|
model.getPartInspectionDetailList().forEach(k -> {
|
|
|
|
|
k.setOrganizeCode(org);
|
|
|
|
|
k.setPid(partInspection.getId());
|
|
|
|
|
ConvertBean.serviceModelInitialize(k, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
partInspectionDetailRepository.saveAll(model.getPartInspectionDetailList());
|
|
|
|
|
|
|
|
|
|
//移库
|
|
|
|
|
MesMove move = createMove(model, configService.getCfgValue(org, "LGORT"), configService.getCfgValue(org, "UMLGO"), org);
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
model.getPartInspection().setInspectionStatus(MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue());
|
|
|
|
|
ConvertBean.serviceModelUpdate(model.getPartInspection(), AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
partInspectionRepository.save(model.getPartInspection());
|
|
|
|
|
|
|
|
|
|
//查询当前单据明细
|
|
|
|
|
List<MesPartInspectionDetail> resultDetailList = queryResultDetailList(model, org);
|
|
|
|
|
|
|
|
|
|
model.getPartInspectionDetailList().forEach(k -> {
|
|
|
|
|
k.setId(null);
|
|
|
|
|
k.setOrganizeCode(org);
|
|
|
|
|
k.setPid(model.getPartInspection().getId());
|
|
|
|
|
ConvertBean.serviceModelInitialize(k, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
partInspectionDetailRepository.saveAll(resultDetailList);
|
|
|
|
|
partInspectionDetailRepository.saveAll(model.getPartInspectionDetailList());
|
|
|
|
|
|
|
|
|
|
//移库
|
|
|
|
|
MesMove move = createMove(model, configService.getCfgValue(org, "LGORT"), configService.getCfgValue(org, "UMLGO"), org);
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取NC-零件检测-单据
|
|
|
|
|
*
|
|
|
|
|
* @param inputModel
|
|
|
|
|
* @param org
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private MesPartInspection getPartInspection(MesPartInspectionInputModel inputModel, String org) {
|
|
|
|
|
|
|
|
|
|
//根据条码找最近一条单据
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(inputModel.getSerialNumber(), "sn", packBean);
|
|
|
|
|
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
|
|
|
|
|
MesPartInspection partInspection = partInspectionRepository.getByProperty(packBean);
|
|
|
|
|
|
|
|
|
|
//若单据经过了NC处理,则返回为空
|
|
|
|
|
partInspection = checkPartInspection(partInspection, inputModel, org);
|
|
|
|
|
|
|
|
|
|
return partInspection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取NC-零件检测-单据
|
|
|
|
|
*
|
|
|
|
|
* @param inputModel
|
|
|
|
|
* @param org
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private MesPartInspection getPartInspectionByPartAndLot(MesPartInspectionInputModel inputModel, String org) {
|
|
|
|
|
//根据扫描的条码查询条码是否存在
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(inputModel.getPartNo(), "partNo", packBean);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(inputModel.getLot(), "lot", packBean);
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(inputModel.getQty(), "qty", packBean);
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.LOT.getValue(), "sourceType", packBean);
|
|
|
|
|
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
|
|
|
|
|
MesPartInspection partInspection = partInspectionRepository.getByProperty(packBean);
|
|
|
|
|
|
|
|
|
|
//保存数据
|
|
|
|
|
saveDate(defectRecordList, part, org);
|
|
|
|
|
checkPartInspection(partInspection, inputModel, org);
|
|
|
|
|
|
|
|
|
|
return partInspection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询当前单据明细
|
|
|
|
|
*
|
|
|
|
|
* @param model
|
|
|
|
|
* @param org
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<MesPartInspectionDetail> queryResultDetailList(MesPartInspectionInputModel model, String org) {
|
|
|
|
|
|
|
|
|
|
//根据扫描的条码查询条码是否存在
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(model.getPartInspection().getId(), "pid", packBean);
|
|
|
|
|
List<MesPartInspectionDetail> resultDetailList = partInspectionDetailRepository.findByHqlWhere(packBean);
|
|
|
|
|
resultDetailList.forEach(k -> {
|
|
|
|
|
k.setIsDeleted(MesCommonConstant.TRUE_INTEGER);
|
|
|
|
|
ConvertBean.serviceModelUpdate(model.getPartInspection(), AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return resultDetailList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验NC-零件检测-单据
|
|
|
|
|
*
|
|
|
|
|
* @param partInspection
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private MesPartInspection checkPartInspection(MesPartInspection partInspection, MesPartInspectionInputModel inputModel, String org) {
|
|
|
|
|
|
|
|
|
|
//针对检测单-一次NC处理是一个单据 若单据经过了NC处理,则返回为空
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(partInspection)) {
|
|
|
|
|
|
|
|
|
|
//可疑,待NC
|
|
|
|
|
if (partInspection.getInspectionStatus() == MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue()
|
|
|
|
|
&& partInspection.getNcStatus() == MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue()) {
|
|
|
|
|
|
|
|
|
|
return partInspection;
|
|
|
|
|
} else if (partInspection.getInspectionStatus() == MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue()
|
|
|
|
|
&& partInspection.getNcStatus() == MesExtEnumUtil.PART_INSPECTION_NC_STATUS.SCRAP.getValue()) {
|
|
|
|
|
|
|
|
|
|
//报废
|
|
|
|
|
throw ImppExceptionBuilder.newInstance().setErrorCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode())
|
|
|
|
|
.setErrorDetail(String.format("【%s】条码已报废,请检查数据", partInspection.getSn()))
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
} else if (partInspection.getInspectionStatus() == MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue()
|
|
|
|
|
&& partInspection.getNcStatus() == MesExtEnumUtil.PART_INSPECTION_NC_STATUS.REWORK.getValue()) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//已创建返修单
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(partInspection.getId(), "partInspectionId", packBean);
|
|
|
|
|
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
|
|
|
|
|
MesReworkTask reworkTask = reworkTaskRepository.getByProperty(packBean);
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(reworkTask) && reworkTask.getStatus() == MesExtEnumUtil.REWORK_TASK_STATUS.CREATE.getValue()) {
|
|
|
|
|
|
|
|
|
|
//已创建返修单
|
|
|
|
|
throw ImppExceptionBuilder.newInstance().setErrorCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode())
|
|
|
|
|
.setErrorDetail(String.format("【%s】已创建返修单,请检查数据", partInspection.getSn()))
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
|
|
|
|
|
.build();
|
|
|
|
|
} else if (!StringUtils.isEmpty(reworkTask) && reworkTask.getStatus() == MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue() &&
|
|
|
|
|
partInspection.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) {
|
|
|
|
|
//返修单 进行返修
|
|
|
|
|
inputModel.setTransferFlg(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 检查条码
|
|
|
|
|
*
|
|
|
|
|
* @param serialNumber
|
|
|
|
|
* @param org
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
private MesProduceSn checkProduceSn(String serialNumber, String org) {
|
|
|
|
|
//根据扫描的条码查询条码是否存在
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
@ -209,6 +439,64 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
return produceSn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建单据
|
|
|
|
|
*
|
|
|
|
|
* @param model
|
|
|
|
|
* @param inspectionStatus
|
|
|
|
|
* @param org
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private MesPartInspection createPartInspection(MesPartInspectionInputModel model, Integer inspectionStatus, String org) {
|
|
|
|
|
MesPartInspection partInspection = new MesPartInspection();
|
|
|
|
|
partInspection.setOrganizeCode(org);
|
|
|
|
|
partInspection.setPartNo(model.getPart().getPartNo());
|
|
|
|
|
partInspection.setPartName(model.getPart().getPartName());
|
|
|
|
|
partInspection.setInspectionDate(TimeTool.getToday());
|
|
|
|
|
partInspection.setInspectionStatus(inspectionStatus);
|
|
|
|
|
partInspection.setNcStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue());
|
|
|
|
|
partInspection.setSn(model.getSerialNumber());
|
|
|
|
|
partInspection.setLot(model.getLot());
|
|
|
|
|
partInspection.setQty(model.getQty());
|
|
|
|
|
partInspection.setWorkCenterCode(model.getWorkCenterCode());
|
|
|
|
|
partInspection.setSourceType(model.getSourceType());
|
|
|
|
|
ConvertBean.serviceModelInitialize(partInspection, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
return partInspection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 移库
|
|
|
|
|
*
|
|
|
|
|
* @param model
|
|
|
|
|
* @param source 来源
|
|
|
|
|
* @param target 目标
|
|
|
|
|
* @param org
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private MesMove createMove(MesPartInspectionInputModel model, String source, String target, String org) {
|
|
|
|
|
GenSerialNoModel serialNoModel = new GenSerialNoModel("INPUT_DEFECT_ZRSUM");
|
|
|
|
|
serialNoModel.setPartNo(model.getPart().getPartNo());
|
|
|
|
|
ResultBean rb = syncFuncService.syncSerialNo(serialNoModel, AuthUtil.getSessionUser().getUserName(), org, 1);
|
|
|
|
|
String zrsum = "";
|
|
|
|
|
if (null != rb && !CollectionUtils.isEmpty(rb.getResultList())) {
|
|
|
|
|
zrsum = (rb.getResultList().get(0)).toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MesMove move = new MesMove();
|
|
|
|
|
move.setMatnr(model.getPart().getPartNo());
|
|
|
|
|
move.setOrganizeCode(org);
|
|
|
|
|
move.setFactoryCode(org);
|
|
|
|
|
move.setLgort(source);
|
|
|
|
|
move.setUmlgo(target);
|
|
|
|
|
move.setMenge(model.getQty());
|
|
|
|
|
move.setMeins(model.getPart().getUnit());
|
|
|
|
|
move.setZrsum(zrsum);
|
|
|
|
|
move.setPostDate(TimeTool.getToday());
|
|
|
|
|
move.setPostTime(TimeTool.getTimeShortWithColon());
|
|
|
|
|
ConvertBean.serviceModelInitialize(move, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
return move;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MesPart checkPart(MesProduceSn produceSn, String org) {
|
|
|
|
|
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
@ -318,7 +606,14 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
return alarmConfigList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MesInputDefectRecordModel getModel(MesPart part, MesPartTypePicture partTypePicture, Integer frontBack, String org) {
|
|
|
|
|
private MesPartInspectionViewModel getModel(MesPartInspection partInspection, MesPart part, MesPartTypePicture partTypePicture, Integer frontBack, String org) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<MesPartInspectionDetail> detailList = new ArrayList<>();
|
|
|
|
|
if (!StringUtils.isEmpty(partInspection) && partInspection.getInspectionStatus() != MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue()) {
|
|
|
|
|
|
|
|
|
|
detailList = checkPartInspectionDetail(partInspection, org);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//位置
|
|
|
|
|
List<MesLocationConfig> locationConfigList = checkLocationConfig(org);
|
|
|
|
@ -340,49 +635,23 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
MesInputDefectRecordModel model = new MesInputDefectRecordModel();
|
|
|
|
|
MesPartInspectionViewModel model = new MesPartInspectionViewModel();
|
|
|
|
|
model.setPart(part);
|
|
|
|
|
model.setPartInspectionDetailList(detailList);
|
|
|
|
|
model.setPartTypePicture(partTypePicture);
|
|
|
|
|
model.setLocationConfigList(locationConfigList);
|
|
|
|
|
model.setPartInspection(partInspection);
|
|
|
|
|
return model;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveDate(List<MesDefectRecord> defectRecordList, MesPart part, String org) {
|
|
|
|
|
|
|
|
|
|
defectRecordList.forEach(r -> {
|
|
|
|
|
r.setId(null);
|
|
|
|
|
r.setPartNo(part.getPartNo());
|
|
|
|
|
r.setPartName(part.getPartName());
|
|
|
|
|
r.setOrganizeCode(org);
|
|
|
|
|
ConvertBean.serviceModelInitialize(r, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//保存不良数据
|
|
|
|
|
defectRecordService.saveDefect(org, AuthUtil.getSessionUser().getUserName(), defectRecordList);
|
|
|
|
|
|
|
|
|
|
GenSerialNoModel serialNoModel = new GenSerialNoModel("INPUT_DEFECT_ZRSUM");
|
|
|
|
|
serialNoModel.setPartNo(part.getPartNo());
|
|
|
|
|
ResultBean rb = syncFuncService.syncSerialNo(serialNoModel, AuthUtil.getSessionUser().getUserName(), org, 1);
|
|
|
|
|
String zrsum = "";
|
|
|
|
|
if (null != rb && !CollectionUtils.isEmpty(rb.getResultList())) {
|
|
|
|
|
zrsum = (rb.getResultList().get(0)).toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MesMove move = new MesMove();
|
|
|
|
|
move.setMatnr(part.getPartNo());
|
|
|
|
|
move.setOrganizeCode(org);
|
|
|
|
|
move.setFactoryCode(org);
|
|
|
|
|
move.setLgort(configService.getCfgValue(org, "LGORT"));
|
|
|
|
|
move.setUmlgo(configService.getCfgValue(org, "UMLGO"));
|
|
|
|
|
move.setMenge(defectRecordList.get(0).getQty().intValue());
|
|
|
|
|
move.setMeins(part.getUnit());
|
|
|
|
|
move.setZrsum(zrsum);
|
|
|
|
|
move.setPostDate(TimeTool.getToday());
|
|
|
|
|
move.setPostTime(TimeTool.getTimeShortWithColon());
|
|
|
|
|
ConvertBean.serviceModelInitialize(move, AuthUtil.getSessionUser().getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
private List<MesPartInspectionDetail> checkPartInspectionDetail(MesPartInspection partInspection, String org) {
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(partInspection.getId(), "pid", packBean);
|
|
|
|
|
List<MesPartInspectionDetail> detailList = partInspectionDetailRepository.findByHqlWhere(packBean);
|
|
|
|
|
|
|
|
|
|
return detailList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|