Merge branch 'uat' into uat-temp-wj-lijia-prod

uat-temp-wj-lijia-prod
王杰 3 months ago
commit 25e4d011fe

@ -1,8 +1,12 @@
package cn.estsh.i3plus.ext.mes.pcn.api.base; package cn.estsh.i3plus.ext.mes.pcn.api.base;
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplate; import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplate;
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplateFieldValue;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.List;
import java.util.Map;
public interface IMesTemplateService { public interface IMesTemplateService {
/** /**
@ -16,4 +20,6 @@ public interface IMesTemplateService {
@ApiOperation(value = "按条件查询", notes = "按条件查询") @ApiOperation(value = "按条件查询", notes = "按条件查询")
MesLabelTemplate getLabelTemplate(String templateCode, String organizeCode); MesLabelTemplate getLabelTemplate(String templateCode, String organizeCode);
Map<String, Object> queryMesLabelTemplateParamPartValue(String partNo, String labelTemplate, String organizeCode);
} }

@ -4,7 +4,6 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionInputModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionViewModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionViewModel;
import cn.estsh.i3plus.pojo.mes.bean.MesPartTypeDefect; import cn.estsh.i3plus.pojo.mes.bean.MesPartTypeDefect;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn; import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionDetail;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.List; import java.util.List;
@ -20,14 +19,14 @@ public interface IMesInputDefectRecordService {
@ApiOperation(value = "查询页面信息") @ApiOperation(value = "查询页面信息")
MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel model, String org); MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel model);
@ApiOperation(value = "零件类型缺陷类型对应关系信息") @ApiOperation(value = "零件类型缺陷类型对应关系信息")
List<MesPartTypeDefect> queryPartTypeDefect(String serialNumber, String defectLocation, boolean flg, Integer frontBack, String org); List<MesPartTypeDefect> queryPartTypeDefect(String serialNumber, String defectLocation, boolean flg, Integer frontBack, String org);
@ApiOperation(value = "完成质检") @ApiOperation(value = "完成质检")
void savePartInspection(MesPartInspectionInputModel model, String org); void savePartInspection(MesPartInspectionInputModel model);
@ApiOperation(value = "客退品") @ApiOperation(value = "客退品")
MesProduceSn customerBack(String organizeCode, String sn, String userName); MesProduceSn customerBack(String organizeCode, String sn, String userName);

@ -20,21 +20,19 @@ import java.util.List;
**/ **/
public interface IMesNcProcessingService { public interface IMesNcProcessingService {
@ApiOperation(value = "查询NC-零件检测-单据") @ApiOperation(value = "查询NC-零件检测-单据")
public ListPager<MesPartInspection> queryPartInspectionByPager(MesPartInspection partInspection, Pager pager); ListPager<MesPartInspection> queryPartInspectionByPager(MesPartInspection partInspection, Pager pager);
@ApiOperation(value = "查询NC-零件检测-单据") @ApiOperation(value = "查询NC-零件检测-单据")
public MesNcProcessingModel queryPartInspection(MesPartInspection partInspection); MesNcProcessingModel queryPartInspection(MesPartInspection partInspection);
@ApiOperation(value = "查询责任人") @ApiOperation(value = "查询责任人")
public List<MesDefectType> queryPerson(String org); List<MesDefectType> queryPerson(String org);
@ApiOperation(value = "查询标记不良的物料及批次") @ApiOperation(value = "查询标记不良的物料及批次")
public ListPager<MesNcProcessingPartAndLotModel> queryPartLot(String partNo, String lot, String org, Pager pager); ListPager<MesNcProcessingPartAndLotModel> queryPartLot(String partNo, String lot, String org, Pager pager);
@ApiOperation(value = "NC处理") @ApiOperation(value = "NC处理")
public void saveNc(MesNcProcessingInputModel model, String org, boolean isOrder); void saveNc(MesNcProcessingInputModel model, String org, boolean isOrder);
} }

@ -4,6 +4,8 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintDataModel;
import cn.estsh.i3plus.pojo.mes.bean.MesPrintedSnLog; import cn.estsh.i3plus.pojo.mes.bean.MesPrintedSnLog;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.Map;
/** /**
* @Description : * @Description :
* @Reference : * @Reference :
@ -16,6 +18,9 @@ public interface IMesPrintedSnLogService {
@ApiOperation(value = "条码打印记录表") @ApiOperation(value = "条码打印记录表")
MesPrintedSnLog getMesPrintedSnLog(String userName, String organizeCode, MesProduceSnPrintDataModel printDataModel); MesPrintedSnLog getMesPrintedSnLog(String userName, String organizeCode, MesProduceSnPrintDataModel printDataModel);
@ApiOperation(value = "条码打印记录表")
MesPrintedSnLog getMesCustomPrintedSnLog(String userName, String organizeCode, MesProduceSnPrintDataModel printDataModel, Map<String, Object> printContext);
@ApiOperation(value = "写入条码打印记录表") @ApiOperation(value = "写入条码打印记录表")
void insertMesPrintedSnLog(MesPrintedSnLog mesPrintedSnLog,String userName); void insertMesPrintedSnLog(MesPrintedSnLog mesPrintedSnLog,String userName);
} }

@ -7,7 +7,6 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionInputModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionViewModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionViewModel;
import cn.estsh.i3plus.platform.common.tool.MathOperation; import cn.estsh.i3plus.platform.common.tool.MathOperation;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn; import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException; import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ResultBean; import cn.estsh.impp.framework.boot.util.ResultBean;
@ -35,8 +34,8 @@ public class MesInputDefectRecordController {
public ResultBean queryPartInspection(@RequestBody MesPartInspectionInputModel model) { public ResultBean queryPartInspection(@RequestBody MesPartInspectionInputModel model) {
try { try {
String organizeCode = !StringUtils.isEmpty(model.getOrganizeCode()) ? model.getOrganizeCode() : AuthUtil.getOrganize().getOrganizeCode(); ValidatorBean.checkNotNull(model.getOrganizeCode(), "工厂不能为空");
MesPartInspectionViewModel result = inputDefectRecordService.queryPartInspection(model, organizeCode); MesPartInspectionViewModel result = inputDefectRecordService.queryPartInspection(model);
String msg = "查询成功"; String msg = "查询成功";
if (!StringUtils.isEmpty(model.getFrontBack()) && model.getFrontBack().compareTo(10) == 0 && (Objects.isNull(result.getPartTypePicture()) || StringUtils.isEmpty(result.getPartTypePicture().getFrontPictureName()))) msg = "A面图片未维护"; if (!StringUtils.isEmpty(model.getFrontBack()) && model.getFrontBack().compareTo(10) == 0 && (Objects.isNull(result.getPartTypePicture()) || StringUtils.isEmpty(result.getPartTypePicture().getFrontPictureName()))) msg = "A面图片未维护";
if (!StringUtils.isEmpty(model.getFrontBack()) && model.getFrontBack().compareTo(20) == 0 && (Objects.isNull(result.getPartTypePicture()) || StringUtils.isEmpty(result.getPartTypePicture().getBackPictureName()))) msg = "B面图片未维护"; if (!StringUtils.isEmpty(model.getFrontBack()) && model.getFrontBack().compareTo(20) == 0 && (Objects.isNull(result.getPartTypePicture()) || StringUtils.isEmpty(result.getPartTypePicture().getBackPictureName()))) msg = "B面图片未维护";
@ -50,16 +49,14 @@ public class MesInputDefectRecordController {
@GetMapping("/query-part-type-defect") @GetMapping("/query-part-type-defect")
@ApiOperation(value = "查询零件类型缺陷类型对应关系") @ApiOperation(value = "查询零件类型缺陷类型对应关系")
public ResultBean queryPartTypeDefect(String partNo, String defectLocation, boolean flg, Integer frontBack,String organizeCode) { public ResultBean queryPartTypeDefect(String partNo, String defectLocation, boolean flg, Integer frontBack, String organizeCode) {
try { try {
// 数据校验
ValidatorBean.checkNotNull(partNo, "物料号不能为空"); ValidatorBean.checkNotNull(partNo, "物料号不能为空");
ValidatorBean.checkNotNull(defectLocation, "位置不能为空"); ValidatorBean.checkNotNull(defectLocation, "位置不能为空");
ValidatorBean.checkNotNull(frontBack, "正反面不能为空"); ValidatorBean.checkNotNull(frontBack, "正反面不能为空");
ValidatorBean.checkNotNull(organizeCode, "工厂不能为空");
// return ResultBean.success("查询成功").setResultList(inputDefectRecordService.queryPartTypeDefect(partNo, defectLocationCode, flg, frontBack, "2031")); return ResultBean.success("查询成功").setResultList(inputDefectRecordService.queryPartTypeDefect(partNo, defectLocation, flg, frontBack, organizeCode));
return ResultBean.success("查询成功").setResultList(inputDefectRecordService.queryPartTypeDefect(partNo, defectLocation, flg, frontBack,!StringUtils.isEmpty(organizeCode)?organizeCode:AuthUtil.getOrganizeCode()));
} catch (ImppBusiException imppException) { } catch (ImppBusiException imppException) {
return ResultBean.fail(imppException); return ResultBean.fail(imppException);
} catch (Exception e) { } catch (Exception e) {
@ -72,15 +69,14 @@ public class MesInputDefectRecordController {
public ResultBean savePartInspection(@RequestBody MesPartInspectionInputModel model) { public ResultBean savePartInspection(@RequestBody MesPartInspectionInputModel model) {
try { try {
ValidatorBean.checkNotNull(model.getOrganizeCode(), "工厂不能为空");
ValidatorBean.checkNotNull(model.getUserInfo(), "操作人不能为空");
if (StringUtils.isEmpty(model.getSn()) && if (StringUtils.isEmpty(model.getSn()) &&
(StringUtils.isEmpty(model.getPartNo()) || StringUtils.isEmpty(model.getLotNo()) || StringUtils.isEmpty(model.getQty()) || MathOperation.compareTo(model.getQty(), new Double(0)) == 0)) { (StringUtils.isEmpty(model.getPartNo()) || StringUtils.isEmpty(model.getLotNo()) || StringUtils.isEmpty(model.getQty()) || MathOperation.compareTo(model.getQty(), new Double(0)) == 0)) {
throw new ImppBusiException("条码为空或零件号+批次+数量为空"); throw new ImppBusiException("条码为空或零件号+批次+数量为空");
} }
// inputDefectRecordService.savePartInspection(model, "CK01"); inputDefectRecordService.savePartInspection(model);
inputDefectRecordService.savePartInspection(model, !StringUtils.isEmpty(model.getOrganizeCode())?model.getOrganizeCode():AuthUtil.getOrganizeCode());
return ResultBean.success("质检已完成,请继续"); return ResultBean.success("质检已完成,请继续");
} catch (ImppBusiException imppException) { } catch (ImppBusiException imppException) {
return ResultBean.fail(imppException); return ResultBean.fail(imppException);
@ -94,7 +90,6 @@ public class MesInputDefectRecordController {
public ResultBean customerBack(@RequestBody MesPartInspectionInputModel model) { public ResultBean customerBack(@RequestBody MesPartInspectionInputModel model) {
try { try {
// inputDefectRecordService.savePartInspection(model, "CK01");
MesProduceSn mesProduceSn = inputDefectRecordService.customerBack(model.getOrganizeCode(), model.getSn(), model.getUserInfo()); MesProduceSn mesProduceSn = inputDefectRecordService.customerBack(model.getOrganizeCode(), model.getSn(), model.getUserInfo());
return ResultBean.success("客退品已完成,请继续").setResultObject(mesProduceSn); return ResultBean.success("客退品已完成,请继续").setResultObject(mesProduceSn);
} catch (ImppBusiException imppException) { } catch (ImppBusiException imppException) {
@ -109,7 +104,6 @@ public class MesInputDefectRecordController {
public ResultBean customerBackCommit(@RequestBody MesPartInspectionInputModel model) { public ResultBean customerBackCommit(@RequestBody MesPartInspectionInputModel model) {
try { try {
// inputDefectRecordService.savePartInspection(model, "CK01");
inputDefectRecordService.customerBackCommit(model.getOrganizeCode(), model.getSn(), model.getUserInfo()); inputDefectRecordService.customerBackCommit(model.getOrganizeCode(), model.getSn(), model.getUserInfo());
return ResultBean.success("客退品提交已完成,请继续"); return ResultBean.success("客退品提交已完成,请继续");
} catch (ImppBusiException imppException) { } catch (ImppBusiException imppException) {

@ -8,7 +8,6 @@ import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager; import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection; import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException; import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ResultBean; import cn.estsh.impp.framework.boot.util.ResultBean;
@ -36,7 +35,7 @@ public class MesNcProcessingController {
public ResultBean queryPartInspectionByPager(MesPartInspection partInspection, Pager pager) { public ResultBean queryPartInspectionByPager(MesPartInspection partInspection, Pager pager) {
try { try {
ValidatorBean.checkNotNull(partInspection.getOrganizeCode(), "工厂不能为空");
partInspection.setOrganizeCode(partInspection.getOrganizeCode()); partInspection.setOrganizeCode(partInspection.getOrganizeCode());
ListPager<MesPartInspection> partInspectionListPager = ncProcessingService.queryPartInspectionByPager(partInspection, pager); ListPager<MesPartInspection> partInspectionListPager = ncProcessingService.queryPartInspectionByPager(partInspection, pager);
return ResultBean.success("查询成功").setListPager(partInspectionListPager); return ResultBean.success("查询成功").setListPager(partInspectionListPager);
@ -52,8 +51,7 @@ public class MesNcProcessingController {
public ResultBean queryPartInspection(MesPartInspection partInspection) { public ResultBean queryPartInspection(MesPartInspection partInspection) {
try { try {
ValidatorBean.checkNotNull(partInspection.getOrganizeCode(), "工厂不能为空");
partInspection.setOrganizeCode(!StringUtils.isEmpty(partInspection.getOrganizeCode())?partInspection.getOrganizeCode():AuthUtil.getOrganizeCode());
return ResultBean.success("查询成功").setResultObject(ncProcessingService.queryPartInspection(partInspection)); return ResultBean.success("查询成功").setResultObject(ncProcessingService.queryPartInspection(partInspection));
} catch (ImppBusiException imppException) { } catch (ImppBusiException imppException) {
return ResultBean.fail(imppException); return ResultBean.fail(imppException);
@ -67,8 +65,8 @@ public class MesNcProcessingController {
public ResultBean queryPerson(String organizeCode) { public ResultBean queryPerson(String organizeCode) {
try { try {
ValidatorBean.checkNotNull(organizeCode, "工厂不能为空");
return ResultBean.success("查询成功").setResultList(ncProcessingService.queryPerson(!StringUtils.isEmpty(organizeCode)?organizeCode:AuthUtil.getOrganizeCode())); return ResultBean.success("查询成功").setResultList(ncProcessingService.queryPerson(organizeCode));
} catch (ImppBusiException imppException) { } catch (ImppBusiException imppException) {
return ResultBean.fail(imppException); return ResultBean.fail(imppException);
} catch (Exception e) { } catch (Exception e) {
@ -82,7 +80,8 @@ public class MesNcProcessingController {
public ResultBean saveNc(@RequestBody MesNcProcessingInputModel model) { public ResultBean saveNc(@RequestBody MesNcProcessingInputModel model) {
try { try {
// 数据校验 ValidatorBean.checkNotNull(model.getOrganizeCode(), "工厂不能为空");
ValidatorBean.checkNotNull(model.getUserName(), "操作人不能为空");
ValidatorBean.checkNotNull(model.getPartInspection(), "单据不能为空"); ValidatorBean.checkNotNull(model.getPartInspection(), "单据不能为空");
ValidatorBean.checkNotNull(model.getPartInspectionDetailList(), "单据明细不能为空"); ValidatorBean.checkNotNull(model.getPartInspectionDetailList(), "单据明细不能为空");
if (model.getType() == MesExtEnumUtil.NC_TYPE.REWORK.getValue() if (model.getType() == MesExtEnumUtil.NC_TYPE.REWORK.getValue()
@ -102,7 +101,7 @@ public class MesNcProcessingController {
if (CollectionUtils.isEmpty(model.getPartInspectionDetailList())) { if (CollectionUtils.isEmpty(model.getPartInspectionDetailList())) {
throw new ImppBusiException("不存在可疑信息,请检查数据"); throw new ImppBusiException("不存在可疑信息,请检查数据");
} }
ncProcessingService.saveNc(model, !StringUtils.isEmpty(model.getOrganizeCode())? model.getOrganizeCode() : AuthUtil.getOrganizeCode(), false); ncProcessingService.saveNc(model, model.getOrganizeCode(), false);
return ResultBean.success("NC处理成功"); return ResultBean.success("NC处理成功");
} catch (ImppBusiException imppException) { } catch (ImppBusiException imppException) {
return ResultBean.fail(imppException); return ResultBean.fail(imppException);

@ -10,6 +10,7 @@ import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyNosortContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyNosortContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblySortContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblySortContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskRequestModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskRequestModel;
@ -142,6 +143,18 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
@Autowired @Autowired
private MesProductVersionRepository productVersionRepository; private MesProductVersionRepository productVersionRepository;
@Autowired
private MesProductionRecordRepository productionRecordRepository;
@Autowired
private IMesMoveRuleRepository mesMoveRuleRepository;
@Autowired
private MesWorkOrderPartRepository workOrderPartRepository;
@Autowired
private MesPartProdGroupRepository mesPartProdGroupRao;
@Override @Override
public ListPager<MesReworkTask> queryReworkTask(MesReworkTask mesReworkTask, Pager pager) { public ListPager<MesReworkTask> queryReworkTask(MesReworkTask mesReworkTask, Pager pager) {
String organizeCode = !StringUtils.isEmpty(mesReworkTask.getOrganizeCode())?mesReworkTask.getOrganizeCode():AuthUtil.getOrganizeCode(); String organizeCode = !StringUtils.isEmpty(mesReworkTask.getOrganizeCode())?mesReworkTask.getOrganizeCode():AuthUtil.getOrganizeCode();
@ -297,6 +310,65 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
// ConvertBean.serviceModelUpdate(mesPartInspection, requestModel.getUserName()); // ConvertBean.serviceModelUpdate(mesPartInspection, requestModel.getUserName());
mesPartInspectionRepository.update(mesPartInspection); mesPartInspectionRepository.update(mesPartInspection);
} }
// 是否头零件模式
boolean headModel = true;
if (!StringUtil.isEmpty(requestModel.getSn())) {
// 判断是头零件还是散件 查询加工记录
DdlPackBean productionPackBean = DdlPackBean.getDdlPackBean(mesReworkTask.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(requestModel.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(mesReworkTask.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(requestModel.getSn(), "workOrderNo", partPackBean);
List<MesWorkOrderPart> workOrderParts = workOrderPartRepository.findByHqlWhere(partPackBean);
if (!CollectionUtils.isEmpty(workOrderParts)) {
DdlPackBean partProdBean = DdlPackBean.getDdlPackBean(mesReworkTask.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(mesPartInspection.getWorkCenterCode(), "workCenterCode", partProdBean);
List<MesPartProdGroup> mesPartProdGroupList = mesPartProdGroupRao.findByHqlTopWhere(partProdBean, 1);
for (MesWorkOrderPart workOrderPart : workOrderParts) {
MesPart partInfo = mesPartService.getMesPartByPartNo(workOrderPart.getPartNo(), mesReworkTask.getOrganizeCode());
String esd = partInfo.getEsd();
// 查询移库规则
DdlPackBean movePackBean = DdlPackBean.getDdlPackBean(mesReworkTask.getOrganizeCode());
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 target = mesConfigService.getCfgValue(requestModel.getOrganizeCode(), "UMLGO");
String workCenterCode = "";
if (mesPartInspection != null) {
workCenterCode = mesPartInspection.getWorkCenterCode();
}
if (MesExtEnumUtil.NC_TYPE.REWORK.getValue() == requestModel.getType()) {
if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) {
String destLocateNo = getDestLocateNo(requestModel.getOrganizeCode(), mesPartInspection.getId());
for (MesPartModel mesPartModel : mesPartModels) {
doCreateReworkMove(requestModel,destLocateNo, target, workCenterCode, mesPartModel.getPartNo(), mesPartInspection.getId());
}
} else {
doCreateReworkMove(requestModel, getDestLocateNo(requestModel.getOrganizeCode(), mesPartInspection.getId()), target, workCenterCode, mesReworkTask.getPartNo(), mesPartInspection.getId());
}
}
} }
if (MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.LOT.getValue() == mesReworkTask.getType()) { if (MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.LOT.getValue() == mesReworkTask.getType()) {
mesReworkTask.setReworkedQty(requestModel.getReworkedQty()); mesReworkTask.setReworkedQty(requestModel.getReworkedQty());

@ -7,15 +7,25 @@ import cn.estsh.i3plus.platform.common.util.MesPcnConstWords;
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;
import cn.estsh.i3plus.pojo.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplate; import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplate;
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplateFieldInfo;
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplateFieldValue;
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplateParam; import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplateParam;
import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateFieldInfoRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateFieldValueRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateParamRepository; import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateParamRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateRepository; import cn.estsh.i3plus.pojo.mes.repository.MesLabelTemplateRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.hutool.core.util.ObjectUtil;
import org.apache.shiro.util.CollectionUtils; import org.apache.shiro.util.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.TreeMap;
/** /**
* @Description : * @Description :
@ -33,6 +43,12 @@ public class MesTemplateServiceImpl implements IMesTemplateService {
@Autowired @Autowired
private MesLabelTemplateParamRepository mesLabelTemplateParamRDao; private MesLabelTemplateParamRepository mesLabelTemplateParamRDao;
@Autowired
private MesLabelTemplateFieldInfoRepository labelTemplateFieldInfoRDao;
@Autowired
private MesLabelTemplateFieldValueRepository labelTemplateFieldValueRDao;
@Override @Override
public MesLabelTemplate getMesLabelTemplate(String templateCode,String organizeCode) { public MesLabelTemplate getMesLabelTemplate(String templateCode,String organizeCode) {
// 根据标签模板代码查询【MES_标签模板表】获取对应的方法代码 // 根据标签模板代码查询【MES_标签模板表】获取对应的方法代码
@ -70,4 +86,43 @@ public class MesTemplateServiceImpl implements IMesTemplateService {
} }
return mesLabelTemplate; return mesLabelTemplate;
} }
@Override
public Map<String, Object> queryMesLabelTemplateParamPartValue(String partNo, String labelTemplate, String organizeCode) {
if (StringUtil.isEmpty(labelTemplate)) {
MesPcnException.throwMesBusiException("零件号【%s】未维护\"零件条码匹配模板\"字段值", partNo);
}
Map<String, Object> result = new HashMap<>();
List<MesLabelTemplateFieldInfo> templateFieldInfos = labelTemplateFieldInfoRDao.findByProperty(
new String[]{"templateCode", "templateFieldType", MesPcnConstWords.IS_VALID, MesPcnConstWords.IS_DELETED, MesPcnConstWords.ORGANIZE_CODE},
new Object[]{labelTemplate, MesExtEnumUtil.LABEL_TEMPLATE_FIELD_TYPE.CUSTOM.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(),
CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), organizeCode});
Map<String, MesLabelTemplateFieldInfo> templateFieldInfoMap = new TreeMap<>();
for (MesLabelTemplateFieldInfo info : templateFieldInfos) {
templateFieldInfoMap.putIfAbsent(info.getTemplateParam(), info);
}
List<MesLabelTemplateFieldValue> fieldValueList = labelTemplateFieldValueRDao.findByProperty(
new String[]{"partNo", "templateCode", MesPcnConstWords.IS_VALID, MesPcnConstWords.IS_DELETED, MesPcnConstWords.ORGANIZE_CODE},
new Object[]{partNo, labelTemplate, CommonEnumUtil.IS_VAILD.VAILD.getValue(),
CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), organizeCode});
if (!CollectionUtils.isEmpty(fieldValueList)) {
for (MesLabelTemplateFieldValue fieldValue : fieldValueList) {
if (StringUtil.isEmpty(fieldValue.getTemplateParam())) {
continue;
}
MesLabelTemplateFieldInfo templateFieldInfo = templateFieldInfoMap.remove(fieldValue.getTemplateParam());
if (templateFieldInfo != null) {
result.put(templateFieldInfo.getTemplateParam(), ObjectUtil.clone(fieldValue.getFieldValue()));
}
}
}
for (Map.Entry<String, MesLabelTemplateFieldInfo> entry : templateFieldInfoMap.entrySet()) {
MesLabelTemplateFieldInfo fieldInfo = entry.getValue();
result.put(fieldInfo.getTemplateParam(), null);
}
return result;
}
} }

@ -10,6 +10,7 @@ import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant; import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionInputModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionInputModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionViewModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionViewModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService; 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;
@ -27,7 +28,6 @@ import cn.estsh.i3plus.pojo.mes.bean.rework.MesReworkTaskDetail;
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel; import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
import cn.estsh.i3plus.pojo.mes.repository.*; import cn.estsh.i3plus.pojo.mes.repository.*;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException; import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ResultBean; import cn.estsh.impp.framework.boot.util.ResultBean;
@ -42,7 +42,6 @@ import org.springframework.util.StringUtils;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* @Description : * @Description :
@ -117,55 +116,67 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
@Autowired @Autowired
private MesWorkCenterPartRelationRepository workCenterPartRelationRepository; private MesWorkCenterPartRelationRepository workCenterPartRelationRepository;
@Autowired
private MesProductionRecordRepository productionRecordRepository;
@Autowired
private IMesMoveRuleRepository mesMoveRuleRepository;
@Autowired
private MesWorkOrderPartRepository workOrderPartRepository;
@Autowired
private MesPartProdGroupRepository mesPartProdGroupRao;
@Override @Override
public MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel inputModel, String org) { public MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel model) {
//检查物料 //检查物料
MesPart part; MesPart part;
//获取NC-零件检测-单据 //获取NC-零件检测-单据
MesPartInspection partInspection = null; MesPartInspection partInspection = null;
Integer sourceType = null; Integer sourceType;
if (!StringUtils.isEmpty(inputModel.getSn())) { if (!StringUtils.isEmpty(model.getSn())) {
// 数据校验 // 数据校验
ValidatorBean.checkNotNull(inputModel.getFrontBack(), "正反面不能为空"); ValidatorBean.checkNotNull(model.getFrontBack(), "正反面不能为空");
//检查条码 //检查条码
MesProduceSn produceSn = checkProduceSn(inputModel.getSn(), org); MesProduceSn produceSn = checkProduceSn(model.getSn(), model.getOrganizeCode());
//获取NC-零件检测-单据 //获取NC-零件检测-单据
partInspection = getPartInspection(produceSn,inputModel, org); partInspection = getPartInspection(produceSn, model, model.getOrganizeCode());
//检查物料 //检查物料
part = checkPart(produceSn, org); part = checkPart(produceSn, model.getOrganizeCode());
sourceType = MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue(); sourceType = MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue();
} else { } else {
// 数据校验 // 数据校验
ValidatorBean.checkNotNull(inputModel.getPartNo(), "物料不能为空"); ValidatorBean.checkNotNull(model.getPartNo(), "物料不能为空");
ValidatorBean.checkNotNull(inputModel.getLotNo(), "批次不能为空"); ValidatorBean.checkNotNull(model.getLotNo(), "批次不能为空");
ValidatorBean.checkNotNull(inputModel.getFrontBack(), "正反面不能为空"); ValidatorBean.checkNotNull(model.getFrontBack(), "正反面不能为空");
ValidatorBean.checkNotNull(inputModel.getQty(), "数量不能为空"); ValidatorBean.checkNotNull(model.getQty(), "数量不能为空");
//检查物料 //检查物料
part = checkPartByPartNo(inputModel.getPartNo(), org); part = checkPartByPartNo(model.getPartNo(), model.getOrganizeCode());
//获取NC-零件检测-单据 //获取NC-零件检测-单据
if(!Objects.isNull(inputModel.getId())){ if(!Objects.isNull(model.getId())){
partInspection = getPartInspectionByPartAndLot(inputModel, org); partInspection = getPartInspectionByPartAndLot(model, model.getOrganizeCode());
} }
sourceType = MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.LOT.getValue(); sourceType = MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.LOT.getValue();
} }
//检查零件类型与图片对应关系 //检查零件类型与图片对应关系
MesPartTypePicture partTypePicture = checkPartTypePicture(part, org); MesPartTypePicture partTypePicture = checkPartTypePicture(part, model.getOrganizeCode());
//构造返回信息 //构造返回信息
MesPartInspectionViewModel model = getModel(partInspection, part, partTypePicture, inputModel, sourceType, org); MesPartInspectionViewModel result = getModel(partInspection, part, partTypePicture, model, sourceType);
model.setSourceType(sourceType); result.setSourceType(sourceType);
model.setTransferFlg(inputModel.isTransferFlg()); result.setTransferFlg(model.isTransferFlg());
return model; return result;
} }
/** /**
@ -222,12 +233,11 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
* - * -
* *
* @param model * @param model
* @param org
*/ */
@Override @Override
public void savePartInspection(MesPartInspectionInputModel model, String org) { public void savePartInspection(MesPartInspectionInputModel model) {
MesProduceSn produceSn = getProduceSn(model.getSn(), org); MesProduceSn produceSn = getProduceSn(model.getSn(), model.getOrganizeCode());
if (null != produceSn && StringUtils.isEmpty(model.getPartNo())) model.setPartNo(produceSn.getPartNo()); if (null != produceSn && StringUtils.isEmpty(model.getPartNo())) model.setPartNo(produceSn.getPartNo());
//武汉 会输入客户条码 //武汉 会输入客户条码
boolean isWorkOrderQcStatus=false; boolean isWorkOrderQcStatus=false;
@ -235,7 +245,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
model.setCustSn(produceSn.getCustSn()); model.setCustSn(produceSn.getCustSn());
model.setSn(produceSn.getProductSn()); model.setSn(produceSn.getProductSn());
//排序产线 更新工单的 qcStatus //排序产线 更新工单的 qcStatus
MesWorkCenter centerDb = prodOrgExtService.getWorkCenterDb(org, produceSn.getWorkCenterCode()); MesWorkCenter centerDb = prodOrgExtService.getWorkCenterDb(model.getOrganizeCode(), produceSn.getWorkCenterCode());
if (!StringUtil.isEmpty(centerDb)){ if (!StringUtil.isEmpty(centerDb)){
isWorkOrderQcStatus= centerDb.getCenterType() == MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue(); isWorkOrderQcStatus= centerDb.getCenterType() == MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue();
} }
@ -245,8 +255,52 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
model.getPartInspection().setQmsSync(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()); model.getPartInspection().setQmsSync(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
} }
if(!Objects.isNull(model.getPart())){ if(!Objects.isNull(model.getPart())){
model.setPart(mesPartService.getMesPartSapByPartNo(model.getPart().getPartNo(), org)); model.setPart(mesPartService.getMesPartSapByPartNo(model.getPart().getPartNo(), model.getOrganizeCode()));
} }
// 是否头零件模式
boolean headModel = true;
if (!StringUtil.isEmpty(model.getSn())) {
// 判断是头零件还是散件 查询加工记录
DdlPackBean productionPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
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(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(model.getSn(), "workOrderNo", partPackBean);
List<MesWorkOrderPart> workOrderParts = workOrderPartRepository.findByHqlWhere(partPackBean);
if (!CollectionUtils.isEmpty(workOrderParts)) {
DdlPackBean partProdBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(produceSn.getWorkCenterCode(), "workCenterCode", partProdBean);
List<MesPartProdGroup> mesPartProdGroupList = mesPartProdGroupRao.findByHqlTopWhere(partProdBean, 1);
for (MesWorkOrderPart workOrderPart : workOrderParts) {
MesPart partInfo = mesPartService.getMesPartByPartNo(workOrderPart.getPartNo(), model.getOrganizeCode());
String esd = partInfo.getEsd();
// 查询移库规则
DdlPackBean movePackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
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 (CollectionUtils.isEmpty(model.getPartInspectionDetailList())) { if (CollectionUtils.isEmpty(model.getPartInspectionDetailList())) {
MesPartInspection partInspection = null; MesPartInspection partInspection = null;
@ -257,23 +311,45 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
//若检验单为空,则生成新的单据并合格 //若检验单为空,则生成新的单据并合格
if (StringUtils.isEmpty(model.getPartInspection())) { if (StringUtils.isEmpty(model.getPartInspection())) {
partInspection = createPartInspection(model, MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue(), org); partInspection = createPartInspection(model, MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue(), model.getOrganizeCode());
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 = 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()) {
//已创建返修单
DdlPackBean reworkPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(model.getSn(), "sn", reworkPackBean);
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue(), "status", reworkPackBean);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, reworkPackBean);
int count = reworkTaskRepository.findByHqlWhereCount(reworkPackBean);
if (count > 0) {
// 如果是批次还需要移库
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean);
MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean);
String srcNo = configService.getCfgValue(model.getOrganizeCode(), "LGORT");
if (version != null) {
srcNo = version.getReceiveInventoryPoint();
}
String destLocateNo = getDestLocateNo(model, model.getOrganizeCode());
if(!model.isTransferFlg() && !Objects.equals(srcNo, destLocateNo)) {
throw new ImppBusiException(String.format("【%s】该条码需要完成质检,再重新录入电子化检验", model.getSn()));
}
}
checkProduceSn(produceSn, model.getSn()); checkProduceSn(produceSn, model.getSn());
produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue()); produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
ConvertBean.serviceModelInitialize(produceSn, AuthUtil.getSessionUser().getUserName()); ConvertBean.serviceModelInitialize(produceSn, model.getUserInfo());
produceSnExtService.update(produceSn); produceSnExtService.update(produceSn);
//更新工单对应qcStatus //更新工单对应qcStatus
if(isWorkOrderQcStatus){ if(isWorkOrderQcStatus){
MesWorkOrder workOrder = getWorkOrder(org,produceSn.getWorkOrderNo()); MesWorkOrder workOrder = getWorkOrder(model.getOrganizeCode(), produceSn.getWorkOrderNo());
if (!StringUtil.isEmpty(workOrder)){ if (!StringUtil.isEmpty(workOrder)){
workOrder.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue()); workOrder.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
ConvertBean.serviceModelUpdate(workOrder, AuthUtil.getSessionUser().getUserName()); ConvertBean.serviceModelUpdate(workOrder, model.getUserInfo());
workOrderRepository.update(workOrder); workOrderRepository.update(workOrder);
} }
} }
@ -284,7 +360,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
//原单据不合格 现合格 //原单据不合格 现合格
if (model.getPartInspection().getInspectionStatus() == MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue()) { if (model.getPartInspection().getInspectionStatus() == MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue()) {
model.getPartInspection().setInspectionStatus(MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue()); model.getPartInspection().setInspectionStatus(MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue());
ConvertBean.serviceModelUpdate(model.getPartInspection(), AuthUtil.getSessionUser().getUserName()); ConvertBean.serviceModelUpdate(model.getPartInspection(), model.getUserInfo());
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());
@ -292,13 +368,13 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
partInspectionRepository.save(model.getPartInspection()); partInspectionRepository.save(model.getPartInspection());
//查询当前单据明细 //查询当前单据明细
List<MesPartInspectionDetail> resultDetailList = queryResultDetailList(model, org); List<MesPartInspectionDetail> resultDetailList = queryResultDetailList(model, model.getOrganizeCode());
List<String> defectTypeNoExitList = new ArrayList<>(); List<String> defectTypeNoExitList = new ArrayList<>();
for (MesPartInspectionDetail detail : model.getPartInspectionDetailList()) { for (MesPartInspectionDetail detail : model.getPartInspectionDetailList()) {
//根据页面上选择的位置 查询位置,若不存在则提示 位置不存在,请检查数据 //根据页面上选择的位置 查询位置,若不存在则提示 位置不存在,请检查数据
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); DdlPackBean packBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(detail.getDefectLocation(), "defectTypeCode", packBean); DdlPreparedPack.getStringEqualPack(detail.getDefectLocation(), "defectTypeCode", packBean);
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.DEFECT_CATEGORY.POSITION.getValue(), "defectType", packBean); DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.DEFECT_CATEGORY.POSITION.getValue(), "defectType", packBean);
MesDefectType defectType = defectTypeRepository.getByProperty(packBean); MesDefectType defectType = defectTypeRepository.getByProperty(packBean);
@ -310,10 +386,10 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
detail.setDefectTypeId(defectType.getId()); detail.setDefectTypeId(defectType.getId());
detail.setId(null); detail.setId(null);
detail.setOrganizeCode(org); detail.setOrganizeCode(model.getOrganizeCode());
detail.setPid(model.getPartInspection().getId()); detail.setPid(model.getPartInspection().getId());
setSystemSyncStatus(detail); setSystemSyncStatus(detail);
ConvertBean.serviceModelInitialize(detail, AuthUtil.getSessionUser().getUserName()); ConvertBean.serviceModelInitialize(detail, model.getUserInfo());
} }
if (!CollectionUtils.isEmpty(defectTypeNoExitList)) { if (!CollectionUtils.isEmpty(defectTypeNoExitList)) {
@ -326,38 +402,48 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) {
checkProduceSn(produceSn, model.getSn()); checkProduceSn(produceSn, model.getSn());
produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue()); produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
ConvertBean.serviceModelInitialize(produceSn, AuthUtil.getSessionUser().getUserName()); ConvertBean.serviceModelInitialize(produceSn, model.getUserInfo());
produceSnExtService.update(produceSn); produceSnExtService.update(produceSn);
//更新工单对应qcStatus //更新工单对应qcStatus
if(isWorkOrderQcStatus){ if(isWorkOrderQcStatus){
MesWorkOrder workOrder = getWorkOrder(org,produceSn.getWorkOrderNo()); MesWorkOrder workOrder = getWorkOrder(model.getOrganizeCode(), produceSn.getWorkOrderNo());
if (!StringUtil.isEmpty(workOrder)){ if (!StringUtil.isEmpty(workOrder)){
workOrder.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue()); workOrder.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
ConvertBean.serviceModelUpdate(workOrder, AuthUtil.getSessionUser().getUserName()); ConvertBean.serviceModelUpdate(workOrder, model.getUserInfo());
workOrderRepository.update(workOrder); workOrderRepository.update(workOrder);
} }
} }
} }
//移库 //移库
String srcLocate; String srcLocate;
MesMove mesMove = getMesMove(model, org); MesMove mesMove = getMesMove(model, model.getOrganizeCode());
if(!Objects.isNull(mesMove)){ if(!Objects.isNull(mesMove)){
srcLocate = mesMove.getUmlgo(); srcLocate = mesMove.getUmlgo();
}else{ }else{
srcLocate= configService.getCfgValue(org, "UMLGO"); srcLocate= configService.getCfgValue(model.getOrganizeCode(), "UMLGO");
} }
if (model.getOptType() != 2) { if (model.getOptType() != 2) {
//移库
MesMove move = createMove(model, srcLocate, configService.getCfgValue(org, "LGORT"), org, null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) {
moveRepository.save(move); for (MesPartModel mesPartModel : mesPartModels) {
//移库
MesMove move = createMove(model, srcLocate, mesPartModel.getLocateNo(), model.getOrganizeCode(), null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode(),mesPartModel.getPartNo());
moveRepository.save(move);
}
} else {
//移库
MesMove move = createMove(model, srcLocate, configService.getCfgValue(model.getOrganizeCode(), "LGORT"), model.getOrganizeCode(), null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode());
moveRepository.save(move);
}
} }
} }
} }
if (model.isTransferFlg() && model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { if (model.isTransferFlg() && model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) {
//电子化检验 //电子化检验
String target = configService.getCfgValue(org, "LGORT"); String target = configService.getCfgValue(model.getOrganizeCode(), "LGORT");
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(org); DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean); DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean);
MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean); MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean);
@ -368,9 +454,16 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
if (partInspection != null) { if (partInspection != null) {
model.setPartInspection(partInspection); model.setPartInspection(partInspection);
} }
MesMove move = createMove(model, getDestLocateNo(model, org), target, org, null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) {
moveRepository.save(move); String locateNo = getDestLocateNo(model, model.getOrganizeCode());
for (MesPartModel mesPartModel : mesPartModels) {
MesMove move = createMove(model,locateNo , mesPartModel.getLocateNo(), model.getOrganizeCode(), null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode(), mesPartModel.getPartNo());
moveRepository.save(move);
}
} else {
MesMove move = createMove(model, getDestLocateNo(model, model.getOrganizeCode()), target, model.getOrganizeCode(), null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode());
moveRepository.save(move);
}
} }
} else { } else {
//零件检测详情不为空,则代表本次校验为不合格。 //零件检测详情不为空,则代表本次校验为不合格。
@ -380,7 +473,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
if (StringUtils.isEmpty(model.getPartInspection())) { if (StringUtils.isEmpty(model.getPartInspection())) {
partInspection = createPartInspection(model, MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), org); partInspection = createPartInspection(model, MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), model.getOrganizeCode());
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());
@ -392,7 +485,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
for (MesPartInspectionDetail detail : model.getPartInspectionDetailList()) { for (MesPartInspectionDetail detail : model.getPartInspectionDetailList()) {
//根据页面上选择的位置 查询位置,若不存在则提示 位置不存在,请检查数据 //根据页面上选择的位置 查询位置,若不存在则提示 位置不存在,请检查数据
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); DdlPackBean packBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(detail.getDefectLocation(), "defectTypeCode", packBean); DdlPreparedPack.getStringEqualPack(detail.getDefectLocation(), "defectTypeCode", packBean);
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.DEFECT_CATEGORY.POSITION.getValue(), "defectType", packBean); DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.DEFECT_CATEGORY.POSITION.getValue(), "defectType", packBean);
MesDefectType defectType = defectTypeRepository.getByProperty(packBean); MesDefectType defectType = defectTypeRepository.getByProperty(packBean);
@ -404,10 +497,10 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
detail.setDefectTypeId(defectType.getId()); detail.setDefectTypeId(defectType.getId());
detail.setId(null); detail.setId(null);
detail.setOrganizeCode(org); detail.setOrganizeCode(model.getOrganizeCode());
detail.setPid(partInspection.getId()); detail.setPid(partInspection.getId());
setSystemSyncStatus(detail); setSystemSyncStatus(detail);
ConvertBean.serviceModelInitialize(detail, AuthUtil.getSessionUser().getUserName()); ConvertBean.serviceModelInitialize(detail, model.getUserInfo());
} }
if (!CollectionUtils.isEmpty(defectTypeNoExitList)) { if (!CollectionUtils.isEmpty(defectTypeNoExitList)) {
@ -420,7 +513,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
//若是扫描条码 则判定条码可疑 //若是扫描条码 则判定条码可疑
if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) {
//已创建返修单 //已创建返修单
DdlPackBean reworkPackBean = DdlPackBean.getDdlPackBean(org); DdlPackBean reworkPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(model.getSn(), "sn", reworkPackBean); DdlPreparedPack.getStringEqualPack(model.getSn(), "sn", reworkPackBean);
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue(), "status", reworkPackBean); DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue(), "status", reworkPackBean);
@ -428,14 +521,17 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
int count = reworkTaskRepository.findByHqlWhereCount(reworkPackBean); int count = reworkTaskRepository.findByHqlWhereCount(reworkPackBean);
if (count > 0) { if (count > 0) {
// 如果是批次还需要移库 // 如果是批次还需要移库
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(org); DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean); DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean);
MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean); MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean);
String srcNo = configService.getCfgValue(org, "LGORT"); String srcNo = configService.getCfgValue(model.getOrganizeCode(), "LGORT");
if (version != null) { if (version != null) {
srcNo = version.getReceiveInventoryPoint(); srcNo = version.getReceiveInventoryPoint();
} }
String destLocateNo = getDestLocateNo(model, org); if (!headModel) {
srcNo = mesPartModels.get(0).getLocateNo();
}
String destLocateNo = getDestLocateNo(model, model.getOrganizeCode());
if(!Objects.equals(srcNo, destLocateNo)) { if(!Objects.equals(srcNo, destLocateNo)) {
throw new ImppBusiException(String.format("【%s】该条码需要完成质检,再重新录入电子化检验", model.getSn())); throw new ImppBusiException(String.format("【%s】该条码需要完成质检,再重新录入电子化检验", model.getSn()));
} }
@ -443,14 +539,14 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
checkProduceSn(produceSn, model.getSn()); checkProduceSn(produceSn, model.getSn());
produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue()); produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue());
ConvertBean.serviceModelInitialize(produceSn, AuthUtil.getSessionUser().getUserName()); ConvertBean.serviceModelInitialize(produceSn, model.getUserInfo());
produceSnExtService.update(produceSn); produceSnExtService.update(produceSn);
//更新工单对应qcStatus //更新工单对应qcStatus
if(isWorkOrderQcStatus){ if(isWorkOrderQcStatus){
MesWorkOrder workOrder = getWorkOrder(org,produceSn.getWorkOrderNo()); MesWorkOrder workOrder = getWorkOrder(model.getOrganizeCode(), produceSn.getWorkOrderNo());
if (!StringUtil.isEmpty(workOrder)){ if (!StringUtil.isEmpty(workOrder)){
workOrder.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue()); workOrder.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue());
ConvertBean.serviceModelUpdate(workOrder, AuthUtil.getSessionUser().getUserName()); ConvertBean.serviceModelUpdate(workOrder, model.getUserInfo());
workOrderRepository.update(workOrder); workOrderRepository.update(workOrder);
} }
} }
@ -459,9 +555,9 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
// srcLocateNo = getDestLocateNo(model, org); // srcLocateNo = getDestLocateNo(model, org);
} }
if (Objects.isNull(srcLocateNo)) { if (Objects.isNull(srcLocateNo)) {
srcLocateNo = configService.getCfgValue(org, "LGORT"); srcLocateNo = configService.getCfgValue(model.getOrganizeCode(), "LGORT");
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(org); DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean); DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean);
MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean); MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean);
@ -472,7 +568,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
String workCenterCode; String workCenterCode;
if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) {
if (null == produceSn || StringUtils.isEmpty(produceSn.getProcessCode())) { if (null == produceSn || StringUtils.isEmpty(produceSn.getProcessCode())) {
List<MesWorkCenterPartRelation> workCenterPartRelationList = getWorkCenterPartRelation(org, model.getPartNo()); List<MesWorkCenterPartRelation> workCenterPartRelationList = getWorkCenterPartRelation(model.getOrganizeCode(), model.getPartNo());
if (CollectionUtils.isEmpty(workCenterPartRelationList) || workCenterPartRelationList.size() > 1 || StringUtils.isEmpty(workCenterPartRelationList.get(0).getWorkCenterCode())) { if (CollectionUtils.isEmpty(workCenterPartRelationList) || workCenterPartRelationList.size() > 1 || StringUtils.isEmpty(workCenterPartRelationList.get(0).getWorkCenterCode())) {
throw new ImppBusiException(String.format("条码[%s]未查询到有效的来源库位!", model.getSn())); throw new ImppBusiException(String.format("条码[%s]未查询到有效的来源库位!", model.getSn()));
} }
@ -484,7 +580,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
workCenterCode = model.getWorkCenterCode(); workCenterCode = model.getWorkCenterCode();
} }
MesWorkCenter workCenter = prodOrgExtService.getWorkCenterDb(org, workCenterCode); MesWorkCenter workCenter = prodOrgExtService.getWorkCenterDb(model.getOrganizeCode(), workCenterCode);
if (null == workCenter) throw new ImppBusiException(String.format("条码[%s]查询来源库位时获取的生产线代码[%s]信息不存在!", model.getSn(), workCenterCode)); if (null == workCenter) throw new ImppBusiException(String.format("条码[%s]查询来源库位时获取的生产线代码[%s]信息不存在!", model.getSn(), workCenterCode));
if (StringUtils.isEmpty(workCenter.getRawLocate())) throw new ImppBusiException(String.format("条码[%s]查询来源库位时获取的生产线代码[%s]信息未维护[材料库位]!", model.getSn(), workCenterCode)); if (StringUtils.isEmpty(workCenter.getRawLocate())) throw new ImppBusiException(String.format("条码[%s]查询来源库位时获取的生产线代码[%s]信息未维护[材料库位]!", model.getSn(), workCenterCode));
srcLocateNo = workCenter.getRawLocate(); srcLocateNo = workCenter.getRawLocate();
@ -494,33 +590,41 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
if (model.getOptType() != 2) { if (model.getOptType() != 2) {
//移库 //移库
//移库 //移库
String dest = configService.getCfgValue(org, "UMLGO"); String dest = configService.getCfgValue(model.getOrganizeCode(), "UMLGO");
if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()){ if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()){
String destLocateNo = getDestLocateNo(model, org); String destLocateNo = getDestLocateNo(model, model.getOrganizeCode());
if (!StringUtils.isEmpty(destLocateNo) && Objects.equals(dest, destLocateNo)) { if (!StringUtils.isEmpty(destLocateNo) && Objects.equals(dest, destLocateNo)) {
return; return;
} }
} }
MesMove move = createMove(model, srcLocateNo, dest, org, null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) {
moveRepository.save(move); for (MesPartModel mesPartModel : mesPartModels) {
MesMove move = createMove(model, mesPartModel.getLocateNo(), dest, model.getOrganizeCode(), null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode(), mesPartModel.getPartNo());
moveRepository.save(move);
}
} else{
MesMove move = createMove(model, srcLocateNo, dest, model.getOrganizeCode(), null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode());
moveRepository.save(move);
}
} }
} else { } else {
model.getPartInspection().setInspectionStatus(MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue()); model.getPartInspection().setInspectionStatus(MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue());
ConvertBean.serviceModelUpdate(model.getPartInspection(), AuthUtil.getSessionUser().getUserName()); ConvertBean.serviceModelUpdate(model.getPartInspection(), model.getUserInfo());
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());
} }
partInspectionRepository.save(model.getPartInspection()); partInspectionRepository.save(model.getPartInspection());
//查询当前单据明细 //查询当前单据明细
List<MesPartInspectionDetail> resultDetailList = queryResultDetailList(model, org); List<MesPartInspectionDetail> resultDetailList = queryResultDetailList(model, model.getOrganizeCode());
List<String> defectTypeNoExitList = new ArrayList<>(); List<String> defectTypeNoExitList = new ArrayList<>();
for (MesPartInspectionDetail detail : model.getPartInspectionDetailList()) { for (MesPartInspectionDetail detail : model.getPartInspectionDetailList()) {
//根据页面上选择的位置 查询位置,若不存在则提示 位置不存在,请检查数据 //根据页面上选择的位置 查询位置,若不存在则提示 位置不存在,请检查数据
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); DdlPackBean packBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(detail.getDefectLocation(), "defectTypeCode", packBean); DdlPreparedPack.getStringEqualPack(detail.getDefectLocation(), "defectTypeCode", packBean);
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.DEFECT_CATEGORY.POSITION.getValue(), "defectType", packBean); DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.DEFECT_CATEGORY.POSITION.getValue(), "defectType", packBean);
MesDefectType defectType = defectTypeRepository.getByProperty(packBean); MesDefectType defectType = defectTypeRepository.getByProperty(packBean);
@ -532,10 +636,10 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
detail.setDefectTypeId(defectType.getId()); detail.setDefectTypeId(defectType.getId());
detail.setId(null); detail.setId(null);
detail.setOrganizeCode(org); detail.setOrganizeCode(model.getOrganizeCode());
detail.setPid(model.getPartInspection().getId()); detail.setPid(model.getPartInspection().getId());
setSystemSyncStatus(detail); setSystemSyncStatus(detail);
ConvertBean.serviceModelInitialize(detail, AuthUtil.getSessionUser().getUserName()); ConvertBean.serviceModelInitialize(detail, model.getUserInfo());
} }
if (!CollectionUtils.isEmpty(defectTypeNoExitList)) { if (!CollectionUtils.isEmpty(defectTypeNoExitList)) {
@ -546,7 +650,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) {
//已创建返修单 //已创建返修单
DdlPackBean reworkPackBean = DdlPackBean.getDdlPackBean(org); DdlPackBean reworkPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(model.getSn(), "sn", reworkPackBean); DdlPreparedPack.getStringEqualPack(model.getSn(), "sn", reworkPackBean);
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue(), "status", reworkPackBean); DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue(), "status", reworkPackBean);
@ -554,29 +658,29 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
int count = reworkTaskRepository.findByHqlWhereCount(reworkPackBean); int count = reworkTaskRepository.findByHqlWhereCount(reworkPackBean);
if (count > 0) { if (count > 0) {
// 如果是批次还需要移库 // 如果是批次还需要移库
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(org); DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean); DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean);
MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean); MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean);
String srcNo = configService.getCfgValue(org, "LGORT"); String srcNo = configService.getCfgValue(model.getOrganizeCode(), "LGORT");
if (version != null) { if (version != null) {
srcNo = version.getReceiveInventoryPoint(); srcNo = version.getReceiveInventoryPoint();
} }
String destLocateNo = getDestLocateNo(model, org); String destLocateNo = getDestLocateNo(model, model.getOrganizeCode());
if(!Objects.equals(srcNo, destLocateNo)) { if (!Objects.equals(srcNo, destLocateNo)) {
throw new ImppBusiException(String.format("【%s】该条码需要完成质检,再重新录入电子化检验", model.getSn())); throw new ImppBusiException(String.format("【%s】该条码需要完成质检,再重新录入电子化检验", model.getSn()));
} }
} }
checkProduceSn(produceSn, model.getSn()); checkProduceSn(produceSn, model.getSn());
produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue()); produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue());
ConvertBean.serviceModelInitialize(produceSn, AuthUtil.getSessionUser().getUserName()); ConvertBean.serviceModelInitialize(produceSn, model.getUserInfo());
produceSnExtService.update(produceSn); produceSnExtService.update(produceSn);
//更新工单对应qcStatus //更新工单对应qcStatus
if(isWorkOrderQcStatus){ if(isWorkOrderQcStatus){
MesWorkOrder workOrder = getWorkOrder(org,produceSn.getWorkOrderNo()); MesWorkOrder workOrder = getWorkOrder(model.getOrganizeCode(), produceSn.getWorkOrderNo());
if (!StringUtil.isEmpty(workOrder)){ if (!StringUtil.isEmpty(workOrder)){
workOrder.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue()); workOrder.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue());
ConvertBean.serviceModelUpdate(workOrder, AuthUtil.getSessionUser().getUserName()); ConvertBean.serviceModelUpdate(workOrder, model.getUserInfo());
workOrderRepository.update(workOrder); workOrderRepository.update(workOrder);
} }
} }
@ -586,9 +690,9 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
//移库 //移库
if (model.getOptType() != 2) { if (model.getOptType() != 2) {
String srcLocateNo = configService.getCfgValue(org, "LGORT"); String srcLocateNo = configService.getCfgValue(model.getOrganizeCode(), "LGORT");
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(org); DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean); DdlPreparedPack.getStringEqualPack(model.getPartNo(), "partNo", ddlPackBean);
MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean); MesProductVersion version = productVersionRepository.getByProperty(ddlPackBean);
@ -596,15 +700,24 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
srcLocateNo = version.getReceiveInventoryPoint(); srcLocateNo = version.getReceiveInventoryPoint();
} }
//移库 //移库
String dest = configService.getCfgValue(org, "UMLGO"); String dest = configService.getCfgValue(model.getOrganizeCode(), "UMLGO");
if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()){ if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()){
String destLocateNo = getDestLocateNo(model, org); String destLocateNo = getDestLocateNo(model, model.getOrganizeCode());
if (!StringUtils.isEmpty(destLocateNo) && Objects.equals(dest, destLocateNo)) { if (!StringUtils.isEmpty(destLocateNo) && Objects.equals(dest, destLocateNo)) {
return; return;
} }
} }
MesMove move = createMove(model, srcLocateNo, dest, org, null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode()); if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) {
moveRepository.save(move); for (MesPartModel mesPartModel : mesPartModels) {
//移库
MesMove move = createMove(model, mesPartModel.getLocateNo(), dest, model.getOrganizeCode(), null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode(),mesPartModel.getPartNo());
moveRepository.save(move);
}
} else{
MesMove move = createMove(model, srcLocateNo, dest, model.getOrganizeCode(), null == produceSn ? model.getWorkCenterCode() : produceSn.getWorkCenterCode());
moveRepository.save(move);
}
} }
} }
@ -706,7 +819,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
resultDetailList.forEach(k -> { resultDetailList.forEach(k -> {
k.setIsDeleted(MesCommonConstant.TRUE_INTEGER); k.setIsDeleted(MesCommonConstant.TRUE_INTEGER);
setSystemSyncStatus(k); setSystemSyncStatus(k);
ConvertBean.serviceModelUpdate(model.getPartInspection(), AuthUtil.getSessionUser().getUserName()); ConvertBean.serviceModelUpdate(model.getPartInspection(), model.getUserInfo());
}); });
return resultDetailList; return resultDetailList;
@ -853,10 +966,9 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
partInspection.setWorkCenterCode(model.getWorkCenterCode()); partInspection.setWorkCenterCode(model.getWorkCenterCode());
partInspection.setShiftCode(model.getShiftCode()); partInspection.setShiftCode(model.getShiftCode());
partInspection.setSourceType(model.getSourceType()); partInspection.setSourceType(model.getSourceType());
// ConvertBean.serviceModelInitialize(partInspection, AuthUtil.getSessionUser().getUserName());
//42984 初检创建时修改人和修改时间不能赋值 //42984 初检创建时修改人和修改时间不能赋值
partInspection.setCreateDatetime(TimeTool.getNowTime(true)); partInspection.setCreateDatetime(TimeTool.getNowTime(true));
partInspection.setCreateUser(AuthUtil.getSessionUser().getUserName()); partInspection.setCreateUser(model.getUserInfo());
partInspection.setIsValid(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()); partInspection.setIsValid(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
partInspection.setIsDeleted(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()); partInspection.setIsDeleted(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
return partInspection; return partInspection;
@ -900,6 +1012,43 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
return move; return move;
} }
/**
*
*
* @param model
* @param source
* @param target
* @param org
* @return
*/
private MesMove createMove(MesPartInspectionInputModel model, String source, String target, String org, String workCenterCode, String partNo) {
if (StringUtils.isEmpty(model.getUserInfo())) model.setUserInfo("系统");
GenSerialNoModel serialNoModel = new GenSerialNoModel("INPUT_DEFECT_ZRSUM");
serialNoModel.setPartNo(partNo);
ResultBean rb = syncFuncService.syncSerialNo(serialNoModel, model.getUserInfo(), 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.getQty());
move.setMeins(model.getPart().getUnit());
move.setZrsum(zrsum);
move.setPostDate(TimeTool.getToday());
move.setPostTime(TimeTool.getTimeShortWithColon());
move.setPartInspectionId(Objects.isNull(model.getPartInspection()) ? 0 : model.getPartInspection().getId());
move.setMoveType(MesExtEnumUtil.MOVE_TYPE.SUSPICIOUS_MOVE.getValue());
move.setProductSn(model.getSn());
move.setWorkCenter(prodOrgExtService.getErpWorkCenterCode(org, workCenterCode));
ConvertBean.serviceModelInitialize(move, model.getUserInfo());
return move;
}
private MesPart checkPart(MesProduceSn produceSn, String org) { private MesPart checkPart(MesProduceSn produceSn, String org) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
@ -995,29 +1144,28 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
return alarmConfigList; return alarmConfigList;
} }
private MesPartInspectionViewModel getModel(MesPartInspection partInspection, MesPart part,MesPartTypePicture partTypePicture, MesPartInspectionInputModel inputModel , private MesPartInspectionViewModel getModel(MesPartInspection partInspection, MesPart part, MesPartTypePicture partTypePicture, MesPartInspectionInputModel model, Integer sourceType) {
Integer sourceType, String org) {
Integer frontBack = inputModel.getFrontBack(); Integer frontBack = model.getFrontBack();
List<MesPartInspectionDetail> detailList = new ArrayList<>(); List<MesPartInspectionDetail> detailList = new ArrayList<>();
if (!StringUtils.isEmpty(partInspection) && partInspection.getInspectionStatus() != MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue()) { if (!StringUtils.isEmpty(partInspection) && partInspection.getInspectionStatus() != MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue()) {
detailList = checkPartInspectionDetail(partInspection, org); detailList = checkPartInspectionDetail(partInspection, model.getOrganizeCode());
if(!CollectionUtils.isEmpty(detailList)){ if(!CollectionUtils.isEmpty(detailList)){
//判断是否返工完成 //判断是否返工完成
checkReworkFinished(org, detailList); checkReworkFinished(model.getOrganizeCode(), detailList);
} }
} }
//位置 //位置
List<MesLocationConfig> locationConfigList = checkLocationConfig(org); List<MesLocationConfig> locationConfigList = checkLocationConfig(model.getOrganizeCode());
List<String> locationCodeList = locationConfigList.stream().map(k -> k.getDefectLocation()).collect(Collectors.toList()); List<String> locationCodeList = locationConfigList.stream().map(k -> k.getDefectLocation()).collect(Collectors.toList());
//查询零件类型缺陷类型对应关系 //查询零件类型缺陷类型对应关系
List<MesPartTypeDefect> partTypeDefectList = checkPartTypeDefect(part, org); List<MesPartTypeDefect> partTypeDefectList = checkPartTypeDefect(part, model.getOrganizeCode());
List<String> partTypeDefectCodeList = partTypeDefectList.stream().map(k -> k.getDefectTypeCode()).collect(Collectors.toList()); List<String> partTypeDefectCodeList = partTypeDefectList.stream().map(k -> k.getDefectTypeCode()).collect(Collectors.toList());
//查询预警数量 //查询预警数量
List<MesDefectWarnConfig> alarmConfigList = queryDefectAlarmConfigByLocationCodeList(part, frontBack, locationCodeList, partTypeDefectCodeList, org); List<MesDefectWarnConfig> alarmConfigList = queryDefectAlarmConfigByLocationCodeList(part, frontBack, locationCodeList, partTypeDefectCodeList, model.getOrganizeCode());
//根据不良类型+位置 若有数据,则表示需要标黄 //根据不良类型+位置 若有数据,则表示需要标黄
Map<String, List<MesDefectWarnConfig>> alarmConfigMap = alarmConfigList.stream().collect(Collectors.groupingBy(MesDefectWarnConfig::getDefectLocation)); Map<String, List<MesDefectWarnConfig>> alarmConfigMap = alarmConfigList.stream().collect(Collectors.groupingBy(MesDefectWarnConfig::getDefectLocation));
@ -1039,17 +1187,17 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
} }
}); });
MesPartInspectionViewModel model = new MesPartInspectionViewModel(); MesPartInspectionViewModel result = new MesPartInspectionViewModel();
model.setPart(part); result.setPart(part);
if (!StringUtils.isEmpty(partInspection) && partInspection.getInspectionStatus() == MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue() if (!StringUtils.isEmpty(partInspection) && partInspection.getInspectionStatus() == MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue()
&& partInspection.getNcStatus() == MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue()) { && partInspection.getNcStatus() == MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue()) {
model.setPartInspectionDetailList(detailList); result.setPartInspectionDetailList(detailList);
model.setPartInspection(partInspection); result.setPartInspection(partInspection);
} }
model.setPartTypePicture(partTypePicture); result.setPartTypePicture(partTypePicture);
model.setLocationConfigList(locationConfigList); result.setLocationConfigList(locationConfigList);
model.setMesDefectWarnConfigList(alarmConfigList); result.setMesDefectWarnConfigList(alarmConfigList);
return model; return result;
} }
@ -1131,7 +1279,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
version = productVersionRepository.getByProperty(ddlPackBean); version = productVersionRepository.getByProperty(ddlPackBean);
if (version != null) { if (version != null) {
source = version.getShipInventoryPoint(); source = version.getReceiveInventoryPoint();
} }
} }
@ -1141,9 +1289,64 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
if (null != workCenter && !StringUtils.isEmpty(workCenter.getRawLocate())) source = workCenter.getRawLocate(); 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 (StringUtils.isEmpty(source)) MesPcnException.throwBusiException("未找到来源库位!");
MesMove move = createMove(model, source, target, org, model.getWorkCenterCode());
moveRepository.save(move);
}
} }
@ApiOperation(value = "客退品查询") @ApiOperation(value = "客退品查询")

