diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/ISxThirdPartyPlcCollectDataStepService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/ISxThirdPartyPlcCollectDataStepService.java index 96d74dd..ecea9bf 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/ISxThirdPartyPlcCollectDataStepService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/ISxThirdPartyPlcCollectDataStepService.java @@ -1,10 +1,7 @@ package cn.estsh.i3plus.ext.mes.pcn.api.busi; import cn.estsh.i3plus.pojo.mes.model.StepResult; -import cn.estsh.impp.framework.boot.exception.ImppBusiException; import io.swagger.annotations.ApiOperation; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; /** * @Author: wangjie @@ -19,7 +16,6 @@ public interface ISxThirdPartyPlcCollectDataStepService { * @return 结果 */ @ApiOperation(value = "第三方PLC数据采集定时任务---步骤执行", notes = "第三方PLC数据采集定时任务---步骤执行") - @Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = {ImppBusiException.class, Exception.class}) StepResult exec(StepResult stepResult); } diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/jx/IJxWorkCellTaktCollectRecordService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/jx/IJxWorkCellTaktCollectRecordService.java new file mode 100644 index 0000000..44d590e --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/jx/IJxWorkCellTaktCollectRecordService.java @@ -0,0 +1,24 @@ +package cn.estsh.i3plus.ext.mes.pcn.api.busi.jx; + +import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.SxWorkCellTaktCollectRecord; +import cn.estsh.impp.framework.boot.exception.ImppBusiException; +import io.swagger.annotations.ApiOperation; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +/** + * @Author: wangjie + * @CreateDate: 2021/01/18 11:22 上午 + * @Description: + **/ +public interface IJxWorkCellTaktCollectRecordService { + + /** + * 插入节拍信息(新事务,不回滚) + * @param workCellTaktCollectRecord 节拍信息 + */ + @ApiOperation(value = "插入节拍信息(新事务,不回滚)", notes = "插入节拍信息(新事务,不回滚)") + @Transactional(propagation = Propagation.REQUIRES_NEW, noRollbackFor = {ImppBusiException.class, Exception.class}) + void insertWorkCellTaktCollectRecordNoRollback(SxWorkCellTaktCollectRecord workCellTaktCollectRecord); + +} diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxCellTaktDispatchSingleton.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxCellTaktDispatchSingleton.java index 26ca82e..cdae971 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxCellTaktDispatchSingleton.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxCellTaktDispatchSingleton.java @@ -36,7 +36,7 @@ public class SxCellTaktDispatchSingleton { } private static void execMonitorRemove(String org, List removeKeyList) { - log.info("工厂{}第三方PLC数据采集 --- {} STRATEGY EXEC SINGLETON --- MONITOR CLOSED KEY:{} --- START ---", org, MesPcnExtConstWords.COLLECT_CELL_TAKT, CollectionUtils.isEmpty(removeKeyList) ? MesPcnExtConstWords.EMPTY : JSONObject.toJSONString(removeKeyList)); + log.info("工厂{}第三方PLC数据采集 --- {} STRATEGY EXEC SINGLETON --- MONITOR CLOSED KEY: {} --- START ---", org, MesPcnExtConstWords.COLLECT_CELL_TAKT, CollectionUtils.isEmpty(removeKeyList) ? MesPcnExtConstWords.EMPTY : JSONObject.toJSONString(removeKeyList)); if (!CollectionUtils.isEmpty(removeKeyList)) removeKeyList.stream().forEach(SxCellTaktDispatchSingleton::execMonitorRemove); } @@ -56,7 +56,7 @@ public class SxCellTaktDispatchSingleton { SxCellTaktMonitorHandler handler = cellTaktMonitorMap.get(key); handler.cancel(); cellTaktMonitorMap.remove(key); - log.info("工厂{}第三方PLC数据采集 --- {} STRATEGY EXEC SINGLETON --- MONITOR CLOSED KEY:[{}] ---", key.split(MesPcnExtConstWords.COLON)[1], MesPcnExtConstWords.COLLECT_CELL_TAKT, key); + log.info("工厂{}第三方PLC数据采集 --- {} STRATEGY EXEC SINGLETON --- MONITOR CLOSED KEY: {} ---", key.split(MesPcnExtConstWords.COLON)[1], MesPcnExtConstWords.COLLECT_CELL_TAKT, key); } private static void execMonitorCompute(String org, Map cfgMap) { @@ -66,7 +66,7 @@ public class SxCellTaktDispatchSingleton { if (null == plcCodeArr || plcCodeArr.length != 2) continue; SxCellTaktMonitorHandler handler = cellTaktMonitorMap.computeIfAbsent(key, o -> new SxCellTaktMonitorHandler(org, key)); handler.isRetry(plcCodeArr); - log.info("工厂{}第三方PLC数据采集 --- {} STRATEGY EXEC SINGLETON --- MONITOR {} KEY:[{}] ---", org, MesPcnExtConstWords.COLLECT_CELL_TAKT, handler.version() ? "ADD" : "RETRY", key); + log.info("工厂{}第三方PLC数据采集 --- {} STRATEGY EXEC SINGLETON --- MONITOR {} KEY: {} ---", org, MesPcnExtConstWords.COLLECT_CELL_TAKT, handler.version() ? "ADD" : "RETRY", key); } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxCellTaktMonitorHandler.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxCellTaktMonitorHandler.java index bab38a9..3ad099c 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxCellTaktMonitorHandler.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxCellTaktMonitorHandler.java @@ -11,6 +11,7 @@ import org.springframework.util.StringUtils; import java.util.HashMap; import java.util.Map; +import java.util.StringJoiner; import java.util.concurrent.ExecutorService; /** @@ -85,7 +86,7 @@ public class SxCellTaktMonitorHandler { filterChain = new SxThirdPartyPlcCollectStepFilterChain(org, key, MesPcnExtConstWords.COLLECT_CELL_TAKT, plcCode2Flag, plcCode2Data); - filterChain.add(new SxThirdPartyPlcCollectReadPlcStepService(plcCode2Flag).targetValue(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr())) + filterChain.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)) .add(new SxThirdPartyPlcCollectWritePlcStepService(plcCode2Flag).targetValue(MesPcnExtConstWords.ZERO_STR)) .add(new SxThirdPartyPlcCollectCellTaktStepService().targetField(plcCode2Data)); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectCellTaktStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectCellTaktStepService.java index ec8f97d..dc85d8c 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectCellTaktStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectCellTaktStepService.java @@ -1,11 +1,11 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.collect; import cn.estsh.i3plus.ext.mes.pcn.api.busi.ISxThirdPartyPlcCollectDataStepService; +import cn.estsh.i3plus.ext.mes.pcn.api.busi.jx.IJxWorkCellTaktCollectRecordService; import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.SxWorkCellTaktCollectRecord; -import cn.estsh.i3plus.ext.mes.pcn.pojo.repository.SxWorkCellTaktCollectRecordRepository; import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords; +import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtEnumUtil; import cn.estsh.i3plus.platform.common.convert.ConvertBean; -import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil; import cn.estsh.i3plus.pojo.mes.model.StepResult; import cn.estsh.impp.framework.boot.util.SpringContextsUtil; import lombok.extern.slf4j.Slf4j; @@ -18,12 +18,12 @@ import java.util.Map; @Slf4j public class SxThirdPartyPlcCollectCellTaktStepService implements ISxThirdPartyPlcCollectDataStepService { - private SxWorkCellTaktCollectRecordRepository workCellTaktCollectRecordRepository; + private IJxWorkCellTaktCollectRecordService workCellTaktCollectRecordService; protected String targetField; public SxThirdPartyPlcCollectCellTaktStepService() { - this.workCellTaktCollectRecordRepository = (SxWorkCellTaktCollectRecordRepository) SpringContextsUtil.getBean("sxWorkCellTaktCollectRecordRepository"); + this.workCellTaktCollectRecordService = (IJxWorkCellTaktCollectRecordService) SpringContextsUtil.getBean("jxWorkCellTaktCollectRecordService"); } public SxThirdPartyPlcCollectCellTaktStepService targetField(String targetField) { @@ -44,9 +44,9 @@ public class SxThirdPartyPlcCollectCellTaktStepService implements ISxThirdPartyP workCellTaktCollectRecord.setWorkCellCode(workCellCode); workCellTaktCollectRecord.setWorkTakt(targetValue.toString()); workCellTaktCollectRecord.setOrganizeCode(organizeCode); - workCellTaktCollectRecord.setSystemSyncStatus(MesPcnEnumUtil.IF_SYNC_STATUS.NO_SYNC.getValue()); + workCellTaktCollectRecord.setSystemSyncStatus(MesPcnExtEnumUtil.IF_SYNC_STATUS.NO_SYNC.getValue()); ConvertBean.serviceModelInitialize(workCellTaktCollectRecord, MesPcnExtConstWords.JOB); - workCellTaktCollectRecordRepository.insert(workCellTaktCollectRecord); + workCellTaktCollectRecordService.insertWorkCellTaktCollectRecordNoRollback(workCellTaktCollectRecord); return stepResult; } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectReadPlcStepService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectReadPlcStepService.java index a67e84e..86320af 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectReadPlcStepService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectReadPlcStepService.java @@ -9,6 +9,7 @@ import cn.estsh.impp.framework.boot.util.SpringContextsUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; +import java.util.Arrays; import java.util.Map; /** @@ -48,7 +49,7 @@ public class SxThirdPartyPlcCollectReadPlcStepService implements ISxThirdPartyPl ((Map) stepResult.getData()).put(plcCode, value); - if (StringUtils.isEmpty(value) || (!StringUtils.isEmpty(targetValue) && !targetValue.equals(value.toString()))) return stepResult.isCompleted(false).msg(String.format("读取plcCode:%s 值无效", plcCode)); + if (StringUtils.isEmpty(value) || (!StringUtils.isEmpty(targetValue) && !Arrays.asList(targetValue.split(MesPcnExtConstWords.COMMA)).contains(value.toString()))) return stepResult.isCompleted(false).msg(String.format("读取plcCode:%s 值无效", plcCode)); return stepResult; } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectStepFilterChain.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectStepFilterChain.java index 36e52da..72e31fe 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectStepFilterChain.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/collect/SxThirdPartyPlcCollectStepFilterChain.java @@ -40,7 +40,7 @@ public class SxThirdPartyPlcCollectStepFilterChain implements ISxThirdPartyPlcCo @Override public StepResult exec(StepResult stepResult) { - LOGGER.info(String.format("工厂%s第三方PLC数据采集 --- %s STEP EXEC --- key:[%s] START --- stepResult:%s ---", org, busiCode, key, JSONObject.toJSONString(stepResult))); + LOGGER.info(String.format("工厂%s第三方PLC数据采集 --- %s STEP EXEC --- key: %s START --- stepResult:%s ---", org, busiCode, key, JSONObject.toJSONString(stepResult))); try { for (ISxThirdPartyPlcCollectDataStepService stepService : stepServiceList) { @@ -52,10 +52,10 @@ public class SxThirdPartyPlcCollectStepFilterChain implements ISxThirdPartyPlcCo TimeUnit.MILLISECONDS.sleep(!stepResult.isCompleted() ? 1000L: 2000L); } catch (Exception e) { - LOGGER.info(String.format("工厂%s第三方PLC数据采集 --- %s STEP ERROR --- key:[%s] %s --- stepResult:%s --- %s ---", org, busiCode, key, e.toString(), JSONObject.toJSONString(stepResult), "\r\n" + JSONObject.toJSONString(e))); + LOGGER.info(String.format("工厂%s第三方PLC数据采集 --- %s STEP ERROR --- key: %s --- %s --- stepResult:%s --- %s ---", org, busiCode, key, e.toString(), JSONObject.toJSONString(stepResult), JSONObject.toJSONString(e))); } - LOGGER.info(String.format("工厂%s第三方PLC数据采集 --- %s STEP EXEC --- key:[%s] END --- stepResult:%s ---", org, busiCode, key, JSONObject.toJSONString(stepResult))); + LOGGER.info(String.format("工厂%s第三方PLC数据采集 --- %s STEP EXEC --- key: %s END --- stepResult:%s ---", org, busiCode, key, JSONObject.toJSONString(stepResult))); return rollBackStepResult(stepResult); @@ -67,7 +67,7 @@ public class SxThirdPartyPlcCollectStepFilterChain implements ISxThirdPartyPlcCo if (StringUtils.isEmpty(field)) continue; ((Map) stepResult.getData()).remove(field); } - return stepResult.isCompleted(true); + return stepResult.isCompleted(true).msg(null); } } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/jx/JxWorkCellTaktCollectRecordService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/jx/JxWorkCellTaktCollectRecordService.java new file mode 100644 index 0000000..2d02e60 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/jx/JxWorkCellTaktCollectRecordService.java @@ -0,0 +1,27 @@ +package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.jx; + +import cn.estsh.i3plus.ext.mes.pcn.api.busi.jx.IJxWorkCellTaktCollectRecordService; +import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.SxWorkCellTaktCollectRecord; +import cn.estsh.i3plus.ext.mes.pcn.pojo.repository.SxWorkCellTaktCollectRecordRepository; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @Author: wangjie + * @CreateDate: 2021/01/18 11:41 上午 + * @Description: + **/ +@Slf4j +@Service +public class JxWorkCellTaktCollectRecordService implements IJxWorkCellTaktCollectRecordService { + + @Autowired + private SxWorkCellTaktCollectRecordRepository workCellTaktCollectRecordRepository; + + @Override + public void insertWorkCellTaktCollectRecordNoRollback(SxWorkCellTaktCollectRecord workCellTaktCollectRecord) { + workCellTaktCollectRecordRepository.insert(workCellTaktCollectRecord); + } + +} \ No newline at end of file