From c31a240bbc03e36adfc8f86daf1defb8fd027533 Mon Sep 17 00:00:00 2001 From: jun Date: Sat, 16 Nov 2024 15:48:15 +0800 Subject: [PATCH] =?UTF-8?q?SPS=E5=8D=95=E6=8D=AE=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=AF=8F=E6=AC=A1?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=9D=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../busi/MesPullingOrderInfoController.java | 1 + .../busi/MesPullingOrderInfoService.java | 2 +- .../MesNoSortCustSnNumberRuleStrategyService.java | 50 ++++++++++++++++++++++ .../print/strategy/WuhanSnPrintStrategy.java | 20 ++++++--- 4 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/MesNoSortCustSnNumberRuleStrategyService.java diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPullingOrderInfoController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPullingOrderInfoController.java index 8fcbd00..a0795c0 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPullingOrderInfoController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesPullingOrderInfoController.java @@ -72,6 +72,7 @@ public class MesPullingOrderInfoController { if (StringUtils.isEmpty(mesPullingOrderInfo.getWorkCenterCode())) { throw new ImppBusiException("产线不能为空"); } + mesPullingOrderInfo.setOrganizeCode(StringUtil.isEmpty(mesPullingOrderInfo.getOrganizeCode()) ? AuthUtil.getOrganizeCode() : mesPullingOrderInfo.getOrganizeCode()); List pullingOrderInfos = mesPullingOrderInfoService.doMesPullingOrderInfoPrint(mesPullingOrderInfo, AuthUtil.getSessionUser().getUserName()); return ResultBean.success("拉动单打印成功") .setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPullingOrderInfoService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPullingOrderInfoService.java index 5b97c77..6b17692 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPullingOrderInfoService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesPullingOrderInfoService.java @@ -180,7 +180,7 @@ public class MesPullingOrderInfoService implements IMesPullingOrderInfoService { DdlPreparedPack.getStringEqualPack(bean.getPullingOrderNo(), "pullingOrderNo", packBean); DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PRINT_STATUS.UNPRINT.getValue(), "printStatus", packBean); DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean); - List pullingOrderInfos = mesPullingOrderInfoRepository.findByHqlWhere(packBean); + List pullingOrderInfos = mesPullingOrderInfoRepository.findByHqlTopWhere(packBean, MesPcnExtConstWords.THREE); if (!CollectionUtils.isEmpty(pullingOrderInfos)) { //根据车型代码查询车型信息 Map> mesCustomerCarModelMap = getMesCustomerCarModelMap(bean.getOrganizeCode(), pullingOrderInfos.stream().map(MesPullingOrderInfo::getCarModelCode).distinct().collect(Collectors.toList())); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/MesNoSortCustSnNumberRuleStrategyService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/MesNoSortCustSnNumberRuleStrategyService.java new file mode 100644 index 0000000..6f9e8ab --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/MesNoSortCustSnNumberRuleStrategyService.java @@ -0,0 +1,50 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.numberrule; + +import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesCustomerPartService; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException; +import cn.estsh.i3plus.mes.pcn.api.iservice.busi.INumberRulePackAttributeStrategyService; +import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart; +import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.Calendar; +import java.util.Date; +import java.util.Map; + +/** + * @Description : 非排序客户条码打印 + * @Reference : + * @Author : junsheng.li + * @CreateDate 2024/11/16 10:56 + * @Modify: + **/ +@Component +public class MesNoSortCustSnNumberRuleStrategyService implements INumberRulePackAttributeStrategyService { + + @Autowired + private IMesCustomerPartService mesCustomerPartService; + + @Override + public GenSerialNoModel execute(GenSerialNoModel genSerialNoModel) { + Map dataMap = genSerialNoModel.getDataMap(); + MesCustomerPart customerPart = (!CollectionUtils.isEmpty(dataMap) && dataMap.containsKey(MesCustomerPart.class.getSimpleName())) ? + (MesCustomerPart)dataMap.get(MesCustomerPart.class.getSimpleName()) : mesCustomerPartService.getMesCustomerPart(genSerialNoModel.getOrganizeCode(), genSerialNoModel.getPartNo()); + if (null != customerPart) { + genSerialNoModel.setCustPartNo(customerPart.getCustPartNo()); + }else { + MesPcnException.throwMesBusiException("请检查客户零件信息,零件[%s]客户零件关系未维护", genSerialNoModel.getPartNo()); + } + Calendar custCalendar = Calendar.getInstance(); + custCalendar.setTime(new Date()); + String partNo = customerPart.getCustPartNo(); + String prefix = partNo.substring(0, partNo.length() - 4); + String partNo4 = partNo.substring(partNo.length() - 4).toUpperCase(); + genSerialNoModel.setPartNo(prefix+partNo4); + String year = custCalendar.get(Calendar.YEAR)+""; + genSerialNoModel.setYear(year.substring(2)); + genSerialNoModel.setDay(String.format("%03d",custCalendar.get(Calendar.DAY_OF_YEAR))); + return genSerialNoModel; + } +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/WuhanSnPrintStrategy.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/WuhanSnPrintStrategy.java index d33666f..0c4cb87 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/WuhanSnPrintStrategy.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/WuhanSnPrintStrategy.java @@ -1,8 +1,10 @@ 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.apiservice.serviceimpl.print.IPrintTemplateStrategyService; import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.BarCodeUtils; +import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException; 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; @@ -12,10 +14,7 @@ import cn.estsh.i3plus.platform.common.tool.TimeTool; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; -import cn.estsh.i3plus.pojo.mes.bean.MesNumberRule; -import cn.estsh.i3plus.pojo.mes.bean.MesPart; -import cn.estsh.i3plus.pojo.mes.bean.MesPrintedSnLog; -import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn; +import cn.estsh.i3plus.pojo.mes.bean.*; import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel; import cn.estsh.i3plus.pojo.mes.model.StationRequestBean; import cn.estsh.i3plus.pojo.mes.model.StepResult; @@ -27,6 +26,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.io.ByteArrayOutputStream; @@ -56,14 +56,21 @@ public class WuhanSnPrintStrategy implements IPrintTemplateStrategyService { @Autowired private ISyncFuncService syncFuncService; + @Autowired + private IMesCustomerPartService mesCustomerPartService; + @Override public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel model, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep) { //物料信息 MesPart mesPart = mesPartService.getMesPartByPartNo(model.getPartNo(), model.getOrganizeCode()); + MesCustomerPart customerPart = (!Objects.isNull(genSerialNoModel) && !CollectionUtils.isEmpty(genSerialNoModel.getDataMap()) && genSerialNoModel.getDataMap().containsKey(MesCustomerPart.class.getSimpleName())) ? (MesCustomerPart) genSerialNoModel.getDataMap().get(MesCustomerPart.class.getSimpleName()) : mesCustomerPartService.getMesCustomerPart(model.getOrganizeCode(),model.getPartNo()); + if(Objects.isNull(customerPart)){ + MesPcnException.throwMesBusiException("零件号:%s客户物料信息不存在",model.getPartNo()); + } // 客户零件号 - String custPartNo = model.getCustPartNo(); + String custPartNo = customerPart.getCustPartNo(); // 客户零件号 前缀 排除后四位 String custPartNoPrefix = StringUtils.isEmpty(custPartNo) ? "" : custPartNo.substring(0, custPartNo.length() - 4); // 客户零件号 后四位 @@ -73,6 +80,7 @@ public class WuhanSnPrintStrategy implements IPrintTemplateStrategyService { // 返回的结果集合 List> printDataMapList = new ArrayList<>(); if (!isStep) { + genSerialNoModel.putDataMap(MesCustomerPart.class.getSimpleName(),customerPart); for (int i = 0; i < model.getPrintQty(); i++) { //保存条码信息 MesProduceSn produceSn = generateMesProduceSn(mesPart, syncFuncService.syncSerialNo(genSerialNoModel, model.getUserName(), model.getOrganizeCode(), 1).getResultList().get(0).toString(), model.getUserName(), model.getQty()); @@ -97,7 +105,7 @@ public class WuhanSnPrintStrategy implements IPrintTemplateStrategyService { } private MesNumberRule getMesNumberRule(MesPart mesPart) { - String custMatchRule = StringUtils.isEmpty(mesPart.getCustMatchRule()) ? "WH_CUST_SN_RULE" : mesPart.getCustMatchRule(); + String custMatchRule = StringUtils.isEmpty(mesPart.getCustMatchRule()) ? "WH_NO_SORT_CUST_SN_RULE" : mesPart.getCustMatchRule(); DdlPackBean packBean = DdlPackBean.getDdlPackBean(mesPart.getOrganizeCode()); DdlPreparedPack.getStringEqualPack(custMatchRule, MesPcnExtConstWords.RULE_CODE, packBean); return numberRuleRepository.getByProperty(packBean);