@ -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.IMesPartService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdOrgExtService; 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.*;
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.apiservice.dao.IMesNcProcessingDao; 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.MesNcProcessingInputModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingModel; 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.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.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService; 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;
@ -115,7 +113,20 @@ public class MesNcProcessingService implements IMesNcProcessingService {
private MesWorkOrderRepository workOrderRepository; private MesWorkOrderRepository workOrderRepository;
@Autowired @Autowired
private MesWorkOrderPartRepository workOrderPartRepository;
@Autowired
private MesPartProdGroupRepository mesPartProdGroupRao;
@Autowired
private MesProductionRecordRepository productionRecordRepository;
@Autowired
private IMesPartService mesPartService; private IMesPartService mesPartService;
@Autowired
private IMesMoveRuleRepository mesMoveRuleRepository;
@Override @Override
public ListPager<MesPartInspection> queryPartInspectionByPager(MesPartInspection partInspection, Pager pager) { 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(); 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 source = configService.getCfgValue(org, "LGORT");
String refundSource = configService.getCfgValue(org, "REFUND"); String refundSource = configService.getCfgValue(org, "REFUND");
if (!StringUtils.isEmpty(model.getProductVersion())) { if (!StringUtils.isEmpty(model.getProductVersion())) {
@ -411,10 +463,24 @@ public class MesNcProcessingService implements IMesNcProcessingService {
target = version.getReceiveInventoryPoint(); 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()); if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) {
moveRepository.save(move); List<MesMove> moveList = new ArrayList<>();
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());
moveList.add(move);
}
moveRepository.saveAll(moveList);
} else {
//移库 转正常、放行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()) { } else if (type == MesExtEnumUtil.NC_TYPE.REWORK.getValue()) {
@ -471,11 +537,19 @@ public class MesNcProcessingService implements IMesNcProcessingService {
} }
partInspectionRepository.save(model.getPartInspection()); partInspectionRepository.save(model.getPartInspection());
if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) {
List<MesMove> moveList = new ArrayList<>();
MesMove move = createMove(model, sourceValue, areaCode, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.RETURN_MOVE); for (MesPartModel mesPartModel : mesPartModels) {
ConvertBean.serviceModelInitialize(move,model.getUserName()); MesMove move = createMove(model, sourceValue, areaCode, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.RETURN_MOVE, mesPartModel.getPartNo());
moveRepository.save(move); ConvertBean.serviceModelInitialize(move, model.getUserName());
moveList.add(move);
}
moveRepository.saveAll(moveList);
} 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()) { } else if (type == MesExtEnumUtil.NC_TYPE.SCRAP.getValue()) {
//批次不需要校验条码 //批次不需要校验条码
@ -518,18 +592,45 @@ public class MesNcProcessingService implements IMesNcProcessingService {
sourceValue = refundSource; sourceValue = refundSource;
} }
MesMove move = createMove(model, sourceValue, configService.getCfgValue(org, "SCRAP"), org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE); if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) {
ConvertBean.serviceModelInitialize(move,model.getUserName()); List<MesMove> moveList = new ArrayList<>();
moveRepository.save(move);
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());
moveList.add(move);
}
moveRepository.saveAll(moveList);
} 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 { } else {
String sourceValue = configService.getCfgValue(org, "UMLGO"); String sourceValue = configService.getCfgValue(org, "UMLGO");
if (model.getOptType() == 2) { if (model.getOptType() == 2) {
sourceValue = refundSource; sourceValue = refundSource;
} }
//移库 转报废 根据责任方库区对应关系的主数据选择哪个责任方就移动到哪个库区8000移至8002/8003 if (!headModel) {
MesMove move = createMove(model, sourceValue, areaCode, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.SCRAP_MOVE); if (!CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) {
ConvertBean.serviceModelInitialize(move,model.getUserName()); List<MesMove> moveList = new ArrayList<>();
moveRepository.save(move);
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());
moveList.add(move);
}
moveRepository.saveAll(moveList);
}
} 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()) { } else if (type == MesExtEnumUtil.NC_TYPE.RELEASE.getValue()) {
@ -576,13 +677,24 @@ public class MesNcProcessingService implements IMesNcProcessingService {
target = version.getReceiveInventoryPoint(); target = version.getReceiveInventoryPoint();
} }
//移库 转正常、放行8000移至2000 if (!headModel && !CollectionUtils.isEmpty(mesPartModels) && mesPartModels.size() > 0) {
MesMove move = createMove(model, sourceValue, target, org, null == sn ? workCenterCode : sn.getWorkCenterCode(), MesExtEnumUtil.MOVE_TYPE.NORMAL_MOVE); List<MesMove> moveList = new ArrayList<>();
ConvertBean.serviceModelInitialize(move,model.getUserName());
moveRepository.save(move);
} 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());
moveList.add(move);
}
moveRepository.saveAll(moveList);
} else {
//移库 转正常、放行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) { public MesWorkOrder getWorkOrder(String organizeCode, String workOrderNo) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workOrderNo)) return null; if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workOrderNo)) return null;
@ -674,4 +786,31 @@ public class MesNcProcessingService implements IMesNcProcessingService {
move.setWorkCenter(prodOrgExtService.getErpWorkCenterCode(org, workCenterCode)); move.setWorkCenter(prodOrgExtService.getErpWorkCenterCode(org, workCenterCode));
return move; 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;
}
} }

