设备计数验证shotCounter

tags/yfai-pcn-ext-v2.0
王杰 8 months ago
parent 5cf100bce8
commit 959eb9aa11

@ -165,13 +165,21 @@ public class MesProductResultReadStepService extends BaseStepService {
Map<String, List<MesEquipVariableCfgCollectContext>> 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<MesEquipVariableCfgCollectContext> shotCounterList = null;
for (Map.Entry<String, List<MesEquipVariableCfgCollectContext>> entry : variableCategoryMap.entrySet()) {
if (null == entry) continue;
List<MesEquipVariableCfgCollectContext> 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<MesEquipVariableCfgCollectContext> 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<MesEquipVariableCfgCollectContext> 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;
}

Loading…
Cancel
Save