|
|
|
@ -2,14 +2,12 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdOrgExtService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesConfigService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesNcProcessingService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnExtService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkOrderExtService;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.*;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.apiservice.dao.IMesNcProcessingDao;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingInputModel;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingModel;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingPartAndLotModel;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartModel;
|
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
@ -115,7 +113,20 @@ public class MesNcProcessingService implements IMesNcProcessingService {
|
|
|
|
|
private MesWorkOrderRepository workOrderRepository;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesWorkOrderPartRepository workOrderPartRepository;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesPartProdGroupRepository mesPartProdGroupRao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesProductionRecordRepository productionRecordRepository;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesPartService mesPartService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesMoveRuleRepository mesMoveRuleRepository;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ListPager<MesPartInspection> queryPartInspectionByPager(MesPartInspection partInspection, Pager pager) {
|
|
|
|
|
|
|
|
|
@ -351,7 +362,48 @@ public class MesNcProcessingService implements IMesNcProcessingService {
|
|
|
|
|
isWorkOrderQcStatus= centerDb.getCenterType() == MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 是否头零件模式
|
|
|
|
|
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) {
|
|
|
|
|
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(sn.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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String source = configService.getCfgValue(org, "LGORT");
|
|
|
|
|
String refundSource = configService.getCfgValue(org, "REFUND");
|
|
|
|
|
if (!StringUtils.isEmpty(model.getProductVersion())) {
|
|
|
|
@ -411,10 +463,21 @@ public class MesNcProcessingService implements IMesNcProcessingService {
|
|
|
|
|
target = version.getReceiveInventoryPoint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//移库 转正常、放行:8000移至2000
|
|
|
|
|
MesMove move = createMove(model, sourceValue, target, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.NORMAL_MOVE);
|
|
|
|
|
ConvertBean.serviceModelInitialize(move,model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) {
|
|
|
|
|
for (MesPartModel mesPartModel : mesPartModels) {
|
|
|
|
|
//移库 转正常、放行:8000移至2000
|
|
|
|
|
MesMove move = createMove(model, sourceValue, mesPartModel.getLocateNo(), org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.NORMAL_MOVE, mesPartModel.getPartNo());
|
|
|
|
|
ConvertBean.serviceModelInitialize(move, model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
}
|
|
|
|
|
} else if (headModel) {
|
|
|
|
|
//移库 转正常、放行:8000移至2000
|
|
|
|
|
MesMove move = createMove(model, sourceValue, target, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.NORMAL_MOVE);
|
|
|
|
|
ConvertBean.serviceModelInitialize(move, model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (type == MesExtEnumUtil.NC_TYPE.REWORK.getValue()) {
|
|
|
|
|
|
|
|
|
@ -471,11 +534,19 @@ public class MesNcProcessingService implements IMesNcProcessingService {
|
|
|
|
|
}
|
|
|
|
|
partInspectionRepository.save(model.getPartInspection());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MesMove move = createMove(model, sourceValue, areaCode, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.RETURN_MOVE);
|
|
|
|
|
ConvertBean.serviceModelInitialize(move,model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
if (!headModel) {
|
|
|
|
|
if (!CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) {
|
|
|
|
|
for (MesPartModel mesPartModel : mesPartModels) {
|
|
|
|
|
MesMove move = createMove(model, sourceValue, areaCode, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.RETURN_MOVE, mesPartModel.getPartNo());
|
|
|
|
|
ConvertBean.serviceModelInitialize(move, model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
MesMove move = createMove(model, sourceValue, areaCode, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.RETURN_MOVE);
|
|
|
|
|
ConvertBean.serviceModelInitialize(move, model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (type == MesExtEnumUtil.NC_TYPE.SCRAP.getValue()) {
|
|
|
|
|
//批次不需要校验条码
|
|
|
|
@ -518,18 +589,40 @@ public class MesNcProcessingService implements IMesNcProcessingService {
|
|
|
|
|
sourceValue = refundSource;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MesMove move = createMove(model, sourceValue, configService.getCfgValue(org, "SCRAP"), org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE);
|
|
|
|
|
ConvertBean.serviceModelInitialize(move,model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
if (!headModel) {
|
|
|
|
|
if (!CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) {
|
|
|
|
|
for (MesPartModel mesPartModel : mesPartModels) {
|
|
|
|
|
MesMove move = createMove(model, sourceValue, configService.getCfgValue(org, "SCRAP"), org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE,mesPartModel.getPartNo());
|
|
|
|
|
ConvertBean.serviceModelInitialize(move,model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
MesMove move = createMove(model, sourceValue, configService.getCfgValue(org, "SCRAP"), org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE);
|
|
|
|
|
ConvertBean.serviceModelInitialize(move,model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
String sourceValue = configService.getCfgValue(org, "UMLGO");
|
|
|
|
|
if (model.getOptType() == 2) {
|
|
|
|
|
sourceValue = refundSource;
|
|
|
|
|
}
|
|
|
|
|
//移库 转报废 根据责任方库区对应关系的主数据,选择哪个责任方,就移动到哪个库区(8000移至8002/8003)
|
|
|
|
|
MesMove move = createMove(model, sourceValue, areaCode, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE);
|
|
|
|
|
ConvertBean.serviceModelInitialize(move,model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
if (!headModel) {
|
|
|
|
|
if (!CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) {
|
|
|
|
|
for (MesPartModel mesPartModel : mesPartModels) {
|
|
|
|
|
//移库 转报废 根据责任方库区对应关系的主数据,选择哪个责任方,就移动到哪个库区(8000移至8002/8003)
|
|
|
|
|
MesMove move = createMove(model, sourceValue, areaCode, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE, mesPartModel.getPartNo());
|
|
|
|
|
ConvertBean.serviceModelInitialize(move,model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//移库 转报废 根据责任方库区对应关系的主数据,选择哪个责任方,就移动到哪个库区(8000移至8002/8003)
|
|
|
|
|
MesMove move = createMove(model, sourceValue, areaCode, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE);
|
|
|
|
|
ConvertBean.serviceModelInitialize(move,model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (type == MesExtEnumUtil.NC_TYPE.RELEASE.getValue()) {
|
|
|
|
@ -576,13 +669,20 @@ public class MesNcProcessingService implements IMesNcProcessingService {
|
|
|
|
|
target = version.getReceiveInventoryPoint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//移库 转正常、放行:8000移至2000
|
|
|
|
|
MesMove move = createMove(model, sourceValue, target, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.NORMAL_MOVE);
|
|
|
|
|
ConvertBean.serviceModelInitialize(move,model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
|
|
|
|
|
if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) {
|
|
|
|
|
for (MesPartModel mesPartModel : mesPartModels) {
|
|
|
|
|
//移库 转正常、放行:8000移至2000
|
|
|
|
|
MesMove move = createMove(model, sourceValue, mesPartModel.getLocateNo(), org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.NORMAL_MOVE, mesPartModel.getPartNo());
|
|
|
|
|
ConvertBean.serviceModelInitialize(move, model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
}
|
|
|
|
|
} else if (headModel) {
|
|
|
|
|
//移库 转正常、放行:8000移至2000
|
|
|
|
|
MesMove move = createMove(model, sourceValue, target, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.NORMAL_MOVE);
|
|
|
|
|
ConvertBean.serviceModelInitialize(move, model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public MesWorkOrder getWorkOrder(String organizeCode, String workOrderNo) {
|
|
|
|
|
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workOrderNo)) return null;
|
|
|
|
@ -674,4 +774,31 @@ public class MesNcProcessingService implements IMesNcProcessingService {
|
|
|
|
|
move.setWorkCenter(prodOrgExtService.getErpWorkCenterCode(org, workCenterCode));
|
|
|
|
|
return move;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MesMove createMove(MesNcProcessingInputModel model, String source, String target, String org, String workCenterCode, MesExtEnumUtil.MOVE_TYPE moveType, String partNo) {
|
|
|
|
|
GenSerialNoModel serialNoModel = new GenSerialNoModel("INPUT_DEFECT_ZRSUM");
|
|
|
|
|
serialNoModel.setPartNo(partNo);
|
|
|
|
|
ResultBean rb = syncFuncService.syncSerialNo(serialNoModel, model.getPartInspection().getModifyUser(), org, 1);
|
|
|
|
|
String zrsum = "";
|
|
|
|
|
if (null != rb && !CollectionUtils.isEmpty(rb.getResultList())) {
|
|
|
|
|
zrsum = (rb.getResultList().get(0)).toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MesMove move = new MesMove();
|
|
|
|
|
move.setMatnr(partNo);
|
|
|
|
|
move.setOrganizeCode(org);
|
|
|
|
|
move.setFactoryCode(org);
|
|
|
|
|
move.setLgort(source);
|
|
|
|
|
move.setUmlgo(target);
|
|
|
|
|
move.setMenge(model.getPartInspection().getQty());
|
|
|
|
|
move.setMeins(model.getPart().getUnit());
|
|
|
|
|
move.setZrsum(zrsum);
|
|
|
|
|
move.setPostDate(TimeTool.getToday());
|
|
|
|
|
move.setPostTime(TimeTool.getTimeShortWithColon());
|
|
|
|
|
move.setMoveType(moveType.getValue());
|
|
|
|
|
move.setPartInspectionId(model.getPartInspection().getId());
|
|
|
|
|
move.setProductSn(model.getSn());
|
|
|
|
|
move.setWorkCenter(prodOrgExtService.getErpWorkCenterCode(org, workCenterCode));
|
|
|
|
|
return move;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|