@ -13,6 +13,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Map;
/** /**
* @Description : * @Description :
* @Reference : * @Reference :
@ -39,6 +41,18 @@ public class MesPrintedSnLogServiceImpl implements IMesPrintedSnLogService {
} }
@Override @Override
public MesPrintedSnLog getMesCustomPrintedSnLog(String userName, String organizeCode, MesProduceSnPrintDataModel printDataModel, Map<String, Object> printContext) {
MesPrintedSnLog snLog = new MesPrintedSnLog();
BeanUtil.copyProperties(printDataModel, snLog);
snLog.setOrganizeCode(organizeCode);
snLog.setPrintContext(printContext);
snLog.setPrintData(JSONObject.toJSONString(printContext));
snLog.setPrintType(MesExtEnumUtil.PRINT_LOG_TYPE.PRINT_LOG_TYPE_10.getValue());
ConvertBean.serviceModelInitialize(snLog, userName);
return snLog;
}
@Override
public void insertMesPrintedSnLog(MesPrintedSnLog mesPrintedSnLog, String userName) { public void insertMesPrintedSnLog(MesPrintedSnLog mesPrintedSnLog, String userName) {
MesPrintedSnLog snLog = new MesPrintedSnLog(); MesPrintedSnLog snLog = new MesPrintedSnLog();
BeanUtil.copyProperties(mesPrintedSnLog, snLog, MesPcnExtConstWords.BASE_BEAN_FIELDS); BeanUtil.copyProperties(mesPrintedSnLog, snLog, MesPcnExtConstWords.BASE_BEAN_FIELDS);

@ -225,8 +225,13 @@ public class MesProduceSnPrintService implements IMesProduceSnPrintService {
} }
MesProduceSnPrintDataModel model = new MesProduceSnPrintDataModel(); MesProduceSnPrintDataModel model = new MesProduceSnPrintDataModel();
BeanUtil.copyProperties(snLog, model); BeanUtil.copyProperties(snLog, model);
model.setPrintDate(TimeTool.getNowTime(true)); if (CollectionUtils.isEmpty(snLog.getPrintContext())) {
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(model); model.setPrintDate(TimeTool.getNowTime(true));
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().add(model);
} else {
snLog.getPrintContext().put(MesPcnExtConstWords.PRINT_DATE, TimeTool.getNowTime(true));
mesProduceSnPrintModel.getPrintContextList().add(snLog.getPrintContext());
}
//记录打印日志 //记录打印日志
mesPrintedSnLogService.insertMesPrintedSnLog(snLog, model.getUserName()); mesPrintedSnLogService.insertMesPrintedSnLog(snLog, model.getUserName());
return mesProduceSnPrintModel; return mesProduceSnPrintModel;

@ -114,7 +114,6 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService {
DdlPreparedPack.getStringEqualPack(bean.getPullCode(), "pullCode", packBeanOne); DdlPreparedPack.getStringEqualPack(bean.getPullCode(), "pullCode", packBeanOne);
DdlPreparedPack.getStringEqualPack(bean.getPullingOrderNo(), "pullingOrderNo", packBeanOne); DdlPreparedPack.getStringEqualPack(bean.getPullingOrderNo(), "pullingOrderNo", packBeanOne);
DdlPreparedPack.getStringEqualPack(bean.getWorkCenterCode(), "workCenterCode", packBeanOne); DdlPreparedPack.getStringEqualPack(bean.getWorkCenterCode(), "workCenterCode", packBeanOne);
// DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PULL_ORDER_STATUS.PULL_ORDER_STATUS_10.getValue(), "pullOrderStatus", packBeanOne);
MesPullingOrderInfo mesPullingOrderInfo = mesPullingOrderInfoRepository.getByProperty(packBeanOne); MesPullingOrderInfo mesPullingOrderInfo = mesPullingOrderInfoRepository.getByProperty(packBeanOne);
if (StringUtil.isEmpty(mesPullingOrderInfo)) { if (StringUtil.isEmpty(mesPullingOrderInfo)) {
MesPcnException.throwMesBusiException("扫描拉动单号【%s】查询数据为空", bean.getPullingOrderNo()); MesPcnException.throwMesBusiException("扫描拉动单号【%s】查询数据为空", bean.getPullingOrderNo());
@ -134,9 +133,10 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService {
//修改当前单号之前的为可强过 //修改当前单号之前的为可强过
DdlPackBean packBeanPass = DdlPackBean.getDdlPackBean(bean.getOrganizeCode()); DdlPackBean packBeanPass = DdlPackBean.getDdlPackBean(bean.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(bean.getPullCode(), "pullCode", packBeanPass); DdlPreparedPack.getStringEqualPack(bean.getPullCode(), "pullCode", packBeanPass);
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PULL_ORDER_STATUS.PULL_ORDER_STATUS_10.getValue(), "pullOrderStatus", packBeanOne); DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PULL_ORDER_STATUS.PULL_ORDER_STATUS_10.getValue(), "pullOrderStatus", packBeanPass);
DdlPreparedPack.getStringSmallerNotEqualPack(bean.getPullingOrderNo(), "pullingOrderNo", packBeanPass); DdlPreparedPack.getStringSmallerNotEqualPack(bean.getPullingOrderNo(), "pullingOrderNo", packBeanPass);
DdlPreparedPack.getStringEqualPack(bean.getWorkCenterCode(), "workCenterCode", packBeanPass); DdlPreparedPack.getStringEqualPack(bean.getWorkCenterCode(), "workCenterCode", packBeanPass);
DdlPreparedPack.getNumNOEqualPack(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), "isPassCode", packBeanPass);
List<MesPullingOrderInfo> mesPullingOrderInfos = mesPullingOrderInfoRepository.findByHqlWhere(packBeanPass); List<MesPullingOrderInfo> mesPullingOrderInfos = mesPullingOrderInfoRepository.findByHqlWhere(packBeanPass);
if (!CollectionUtils.isEmpty(mesPullingOrderInfos)) { if (!CollectionUtils.isEmpty(mesPullingOrderInfos)) {
for (MesPullingOrderInfo pullingOrderInfo : mesPullingOrderInfos) { for (MesPullingOrderInfo pullingOrderInfo : mesPullingOrderInfos) {

@ -695,6 +695,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
if (CollectionUtils.isEmpty(shippingOrderManagementDetails)) { if (CollectionUtils.isEmpty(shippingOrderManagementDetails)) {
DdlPackBean detailPackBean = DdlPackBean.getDdlPackBean(mesShippingOrderManagement.getOrganizeCode()); DdlPackBean detailPackBean = DdlPackBean.getDdlPackBean(mesShippingOrderManagement.getOrganizeCode());
DdlPreparedPack.getNumEqualPack(mesShippingOrderManagement.getId(), "pid", detailPackBean); DdlPreparedPack.getNumEqualPack(mesShippingOrderManagement.getId(), "pid", detailPackBean);
DdlPreparedPack.getNumberSmallerPack(MesExtEnumUtil.SHIPPING_ORDER_DETAIL_SHIPPING_STATUS.SKIP.getValue(), "status", detailPackBean);
shippingOrderManagementDetails = shippingOrderManagementDetailRepository.findByHqlWhere(detailPackBean); shippingOrderManagementDetails = shippingOrderManagementDetailRepository.findByHqlWhere(detailPackBean);
} }
//当前装车单所有发运单明细 需要报工的数据 //当前装车单所有发运单明细 需要报工的数据

@ -0,0 +1,156 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesCustomerPartService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesTemplateService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesPrintedSnLogService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintDataModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
import cn.estsh.i3plus.mes.pcn.util.DateUtil;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart;
import cn.estsh.i3plus.pojo.mes.bean.MesNumberRule;
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StepResult;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.*;
/**
* @Description :
* @Reference :
* @Author : junsheng.li
* @CreateDate 2024/9/26 18:20
* @Modify:
**/
@Component
@Slf4j
public class CustomFieldPrintStrategy implements IPrintTemplateStrategyService {
@Autowired
private ISyncFuncService syncFuncService;
@Autowired
private SnowflakeIdMaker snowflakeIdMaker;
@Autowired
private IMesPartService mesPartService;
@Autowired
private IMesPrintedSnLogService mesPrintedSnLogService;
@Autowired
private IMesCustomerPartService mesCustomerPartService;
@Autowired
private IMesTemplateService mesTemplateService;
@Override
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep) {
String organizeCode = mesProduceSnPrintModel.getOrganizeCode();
//物料信息
MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), organizeCode);
MesCustomerPart customerPart = (!Objects.isNull(genSerialNoModel) && !CollectionUtils.isEmpty(genSerialNoModel.getDataMap()) && genSerialNoModel.getDataMap().containsKey(MesCustomerPart.class.getSimpleName())) ? (MesCustomerPart) genSerialNoModel.getDataMap().get(MesCustomerPart.class.getSimpleName()) : mesCustomerPartService.getMesCustomerPart(organizeCode,mesProduceSnPrintModel.getPartNo());
Map<String, Object> customParamValue = mesTemplateService.queryMesLabelTemplateParamPartValue(mesPart.getPartNo(), mesPart.getProductLabelTemplate(), organizeCode);
if (!isStep){
if (!Objects.isNull(customerPart)) {
genSerialNoModel.setCustPartNo(customerPart.getCustPartNo());
}
for (int i = 0; i < mesProduceSnPrintModel.getPrintQty(); i++) {
//保存条码信息
MesProduceSn produceSn = generateMesProduceSn(mesPart, syncFuncService.syncSerialNo(genSerialNoModel.partSnParam(mesPart.getPartSnParam()), mesProduceSnPrintModel.getUserName(), organizeCode, 1).getResultList().get(0).toString(), mesProduceSnPrintModel.getUserName(), mesProduceSnPrintModel.getQty());
//封装打印信息
MesProduceSnPrintDataModel printDataModel = getModel(produceSn, customerPart);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().clear();
mesProduceSnPrintModel.getMesProduceSnList().add(produceSn);
Map<String, Object> printTemplateData = new HashMap<>(getPrintContextMap(produceSn, customerPart));
printTemplateData.putAll(customParamValue);
mesProduceSnPrintModel.getPrintContextList().add(printTemplateData);
//保存打印记录
mesProduceSnPrintModel.getMesPrintedSnLogList().add(mesPrintedSnLogService.getMesCustomPrintedSnLog(mesProduceSnPrintModel.getUserName(), organizeCode, printDataModel, printTemplateData));
}
}else{
MesProduceSn mesProduceSn = mesProduceSnPrintModel.getMesProduceSnList().get(0);
//封装打印信息
MesProduceSnPrintDataModel printDataModel = getModel(mesProduceSn, customerPart);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().clear();
Map<String, Object> printTemplateData = new HashMap<>(getPrintContextMap(mesProduceSn, customerPart));
printTemplateData.putAll(customParamValue);
List<Map<String, Object>> printDataMapList = new ArrayList<>();
printDataMapList.add(printTemplateData);
mesProduceSnPrintModel.getPrintContextList().add(packResultMap(mesProduceSnPrintModel, printDataMapList));
//保存打印记录
mesProduceSnPrintModel.getMesPrintedSnLogList().add(mesPrintedSnLogService.getMesCustomPrintedSnLog(mesProduceSnPrintModel.getUserName(), organizeCode, printDataModel, printTemplateData));
}
return mesProduceSnPrintModel;
}
private MesProduceSn generateMesProduceSn(MesPart mesPart, String sn, String userName, Double qty) {
MesProduceSn mesProduceSn = new MesProduceSn();
mesProduceSn.setSerialNumber(snowflakeIdMaker.nextId() + "");
mesProduceSn.setProductSn(sn);
mesProduceSn.setCustSn(sn);
mesProduceSn.setPartNo(mesPart.getPartNo());
mesProduceSn.setPartName(mesPart.getPartName());
mesProduceSn.setProcessLabelTemplate(mesPart.getProcessLabelTemplate());
mesProduceSn.setCustLabelTemplate(mesPart.getCustLabelTemplate());
mesProduceSn.setProdLabelTemplate(mesPart.getProductLabelTemplate());
mesProduceSn.setQty(qty);
mesProduceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.CREATE.getValue());
mesProduceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
mesProduceSn.setLotNo(TimeTool.getToday());
mesProduceSn.setPrintCount(MesPcnExtConstWords.ONE);
mesProduceSn.setPrintStatus(MesExtEnumUtil.PRINT_STATUS.PRINTED.getValue());
mesProduceSn.setOrganizeCode(mesPart.getOrganizeCode());
ConvertBean.serviceModelInitialize(mesProduceSn, userName);
return mesProduceSn;
}
private MesProduceSnPrintDataModel getModel(MesProduceSn produceSn, MesCustomerPart customerPart) {
MesProduceSnPrintDataModel mesProduceSnPrintDataModel = new MesProduceSnPrintDataModel();
mesProduceSnPrintDataModel.setPartNo(produceSn.getPartNo());
mesProduceSnPrintDataModel.setPartName(produceSn.getPartName());
if (!Objects.isNull(customerPart)) {
mesProduceSnPrintDataModel.setCustPartNo(customerPart.getCustPartNo());
}
mesProduceSnPrintDataModel.setBarcode(produceSn.getProductSn());
mesProduceSnPrintDataModel.setPrintDate(TimeTool.getNowTime(true));
mesProduceSnPrintDataModel.setUserName(produceSn.getCreateUser());
mesProduceSnPrintDataModel.setProductDate(TimeTool.parseStringFormat(produceSn.getLotNo(), DateUtil.SHORT_FORMAT, "yyyy/MM/dd"));
return mesProduceSnPrintDataModel;
}
private Map<String, Object> getPrintContextMap(MesProduceSn produceSn, MesCustomerPart customerPart) {
Map<String, Object> result = new HashMap<>();
result.put(MesPcnExtConstWords.PART_NO, produceSn.getPartNo());
result.put(MesPcnExtConstWords.PART_NAME, produceSn.getPartName());
if (!Objects.isNull(customerPart)) {
result.put(MesPcnExtConstWords.CUST_PART_NO, customerPart.getCustPartNo());
}
result.put(MesPcnExtConstWords.PRINT_BAR_CODE, produceSn.getProductSn());
result.put(MesPcnExtConstWords.PRINT_DATE, TimeTool.getNowTime(true));
result.put(MesPcnExtConstWords.USER_NAME, produceSn.getCreateUser());
return result;
}
private Map<String, Object> packResultMap(MesProduceSnPrintModel printModel, List<Map<String, Object>> printTemplateDateList) {
Map<String, Object> resultMap = new HashMap<>();
resultMap.put(MesPcnExtConstWords.LABEL_TEMPLATE, printModel.getMesLabelTemplate());
resultMap.put(MesPcnExtConstWords.TEMPLATE_DATA, printTemplateDateList);
resultMap.put(MesPcnExtConstWords.TEMPLATE_CODE, printModel.getMesLabelTemplate().getTemplateCode());
resultMap.put(MesPcnExtConstWords.PRINTER, printModel.getPrinter());
return resultMap;
}
}

