From 4cbd0558ee49a5f97a2724e4396ff94c7c97fbd1 Mon Sep 17 00:00:00 2001 From: "jhforever.wang@estsh.com" Date: Wed, 24 Jul 2024 14:08:01 +0800 Subject: [PATCH] status --- .../equiplog/MesEquipmentRwExtService.java | 36 ++++++++++++---------- .../numberrule/GqxnyNumberRuleStrategyService.java | 4 ++- .../XiaoPengNumberRuleStrategyService.java | 27 ++++++++++++---- .../print/strategy/XiaoPengPrintStrategy.java | 15 +++++++++ .../MesProductionRecordGenerateStepService.java | 2 +- .../ext/mes/pcn/pojo/util/MesPcnExtConstWords.java | 10 +++--- 6 files changed, 64 insertions(+), 30 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/equiplog/MesEquipmentRwExtService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/equiplog/MesEquipmentRwExtService.java index 3d3141b..cd41a93 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/equiplog/MesEquipmentRwExtService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/equiplog/MesEquipmentRwExtService.java @@ -45,21 +45,22 @@ public class MesEquipmentRwExtService implements IMesEquipVariableRwExtService { //根据cfgCode查询缓存的配置数据 List configList = configService.doCachedConfigList(MesPcnExtConstWords.EQUIP_VARIABLE_RW_CFG, equipVariableRwModel.getOrganizeCode()); - //根据设备标识分组 - Map> requestUrlMap = getConfigMap(configList, MesPcnExtConstWords.KEPWARE_FLAG_CFG); - //根据读写标志分组 - Map> rwApiMap = getConfigMap(configList, MesPcnExtConstWords.RW_API_CFG); + //搜集读标志数据根据kepwareFlag分组 + Map> readUrlMap = getConfigMap(configList, MesExtEnumUtil.READ_WRITE_FLAG.READ.getValueStr()); + //搜集写标志数据根据kepwareFlag分组 + Map> writeUrlMap = getConfigMap(configList, MesExtEnumUtil.READ_WRITE_FLAG.WRITE.getValueStr()); - if (CollectionUtils.isEmpty(requestUrlMap) || CollectionUtils.isEmpty(rwApiMap)) return equipVariableRwModel; - if (!rwApiMap.containsKey(MesExtEnumUtil.READ_WRITE_FLAG.READ.getValueStr()) || !rwApiMap.containsKey(MesExtEnumUtil.READ_WRITE_FLAG.WRITE.getValueStr())) return equipVariableRwModel; - - List requestUrlList = (StringUtils.isEmpty(equipVariableRwModel.getKepwareFlag()) || !requestUrlMap.containsKey(equipVariableRwModel.getKepwareFlag())) ? requestUrlMap.get(MesPcnExtConstWords.DEFAULT_URL) : requestUrlMap.get(equipVariableRwModel.getKepwareFlag()); - if (CollectionUtils.isEmpty(requestUrlList)) return equipVariableRwModel; + if (CollectionUtils.isEmpty(readUrlMap) && CollectionUtils.isEmpty(writeUrlMap)) return equipVariableRwModel; //赋值读/写访问地址 - return equipVariableRwModel.readRequestUrl(requestUrlList.get(0).getCfgValue() + rwApiMap.get(MesExtEnumUtil.READ_WRITE_FLAG.READ.getValueStr()).get(0).getCfgValue()). - writeRequestUrl(requestUrlList.get(0).getCfgValue() + rwApiMap.get(MesExtEnumUtil.READ_WRITE_FLAG.WRITE.getValueStr()).get(0).getCfgValue()); + return equipVariableRwModel.readRequestUrl(getRequestUrl(readUrlMap, equipVariableRwModel.getKepwareFlag())).writeRequestUrl(getRequestUrl(writeUrlMap, equipVariableRwModel.getKepwareFlag())); + + } + private String getRequestUrl(Map> urlMap, String kepwareFlag) { + if (!CollectionUtils.isEmpty(urlMap) && urlMap.containsKey(kepwareFlag)) return urlMap.get(kepwareFlag).get(0).getCfgValue(); + if (!CollectionUtils.isEmpty(urlMap) && urlMap.containsKey(MesPcnExtConstWords.DEFAULT_KEPWARE_FLAG)) return urlMap.get(MesPcnExtConstWords.DEFAULT_KEPWARE_FLAG).get(0).getCfgValue(); + return null; } private Map> getConfigMap(List configList, String cfgType) { @@ -71,7 +72,7 @@ public class MesEquipmentRwExtService implements IMesEquipVariableRwExtService { @Override public MesEquipVariableRwResult writeVariable(MesEquipVariableRwModel equipVariableRwModel) { - MesEquipVariableRwResult result = checkBefore(equipVariableRwModel); + MesEquipVariableRwResult result = checkBefore(equipVariableRwModel, MesExtEnumUtil.READ_WRITE_FLAG.WRITE.getValueStr()); if (!result.getIsSuccessed()) return result; @@ -94,7 +95,7 @@ public class MesEquipmentRwExtService implements IMesEquipVariableRwExtService { } - private MesEquipVariableRwResult checkBefore(MesEquipVariableRwModel equipVariableRwModel) { + private MesEquipVariableRwResult checkBefore(MesEquipVariableRwModel equipVariableRwModel, String readWriteFlag) { if (null == equipVariableRwModel) return new MesEquipVariableRwResult().noSuccessed().isNoCfg().message("入参为空!"); @@ -103,8 +104,11 @@ public class MesEquipmentRwExtService implements IMesEquipVariableRwExtService { if (StringUtils.isEmpty(equipVariableRwModel.getWriteRequestUrl()) || StringUtils.isEmpty(equipVariableRwModel.getReadRequestUrl())) getRwRequestUrl(equipVariableRwModel); - if (StringUtils.isEmpty(equipVariableRwModel.getWriteRequestUrl()) || StringUtils.isEmpty(equipVariableRwModel.getReadRequestUrl())) - return new MesEquipVariableRwResult().noSuccessed().isNoCfg().message(String.format("工厂[%s]缺失系统配置信息[%s]!", equipVariableRwModel.getOrganizeCode(), MesPcnExtConstWords.EQUIP_VARIABLE_RW_CFG)); + if (MesExtEnumUtil.READ_WRITE_FLAG.READ.getValueStr().equals(readWriteFlag) && StringUtils.isEmpty(equipVariableRwModel.getReadRequestUrl())) + return new MesEquipVariableRwResult().noSuccessed().isNoCfg().message(String.format("工厂[%s]缺失系统配置信息[%s]读地址URL配置!", equipVariableRwModel.getOrganizeCode(), MesPcnExtConstWords.EQUIP_VARIABLE_RW_CFG)); + + if (MesExtEnumUtil.READ_WRITE_FLAG.WRITE.getValueStr().equals(readWriteFlag) && StringUtils.isEmpty(equipVariableRwModel.getWriteRequestUrl())) + return new MesEquipVariableRwResult().noSuccessed().isNoCfg().message(String.format("工厂[%s]缺失系统配置信息[%s]写地址URL配置!", equipVariableRwModel.getOrganizeCode(), MesPcnExtConstWords.EQUIP_VARIABLE_RW_CFG)); return new MesEquipVariableRwResult(); @@ -113,7 +117,7 @@ public class MesEquipmentRwExtService implements IMesEquipVariableRwExtService { @Override public MesEquipVariableRwResult readVariable(MesEquipVariableRwModel equipVariableRwModel) { - MesEquipVariableRwResult result = checkBefore(equipVariableRwModel); + MesEquipVariableRwResult result = checkBefore(equipVariableRwModel, MesExtEnumUtil.READ_WRITE_FLAG.READ.getValueStr()); if (!result.getIsSuccessed()) return result; 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 2745cce..299d6e3 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 @@ -14,6 +14,7 @@ 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 org.springframework.util.StringUtils; import java.util.Date; import java.util.Map; @@ -36,7 +37,6 @@ public class GqxnyNumberRuleStrategyService implements INumberRulePackAttributeS @Override public GenSerialNoModel execute(GenSerialNoModel genSerialNoModel) { - Date date = new Date(); //----广乘 45位 GQXNY //{custPartNo}{SPILTURE}{custCode}{spiltrure}{spiltrule}{year}{serialNo}{spilture}{spiltrule} //客户零件号-扩展位-客户代码-预留位000-产线1-年月日-条码-扩展0000-追溯位+ @@ -63,6 +63,7 @@ public class GqxnyNumberRuleStrategyService implements INumberRulePackAttributeS //扩展位 3位 预留扩展位0~9 A~Z 不使用时,补 0 {SPILTRULE} //产线 1位 供应商产线号,表示由数字1~9 和字母A~Z(I/O除外)组成; {SPILTRULE} //年月日 6位 yyMMdd 零部件生产日期,年月日各2位 + Date date = new Date(); String year = TimeTool.pareDateToString(MesPcnExtConstWords.DATE_FORMAT_SHORT, date); genSerialNoModel.setYear(year); //流水号 4位 采用34进制 0001~ZZZZ (I、O除外)顺位进行标注 (同广汽 & 广新) {serialNo} @@ -101,6 +102,7 @@ public class GqxnyNumberRuleStrategyService implements INumberRulePackAttributeS } private MesCustomerPart getMesCustomerPart(String orgaizeCode, String partNo) { + if (StringUtils.isEmpty(orgaizeCode) || StringUtils.isEmpty(partNo)) return null; DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(orgaizeCode); DdlPreparedPack.getStringEqualPack(partNo, MesPcnExtConstWords.ERP_PART_NO, ddlPackBean); MesCustomerPart customerPart = customerPartRepository.getByProperty(ddlPackBean); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/XiaoPengNumberRuleStrategyService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/XiaoPengNumberRuleStrategyService.java index 090aaf2..a4f149e 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/XiaoPengNumberRuleStrategyService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/numberrule/XiaoPengNumberRuleStrategyService.java @@ -1,13 +1,18 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.numberrule; +import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; 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.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 org.springframework.util.StringUtils; import java.util.Date; import java.util.Map; @@ -27,13 +32,14 @@ public class XiaoPengNumberRuleStrategyService implements INumberRulePackAttribu @Override public GenSerialNoModel execute(GenSerialNoModel genSerialNoModel) { - Date date = new Date(); - Map dataMap =genSerialNoModel.getDataMap(); - MesCustomerPart customerPart = (MesCustomerPart) dataMap.get(MesCustomerPart.class.getSimpleName()); - //客户零件号 - String custPartNo = customerPart.getCustPartNo(); - genSerialNoModel.setCustPartNo(custPartNo); + + Map dataMap = genSerialNoModel.getDataMap(); + MesCustomerPart customerPart = (!CollectionUtils.isEmpty(dataMap) && dataMap.containsKey(MesCustomerPart.class.getSimpleName())) ? + (MesCustomerPart)dataMap.get(MesCustomerPart.class.getSimpleName()) : getMesCustomerPart(genSerialNoModel.getOrganizeCode(), genSerialNoModel.getPartNo()); + if (null != customerPart) genSerialNoModel.setCustPartNo(customerPart.getCustPartNo()); + //年月日缩写 + Date date = new Date(); genSerialNoModel.setYear(getYearShort(date)); genSerialNoModel.setMonth(getMonthShort(date)); genSerialNoModel.setDay(getDayShort(date)); @@ -52,4 +58,13 @@ public class XiaoPengNumberRuleStrategyService implements INumberRulePackAttribu private String getDayShort(Date date) { return TimeTool.getDay(date); } + + private MesCustomerPart getMesCustomerPart(String orgaizeCode, String partNo) { + if (StringUtils.isEmpty(orgaizeCode) || StringUtils.isEmpty(partNo)) return null; + 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-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/XiaoPengPrintStrategy.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/XiaoPengPrintStrategy.java index 166ad8c..0e99e90 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/XiaoPengPrintStrategy.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/print/strategy/XiaoPengPrintStrategy.java @@ -13,12 +13,14 @@ import cn.estsh.i3plus.platform.common.convert.ConvertBean; 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.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; 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; import cn.estsh.i3plus.pojo.mes.repository.MesCustomerPartRepository; +import cn.estsh.i3plus.pojo.mes.repository.MesNumberRuleRepository; import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil; import cn.estsh.impp.framework.boot.util.ResultBean; import cn.hutool.core.bean.BeanUtil; @@ -55,6 +57,9 @@ public class XiaoPengPrintStrategy implements IPrintTemplateStrategyService { @Autowired private IConfigService configService; + @Autowired + private MesNumberRuleRepository numberRuleRepository; + @Override public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep) { String format = DateUtil.BASE_FORMAT; @@ -66,6 +71,7 @@ public class XiaoPengPrintStrategy implements IPrintTemplateStrategyService { //客户零件号 String custPartNo = getMesCustomerPart(mesProduceSnPrintModel).getCustPartNo(); MesPart mesPart = mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), organizeCode); + numberRule = null != numberRule ? numberRule : getNumberRule(organizeCode, mesPart); MesConfig mesConfig = configService.getMesConfigByCfgCode(MesPcnExtConstWords.ORGANIZE_NAME, organizeCode); String organizeName = mesConfig.getCfgValue(); if (!isStep){ @@ -113,6 +119,15 @@ public class XiaoPengPrintStrategy implements IPrintTemplateStrategyService { return mesProduceSnPrintModel; } + private MesNumberRule getNumberRule(String organizeCode, MesPart part) { + if (StringUtils.isEmpty(part.getProductMatchRule())) MesPcnException.throwMesBusiException("物料[%s]未维护零件条码匹配规则", part.getPartNo()); + MesNumberRule numberRule = numberRuleRepository.getByProperty( + new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.RULE_CODE}, + new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), part.getProcessMatchRule()}); + if (null == numberRule) MesPcnException.throwMesBusiException("物料[%s]维护的零件条码匹配规则[%s]信息不存在", part.getPartNo(), part.getProcessMatchRule()); + return numberRule; + } + private MesCustomerPart getMesCustomerPart(MesProduceSnPrintModel mesProduceSnPrintModel) { DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(mesProduceSnPrintModel.getOrganizeCode()); DdlPreparedPack.getStringEqualPack(mesProduceSnPrintModel.getPartNo(), "erpPartNo", ddlPackBean); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductionRecordGenerateStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductionRecordGenerateStepService.java index b1d6cfd..296942e 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductionRecordGenerateStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductionRecordGenerateStepService.java @@ -128,7 +128,7 @@ public class MesProductionRecordGenerateStepService extends BaseStepService { productionRecord.setModuleStatisticsStatus(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()); - productionRecord.setAreaCode(reqBean.getWorkCenterCode()); + productionRecord.setAreaCode(reqBean.getAreaCode()); productionRecord.setWorkCenterCode(reqBean.getWorkCenterCode()); productionRecord.setWorkCellCode(reqBean.getWorkCellCode()); productionRecord.setProcessCode(reqBean.getProcessCode()); 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 517acfd..c95ef52 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 @@ -157,6 +157,8 @@ public class MesPcnExtConstWords { public static final String DEAL_STATUS = "dealStatus"; // erp物料编码 public static final String ERP_PART_NO = "erpPartNo"; + // 编码规则代码 + public static final String RULE_CODE = "ruleCode"; // 时间格式 public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; @@ -165,12 +167,8 @@ public class MesPcnExtConstWords { //设备数据变量读写访问配置 public static final String EQUIP_VARIABLE_RW_CFG = "EQUIP_VARIABLE_RW_CFG"; - //kepware标识 - public static final String KEPWARE_FLAG_CFG = "KEPWARE_FLAG_CFG"; - //默认URL - public static final String DEFAULT_URL = "DEFAULT_URL"; - //读写API - public static final String RW_API_CFG = "RW_API_CFG"; + //默认KEPWARE_FLAG + public static final String DEFAULT_KEPWARE_FLAG = "DEFAULT_KEPWARE_FLAG"; //工步禁用扫描框标志 public static final String STEP_DISABLE_SCAN = "STEP_DISABLE_SCAN";