From 5faef47bd60bd681dcf0564e5846307f060e24a7 Mon Sep 17 00:00:00 2001 From: "jhforever.wang@estsh.com" Date: Fri, 22 Dec 2023 11:37:39 +0800 Subject: [PATCH] =?UTF-8?q?jx=20pcn=20=E9=87=87=E9=9B=86=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SxThirdPartyPlcCollectCellTaktService.java | 14 +++++----- .../SxThirdPartyPlcCollectDispatchSingleton.java | 25 ++++++++++++++++- ...hirdPartyPlcCollectMonitorCellTaktHandler.java} | 10 +++---- .../SxThirdPartyPlcCollectMonitorHandler.java | 4 +-- ...rdPartyPlcCollectMonitorProductDataHandler.java | 32 ++++++++++++++++++++++ ...SnProcessingCollectProductDataStepService.java} | 10 +++---- .../ext/mes/pcn/pojo/util/MesPcnExtConstWords.java | 9 +++++- 7 files changed, 82 insertions(+), 22 deletions(-) rename modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/{SxThirdPartyPlcCollectCellTaktMonitorHandler.java => SxThirdPartyPlcCollectMonitorCellTaktHandler.java} (89%) create mode 100644 modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectMonitorProductDataHandler.java rename modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/step/jx/{JxSnProcessingCollectDataStepService.java => JxSnProcessingCollectProductDataStepService.java} (69%) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectCellTaktService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectCellTaktService.java index 8354808..3362d39 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectCellTaktService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectCellTaktService.java @@ -29,26 +29,26 @@ public class SxThirdPartyPlcCollectCellTaktService implements ISxThirdPartyPlcCo String organizeCode = paramMap.get(MesPcnExtConstWords.ORGANIZE_CODE); - log.info("工厂{}第三方PLC数据采集 --- STRATEGY {} EXEC SERVICE START --- PARAM:{}", organizeCode, MesPcnExtConstWords.COLLECT_CELL_TAKT, paramMap.toString()); + log.info("工厂{}第三方PLC数据采集 --- STRATEGY {} EXEC SERVICE START --- PARAM:{}", organizeCode, MesPcnExtConstWords.CELL_TAKT, paramMap.toString()); if (checkOrgIsStopMonitor(organizeCode, paramMap.get(MesPcnExtConstWords.STATUS))) return; Map cfgMap = getWorkCellTaktCollectPlcCfgList(organizeCode); - log.info("工厂{}第三方PLC数据采集 --- STRATEGY {} EXEC SERVICE --- CFGMAP:{}", organizeCode, MesPcnExtConstWords.COLLECT_CELL_TAKT, cfgMap.toString()); + log.info("工厂{}第三方PLC数据采集 --- STRATEGY {} EXEC SERVICE --- CFGMAP:{}", organizeCode, MesPcnExtConstWords.CELL_TAKT, cfgMap.toString()); if (!SxThirdPartyPlcCollectDispatchSingleton.getIsInit()) SxThirdPartyPlcCollectDispatchSingleton.getInstance(); - SxThirdPartyPlcCollectDispatchSingleton.execMonitor(organizeCode, MesPcnExtConstWords.COLLECT_CELL_TAKT, cfgMap, true); + SxThirdPartyPlcCollectDispatchSingleton.execMonitor(organizeCode, MesPcnExtConstWords.CELL_TAKT, cfgMap, true); - log.info("工厂{}第三方PLC数据采集 --- STRATEGY {} EXEC SERVICE END ---", organizeCode, MesPcnExtConstWords.COLLECT_CELL_TAKT); + log.info("工厂{}第三方PLC数据采集 --- STRATEGY {} EXEC SERVICE END ---", organizeCode, MesPcnExtConstWords.CELL_TAKT); } private Boolean checkOrgIsStopMonitor(String organizeCode, String status) { if (!StringUtils.isEmpty(status) && status.equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr())) return false; - if (SxThirdPartyPlcCollectDispatchSingleton.getIsInit()) SxThirdPartyPlcCollectDispatchSingleton.execMonitor(organizeCode, MesPcnExtConstWords.COLLECT_CELL_TAKT, null, true); - log.info("工厂{}第三方PLC数据采集 --- STRATEGY {} EXEC SERVICE END --- MONITOR CLOSED COMPLETED ---", organizeCode, MesPcnExtConstWords.COLLECT_CELL_TAKT); + if (SxThirdPartyPlcCollectDispatchSingleton.getIsInit()) SxThirdPartyPlcCollectDispatchSingleton.execMonitor(organizeCode, MesPcnExtConstWords.CELL_TAKT, null, true); + log.info("工厂{}第三方PLC数据采集 --- STRATEGY {} EXEC SERVICE END --- MONITOR CLOSED COMPLETED ---", organizeCode, MesPcnExtConstWords.CELL_TAKT); return true; } @@ -64,7 +64,7 @@ public class SxThirdPartyPlcCollectCellTaktService implements ISxThirdPartyPlcCo Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SxWorkCellTaktCollectPlcCfg::getPlcCode))), ArrayList::new)); return CollectionUtils.isEmpty(workCellTaktCollectPlcCfgList) ? new HashMap<>() : workCellTaktCollectPlcCfgList.stream().filter(o -> null != o).collect(Collectors.toMap(o -> - new StringJoiner(MesPcnExtConstWords.COLON).add(MesPcnExtConstWords.COLLECT_CELL_TAKT).add(organizeCode).add(o.getWorkCenterCode()).add(o.getWorkCellCode()).toString(), SxWorkCellTaktCollectPlcCfg::getPlcCode)); + new StringJoiner(MesPcnExtConstWords.COLON).add(MesPcnExtConstWords.CELL_TAKT).add(organizeCode).add(o.getWorkCenterCode()).add(o.getWorkCellCode()).toString(), SxWorkCellTaktCollectPlcCfg::getPlcCode)); } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectDispatchSingleton.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectDispatchSingleton.java index c83b86c..a696b2b 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectDispatchSingleton.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectDispatchSingleton.java @@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; +import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -67,10 +68,32 @@ public class SxThirdPartyPlcCollectDispatchSingleton { private static void execMonitorCompute(String org, String busiCode, Map cfgMap) { for (String key : cfgMap.keySet()) { if (StringUtils.isEmpty(key)) continue; - SxThirdPartyPlcCollectMonitorHandler handler = monitorHandlerMap.computeIfAbsent(key, o -> new SxThirdPartyPlcCollectCellTaktMonitorHandler(org, key)); + SxThirdPartyPlcCollectMonitorHandler handler = monitorHandlerMap.computeIfAbsent(key, o -> instanceStrategyHandler(busiCode, org, key)); + if (null == handler) continue; handler.doRetry(cfgMap.get(key)); log.info("工厂{}第三方PLC数据采集 --- STRATEGY {} EXEC SINGLETON --- MONITOR {} KEY: {} ---", org, busiCode, handler.version() ? "ADD" : "RETRY", key); } } + private static SxThirdPartyPlcCollectMonitorHandler instanceStrategyHandler(String busiCode, String org, String key) { + + try { + + Class clazz = Class.forName(new StringJoiner(MesPcnExtConstWords.DECIMAL_POINT_UNESCAPE) + .add(SxThirdPartyPlcCollectDispatchSingleton.class.getPackage().getName()).add(MesPcnExtConstWords.SX_TPPCM_SUFFIX + busiCode + MesPcnExtConstWords.HANDLER_SUFFIX).toString()); + + Constructor constructor = clazz.getConstructor(String.class, String.class); + + return (SxThirdPartyPlcCollectMonitorHandler) constructor.newInstance(org, key); + + } catch (Exception e) { + + log.info("工厂{}第三方PLC数据采集 --- STRATEGY {} EXEC SINGLETON --- MONITOR ERROR KEY: {} --- INSTANCE STRATEGY HANDLER ERROR: {} ---", org, busiCode, key, e.getMessage()); + + return null; + + } + + } + } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectCellTaktMonitorHandler.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectMonitorCellTaktHandler.java similarity index 89% rename from modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectCellTaktMonitorHandler.java rename to modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectMonitorCellTaktHandler.java index 3fd6fcc..ec93fc8 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectCellTaktMonitorHandler.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectMonitorCellTaktHandler.java @@ -10,25 +10,25 @@ import java.util.StringJoiner; /** * 第三方PLC数据采集-监控处理器-工位节拍 */ -public class SxThirdPartyPlcCollectCellTaktMonitorHandler extends SxThirdPartyPlcCollectMonitorHandler { +public class SxThirdPartyPlcCollectMonitorCellTaktHandler extends SxThirdPartyPlcCollectMonitorHandler { private volatile String plcCode2Flag; private volatile String plcCode2Data; - public SxThirdPartyPlcCollectCellTaktMonitorHandler(String org, String key) { + public SxThirdPartyPlcCollectMonitorCellTaktHandler(String org, String key) { super(org, key); initStepResult(); } private void initStepResult() { - ((Map) stepResult.getData()).put(MesPcnExtConstWords.BUSI_CODE, MesPcnExtConstWords.COLLECT_CELL_TAKT); + ((Map) stepResult.getData()).put(MesPcnExtConstWords.BUSI_CODE, MesPcnExtConstWords.CELL_TAKT); ((Map) stepResult.getData()).put(MesPcnExtConstWords.WORK_CENTER_CODE, key.split(MesPcnExtConstWords.COLON)[2]); ((Map) stepResult.getData()).put(MesPcnExtConstWords.WORK_CELL_CODE, key.split(MesPcnExtConstWords.COLON)[3]); } @Override - public SxThirdPartyPlcCollectCellTaktMonitorHandler doRetry(Object obj) { + public SxThirdPartyPlcCollectMonitorCellTaktHandler doRetry(Object obj) { super.doRetry(obj); if (isRetry) return this; String[] plcCodeArr = obj.toString().split(MesPcnExtConstWords.COMMA); @@ -56,7 +56,7 @@ public class SxThirdPartyPlcCollectCellTaktMonitorHandler extends SxThirdPartyPl } private void instanceFilterChain() { - filterChain = new SxThirdPartyPlcCollectStepFilterChain(org, key, MesPcnExtConstWords.COLLECT_CELL_TAKT) + filterChain = new SxThirdPartyPlcCollectStepFilterChain(org, key, MesPcnExtConstWords.CELL_TAKT) .clearField(plcCode2Flag, plcCode2Data).sleepTime2UnComplete(1000L).sleepTime2Completed(2000L) .add(new SxThirdPartyPlcCollectReadPlcStepService(plcCode2Flag).targetValue(new StringJoiner(MesPcnExtConstWords.COMMA).add(CommonEnumUtil.TRUE_OR_FALSE.TRUE.name().toLowerCase()).add(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr()).toString())) .add(new SxThirdPartyPlcCollectReadPlcStepService(plcCode2Data)) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectMonitorHandler.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectMonitorHandler.java index 337851f..a4be34c 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectMonitorHandler.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectMonitorHandler.java @@ -53,9 +53,7 @@ public class SxThirdPartyPlcCollectMonitorHandler { } - public void execMonitor() { - System.out.println("3条34用她4用"); - } + public void execMonitor() {} public SxThirdPartyPlcCollectMonitorHandler doRetry(Object obj) { if (version == 0) version ++; diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectMonitorProductDataHandler.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectMonitorProductDataHandler.java new file mode 100644 index 0000000..6431fc3 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectMonitorProductDataHandler.java @@ -0,0 +1,32 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.collect; + +/** + * 第三方PLC数据采集-监控处理器-生产数据 + */ +public class SxThirdPartyPlcCollectMonitorProductDataHandler extends SxThirdPartyPlcCollectMonitorHandler { + + private volatile String plcCode2Flag; + + private volatile String plcCode2Data; + + public SxThirdPartyPlcCollectMonitorProductDataHandler(String org, String key) { + super(org, key); + initStepResult(); + } + + private void initStepResult() { + } + + @Override + public SxThirdPartyPlcCollectMonitorProductDataHandler doRetry(Object obj) { + return doRetry(obj); + } + + @Override + public void execMonitor() { + + } + + + +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/step/jx/JxSnProcessingCollectDataStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/step/jx/JxSnProcessingCollectProductDataStepService.java similarity index 69% rename from modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/step/jx/JxSnProcessingCollectDataStepService.java rename to modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/step/jx/JxSnProcessingCollectProductDataStepService.java index 9d568dd..8176d2f 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/step/jx/JxSnProcessingCollectDataStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/step/jx/JxSnProcessingCollectProductDataStepService.java @@ -9,20 +9,20 @@ import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; /** - * @Description : 嘉兴条码加工采集数据工步 + * @Description : 嘉兴条码加工采集生产数据工步 * @Reference : * @Author : wangjie * @CreateDate : 2019-07-11 * @Modify: **/ @Slf4j -@Service("jxSnProcessingCollectDataStepService") -public class JxSnProcessingCollectDataStepService extends BaseStepService { +@Service("jxSnProcessingCollectProductDataStepService") +public class JxSnProcessingCollectProductDataStepService extends BaseStepService { @Override public StepResult execute(StationRequestBean reqBean) { - log.info("工厂{}生产线{}工位{}: --- STEP EXECUTE --- JxSnProcessingCollectDataStepService --- START --- ", reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode()); + log.info("工厂{}生产线{}工位{}: --- STEP EXECUTE --- JxSnProcessingCollectProductDataStepService --- START --- ", reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode()); StepResult stepResult = StepResult.getSuccessComplete(); @@ -31,7 +31,7 @@ public class JxSnProcessingCollectDataStepService extends BaseStepService { if (StringUtils.isEmpty(reqBean.getSerialNumber()) && StringUtils.isEmpty(reqBean.getProductSn())) return execNonCompleteAndSendMsgReturn(reqBean, resultBean, stepResult, "入参缺少过程条码或产品条码!"); - log.info("工厂{}生产线{}工位{}: --- STEP EXECUTE --- JxSnProcessingCollectDataStepService --- SUCCESS --- ", reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode()); + log.info("工厂{}生产线{}工位{}: --- STEP EXECUTE --- JxSnProcessingCollectProductDataStepService --- SUCCESS --- ", reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode()); return stepResult; } 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 a3cc7e6..889c415 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 @@ -515,6 +515,8 @@ public class MesPcnExtConstWords { //-----------------DATE-------------------------- //. public static final String DECIMAL_POINT = "\\."; + //. + public static final String DECIMAL_POINT_UNESCAPE = "."; //空格 public static final String ONE_SPACE = " "; //拼接秒 @@ -1024,7 +1026,12 @@ public class MesPcnExtConstWords { public static final String KEY = "key"; //工位节拍 - public final static String COLLECT_CELL_TAKT = "COLLECT_CELL_TAKT"; + public final static String CELL_TAKT = "CellTakt"; + //生产数据 + public final static String PRODUCT_DATA = "ProductData"; + + public final static String SX_TPPCM_SUFFIX = "SxThirdPartyPlcCollectMonitor"; + public final static String HANDLER_SUFFIX = "Handler"; //业务代码 public static final String BUSI_CODE = "BUSI_CODE";