|
|
@ -16,6 +16,7 @@ import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
|
|
|
|
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.MesConstWords;
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
|
|
@ -129,6 +130,12 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private MesPartProdGroupRepository mesPartProdGroupRao;
|
|
|
|
private MesPartProdGroupRepository mesPartProdGroupRao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MesWorkCellRepository workCellRDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MesWorkCenterRepository mesWorkCenterRDao;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel model) {
|
|
|
|
public MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel model) {
|
|
|
|
|
|
|
|
|
|
|
@ -142,6 +149,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
ValidatorBean.checkNotNull(model.getFrontBack(), "正反面不能为空");
|
|
|
|
ValidatorBean.checkNotNull(model.getFrontBack(), "正反面不能为空");
|
|
|
|
//检查条码
|
|
|
|
//检查条码
|
|
|
|
MesProduceSn produceSn = checkProduceSn(model.getSn(), model.getOrganizeCode());
|
|
|
|
MesProduceSn produceSn = checkProduceSn(model.getSn(), model.getOrganizeCode());
|
|
|
|
|
|
|
|
checkOtherWorkCell(produceSn, model, model.getOrganizeCode());
|
|
|
|
|
|
|
|
|
|
|
|
//获取NC-零件检测-单据
|
|
|
|
//获取NC-零件检测-单据
|
|
|
|
partInspection = getPartInspection(produceSn, model, model.getOrganizeCode());
|
|
|
|
partInspection = getPartInspection(produceSn, model, model.getOrganizeCode());
|
|
|
@ -249,7 +257,6 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
if (!StringUtil.isEmpty(produceSn)){
|
|
|
|
if (!StringUtil.isEmpty(produceSn)){
|
|
|
|
model.setCustSn(produceSn.getCustSn());
|
|
|
|
model.setCustSn(produceSn.getCustSn());
|
|
|
|
model.setSn(produceSn.getProductSn());
|
|
|
|
model.setSn(produceSn.getProductSn());
|
|
|
|
model.setWorkCenterCode(produceSn.getWorkCenterCode());
|
|
|
|
|
|
|
|
//排序产线 更新工单的 qcStatus
|
|
|
|
//排序产线 更新工单的 qcStatus
|
|
|
|
MesWorkCenter centerDb = prodOrgExtService.getWorkCenterDb(model.getOrganizeCode(), produceSn.getWorkCenterCode());
|
|
|
|
MesWorkCenter centerDb = prodOrgExtService.getWorkCenterDb(model.getOrganizeCode(), produceSn.getWorkCenterCode());
|
|
|
|
if (!StringUtil.isEmpty(centerDb)){
|
|
|
|
if (!StringUtil.isEmpty(centerDb)){
|
|
|
@ -306,7 +313,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final Integer workCellType = getPartInspectionType(model.getOrganizeCode(), model.getWorkCenterCode(), model.getWorkCellCode());
|
|
|
|
//零件检测详情为空,则代表本次校验为合格。
|
|
|
|
//零件检测详情为空,则代表本次校验为合格。
|
|
|
|
if (CollectionUtils.isEmpty(model.getPartInspectionDetailList())) {
|
|
|
|
if (CollectionUtils.isEmpty(model.getPartInspectionDetailList())) {
|
|
|
|
MesPartInspection partInspection = null;
|
|
|
|
MesPartInspection partInspection = null;
|
|
|
@ -321,6 +328,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
if (model.getOptType() != null && model.getOptType() == 2) {
|
|
|
|
if (model.getOptType() != null && model.getOptType() == 2) {
|
|
|
|
partInspection.setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
partInspection.setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
partInspection.setInspectionType(workCellType);
|
|
|
|
partInspection = partInspectionRepository.save(partInspection);
|
|
|
|
partInspection = partInspectionRepository.save(partInspection);
|
|
|
|
|
|
|
|
|
|
|
|
if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) {
|
|
|
|
if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) {
|
|
|
@ -371,6 +379,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
if (model.getOptType() != null && model.getOptType() == 2) {
|
|
|
|
if (model.getOptType() != null && model.getOptType() == 2) {
|
|
|
|
model.getPartInspection().setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
model.getPartInspection().setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
model.getPartInspection().setInspectionType(workCellType);
|
|
|
|
partInspectionRepository.save(model.getPartInspection());
|
|
|
|
partInspectionRepository.save(model.getPartInspection());
|
|
|
|
|
|
|
|
|
|
|
|
//查询当前单据明细
|
|
|
|
//查询当前单据明细
|
|
|
@ -484,7 +493,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
if (model.getOptType() != null && model.getOptType() == 2) {
|
|
|
|
if (model.getOptType() != null && model.getOptType() == 2) {
|
|
|
|
partInspection.setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
partInspection.setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
partInspection.setInspectionType(workCellType);
|
|
|
|
model.setPartInspection(partInspectionRepository.save(partInspection));
|
|
|
|
model.setPartInspection(partInspectionRepository.save(partInspection));
|
|
|
|
|
|
|
|
|
|
|
|
List<String> defectTypeNoExitList = new ArrayList<>();
|
|
|
|
List<String> defectTypeNoExitList = new ArrayList<>();
|
|
|
@ -622,6 +631,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
if (model.getOptType() != null && model.getOptType() == 2) {
|
|
|
|
if (model.getOptType() != null && model.getOptType() == 2) {
|
|
|
|
model.getPartInspection().setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
model.getPartInspection().setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
model.getPartInspection().setInspectionType(workCellType);
|
|
|
|
partInspectionRepository.save(model.getPartInspection());
|
|
|
|
partInspectionRepository.save(model.getPartInspection());
|
|
|
|
//查询当前单据明细
|
|
|
|
//查询当前单据明细
|
|
|
|
List<MesPartInspectionDetail> resultDetailList = queryResultDetailList(model, model.getOrganizeCode());
|
|
|
|
List<MesPartInspectionDetail> resultDetailList = queryResultDetailList(model, model.getOrganizeCode());
|
|
|
@ -776,6 +786,10 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
//根据条码找最近一条单据
|
|
|
|
//根据条码找最近一条单据
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
DdlPreparedPack.getStringEqualPack(produceSn.getProductSn(), "sn", packBean);
|
|
|
|
DdlPreparedPack.getStringEqualPack(produceSn.getProductSn(), "sn", packBean);
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(inputModel.getWorkCellCode())) {
|
|
|
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(inputModel.getWorkCenterCode(), "workCenterCode", packBean);
|
|
|
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(inputModel.getWorkCellCode(), "workCellCode", packBean);
|
|
|
|
|
|
|
|
}
|
|
|
|
DdlPreparedPack.getNumEqualPack(refundFlag, "refundFlag", packBean);
|
|
|
|
DdlPreparedPack.getNumEqualPack(refundFlag, "refundFlag", packBean);
|
|
|
|
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
|
|
|
|
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
|
|
|
|
MesPartInspection partInspection = partInspectionRepository.getByProperty(packBean);
|
|
|
|
MesPartInspection partInspection = partInspectionRepository.getByProperty(packBean);
|
|
|
@ -787,6 +801,43 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 检查条码是否在其他工位判为不良
|
|
|
|
|
|
|
|
* @param produceSn 条码
|
|
|
|
|
|
|
|
* @param inputModel 前端传入参数
|
|
|
|
|
|
|
|
* @param org 工厂代码
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void checkOtherWorkCell(MesProduceSn produceSn,MesPartInspectionInputModel inputModel, String org) {
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(inputModel.getWorkCellCode())) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//根据条码找最近一条单据
|
|
|
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(produceSn.getProductSn(), "sn", packBean);
|
|
|
|
|
|
|
|
DdlPreparedPack.getStringNoEqualPack(inputModel.getWorkCellCode(), "workCellCode", packBean);
|
|
|
|
|
|
|
|
DdlPreparedPack.getStringNotBlanklPack("workCellCode", packBean);
|
|
|
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue(), "ncStatus", packBean);
|
|
|
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), "inspectionStatus", packBean);
|
|
|
|
|
|
|
|
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
|
|
|
|
|
|
|
|
MesPartInspection partInspection = partInspectionRepository.getByProperty(packBean);
|
|
|
|
|
|
|
|
if (partInspection != null) {
|
|
|
|
|
|
|
|
MesWorkCenter mesWorkCenter = null;
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(partInspection.getWorkCenterCode())) {
|
|
|
|
|
|
|
|
mesWorkCenter = mesWorkCenterRDao.getByProperty(
|
|
|
|
|
|
|
|
new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_DELETED, MesConstWords.IS_VALID, "workCenterCode"},
|
|
|
|
|
|
|
|
new Object[]{org, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), partInspection.getWorkCenterCode()});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
final String workCenterName = mesWorkCenter != null ? mesWorkCenter.getWorkCenterName() : partInspection.getWorkCenterCode();
|
|
|
|
|
|
|
|
MesWorkCell mesWorkCell = workCellRDao.getByProperty(new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_DELETED, MesConstWords.IS_VALID, "workCellCode"},
|
|
|
|
|
|
|
|
new Object[]{org, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), partInspection.getWorkCellCode()});
|
|
|
|
|
|
|
|
final String workCellName = mesWorkCell != null ? mesWorkCell.getWorkCellName() : partInspection.getWorkCellCode();
|
|
|
|
|
|
|
|
throw ImppExceptionBuilder.newInstance().setErrorCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode())
|
|
|
|
|
|
|
|
.setErrorDetail(String.format("【%s】条码在产线【%s】工位【%s】判为不良,请检查数据", partInspection.getSn(), workCenterName, workCellName))
|
|
|
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取NC-零件检测-单据
|
|
|
|
* 获取NC-零件检测-单据
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param inputModel
|
|
|
|
* @param inputModel
|
|
|
@ -972,6 +1023,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
partInspection.setLotNo(model.getLotNo());
|
|
|
|
partInspection.setLotNo(model.getLotNo());
|
|
|
|
partInspection.setQty(model.getQty());
|
|
|
|
partInspection.setQty(model.getQty());
|
|
|
|
partInspection.setWorkCenterCode(model.getWorkCenterCode());
|
|
|
|
partInspection.setWorkCenterCode(model.getWorkCenterCode());
|
|
|
|
|
|
|
|
partInspection.setWorkCellCode(model.getWorkCellCode());
|
|
|
|
partInspection.setShiftCode(model.getShiftCode());
|
|
|
|
partInspection.setShiftCode(model.getShiftCode());
|
|
|
|
partInspection.setSourceType(model.getSourceType());
|
|
|
|
partInspection.setSourceType(model.getSourceType());
|
|
|
|
//42984 初检创建时修改人和修改时间不能赋值
|
|
|
|
//42984 初检创建时修改人和修改时间不能赋值
|
|
|
@ -1404,4 +1456,65 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
detail.setSystemSyncStatus(CommonEnumUtil.FALSE);
|
|
|
|
detail.setSystemSyncStatus(CommonEnumUtil.FALSE);
|
|
|
|
detail.setSystemSyncDatetime(MesPcnExtConstWords.EMPTY);
|
|
|
|
detail.setSystemSyncDatetime(MesPcnExtConstWords.EMPTY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Integer getPartInspectionType(String organizeCode, String workCenterCode, String workCellCode) {
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(workCenterCode) || StringUtils.isEmpty(workCellCode)) {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(workCenterCode, "workCenterCode", packBean);
|
|
|
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(workCellCode, "workCellCode", packBean);
|
|
|
|
|
|
|
|
MesWorkCell workCell = workCellRDao.getByProperty(packBean);
|
|
|
|
|
|
|
|
MesExtEnumUtil.MES_PART_INSPECTION_TYPE type = null;
|
|
|
|
|
|
|
|
if (workCell != null && workCell.getType() != null) {
|
|
|
|
|
|
|
|
if (workCell.getType() == MesExtEnumUtil.MES_WORK_CELL_CHECK_TYPE.PRODUCT_CELL.getValue()) {
|
|
|
|
|
|
|
|
type = MesExtEnumUtil.MES_PART_INSPECTION_TYPE.ONLINE_CHECK;
|
|
|
|
|
|
|
|
} else if (workCell.getType() == MesExtEnumUtil.MES_WORK_CELL_CHECK_TYPE.GP12_CELL.getValue()) {
|
|
|
|
|
|
|
|
type = MesExtEnumUtil.MES_PART_INSPECTION_TYPE.GP12_CHECK;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return type != null ? type.getValue() : null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void checkProductSnInspection(String organizeCode, String partNo, String sn) {
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(partNo)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(partNo, "partNo", packBean);
|
|
|
|
|
|
|
|
MesPart mesPart = partRepository.getByProperty(packBean);
|
|
|
|
|
|
|
|
if (mesPart == null) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DdlPackBean inspectionPackBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(sn, "sn", inspectionPackBean);
|
|
|
|
|
|
|
|
DdlPreparedPack.getIsNotNull("inspectionType", inspectionPackBean);
|
|
|
|
|
|
|
|
List<MesPartInspection> inspectionList = partInspectionRepository.findByHqlWhere(inspectionPackBean);
|
|
|
|
|
|
|
|
Map<Integer, List<MesPartInspection>> typeMapInspection = inspectionList.stream().collect(Collectors.groupingBy(MesPartInspection::getInspectionType));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mesPart.getSlcGateQty() != null) {
|
|
|
|
|
|
|
|
List<MesPartInspection> inspections = typeMapInspection.get(MesExtEnumUtil.MES_PART_INSPECTION_TYPE.GP12_CHECK.getValue());
|
|
|
|
|
|
|
|
final int checkCount = inspections == null ? 0 : inspections.size();
|
|
|
|
|
|
|
|
if (mesPart.getSlcGateQty() == 1) {
|
|
|
|
|
|
|
|
if (checkCount == 0) {
|
|
|
|
|
|
|
|
MesPcnException.throwFlowException(String.format("物料【%s】的SLC GATE 数量为1,至少需要一次GP12检验!", partNo));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (mesPart.getSlcGateQty() == 2) {
|
|
|
|
|
|
|
|
Set<String> opUser = inspections != null ? inspections.stream().map(MesPartInspection::getCreateUser).collect(Collectors.toSet()) : new HashSet<>();
|
|
|
|
|
|
|
|
if (opUser.size() != 2) {
|
|
|
|
|
|
|
|
MesPcnException.throwFlowException(String.format("物料【%s】的SLC GATE 数量为2,需要2次不同创建人的GP12检验!", partNo));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mesPart.getOlGateQty() != null) {
|
|
|
|
|
|
|
|
List<MesPartInspection> inspections = typeMapInspection.get(MesExtEnumUtil.MES_PART_INSPECTION_TYPE.ONLINE_CHECK.getValue());
|
|
|
|
|
|
|
|
final int checkCount = inspections == null ? 0 : inspections.size();
|
|
|
|
|
|
|
|
if (mesPart.getSlcGateQty() == 1 && checkCount == 0) {
|
|
|
|
|
|
|
|
MesPcnException.throwFlowException(String.format("物料【%s】的SLC GATE 数量为1,至少需要一次在线检验!", partNo));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|