@ -67,6 +67,16 @@ public class MesAssemblyMatchSortStepService extends BaseStepService {
//存储生产过程上下文对象 //存储生产过程上下文对象
productionProcessContextStepService.dispatchProductionProcessContext(reqBean, productionProcessContext); productionProcessContextStepService.dispatchProductionProcessContext(reqBean, productionProcessContext);
//获取加工结果
String productResult = productionDispatchContextStepService.getProductResultContext(reqBean);
if (!StringUtils.isEmpty(productResult) && !productResult.equals(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue() + MesPcnExtConstWords.EMPTY) &&
(StringUtils.isEmpty(productionProcessContext.getWorkCenter().getIsIgnoreQc())
|| productionProcessContext.getWorkCenter().getIsIgnoreQc().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) != 0)) {
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult,
String.format("加工单质量状态标记[%s],当前装配件清单默认跳过!", MesExtEnumUtil.PRODUCE_QC_STATUS.valueOfDescription(Integer.parseInt(productResult))),
MesPcnEnumUtil.PROMPT_SOUND.SUCCESS.getValue());
}
//获取上下文产品加工规则数据信息集合 //获取上下文产品加工规则数据信息集合
List<MesProdRuleContext> prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean); List<MesProdRuleContext> prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
if (CollectionUtils.isEmpty(prodRuleContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在非排序加工规则数据,请重置工序!"); if (CollectionUtils.isEmpty(prodRuleContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在非排序加工规则数据,请重置工序!");

@ -112,7 +112,7 @@ public class MesAssemblyScanStepService extends BaseStepService {
productionCustomContextStepService.sendStepContextMessage(reqBean, scanInfo, MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN); productionCustomContextStepService.sendStepContextMessage(reqBean, scanInfo, MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN);
//封装当前扫描的装配件信息 //封装当前扫描的装配件信息
List<MesEquipVariableCollectContext> equipVariableCollectContextList = getAssemblySnJson(reqBean, scanInfo); List<MesEquipVariableCollectContext> equipVariableCollectContextList = getAssemblySnJson(reqBean, productionProcessContext, scanInfo);
//从上下文中取出工位当前要使用的设备 //从上下文中取出工位当前要使用的设备
MesCellEquipContext cellEquipContext = productionProcessContext.getCurCellEquip(); MesCellEquipContext cellEquipContext = productionProcessContext.getCurCellEquip();
@ -153,7 +153,17 @@ public class MesAssemblyScanStepService extends BaseStepService {
productionDispatchContextStepService.dispatchScanAssemblySnContext(reqBean, equipVariableCollectContextList); productionDispatchContextStepService.dispatchScanAssemblySnContext(reqBean, equipVariableCollectContextList);
//唯一加工规则场景 默认扫描一次 匹配一次 循环处理直到当前的加工规则全部匹配完毕 //唯一加工规则场景 默认扫描一次 匹配一次 循环处理直到当前的加工规则全部匹配完毕
if (busiType == BUSI_TYPE.ONE.value) return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.SCAN.getValue()).scanInfo(scanInfo), stepResult, String.format("当前扫描信息装配件条码[%s]!", scanInfo)); if (busiType == BUSI_TYPE.ONE.value) {
//排序线可疑码场景下,该数据为空,验证生产线是否忽略质量状态
if (CollectionUtils.isEmpty(equipVariableCollectContextList)) {
//保存上下文加工结果:可疑
productionDispatchContextStepService.dispatchProductResultContext(reqBean, MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue() + MesPcnExtConstWords.EMPTY);
this.sendMessage(reqBean, new StationResultBean().writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.SCAN.getValue()).scanInfo(scanInfo), "当前扫描信息[排序线可疑码]!", MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
if (StringUtils.isEmpty(productionProcessContext.getWorkCenter().getIsIgnoreQc()) || productionProcessContext.getWorkCenter().getIsIgnoreQc().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) != 0) return stepResult;
else stepSendGuideAndThrowEx(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), "请扫描装配件条码!");
}
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.SCAN.getValue()).scanInfo(scanInfo), stepResult, String.format("当前扫描信息装配件条码[%s]!", scanInfo));
}
String suffix = repeatAssemblySnAmount == 0 ? MesPcnExtConstWords.EMPTY : String.format(",可复用个数[%s]", repeatAssemblySnAmount); String suffix = repeatAssemblySnAmount == 0 ? MesPcnExtConstWords.EMPTY : String.format(",可复用个数[%s]", repeatAssemblySnAmount);
@ -265,7 +275,10 @@ public class MesAssemblyScanStepService extends BaseStepService {
} }
//封装当前扫描的装配件信息 //封装当前扫描的装配件信息
private List<MesEquipVariableCollectContext> getAssemblySnJson(StationRequestBean reqBean, String scanInfo) { private List<MesEquipVariableCollectContext> getAssemblySnJson(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext, String scanInfo) {
//排序线可疑码
if (productionProcessContext.getWorkCenter().getCenterType().compareTo(MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue()) == 0 && scanInfo.equals(productionProcessContext.getSortSuspiciousCode())) return null;
List<MesEquipVariableCollectContext> equipVariableCollectContextList = new ArrayList<>(); List<MesEquipVariableCollectContext> equipVariableCollectContextList = new ArrayList<>();

@ -4,9 +4,12 @@ import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesTemplateService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService; import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdRuleContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblySortContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext; import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel; import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.api.iservice.base.IConfigService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService; import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.platform.common.convert.ConvertBean; import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
@ -30,6 +33,7 @@ import org.springframework.util.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -62,6 +66,9 @@ public class MesProductSnPrintSortStepService extends BaseStepService {
@Autowired @Autowired
private IMesTemplateService mesTemplateService; private IMesTemplateService mesTemplateService;
@Autowired
private IConfigService configService;
@Override @Override
public StepResult execute(StationRequestBean reqBean) { public StepResult execute(StationRequestBean reqBean) {
// /** // /**
@ -83,6 +90,9 @@ public class MesProductSnPrintSortStepService extends BaseStepService {
//1. 获取上下文中生成的主条码 //1. 获取上下文中生成的主条码
List<MesProductionPartContext> productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean); List<MesProductionPartContext> productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean);
//获取上下文产品加工规则数据信息集合
List<MesProdRuleContext> prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
// 排除掉空腔的partContext数据 // 排除掉空腔的partContext数据
productionPartContextList = CollectionUtils.isEmpty(productionPartContextList) ? null :productionPartContextList.stream().filter(o -> o.getForeignKey() != null).collect(Collectors.toList()); productionPartContextList = CollectionUtils.isEmpty(productionPartContextList) ? null :productionPartContextList.stream().filter(o -> o.getForeignKey() != null).collect(Collectors.toList());
@ -97,53 +107,67 @@ public class MesProductSnPrintSortStepService extends BaseStepService {
// 根据工单号分组 // 根据工单号分组
Map<String, MesWorkOrder> workOrderMap = getMesWorkOrderMap(reqBean, productionPartContextList); Map<String, MesWorkOrder> workOrderMap = getMesWorkOrderMap(reqBean, productionPartContextList);
//加工规则根据数据关联键分组
Map<Integer, MesProdRuleContext> prodRuleContextMap = prodRuleContextList.stream().filter(o -> null != o).collect(Collectors.toMap(MesProdRuleContext::getForeignKey, o -> o));
// 获取零件信息上下文 // 获取零件信息上下文
Map<String, MesPart> partDataContext = productionProcessContextStepService.getPartDataContext(reqBean); Map<String, MesPart> partDataContext = productionProcessContextStepService.getPartDataContext(reqBean);
//默认客户条码编码规则配置代码
String defaultCustMatchRule = getDefaultCustMatchRule(reqBean.getOrganizeCode());
List<MesPrintedSnLog> snLogList = new ArrayList<>(); List<MesPrintedSnLog> snLogList = new ArrayList<>();
List<Map<String, Object>> resultMap = new ArrayList<>(); List<Map<String, Object>> resultMap = new ArrayList<>();
for (MesProductionPartContext sn : productionPartContextList) { for (MesProductionPartContext productionPartContext : productionPartContextList) {
// 根据工单号获取工单信息 // 根据工单号获取工单信息
MesWorkOrder workOrder = workOrderMap.get(sn.getWorkOrderNo()); MesWorkOrder workOrder = workOrderMap.get(productionPartContext.getWorkOrderNo());
if (null == workOrder) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号:{}无效!", sn.getWorkOrderNo())); if (null == workOrder) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号:{}无效!", productionPartContext.getWorkOrderNo()));
if (CollectionUtils.isEmpty(partDataContext) || !partDataContext.containsKey(workOrder.getPartNo())) if (CollectionUtils.isEmpty(partDataContext) || !partDataContext.containsKey(workOrder.getPartNo()))
stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]丢失零件信息缓存!", sn.getWorkOrderNo(), sn.getPartNo())); stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]丢失零件信息缓存!", productionPartContext.getWorkOrderNo(), productionPartContext.getPartNo()));
MesPart mesPart = partDataContext.get(sn.getPartNo()); MesPart mesPart = partDataContext.get(productionPartContext.getPartNo());
String custMatchRule = StringUtils.isEmpty(mesPart.getCustMatchRule()) ? "WH_CUST_SN_RULE" : mesPart.getCustMatchRule(); //验证是否配置客户条码编码规则信息
String custMatchRule = !StringUtils.isEmpty(mesPart.getCustMatchRule()) ? mesPart.getCustMatchRule() : defaultCustMatchRule;
if (StringUtils.isEmpty(custMatchRule)) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]未维护客户条码编码规则!", productionPartContext.getWorkOrderNo(), productionPartContext.getPartNo()));
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode); DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(custMatchRule, MesPcnExtConstWords.RULE_CODE, packBean); DdlPreparedPack.getStringEqualPack(custMatchRule, MesPcnExtConstWords.RULE_CODE, packBean);
MesNumberRule numberRule = numberRuleRepository.getByProperty(packBean); MesNumberRule numberRule = numberRuleRepository.getByProperty(packBean);
if (null == numberRule) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]客户条码编码规则[%s]无效!", productionPartContext.getWorkOrderNo(), productionPartContext.getPartNo(), custMatchRule));
if (null == numberRule) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]客户条码编码规则[%s]无效!", sn.getWorkOrderNo(), sn.getPartNo(), custMatchRule)); //获取零件表的打印模版和打印机
String labelTemplateCode = mesPart.getCustLabelTemplate();;
// 从物料信息中获取标签模板 String printer = mesPart.getProductPrinterCode();
String labelTemplateCode = partDataContext.get(sn.getPartNo()).getCustLabelTemplate(); if (StringUtils.isEmpty(labelTemplateCode)) {
//获取工单装配件的打印模版和打印机
MesProdRuleContext prodRuleContext = prodRuleContextMap.get(productionPartContext.getForeignKey());
MesProductionAssemblySortContext productionAssemblySortContext = filterPrintInfo(prodRuleContext);
labelTemplateCode = null != productionAssemblySortContext ? productionAssemblySortContext.getPrintTemplate() : null;
printer = null != productionAssemblySortContext ? productionAssemblySortContext.getPrinter() : null;
}
if (null == labelTemplateCode) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]未在ERP物料信息维护打印模板,请检查并修改!", sn.getWorkOrderNo(), sn.getPartNo())); if (null == labelTemplateCode) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]未在ERP物料信息维护打印模板,请检查并修改!", productionPartContext.getWorkOrderNo(), productionPartContext.getPartNo()));
MesProduceSnPrintModel mesProduceSnPrintModel = new MesProduceSnPrintModel();
// 查模板代码 // 查模板代码
MesLabelTemplate labelTemplate = mesTemplateService.getLabelTemplate(labelTemplateCode, organizeCode); MesLabelTemplate labelTemplate = mesTemplateService.getLabelTemplate(labelTemplateCode, organizeCode);
if (null == labelTemplate) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]的模板代码[%s]无效,请检查并修改!", productionPartContext.getWorkOrderNo(), productionPartContext.getPartNo(), labelTemplateCode));
if (null == labelTemplate) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]的模板代码[%s]无效,请检查并修改!", sn.getWorkOrderNo(), sn.getPartNo(), labelTemplateCode)); MesProduceSnPrintModel mesProduceSnPrintModel = new MesProduceSnPrintModel();
mesProduceSnPrintModel.setMesLabelTemplate(labelTemplate); mesProduceSnPrintModel.setMesLabelTemplate(labelTemplate);
mesProduceSnPrintModel.setPrinter(partDataContext.get(sn.getPartNo()).getProductPrinterCode()); mesProduceSnPrintModel.setPrinter(printer);
mesProduceSnPrintModel.setPartNo(sn.getPartNo()); mesProduceSnPrintModel.setPartNo(productionPartContext.getPartNo());
mesProduceSnPrintModel.setOrganizeCode(organizeCode); mesProduceSnPrintModel.setOrganizeCode(organizeCode);
mesProduceSnPrintModel.setSourceData(workOrder); mesProduceSnPrintModel.setSourceData(workOrder);
mesProduceSnPrintModel.setUserName(reqBean.getUserInfo()); mesProduceSnPrintModel.setUserName(reqBean.getUserInfo());
//根据反射获取策略类--封装打印数据 //根据反射获取策略类--封装打印数据
String methodCode = labelTemplate.getMethodCode(); String methodCode = labelTemplate.getMethodCode();
//模板信息丢失抛出异常 //模板信息丢失抛出异常
if (StringUtils.isEmpty(methodCode)) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]的模板代码[%s]的反射类丢失,请配置!", sn.getWorkOrderNo(), sn.getPartNo(), labelTemplateCode)); if (StringUtils.isEmpty(methodCode)) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]的模板代码[%s]的反射类丢失,请配置!", productionPartContext.getWorkOrderNo(), productionPartContext.getPartNo(), labelTemplateCode));
IPrintTemplateStrategyService strategyService = (IPrintTemplateStrategyService) SpringContextsUtil.getBean(methodCode); IPrintTemplateStrategyService strategyService = (IPrintTemplateStrategyService) SpringContextsUtil.getBean(methodCode);
MesProduceSnPrintModel printModel = strategyService.execute(null, mesProduceSnPrintModel, numberRule, stepResult, reqBean, true); MesProduceSnPrintModel printModel = strategyService.execute(null, mesProduceSnPrintModel, numberRule, stepResult, reqBean, true);
@ -163,6 +187,12 @@ public class MesProductSnPrintSortStepService extends BaseStepService {
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "打印成功!"); return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "打印成功!");
} }
//默认客户条码编码规则配置代码
private String getDefaultCustMatchRule(String organizeCode) {
List<MesConfig> configList = configService.doCachedConfigList(MesPcnExtConstWords.DEFAULT_CUST_MATCH_RULE, organizeCode);
return !CollectionUtils.isEmpty(configList) ? configList.get(0).getCfgValue() : null;
}
private MesPrintedSnLog getMesPrintedSnLog(StationRequestBean reqBean, MesWorkOrder workOrder,String printData) { private MesPrintedSnLog getMesPrintedSnLog(StationRequestBean reqBean, MesWorkOrder workOrder,String printData) {
MesPrintedSnLog snLog = new MesPrintedSnLog(); MesPrintedSnLog snLog = new MesPrintedSnLog();
snLog.setBarcode(workOrder.getCustSn()); snLog.setBarcode(workOrder.getCustSn());
@ -191,4 +221,13 @@ public class MesProductSnPrintSortStepService extends BaseStepService {
return CollectionUtils.isEmpty(workOrderList) ? null : return CollectionUtils.isEmpty(workOrderList) ? null :
workOrderList.stream().collect(Collectors.toMap(MesWorkOrder::getWorkOrderNo, Function.identity(), (x, y) -> y)); workOrderList.stream().collect(Collectors.toMap(MesWorkOrder::getWorkOrderNo, Function.identity(), (x, y) -> y));
} }
//过滤打印配置信息
private MesProductionAssemblySortContext filterPrintInfo(MesProdRuleContext prodRuleContext) {
List<MesProductionAssemblySortContext> productionAssemblySortContextList = prodRuleContext.getSortAssemblyDataContext();
Optional<MesProductionAssemblySortContext> optional = CollectionUtils.isEmpty(productionAssemblySortContextList) ? null :
productionAssemblySortContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPrintTemplate()))).findFirst();
return (null != optional && optional.isPresent()) ? optional.get() : null;
}
} }

