|
|
|
@ -1246,9 +1246,64 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
|
|
|
|
|
if (null != workCenter && !StringUtils.isEmpty(workCenter.getRawLocate())) source = workCenter.getRawLocate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(source)) MesPcnException.throwBusiException("未找到来源库位!");
|
|
|
|
|
MesMove move = createMove(model, source, target, org, model.getWorkCenterCode());
|
|
|
|
|
moveRepository.insert(move);
|
|
|
|
|
|
|
|
|
|
// 是否头零件模式
|
|
|
|
|
boolean headModel = true;
|
|
|
|
|
if (!StringUtil.isEmpty(model.getSn())) {
|
|
|
|
|
|
|
|
|
|
// 判断是头零件还是散件 查询加工记录
|
|
|
|
|
DdlPackBean productionPackBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(model.getSn(), "productSn", productionPackBean);
|
|
|
|
|
DdlPreparedPack.getNumNOEqualPack(MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_30.getValue(), "reportStatus", productionPackBean);
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.MES_REPORT_TYPE.CUSTOMER_SUPPLY_MOVE.getValue(), "reportType", productionPackBean);
|
|
|
|
|
MesProductionRecord record = productionRecordRepository.getByProperty(productionPackBean);
|
|
|
|
|
if (record != null) {
|
|
|
|
|
headModel = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 如果是散件模式,需要查询出对应明细
|
|
|
|
|
List<MesPartModel> mesPartModels = new ArrayList<>();
|
|
|
|
|
if (!headModel) {
|
|
|
|
|
MesProduceSn produceSn = getProduceSn(model.getSn(), org);
|
|
|
|
|
|
|
|
|
|
DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(model.getSn(), "workOrderNo", partPackBean);
|
|
|
|
|
List<MesWorkOrderPart> workOrderParts = workOrderPartRepository.findByHqlWhere(partPackBean);
|
|
|
|
|
if (!CollectionUtils.isEmpty(workOrderParts)) {
|
|
|
|
|
DdlPackBean partProdBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(produceSn.getWorkCenterCode(), "workCenterCode", partProdBean);
|
|
|
|
|
List<MesPartProdGroup> mesPartProdGroupList = mesPartProdGroupRao.findByHqlTopWhere(partProdBean, 1);
|
|
|
|
|
for (MesWorkOrderPart workOrderPart : workOrderParts) {
|
|
|
|
|
MesPart partInfo = mesPartService.getMesPartByPartNo(workOrderPart.getPartNo(), org);
|
|
|
|
|
String esd = partInfo.getEsd();
|
|
|
|
|
|
|
|
|
|
// 查询移库规则
|
|
|
|
|
DdlPackBean movePackBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(esd, "srcType", movePackBean);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(mesPartProdGroupList.get(0).getPartProdGroupCode(), "code", movePackBean);
|
|
|
|
|
List<MesMoveRule> moveRules = mesMoveRuleRepository.findByHqlWhere(movePackBean);
|
|
|
|
|
if (!CollectionUtils.isEmpty(moveRules)) {
|
|
|
|
|
MesPartModel mesPartModel = new MesPartModel();
|
|
|
|
|
mesPartModel.setPartNo(workOrderPart.getPartNo());
|
|
|
|
|
mesPartModel.setLocateNo(moveRules.get(0).getErpDestLocateNo());
|
|
|
|
|
mesPartModels.add(mesPartModel);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) {
|
|
|
|
|
for (MesPartModel mesPartModel : mesPartModels) {
|
|
|
|
|
//移库
|
|
|
|
|
MesMove move = createMove(model, mesPartModel.getLocateNo(),target, org, model.getWorkCenterCode());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
}
|
|
|
|
|
} else if (headModel) {
|
|
|
|
|
//移库
|
|
|
|
|
if (StringUtils.isEmpty(source)) MesPcnException.throwBusiException("未找到来源库位!");
|
|
|
|
|
MesMove move = createMove(model, source, target, org, model.getWorkCenterCode());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "客退品查询")
|
|
|
|
|