From aa828063a76cbc44d16631e1f552fb33e096d32b Mon Sep 17 00:00:00 2001 From: "jhforever.wang@estsh.com" Date: Fri, 19 Jul 2024 14:57:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E7=A0=81=E7=AD=96=E7=95=A5=EF=BC=9A?= =?UTF-8?q?=20gqxnyNumberRuleStrategyService=20=20=E4=BF=AE=E6=94=B9=20?= =?UTF-8?q?=E5=B7=A5=E6=AD=A5=E6=9C=AA=E4=BC=A0=20=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E9=9B=B6=E4=BB=B6=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../numberrule/GqxnyNumberRuleStrategyService.java | 42 ++++++++++++++++------ .../ext/mes/pcn/pojo/util/MesPcnExtConstWords.java | 5 +++ 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/GqxnyNumberRuleStrategyService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/GqxnyNumberRuleStrategyService.java index a5ba133..ecfafcd 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/GqxnyNumberRuleStrategyService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/GqxnyNumberRuleStrategyService.java @@ -4,15 +4,18 @@ 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.api.iservice.busi.INumberRulePackAttributeStrategyService; import cn.estsh.i3plus.platform.common.tool.TimeTool; +import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; +import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; import cn.estsh.i3plus.pojo.mes.bean.MesConfig; import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart; import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel; +import cn.estsh.i3plus.pojo.mes.repository.MesCustomerPartRepository; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import java.util.Date; -import java.util.HashMap; import java.util.Map; /** @@ -24,8 +27,13 @@ import java.util.Map; **/ @Component public class GqxnyNumberRuleStrategyService implements INumberRulePackAttributeStrategyService { + @Autowired private IConfigService configService; + + @Autowired + private MesCustomerPartRepository customerPartRepository; + @Override public GenSerialNoModel execute(GenSerialNoModel genSerialNoModel) { Date date = new Date(); @@ -35,20 +43,27 @@ public class GqxnyNumberRuleStrategyService implements INumberRulePackAttributeS //零件长号---17位,不足17位 右边补* //获取客户零件号 Map dataMap = genSerialNoModel.getDataMap(); - MesCustomerPart mesCustomerPart = (MesCustomerPart)dataMap.get("mesCustomerPart"); - String custPartNo = mesCustomerPart.getCustPartNo(); - String custPartNoFormat = stringFormat(custPartNo, 17); - genSerialNoModel.setCustPartNo(custPartNoFormat); + MesCustomerPart customerPart = (!CollectionUtils.isEmpty(dataMap) && dataMap.containsKey(MesCustomerPart.class.getSimpleName())) ? + (MesCustomerPart)dataMap.get(MesCustomerPart.class.getSimpleName()) : getMesCustomerPart(genSerialNoModel.getOrganizeCode(), genSerialNoModel.getPartNo()); + if (null != customerPart) { + String custPartNo = customerPart.getCustPartNo(); + String custPartNoFormat = stringFormat(custPartNo, 17); + genSerialNoModel.setCustPartNo(custPartNoFormat); + } + //拓展位 2位 00 包含0~9,A~Z 不使用时,补“0”填充 {SPILTRULE} //供应商代码 7位 供应商代码 0~9,A~Z;不足7位 右测补* MesConfig supplierConfig = configService.getMesConfigByCfgCodeKeyOrg(MesPcnExtConstWords.SUPPLIER_CODE, MesExtEnumUtil.MES_PRINT_TEMPLATE.GQXNY.getValue(), genSerialNoModel.getOrganizeCode()); - String supplierCode = supplierConfig.getCfgValue(); - String supplierCodeFormat = stringFormat(supplierCode, 7); - genSerialNoModel.setCustCode(supplierCodeFormat); + if (null != supplierConfig) { + String supplierCode = supplierConfig.getCfgValue(); + String supplierCodeFormat = stringFormat(supplierCode, 7); + genSerialNoModel.setCustCode(supplierCodeFormat); + } + //扩展位 3位 预留扩展位0~9 A~Z 不使用时,补 0 {SPILTRULE} //产线 1位 供应商产线号,表示由数字1~9 和字母A~Z(I/O除外)组成; {SPILTRULE} //年月日 6位 yyMMdd 零部件生产日期,年月日各2位 - String year = TimeTool.pareDateToString("yyMMdd", date); + String year = TimeTool.pareDateToString(MesPcnExtConstWords.DATE_FORMAT_SHORT, date); genSerialNoModel.setYear(year); //流水号 4位 采用34进制 0001~ZZZZ (I、O除外)顺位进行标注 (同广汽 & 广新) {serialNo} //扩展位 4位 预留扩展位信息,包含0~9和字母A~Z,不使用时,补“0” 填充; {SPILTRULE} @@ -58,7 +73,7 @@ public class GqxnyNumberRuleStrategyService implements INumberRulePackAttributeS } private String stringFormat(String data, Integer length) { - return stringFormat(data, length, true, "*"); + return stringFormat(data, length, true, MesPcnExtConstWords.ASTERISK); } private String stringFormat(String data, Integer length, boolean left, String symbol) { @@ -85,4 +100,11 @@ public class GqxnyNumberRuleStrategyService implements INumberRulePackAttributeS return dataBuffer.toString(); } + private MesCustomerPart getMesCustomerPart(String orgaizeCode, String partNo) { + DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(orgaizeCode); + DdlPreparedPack.getStringEqualPack(partNo, MesPcnExtConstWords.ERP_PART_NO, ddlPackBean); + MesCustomerPart customerPart = customerPartRepository.getByProperty(ddlPackBean); + return customerPart; + } + } diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java index 9d2b4f8..eea9d9d 100644 --- a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java @@ -155,9 +155,12 @@ public class MesPcnExtConstWords { public static final String URL = "url"; // 处理状态 public static final String DEAL_STATUS = "dealStatus"; + // erp物料编码 + public static final String ERP_PART_NO = "erpPartNo"; // 时间格式 public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; + public static final String DATE_FORMAT_SHORT = "yyMMdd"; //设备数据变量读写访问配置 @@ -266,6 +269,8 @@ public class MesPcnExtConstWords { public static final String SQUARE_BRACKETS_L = "["; // ] public static final String SQUARE_BRACKETS_R = "]"; + // * + public static final String ASTERISK = "*";