@ -17,6 +17,7 @@ import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import cn.estsh.i3plus.pojo.mes.model.StepResult; import cn.estsh.i3plus.pojo.mes.model.StepResult;
import cn.estsh.i3plus.pojo.mes.repository.MesWorkOrderRepository; import cn.estsh.i3plus.pojo.mes.repository.MesWorkOrderRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -26,7 +27,9 @@ import org.springframework.util.StringUtils;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @Description : * @Description :
@ -89,42 +92,68 @@ public class MesWorkOrderSaveSortStepService extends BaseStepService {
private void doHandleWorkOrderData(StationRequestBean reqBean, StationResultBean resultBean, List<MesProductionPartContext> productionPartContextList, MesWorkCell workCell) { private void doHandleWorkOrderData(StationRequestBean reqBean, StationResultBean resultBean, List<MesProductionPartContext> productionPartContextList, MesWorkCell workCell) {
//获取上下文加工结果
String productResult = productionDispatchContextStepService.getProductResultContext(reqBean);
Map<String, Object> propertyMap;
for (MesProductionPartContext productionPartContext : productionPartContextList) { for (MesProductionPartContext productionPartContext : productionPartContextList) {
if (null == productionPartContext || StringUtils.isEmpty(productionPartContext.getForeignKey())) continue; if (null == productionPartContext || StringUtils.isEmpty(productionPartContext.getForeignKey())) continue;
//判断是否末道工位
Boolean isEndWorkCell = (!StringUtils.isEmpty(workCell.getIsEndWorkCell()) && workCell.getIsEndWorkCell().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0) ? true : false; Boolean isEndWorkCell = (!StringUtils.isEmpty(workCell.getIsEndWorkCell()) && workCell.getIsEndWorkCell().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0) ? true : false;
if (!isEndWorkCell && productionPartContext.getWorkOrderStatus().compareTo(MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue()) == 0) continue; propertyMap = new HashMap<>();
if (!isEndWorkCell) { //质量非合格
workOrderRepository.updateByPropertiesNoSync( if (!StringUtils.isEmpty(productResult) && !productResult.equals(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue() + MesPcnExtConstWords.EMPTY)) {
new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE}, propertyMap.put(MesPcnExtConstWords.QC_STATUS, Integer.valueOf(productResult));
new Object[]{productionPartContext.getId(), reqBean.getOrganizeCode()},
new String[]{MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME,
MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME,
MesPcnExtConstWords.WORK_ORDER_STATUS, MesPcnExtConstWords.START_TIME, MesPcnExtConstWords.ONLINE_TIME},
new Object[]{reqBean.getUserInfo(), (new SimpleDateFormat(MesPcnExtConstWords.DATE_FORMAT_SSS)).format(new Date()),
CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), MesPcnExtConstWords.EMPTY,
MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue(), productionPartContext.getOnlineTime(), productionPartContext.getOnlineTime()});
} else {
productionPartContext.setOfflineTime(TimeTool.getNowTime(true));
workOrderRepository.updateByPropertiesNoSync(
new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE},
new Object[]{productionPartContext.getId(), reqBean.getOrganizeCode()},
new String[]{MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME,
MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME,
MesPcnExtConstWords.WORK_ORDER_STATUS, MesPcnExtConstWords.COMPLETE_QTY, MesPcnExtConstWords.UN_COMPLETE_QTY,
MesPcnExtConstWords.START_TIME, MesPcnExtConstWords.ONLINE_TIME, MesPcnExtConstWords.END_TIME, MesPcnExtConstWords.OFFLINE_TIME},
new Object[]{reqBean.getUserInfo(), (new SimpleDateFormat(MesPcnExtConstWords.DATE_FORMAT_SSS)).format(new Date()),
CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), MesPcnExtConstWords.EMPTY,
MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue(), new Double(1), new Double(0),
productionPartContext.getOnlineTime(), productionPartContext.getOnlineTime(), productionPartContext.getOfflineTime(), productionPartContext.getOfflineTime()});
} }
log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- ORDER:{} --- UPDATE:[{}:{}]", //末工位 或者 非加工中
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), if (isEndWorkCell || productionPartContext.getWorkOrderStatus().compareTo(MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue()) != 0) {
StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), productionPartContext.getWorkOrderNo(), MesPcnExtConstWords.WORK_ORDER_STATUS, !isEndWorkCell ? MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue() : MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue()); if (!isEndWorkCell) {
propertyMap.put(MesPcnExtConstWords.WORK_ORDER_STATUS, MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue());
propertyMap.put(MesPcnExtConstWords.START_TIME, productionPartContext.getOnlineTime());
propertyMap.put(MesPcnExtConstWords.ONLINE_TIME, productionPartContext.getOnlineTime());
} else {
productionPartContext.setOfflineTime(TimeTool.getNowTime(true));
propertyMap.put(MesPcnExtConstWords.WORK_ORDER_STATUS, MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue());
propertyMap.put(MesPcnExtConstWords.START_TIME, productionPartContext.getOnlineTime());
propertyMap.put(MesPcnExtConstWords.ONLINE_TIME, productionPartContext.getOnlineTime());
propertyMap.put(MesPcnExtConstWords.END_TIME, productionPartContext.getOfflineTime());
propertyMap.put(MesPcnExtConstWords.OFFLINE_TIME, productionPartContext.getOfflineTime());
propertyMap.put(MesPcnExtConstWords.COMPLETE_QTY, new Double(1));
propertyMap.put(MesPcnExtConstWords.UN_COMPLETE_QTY, new Double(0));
}
}
//当存在修改字段的情况下进行修改工单信息
if (!CollectionUtils.isEmpty(propertyMap) && propertyMap.size() > 0) {
propertyMap.put(MesPcnExtConstWords.MODIFY_USER, reqBean.getUserInfo());
propertyMap.put(MesPcnExtConstWords.MODIFY_DATE_TIME, (new SimpleDateFormat(MesPcnExtConstWords.DATE_FORMAT_SSS)).format(new Date()));
propertyMap.put(MesPcnExtConstWords.SYSTEM_SYNC_STATUS, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
propertyMap.put(MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME, MesPcnExtConstWords.EMPTY);
String[] propertyName = new String[propertyMap.size()];
Object[] propertyValue = new Object[propertyMap.size()];
Integer index = 0;
for (Map.Entry<String, Object> innerEntry : propertyMap.entrySet()) {
if (null == innerEntry) continue;
propertyName[index] = innerEntry.getKey();
propertyValue[index] = innerEntry.getValue();
index ++;
}
workOrderRepository.updateByPropertiesNoSync(new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE}, new Object[]{productionPartContext.getId(), reqBean.getOrganizeCode()}, propertyName, propertyValue);
log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- ORDER:{} --- UPDATE:{}",
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(),
StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), productionPartContext.getWorkOrderNo(), JSONObject.toJSONString(propertyMap));
}
} }
} }

