|
|
|
@ -4,10 +4,7 @@ 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.*;
|
|
|
|
|
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.model.*;
|
|
|
|
|
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;
|
|
|
|
@ -22,6 +19,7 @@ import cn.estsh.i3plus.pojo.base.util.StringUtil;
|
|
|
|
|
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.nc.MesPartInspectionPerson;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.rework.MesReworkTask;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.bean.rework.MesReworkTaskDetail;
|
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
|
|
|
|
@ -124,6 +122,10 @@ public class MesNcProcessingService implements IMesNcProcessingService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private IMesMoveRuleRepository mesMoveRuleRepository;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private MesPartInspectionPersonRepository mesPartInspectionPersonRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ListPager<MesPartInspection> queryPartInspectionByPager(MesPartInspection partInspection, Pager pager) {
|
|
|
|
|
|
|
|
|
@ -204,11 +206,8 @@ public class MesNcProcessingService implements IMesNcProcessingService {
|
|
|
|
|
//保存数据
|
|
|
|
|
saveDate(model, model.getPart(), type, person, org,model.getInventoryLocationCode(),isOrder);
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
Integer type = model.getType();
|
|
|
|
|
MesDefectType person = StringUtil.isEmpty(model.getPerson())?new MesDefectType():model.getPerson();
|
|
|
|
|
//保存数据
|
|
|
|
|
saveDate(model, model.getPart(), type, person, org,model.getInventoryLocationCode(), isOrder);
|
|
|
|
|
saveLotDate(model, model.getPart(), org, isOrder);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -698,6 +697,227 @@ public class MesNcProcessingService implements IMesNcProcessingService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存数据
|
|
|
|
|
*
|
|
|
|
|
* @param part
|
|
|
|
|
* @param model
|
|
|
|
|
* @param org
|
|
|
|
|
*/
|
|
|
|
|
private void saveLotDate(MesNcProcessingInputModel model, MesPartSap part,String org, boolean isOrder) {
|
|
|
|
|
String workCenterCode = null == model.getPartInspection() ? null : model.getPartInspection().getWorkCenterCode();
|
|
|
|
|
assert model.getPartInspection() != null;
|
|
|
|
|
model.getPartInspection().setQmsSync(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
|
|
|
|
|
|
|
|
|
String refundSource = configService.getCfgValue(org, "REFUND");
|
|
|
|
|
List<MesPartInspectionPerson> personList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
MesPartInspection mesPartInspection = model.getPartInspection();
|
|
|
|
|
for (MesNcPersonModel mesNcPersonModel : model.getPersonModelList()) {
|
|
|
|
|
Integer type = mesNcPersonModel.getNcStatus();
|
|
|
|
|
|
|
|
|
|
if (type == MesExtEnumUtil.PART_INSPECTION_NC_STATUS.NORMAL.getValue()) {
|
|
|
|
|
|
|
|
|
|
model.getPartInspection().setInspectionStatus(MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue());
|
|
|
|
|
model.getPartInspection().setNcStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.NORMAL.getValue());
|
|
|
|
|
ConvertBean.serviceModelUpdate(model.getPartInspection(), model.getUserName());
|
|
|
|
|
String sourceValue = configService.getCfgValue(org, "UMLGO");
|
|
|
|
|
|
|
|
|
|
if (model.getOptType() == 2) {
|
|
|
|
|
sourceValue = refundSource;
|
|
|
|
|
model.getPartInspection().setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//partInspectionRepository.save(model.getPartInspection());
|
|
|
|
|
|
|
|
|
|
MesPartInspectionPerson mesPartInspectionPerson = new MesPartInspectionPerson();
|
|
|
|
|
mesPartInspectionPerson.setQty(Double.valueOf(mesNcPersonModel.getQty()));
|
|
|
|
|
mesPartInspectionPerson.setNcStatus(mesNcPersonModel.getNcStatus());
|
|
|
|
|
mesPartInspectionPerson.setSn(model.getPartInspection().getSn());
|
|
|
|
|
mesPartInspectionPerson.setOrganizeCode(model.getOrganizeCode());
|
|
|
|
|
mesPartInspectionPerson.setPid(model.getPartInspection().getId());
|
|
|
|
|
ConvertBean.serviceModelInitialize(mesPartInspectionPerson, model.getUserName());
|
|
|
|
|
personList.add(mesPartInspectionPerson);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String target = configService.getCfgValue(org, "LGORT");
|
|
|
|
|
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(model.getPart().getPartNo(), "partNo", ddlPackBean);
|
|
|
|
|
|
|
|
|
|
MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean);
|
|
|
|
|
if (version != null) {
|
|
|
|
|
target = version.getReceiveInventoryPoint();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//移库 转正常、放行:8000移至2000
|
|
|
|
|
MesMove move = createLotMove(model,mesNcPersonModel.getQty(), sourceValue, target, org, workCenterCode, MesExtEnumUtil.MOVE_TYPE.NORMAL_MOVE);
|
|
|
|
|
ConvertBean.serviceModelInitialize(move, model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
}
|
|
|
|
|
else if (type == MesExtEnumUtil.PART_INSPECTION_NC_STATUS.REWORK.getValue()) {
|
|
|
|
|
|
|
|
|
|
//生成返工单 根据责任方库区对应关系,选择哪个责任方,就移动到哪个库区(8000移至8002/8003);
|
|
|
|
|
GenSerialNoModel serialNoModel = new GenSerialNoModel("NC_REWORK");
|
|
|
|
|
serialNoModel.setPartNo(part.getPartNo());
|
|
|
|
|
ResultBean rb = syncFuncService.syncSerialNo(serialNoModel, model.getPartInspection().getModifyUser(), org, 1);
|
|
|
|
|
String rework = "";
|
|
|
|
|
if (null != rb && !CollectionUtils.isEmpty(rb.getResultList())) {
|
|
|
|
|
rework = (rb.getResultList().get(0)).toString();
|
|
|
|
|
}
|
|
|
|
|
MesPartInspectionPerson mesPartInspectionPerson = new MesPartInspectionPerson();
|
|
|
|
|
mesPartInspectionPerson.setQty(Double.valueOf(mesNcPersonModel.getQty()));
|
|
|
|
|
mesPartInspectionPerson.setNcStatus(mesNcPersonModel.getNcStatus());
|
|
|
|
|
mesPartInspectionPerson.setSn(model.getPartInspection().getSn());
|
|
|
|
|
mesPartInspectionPerson.setOrganizeCode(model.getOrganizeCode());
|
|
|
|
|
mesPartInspectionPerson.setPid(model.getPartInspection().getId());
|
|
|
|
|
|
|
|
|
|
DdlPackBean partyPackBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(mesNcPersonModel.getOnlyPerson(), "responsibleParty", partyPackBean);
|
|
|
|
|
MesOrg mesOrg = mesOrgRDao.getByProperty(partyPackBean);
|
|
|
|
|
|
|
|
|
|
mesPartInspectionPerson.setResponsibleParty(mesOrg.getResponsibleParty());
|
|
|
|
|
ConvertBean.serviceModelInitialize(mesPartInspectionPerson, model.getUserName());
|
|
|
|
|
personList.add(mesPartInspectionPerson);
|
|
|
|
|
|
|
|
|
|
MesReworkTask reworkTask = new MesReworkTask();
|
|
|
|
|
reworkTask.setQty(mesNcPersonModel.getQty());
|
|
|
|
|
reworkTask.setSn(model.getPartInspection().getSn());
|
|
|
|
|
reworkTask.setReworkOrder(rework);
|
|
|
|
|
reworkTask.setStatus(MesExtEnumUtil.REWORK_TASK_STATUS.CREATE.getValue());
|
|
|
|
|
reworkTask.setPartNo(model.getPartInspection().getPartNo());
|
|
|
|
|
reworkTask.setPartName(model.getPartInspection().getPartName());
|
|
|
|
|
reworkTask.setPartInspectionId(model.getPartInspection().getId());
|
|
|
|
|
reworkTask.setOrganizeCode(org);
|
|
|
|
|
reworkTask.setResponsibleParty(mesNcPersonModel.getOnlyPerson());
|
|
|
|
|
reworkTask.setDisassembleType(MesPcnExtConstWords.ZERO);
|
|
|
|
|
reworkTask.setLotNo(model.getPartInspection().getLotNo());
|
|
|
|
|
reworkTask.setType(model.getPartInspection().getSourceType());
|
|
|
|
|
ConvertBean.serviceModelInitialize(reworkTask, model.getUserName());
|
|
|
|
|
reworkTaskRepository.insert(reworkTask);
|
|
|
|
|
|
|
|
|
|
//生成返工单明细
|
|
|
|
|
List<MesReworkTaskDetail> taskDetailList = new ArrayList<>();
|
|
|
|
|
for (MesPartInspectionDetail detail : model.getPartInspectionDetailList()) {
|
|
|
|
|
|
|
|
|
|
MesReworkTaskDetail taskDetail = new MesReworkTaskDetail();
|
|
|
|
|
taskDetail.setPid(reworkTask.getId());
|
|
|
|
|
taskDetail.setStatus(MesExtEnumUtil.REWORK_TASK_DETAIL_STATUS.REWORK_TASK_DETAIL_STATUS_10.getValue());
|
|
|
|
|
taskDetail.setPartInspectionDetailId(detail.getId());
|
|
|
|
|
taskDetail.setOrganizeCode(org);
|
|
|
|
|
ConvertBean.serviceModelInitialize(taskDetail, model.getUserName());
|
|
|
|
|
taskDetailList.add(taskDetail);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reworkTaskDetailRepository.saveAll(taskDetailList);
|
|
|
|
|
|
|
|
|
|
//model.getPartInspection().setDefectTypeId(person.getId());
|
|
|
|
|
model.getPartInspection().setNcStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.REWORK.getValue());
|
|
|
|
|
model.getPartInspection().setReworkTaskId(reworkTask.getId());
|
|
|
|
|
ConvertBean.serviceModelUpdate(model.getPartInspection(),model.getUserName());
|
|
|
|
|
String sourceValue = configService.getCfgValue(org, "UMLGO");
|
|
|
|
|
|
|
|
|
|
if (model.getOptType() == 2) {
|
|
|
|
|
sourceValue = refundSource;
|
|
|
|
|
model.getPartInspection().setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
|
}
|
|
|
|
|
//partInspectionRepository.save(model.getPartInspection());
|
|
|
|
|
|
|
|
|
|
MesMove move = createLotMove(model,mesNcPersonModel.getQty(), sourceValue, mesNcPersonModel.getInventoryLocationCode(), org,workCenterCode, MesExtEnumUtil.MOVE_TYPE.RETURN_MOVE);
|
|
|
|
|
ConvertBean.serviceModelInitialize(move, model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
|
|
|
|
|
} else if (type == MesExtEnumUtil.PART_INSPECTION_NC_STATUS.SCRAP.getValue()) {
|
|
|
|
|
//报废时设置责任人
|
|
|
|
|
model.getPartInspection().setResponsibleParty(mesNcPersonModel.getOnlyPerson());
|
|
|
|
|
//model.getPartInspection().setDefectTypeId(person.getId());
|
|
|
|
|
model.getPartInspection().setNcStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.SCRAP.getValue());
|
|
|
|
|
model.getPartInspection().setRejectQty(model.getPartInspection().getQty());
|
|
|
|
|
ConvertBean.serviceModelUpdate(model.getPartInspection(), model.getUserName());
|
|
|
|
|
|
|
|
|
|
if (model.getOptType() == 2) {
|
|
|
|
|
model.getPartInspection().setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//partInspectionRepository.save(model.getPartInspection());
|
|
|
|
|
|
|
|
|
|
MesPartInspectionPerson mesPartInspectionPerson = new MesPartInspectionPerson();
|
|
|
|
|
mesPartInspectionPerson.setQty(Double.valueOf(mesNcPersonModel.getQty()));
|
|
|
|
|
mesPartInspectionPerson.setNcStatus(mesNcPersonModel.getNcStatus());
|
|
|
|
|
mesPartInspectionPerson.setSn(model.getPartInspection().getSn());
|
|
|
|
|
mesPartInspectionPerson.setOrganizeCode(model.getOrganizeCode());
|
|
|
|
|
mesPartInspectionPerson.setPid(model.getPartInspection().getId());
|
|
|
|
|
|
|
|
|
|
DdlPackBean partyPackBean = DdlPackBean.getDdlPackBean(org);
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(mesNcPersonModel.getOnlyPerson(), "responsibleParty", partyPackBean);
|
|
|
|
|
MesOrg mesOrg = mesOrgRDao.getByProperty(partyPackBean);
|
|
|
|
|
if (mesOrg ==null) {
|
|
|
|
|
throw new ImppBusiException(String.format("责任人【%s】不存在", mesNcPersonModel.getOnlyPerson()));
|
|
|
|
|
}
|
|
|
|
|
mesPartInspectionPerson.setResponsibleParty(mesOrg.getResponsibleParty());
|
|
|
|
|
ConvertBean.serviceModelInitialize(mesPartInspectionPerson, model.getUserName());
|
|
|
|
|
personList.add(mesPartInspectionPerson);
|
|
|
|
|
|
|
|
|
|
String sourceValue = configService.getCfgValue(org, "UMLGO");
|
|
|
|
|
if (model.getOptType() == 2) {
|
|
|
|
|
sourceValue = refundSource;
|
|
|
|
|
}
|
|
|
|
|
//移库 转报废 根据责任方库区对应关系的主数据,选择哪个责任方,就移动到哪个库区(8000移至8002/8003)
|
|
|
|
|
MesMove move = createLotMove(model,mesNcPersonModel.getQty(), sourceValue, mesNcPersonModel.getInventoryLocationCode(), org, workCenterCode, MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE);
|
|
|
|
|
ConvertBean.serviceModelInitialize(move,model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
} else if (type == MesExtEnumUtil.PART_INSPECTION_NC_STATUS.RELEASE.getValue()) {
|
|
|
|
|
//更新检验单
|
|
|
|
|
/* if (model.getType() != 10 && model.getType() != 40) {
|
|
|
|
|
model.getPartInspection().setDefectTypeId(person.getId());
|
|
|
|
|
}*/
|
|
|
|
|
model.getPartInspection().setInspectionStatus(MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue());
|
|
|
|
|
model.getPartInspection().setNcStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.RELEASE.getValue());
|
|
|
|
|
ConvertBean.serviceModelUpdate(model.getPartInspection(), model.getUserName());
|
|
|
|
|
String sourceValue = configService.getCfgValue(org, "UMLGO");
|
|
|
|
|
|
|
|
|
|
if (model.getOptType() == 2) {
|
|
|
|
|
sourceValue = refundSource;
|
|
|
|
|
model.getPartInspection().setRefundFlag(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
|
}
|
|
|
|
|
//partInspectionRepository.save(model.getPartInspection());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MesPartInspectionPerson mesPartInspectionPerson = new MesPartInspectionPerson();
|
|
|
|
|
mesPartInspectionPerson.setQty(Double.valueOf(mesNcPersonModel.getQty()));
|
|
|
|
|
mesPartInspectionPerson.setNcStatus(mesNcPersonModel.getNcStatus());
|
|
|
|
|
mesPartInspectionPerson.setSn(model.getPartInspection().getSn());
|
|
|
|
|
mesPartInspectionPerson.setOrganizeCode(model.getOrganizeCode());
|
|
|
|
|
mesPartInspectionPerson.setPid(model.getPartInspection().getId());
|
|
|
|
|
|
|
|
|
|
ConvertBean.serviceModelInitialize(mesPartInspectionPerson, model.getUserName());
|
|
|
|
|
personList.add(mesPartInspectionPerson);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String target = configService.getCfgValue(org, "LGORT");
|
|
|
|
|
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean();
|
|
|
|
|
DdlPreparedPack.getStringEqualPack(model.getPart().getPartNo(), "partNo", ddlPackBean);
|
|
|
|
|
|
|
|
|
|
MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean);
|
|
|
|
|
if (version != null) {
|
|
|
|
|
target = version.getReceiveInventoryPoint();
|
|
|
|
|
}
|
|
|
|
|
//移库 转正常、放行:8000移至2000
|
|
|
|
|
MesMove move = createLotMove(model,mesNcPersonModel.getQty(), sourceValue, target, org, workCenterCode, MesExtEnumUtil.MOVE_TYPE.NORMAL_MOVE);
|
|
|
|
|
ConvertBean.serviceModelInitialize(move, model.getUserName());
|
|
|
|
|
moveRepository.save(move);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mesPartInspection.setNcStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.SUCCESS.getValue());
|
|
|
|
|
ConvertBean.serviceModelUpdate(mesPartInspection, model.getUserName());
|
|
|
|
|
partInspectionRepository.save(mesPartInspection);
|
|
|
|
|
mesPartInspectionPersonRepository.saveAll(personList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MesWorkOrder getWorkOrder(String organizeCode, String workOrderNo) {
|
|
|
|
|
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workOrderNo)) return null;
|
|
|
|
|
return workOrderRepository.getByProperty(
|
|
|
|
@ -789,6 +1009,33 @@ public class MesNcProcessingService implements IMesNcProcessingService {
|
|
|
|
|
return move;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MesMove createLotMove(MesNcProcessingInputModel model,double qty, String source, String target, String org, String workCenterCode, MesExtEnumUtil.MOVE_TYPE moveType) {
|
|
|
|
|
GenSerialNoModel serialNoModel = new GenSerialNoModel("INPUT_DEFECT_ZRSUM");
|
|
|
|
|
serialNoModel.setPartNo(model.getPart().getPartNo());
|
|
|
|
|
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(model.getPart().getPartNo());
|
|
|
|
|
move.setOrganizeCode(org);
|
|
|
|
|
move.setFactoryCode(org);
|
|
|
|
|
move.setLgort(source);
|
|
|
|
|
move.setUmlgo(target);
|
|
|
|
|
move.setMenge(qty);
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|