|
|
|
@ -129,6 +129,9 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesPartProdGroupRepository mesPartProdGroupRao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesWorkCellRepository workCellRDao;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel model) {
|
|
|
|
|
|
|
|
|
@ -306,7 +309,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final Integer workCellType = getWorkCellType(model.getOrganizeCode(), model.getWorkCenterCode(), model.getWorkCellCode());
|
|
|
|
|
//零件检测详情为空,则代表本次校验为合格。
|
|
|
|
|
if (CollectionUtils.isEmpty(model.getPartInspectionDetailList())) {
|
|
|
|
|
MesPartInspection partInspection = null;
|
|
|
|
@ -321,6 +324,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
if (model.getOptType() != null && model.getOptType() == 2) {
|
|
|
|
|
partInspection.setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
|
}
|
|
|
|
|
partInspection.setInspectionType(workCellType);
|
|
|
|
|
partInspection = partInspectionRepository.save(partInspection);
|
|
|
|
|
|
|
|
|
|
if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) {
|
|
|
|
@ -371,6 +375,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
if (model.getOptType() != null && model.getOptType() == 2) {
|
|
|
|
|
model.getPartInspection().setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
|
}
|
|
|
|
|
model.getPartInspection().setInspectionType(workCellType);
|
|
|
|
|
partInspectionRepository.save(model.getPartInspection());
|
|
|
|
|
|
|
|
|
|
//查询当前单据明细
|
|
|
|
@ -484,7 +489,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
if (model.getOptType() != null && model.getOptType() == 2) {
|
|
|
|
|
partInspection.setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
partInspection.setInspectionType(workCellType);
|
|
|
|
|
model.setPartInspection(partInspectionRepository.save(partInspection));
|
|
|
|
|
|
|
|
|
|
List<String> defectTypeNoExitList = new ArrayList<>();
|
|
|
|
@ -622,6 +627,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
if (model.getOptType() != null && model.getOptType() == 2) {
|
|
|
|
|
model.getPartInspection().setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
|
}
|
|
|
|
|
model.getPartInspection().setInspectionType(workCellType);
|
|
|
|
|
partInspectionRepository.save(model.getPartInspection());
|
|
|
|
|
//查询当前单据明细
|
|
|
|
|
List<MesPartInspectionDetail> resultDetailList = queryResultDetailList(model, model.getOrganizeCode());
|
|
|
|
@ -776,6 +782,10 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
//根据条码找最近一条单据
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(produceSn.getProductSn(), "sn", packBean);
|
|
|
|
|
if (!StringUtils.isEmpty(inputModel.getWorkCellCode())) {
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(inputModel.getWorkCenterCode(), "workCenterCode", packBean);
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(inputModel.getWorkCellCode(), "workCellCode", packBean);
|
|
|
|
|
}
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(refundFlag, "refundFlag", packBean);
|
|
|
|
|
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
|
|
|
|
|
MesPartInspection partInspection = partInspectionRepository.getByProperty(packBean);
|
|
|
|
@ -972,6 +982,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
partInspection.setLotNo(model.getLotNo());
|
|
|
|
|
partInspection.setQty(model.getQty());
|
|
|
|
|
partInspection.setWorkCenterCode(model.getWorkCenterCode());
|
|
|
|
|
partInspection.setWorkCellCode(model.getWorkCellCode());
|
|
|
|
|
partInspection.setShiftCode(model.getShiftCode());
|
|
|
|
|
partInspection.setSourceType(model.getSourceType());
|
|
|
|
|
//42984 初检创建时修改人和修改时间不能赋值
|
|
|
|
@ -1404,4 +1415,62 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
detail.setSystemSyncStatus(CommonEnumUtil.FALSE);
|
|
|
|
|
detail.setSystemSyncDatetime(MesPcnExtConstWords.EMPTY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Integer getWorkCellType(String organizeCode, String workCenterCode, String workCellCode) {
|
|
|
|
|
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(workCenterCode, "workCenterCode", packBean);
|
|
|
|
|
DdlPreparedPack.getNumNOEqualPack(workCellCode, "workCellCode", packBean);
|
|
|
|
|
MesWorkCell workCell = workCellRDao.getByProperty(packBean);
|
|
|
|
|
MesExtEnumUtil.MES_PART_INSPECTION_TYPE type = null;
|
|
|
|
|
if (workCell != null) {
|
|
|
|
|
if (workCell.getType() == MesExtEnumUtil.MES_WORK_CELL_TYPE.PRODUCT_CELL.getValue()) {
|
|
|
|
|
type = MesExtEnumUtil.MES_PART_INSPECTION_TYPE.ONLINE_CHECK;
|
|
|
|
|
} else if (workCell.getType() == MesExtEnumUtil.MES_WORK_CELL_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.ONLINE_CHECK.getValue());
|
|
|
|
|
final int checkCount = inspections == null ? 0 : inspections.size();
|
|
|
|
|
if (mesPart.getSlcGateQty() == 1) {
|
|
|
|
|
if (checkCount == 0) {
|
|
|
|
|
MesPcnException.throwFlowException("物料【%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("物料【%s】的SLC GATE 数量为2,需要2次不同创建人的GP12检验!", partNo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else 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("物料【%s】的SLC GATE 数量为1,至少需要一次在线检验!", partNo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|