From d83d7506328cba502b7da530b2608267a60c0c1a Mon Sep 17 00:00:00 2001 From: "jhforever.wang@estsh.com" Date: Tue, 17 Sep 2024 21:27:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E5=BA=8F=E8=A3=85=E9=85=8D=E4=BB=B6?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E6=96=B9=E5=BC=8F=EF=BC=9A=E9=80=9A=E7=94=A8?= =?UTF-8?q?=E8=87=AA=E5=88=B6=E4=BB=B6=E8=A1=A5=E6=9D=A1=E7=A0=81=E5=AD=97?= =?UTF-8?q?=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MesNumberRuleMatchSortSnGmService.java | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/rulematch/MesNumberRuleMatchSortSnGmService.java diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/rulematch/MesNumberRuleMatchSortSnGmService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/rulematch/MesNumberRuleMatchSortSnGmService.java new file mode 100644 index 0000000..60ab637 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/rulematch/MesNumberRuleMatchSortSnGmService.java @@ -0,0 +1,60 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.rulematch; + +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesCustomerSnTransformService; +import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesNumberRuleMatchDispatchService; +import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyContext; +import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; +import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; +import cn.estsh.impp.framework.boot.util.SpringContextsUtil; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; + +import java.util.HashMap; +import java.util.Map; + +/** + * 自制件规则匹配【排序: 通用自制件补条码字符】 + */ +@Slf4j +@Service +public class MesNumberRuleMatchSortSnGmService implements IMesNumberRuleMatchDispatchService { + + private static final Logger LOGGER = LoggerFactory.getLogger(MesNumberRuleMatchSortSnGmService.class); + + @Autowired + private IMesCustomerSnTransformService customerSnTransformService; + + @Override + public Map matchNumberRule(String organizeCode, String sn, Object... params) { + + Map result = new HashMap<>(); + result.put(MesPcnExtConstWords.RESULT, false); + + if (StringUtils.isEmpty(sn)) { + result.put(MesPcnExtConstWords.MESSAGE, "参数缺失零件条码!"); + return result; + } + + if (!MesProductionAssemblyContext.class.isAssignableFrom(params[0].getClass())) { + result.put(MesPcnExtConstWords.MESSAGE, "参数匹配规则信息不是装配件匹配规则!"); + return result; + } + + String productSn = customerSnTransformService.transformBarCodeGm(sn); + if (productSn.length() == sn.length()) { + result.put(MesPcnExtConstWords.MESSAGE, String.format("通用自制件条码固定长度为58位,零件条码[%s]长度[%s]位!", sn, sn.length())); + return result; + } + + // 自制件条码 + result = ((IMesNumberRuleMatchDispatchService) SpringContextsUtil.getBean(MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_10.getStrategyClass())).matchNumberRule(organizeCode, sn, params); + + if (!(Boolean) result.get(MesPcnExtConstWords.RESULT)) result.put(MesPcnExtConstWords.MESSAGE, String.format("通用%s", result.get(MesPcnExtConstWords.MESSAGE))); + + return result; + } +}