From bdeb76d456ffbe8f4723d6c918def6252c39ec21 Mon Sep 17 00:00:00 2001 From: jun Date: Tue, 9 Jul 2024 11:49:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0pisces=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mes/apiservice/cus_suit/PiscesProperties.java | 69 ++++++++++++++++++++++ .../apiservice/dbinterface/MesSAPDbAdapter.java | 33 +++++++++-- 2 files changed, 96 insertions(+), 6 deletions(-) create mode 100644 modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/cus_suit/PiscesProperties.java diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/cus_suit/PiscesProperties.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/cus_suit/PiscesProperties.java new file mode 100644 index 0000000..0484ec2 --- /dev/null +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/cus_suit/PiscesProperties.java @@ -0,0 +1,69 @@ +package cn.estsh.i3plus.ext.mes.apiservice.cus_suit; + +import cn.estsh.i3plus.platform.common.util.CommonConstWords; +import cn.estsh.i3plus.platform.plugin.datasource.DynamicDataSourceProxy; +import lombok.Getter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.concurrent.TimeUnit; + +/** + * @Description : pisces数据源配置 + * @Reference : + * @Author : junsheng.li + * @CreateDate 2024/7/9 11:14 + * @Modify: + **/ +@Configuration +public class PiscesProperties { + + public static final Logger LOGGER = LoggerFactory.getLogger(CommonConstWords.SYSTEM_LOG); + + /*********************** + * pisces数据源配置 + */ + @Value("${impp.pisces.datasource.isopen}") + @Getter + private boolean piscesIsOpen; + + @Value("${impp.pisces.datasource.driver-class-name}") + @Getter + private String piscesDriverClassName; + + @Value("${impp.pisces.datasource.alias}") + @Getter + private String piscesDsAlias; + + @Value("${impp.pisces.datasource.jdbc-url}") + @Getter + private String piscesDsJdbcUrl; + + @Value("${impp.pisces.datasource.username}") + @Getter + private String piscesDsUsername; + + @Value("${impp.pisces.datasource.password}") + @Getter + private String piscesDsPassword; + + @ConditionalOnExpression("'${impp.pisces.datasource.isopen:false}' == 'true'") + @Bean(name = "piscesDataSource") + public DynamicDataSourceProxy initPiscesCustomerSet(){ + LOGGER.info("【初始化客户定制化...】"); + + /** + * 注册客户定制数据源 + */ + LOGGER.info("【客户定制化:pisces数据源加载...】"); + //安道拓定制业务 + DynamicDataSourceProxy piscesDataSource = DynamicDataSourceProxy.initDataSourceFactory(this.getPiscesDriverClassName(), + this.getPiscesDsJdbcUrl(),this.getPiscesDsUsername(),this.getPiscesDsPassword(),TimeUnit.MINUTES.toMillis(30)); + + return piscesDataSource; + } +} diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/dbinterface/MesSAPDbAdapter.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/dbinterface/MesSAPDbAdapter.java index a2d28fe..d829e26 100644 --- a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/dbinterface/MesSAPDbAdapter.java +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/dbinterface/MesSAPDbAdapter.java @@ -47,6 +47,9 @@ public class MesSAPDbAdapter { @Resource(name = "mesDataSource") private DynamicDataSourceProxy mesDataSourceProxy; + @Resource(name = "piscesDataSource") + private DynamicDataSourceProxy piscesDataSourceProxy; + @Value("${sync.redis.time:1800}") private Integer redisTime; @@ -73,7 +76,8 @@ public class MesSAPDbAdapter { private WmsSAPDbWriter buildWriter(String groupName, DynamicDataSourceProxy sapDataSourceProxy, - DynamicDataSourceProxy mesDataSourceProxy) throws Exception { + DynamicDataSourceProxy mesDataSourceProxy, + DynamicDataSourceProxy piscesDataSourceProxy) throws Exception { WmsSAPDbWriter wmsSAPDbWriter = null; @@ -85,6 +89,14 @@ public class MesSAPDbAdapter { wmsSAPDbWriter = new WmsSAPDbWriter(mesDataSourceProxy, sapDataSourceProxy); } + if (groupName.equals(MesInterfaceEnumUtil.DIRECTION_TYPE.PISCES2MES.getName())) { + wmsSAPDbWriter = new WmsSAPDbWriter(piscesDataSourceProxy, mesDataSourceProxy); + } + + if (groupName.equals(MesInterfaceEnumUtil.DIRECTION_TYPE.MES2PISCES.getName())) { + wmsSAPDbWriter = new WmsSAPDbWriter(mesDataSourceProxy, piscesDataSourceProxy); + } + @@ -115,7 +127,8 @@ public class MesSAPDbAdapter { private WmsSAPDbReader buildReader(String groupName, DynamicDataSourceProxy sapDataSourceProxy, - DynamicDataSourceProxy mesDataSourceProxy) { + DynamicDataSourceProxy mesDataSourceProxy, + DynamicDataSourceProxy piscesDataSourceProxy) { WmsSAPDbReader wmsSAPDbReader = null; @@ -127,6 +140,14 @@ public class MesSAPDbAdapter { wmsSAPDbReader = new WmsSAPDbReader(mesDataSourceProxy); } + if (groupName.equals(MesInterfaceEnumUtil.DIRECTION_TYPE.PISCES2MES.getName())) { + wmsSAPDbReader = new WmsSAPDbReader(piscesDataSourceProxy); + } + + if (groupName.equals(MesInterfaceEnumUtil.DIRECTION_TYPE.MES2PISCES.getName())) { + wmsSAPDbReader = new WmsSAPDbReader(mesDataSourceProxy); + } + // if (groupName.equals(MesInterfaceEnumUtil.DIRECTION_TYPE.WMS2MES.getName())) { // wmsSAPDbReader = new WmsSAPDbReader(mesDataSourceProxy); // } @@ -179,11 +200,11 @@ public class MesSAPDbAdapter { // 不需要在这里处理 //initConnection(); - writer = buildWriter(groupName, sapDataSourceProxy, mesDataSourceProxy); + writer = buildWriter(groupName, sapDataSourceProxy, mesDataSourceProxy,piscesDataSourceProxy); writer.setSrcConn(this.srcConn); writer.setDestConn(this.destConn); - reader = buildReader(groupName, sapDataSourceProxy, mesDataSourceProxy); + reader = buildReader(groupName, sapDataSourceProxy, mesDataSourceProxy,piscesDataSourceProxy); reader.setSrcConn(this.srcConn); @@ -340,11 +361,11 @@ public class MesSAPDbAdapter { // 不需要在这里处理 //initConnection(); - writer = buildWriter(groupName, sapDataSourceProxy, mesDataSourceProxy); + writer = buildWriter(groupName, sapDataSourceProxy, mesDataSourceProxy,piscesDataSourceProxy); writer.setSrcConn(this.srcConn); writer.setDestConn(this.destConn); - reader = buildReader(groupName, sapDataSourceProxy, mesDataSourceProxy); + reader = buildReader(groupName, sapDataSourceProxy, mesDataSourceProxy,piscesDataSourceProxy); reader.setSrcConn(this.srcConn);