@ -114,7 +114,9 @@ public class MesProductionProcessContextStepService extends BaseStepService impl
if (isCheckProcess && (StringUtils.isEmpty(productionProcessContext.getProcessCode()) || !productionProcessContext.getProcessCode().equals(reqBean.getProcessCode()))) processContext(reqBean, productionProcessContext); if (isCheckProcess && (StringUtils.isEmpty(productionProcessContext.getProcessCode()) || !productionProcessContext.getProcessCode().equals(reqBean.getProcessCode()))) processContext(reqBean, productionProcessContext);
//生产过程上下文对象赋值生产过程控制全局密码 //生产过程上下文对象赋值生产过程控制全局密码
if (StringUtils.isEmpty(productionProcessContext.getFinishCode()) || StringUtils.isEmpty(productionProcessContext.getCraftJumpCode()) || StringUtils.isEmpty(productionProcessContext.getAssemblySkipCode()) || StringUtils.isEmpty(productionProcessContext.getAssemblyCavitySkipCode())) productionPwdContext(reqBean, productionProcessContext); if (StringUtils.isEmpty(productionProcessContext.getFinishCode()) || StringUtils.isEmpty(productionProcessContext.getCraftJumpCode()) ||
StringUtils.isEmpty(productionProcessContext.getAssemblySkipCode()) || StringUtils.isEmpty(productionProcessContext.getAssemblyCavitySkipCode()) ||
StringUtils.isEmpty(productionProcessContext.getSortSuspiciousCode())) productionPwdContext(reqBean, productionProcessContext);
return productionProcessContext; return productionProcessContext;
@ -152,7 +154,8 @@ public class MesProductionProcessContextStepService extends BaseStepService impl
return productionProcessContext.finishCode((!CollectionUtils.isEmpty(cfgKeyMap) && cfgKeyMap.containsKey(MesPcnExtConstWords.CAVITY_FINISH_CODE)) ? cfgKeyMap.get(MesPcnExtConstWords.CAVITY_FINISH_CODE).get(0).getCfgValue() : MesPcnExtConstWords.CAVITY_FINISH_CODE) return productionProcessContext.finishCode((!CollectionUtils.isEmpty(cfgKeyMap) && cfgKeyMap.containsKey(MesPcnExtConstWords.CAVITY_FINISH_CODE)) ? cfgKeyMap.get(MesPcnExtConstWords.CAVITY_FINISH_CODE).get(0).getCfgValue() : MesPcnExtConstWords.CAVITY_FINISH_CODE)
.craftJumpCode((!CollectionUtils.isEmpty(cfgKeyMap) && cfgKeyMap.containsKey(MesPcnExtConstWords.CRAFT_JUMP_CODE)) ? cfgKeyMap.get(MesPcnExtConstWords.CRAFT_JUMP_CODE).get(0).getCfgValue() : MesPcnExtConstWords.CRAFT_JUMP_CODE) .craftJumpCode((!CollectionUtils.isEmpty(cfgKeyMap) && cfgKeyMap.containsKey(MesPcnExtConstWords.CRAFT_JUMP_CODE)) ? cfgKeyMap.get(MesPcnExtConstWords.CRAFT_JUMP_CODE).get(0).getCfgValue() : MesPcnExtConstWords.CRAFT_JUMP_CODE)
.assemblySkipCode((!CollectionUtils.isEmpty(cfgKeyMap) && cfgKeyMap.containsKey(MesPcnExtConstWords.ASSEMBLY_SKIP_CODE)) ? cfgKeyMap.get(MesPcnExtConstWords.ASSEMBLY_SKIP_CODE).get(0).getCfgValue() : MesPcnExtConstWords.ASSEMBLY_SKIP_CODE) .assemblySkipCode((!CollectionUtils.isEmpty(cfgKeyMap) && cfgKeyMap.containsKey(MesPcnExtConstWords.ASSEMBLY_SKIP_CODE)) ? cfgKeyMap.get(MesPcnExtConstWords.ASSEMBLY_SKIP_CODE).get(0).getCfgValue() : MesPcnExtConstWords.ASSEMBLY_SKIP_CODE)
.assemblyCavitySkipCode((!CollectionUtils.isEmpty(cfgKeyMap) && cfgKeyMap.containsKey(MesPcnExtConstWords.ASSEMBLY_CAVITY_SKIP_CODE)) ? cfgKeyMap.get(MesPcnExtConstWords.ASSEMBLY_CAVITY_SKIP_CODE).get(0).getCfgValue() : MesPcnExtConstWords.ASSEMBLY_CAVITY_SKIP_CODE); .assemblyCavitySkipCode((!CollectionUtils.isEmpty(cfgKeyMap) && cfgKeyMap.containsKey(MesPcnExtConstWords.ASSEMBLY_CAVITY_SKIP_CODE)) ? cfgKeyMap.get(MesPcnExtConstWords.ASSEMBLY_CAVITY_SKIP_CODE).get(0).getCfgValue() : MesPcnExtConstWords.ASSEMBLY_CAVITY_SKIP_CODE)
.sortSuspiciousCode((!CollectionUtils.isEmpty(cfgKeyMap) && cfgKeyMap.containsKey(MesPcnExtConstWords.SORT_SUSPICIOUS_CODE)) ? cfgKeyMap.get(MesPcnExtConstWords.SORT_SUSPICIOUS_CODE).get(0).getCfgValue() : MesPcnExtConstWords.SORT_SUSPICIOUS_CODE);
} }
//验证组织模型有效性 //验证组织模型有效性

