From 959eb9aa11cbfd91e7fb5f179afae64ab9558c2c Mon Sep 17 00:00:00 2001 From: "jhforever.wang@estsh.com" Date: Mon, 9 Sep 2024 10:59:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E8=AE=A1=E6=95=B0=E9=AA=8C?= =?UTF-8?q?=E8=AF=81shotCounter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../step/MesProductResultReadStepService.java | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductResultReadStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductResultReadStepService.java index 5ba6eaa..6696155 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductResultReadStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/step/MesProductResultReadStepService.java @@ -165,13 +165,21 @@ public class MesProductResultReadStepService extends BaseStepService { Map> variableCategoryMap = equipLogDispatchContext.getEquipVariableCfgCollectContextList().stream().filter(o -> null != o).collect(Collectors.groupingBy(MesEquipVariableCfgCollectContext::getVariableCategory)); Integer shotCounterCached = !shotCounter ? MesPcnExtConstWords.ZERO : productionCustomContextStepService.getShortCounter(reqBean); + Boolean checkShotCounter = true; + + List shotCounterList = null; for (Map.Entry> entry : variableCategoryMap.entrySet()) { if (null == entry) continue; List equipVariableCfgCollectContextList = !shotCounter ? entry.getValue() : entry.getValue().stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getCategoryLevelTwo()) && !o.getCategoryLevelTwo().equals(MesPcnExtConstWords.SHOT_COUNTER))).collect(Collectors.toList()); - List shotCounterList = !shotCounter ? null : entry.getValue().stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getCategoryLevelTwo()) && o.getCategoryLevelTwo().equals(MesPcnExtConstWords.SHOT_COUNTER))).collect(Collectors.toList()); + + //存在设备计数则直接判断,且只需要判断一次 [设备计数] + if (CollectionUtils.isEmpty(shotCounterList) && shotCounter) { + shotCounterList = entry.getValue().stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getCategoryLevelTwo()) && o.getCategoryLevelTwo().equals(MesPcnExtConstWords.SHOT_COUNTER))).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(shotCounterList)) checkShotCounter = checkShotCounter(reqBean, shotCounterList, shotCounterCached); + } //当存在采集数据或者 不存在采集数据但非加工成功类型 if (!CollectionUtils.isEmpty(equipVariableCfgCollectContextList) || !MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.PRODUCT_OK.getValue().equals(entry.getKey())) { @@ -179,8 +187,8 @@ public class MesProductResultReadStepService extends BaseStepService { if (!(Boolean) equipVariableCfgRuleMatchService.matchEquipVariableCfgCollectContext(reqBean, productionProcessContext, entry.getKey(), equipVariableCfgCollectContextList)) continue; } - //需要判断设备计数且非加工失败类型,验证shotCounter - if (shotCounter && !MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.PRODUCT_NOK.getValue().equals(entry.getKey()) && !checkShotCounter(reqBean, shotCounterList, shotCounterCached)) continue; + //非设备加工失败情况下: 判断设备计数 + if (!MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.PRODUCT_NOK.getValue().equals(entry.getKey()) && !checkShotCounter) continue; //发送工步内容 productionCustomContextStepService.sendStepContextMessage(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.valueOfDescription(entry.getKey()), MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ); @@ -214,16 +222,16 @@ public class MesProductResultReadStepService extends BaseStepService { return (null != optional && optional.isPresent()) ? true : false; } - //验证shotCounter, 大于缓存的计数则默认加工成功, 等于0则默认为换膜 + //验证shotCounter, 大于缓存的计数则默认加工成功, 与缓存的计数不一致则更新缓存 private Boolean checkShotCounter(StationRequestBean reqBean, List shotCounterList, Integer shotCounterCached) { if (CollectionUtils.isEmpty(shotCounterList)) return false; if (CollectionUtils.isEmpty(shotCounterList.get(0).getEquipVariableCollectContextList())) return false; - if (StringUtils.isEmpty(shotCounterList.get(0).getEquipVariableCollectContextList().get(0).getEquipVariableValue())) return false; - if (!shotCounterList.get(0).getEquipVariableCollectContextList().get(0).getEquipVariableValue().equals(MesPcnExtConstWords.ZERO_STR) && - shotCounterCached.compareTo(Integer.valueOf(shotCounterList.get(0).getEquipVariableCollectContextList().get(0).getEquipVariableValue())) >= 0) return false; - shotCounterCached = Integer.valueOf(shotCounterList.get(0).getEquipVariableCollectContextList().get(0).getEquipVariableValue()); - productionCustomContextStepService.dispatchShortCounter(reqBean, shotCounterCached); - if (shotCounterCached.compareTo(MesPcnExtConstWords.ZERO) == 0) return false; + Integer equipVariableValue = StringUtils.isEmpty(shotCounterList.get(0).getEquipVariableCollectContextList().get(0).getEquipVariableValue()) ? MesPcnExtConstWords.ZERO : Integer.valueOf(shotCounterList.get(0).getEquipVariableCollectContextList().get(0).getEquipVariableValue()); + if (shotCounterCached.compareTo(equipVariableValue) != 0) { + productionCustomContextStepService.dispatchShortCounter(reqBean, equipVariableValue); + log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- mesProductResultReadStepService EXEC --- shotCounterCached:{} --- UPDATE:{}", reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), shotCounterCached, equipVariableValue); + } + if (shotCounterCached.compareTo(equipVariableValue) >= 0) return false; return true; }