@ -47,6 +47,9 @@ public class MesProductionProcessContext implements Serializable {
@ApiParam("装配件整腔跳过码") @ApiParam("装配件整腔跳过码")
private String assemblyCavitySkipCode; private String assemblyCavitySkipCode;
@ApiParam("排序线可疑码")
private String sortSuspiciousCode;
@ApiParam("生产线信息([Json]MesWorkCenter)") @ApiParam("生产线信息([Json]MesWorkCenter)")
private String workCenterJson; private String workCenterJson;
@ -142,6 +145,12 @@ public class MesProductionProcessContext implements Serializable {
return this.isNeedCache(); return this.isNeedCache();
} }
//排序线可疑码
public MesProductionProcessContext sortSuspiciousCode(String sortSuspiciousCode) {
this.sortSuspiciousCode = sortSuspiciousCode;
return this.isNeedCache();
}
//---------------------- 生产线对象 --------------------------------------- //---------------------- 生产线对象 ---------------------------------------

@ -0,0 +1,11 @@
package cn.estsh.i3plus.ext.mes.pcn.pojo.model;
import lombok.Data;
@Data
public class MesPartModel {
private String partNo;
private String locateNo;
}

@ -344,6 +344,9 @@ public class MesPcnExtConstWords {
// 扩展字段 // 扩展字段
public static final String EXTEND = "extend"; public static final String EXTEND = "extend";
// 默认客户条码编码规则配置代码
public static final String DEFAULT_CUST_MATCH_RULE = "DEFAULT_CUST_MATCH_RULE";
// 用户缓存 // 用户缓存
public static final String USER_INFO_CONTEXT = "USER_INFO_CONTEXT"; public static final String USER_INFO_CONTEXT = "USER_INFO_CONTEXT";
// 装箱防错 // 装箱防错
@ -386,6 +389,8 @@ public class MesPcnExtConstWords {
public static final String ASSEMBLY_SKIP_CODE = "ASSEMBLY_SKIP_CODE"; public static final String ASSEMBLY_SKIP_CODE = "ASSEMBLY_SKIP_CODE";
// 装配件整腔跳过码 // 装配件整腔跳过码
public static final String ASSEMBLY_CAVITY_SKIP_CODE = "ASSEMBLY_CAVITY_SKIP_CODE"; public static final String ASSEMBLY_CAVITY_SKIP_CODE = "ASSEMBLY_CAVITY_SKIP_CODE";
// 排序线可疑码
public static final String SORT_SUSPICIOUS_CODE = "SORT_SUSPICIOUS_CODE";
// 设备代码[工步参数] // 设备代码[工步参数]
public static final String EQUIPMENT_CODE_UC = "EQUIPMENT_CODE"; public static final String EQUIPMENT_CODE_UC = "EQUIPMENT_CODE";
// 模具号读一模多腔配置[工步参数] // 模具号读一模多腔配置[工步参数]
@ -707,6 +712,8 @@ public class MesPcnExtConstWords {
public static final String QR_CODE = "qrCode"; public static final String QR_CODE = "qrCode";
//条形码 //条形码
public static final String BAR_CODE = "barCode"; public static final String BAR_CODE = "barCode";
//打印条形码
public static final String PRINT_BAR_CODE = "barcode";
//竖杠 //竖杠
public static final String VERTICAL_BAR = "|"; public static final String VERTICAL_BAR = "|";
@ -736,6 +743,8 @@ public class MesPcnExtConstWords {
public static final String PARAM = "param"; public static final String PARAM = "param";
//成品零件号 //成品零件号
public static final String FG_PART_NO = "fgPartNo"; public static final String FG_PART_NO = "fgPartNo";
// 打印日期
public static final String PRINT_DATE = "printDate";
// 打印时间 // 打印时间
public static final String PRINT_TIME = "printTime"; public static final String PRINT_TIME = "printTime";
//替换数 //替换数

Loading…
Cancel
Save