diff --git a/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/cus_suit/Pisces3Properties.java b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/cus_suit/Pisces3Properties.java new file mode 100644 index 0000000..be81436 --- /dev/null +++ b/modules/i3plus-ext-mes-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/apiservice/cus_suit/Pisces3Properties.java @@ -0,0 +1,67 @@ +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 : pisces3数据源配置 + * @Reference : + * @Author : junsheng.li + * @CreateDate 2024/11/5 11:29 + * @Modify: + **/ +@Configuration +public class Pisces3Properties { + + public static final Logger LOGGER = LoggerFactory.getLogger(CommonConstWords.SYSTEM_LOG); + + /*********************** + * pisces3数据源配置 + */ + @Value("${impp.pisces3.datasource.isopen}") + @Getter + private boolean piscesIsOpen; + + @Value("${impp.pisces3.datasource.driver-class-name}") + @Getter + private String piscesDriverClassName; + + @Value("${impp.pisces3.datasource.alias}") + @Getter + private String piscesDsAlias; + + @Value("${impp.pisces3.datasource.jdbc-url}") + @Getter + private String piscesDsJdbcUrl; + + @Value("${impp.pisces3.datasource.username}") + @Getter + private String piscesDsUsername; + + @Value("${impp.pisces3.datasource.password}") + @Getter + private String piscesDsPassword; + + @Bean(name = "pisces3DataSource") + @ConditionalOnExpression("'${impp.pisces3.datasource.isopen:false}' == 'true'") + public DynamicDataSourceProxy initPiscesCustomerSet(){ + LOGGER.info("【初始化客户定制化...】"); + + /** + * 注册客户定制数据源 + */ + LOGGER.info("【客户定制化:pisces3数据源加载...】"); + + return DynamicDataSourceProxy.initDataSourceFactory(this.getPiscesDriverClassName(), + this.getPiscesDsJdbcUrl(), this.getPiscesDsUsername(), this.getPiscesDsPassword(),TimeUnit.MINUTES.toMillis(30)); + } +} 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 a2ae996..ae9843c 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 @@ -56,6 +56,9 @@ public class MesSAPDbAdapter { @Resource(name = "pisces2DataSource") private DynamicDataSourceProxy pisces2DataSourceProxy; + @Resource(name = "pisces3DataSource") + private DynamicDataSourceProxy pisces3DataSourceProxy; + @Value("${sync.redis.time:1800}") private Integer redisTime; @@ -85,7 +88,8 @@ public class MesSAPDbAdapter { DynamicDataSourceProxy mesDataSourceProxy, DynamicDataSourceProxy piscesDataSourceProxy, DynamicDataSourceProxy pisces1DataSourceProxy, - DynamicDataSourceProxy pisces2DataSourceProxy) throws Exception { + DynamicDataSourceProxy pisces2DataSourceProxy, + DynamicDataSourceProxy pisces3DataSourceProxy) throws Exception { WmsSAPDbWriter wmsSAPDbWriter = null; @@ -121,6 +125,14 @@ public class MesSAPDbAdapter { wmsSAPDbWriter = new WmsSAPDbWriter(mesDataSourceProxy, pisces2DataSourceProxy); } + if (groupName.equals(MesInterfaceEnumUtil.DIRECTION_TYPE.PISCES32MES.getCode())) { + wmsSAPDbWriter = new WmsSAPDbWriter(pisces3DataSourceProxy, mesDataSourceProxy); + } + + if (groupName.equals(MesInterfaceEnumUtil.DIRECTION_TYPE.MES2PISCES3.getCode())) { + wmsSAPDbWriter = new WmsSAPDbWriter(mesDataSourceProxy, pisces3DataSourceProxy); + } + // new 的对象需要手工注入 bean if (SpringContextsUtil.getApplicationContext() != null) { @@ -152,7 +164,8 @@ public class MesSAPDbAdapter { DynamicDataSourceProxy mesDataSourceProxy, DynamicDataSourceProxy piscesDataSourceProxy, DynamicDataSourceProxy pisces1DataSourceProxy, - DynamicDataSourceProxy pisces2DataSourceProxy) { + DynamicDataSourceProxy pisces2DataSourceProxy, + DynamicDataSourceProxy pisces3DataSourceProxy) { WmsSAPDbReader wmsSAPDbReader = null; @@ -188,6 +201,14 @@ public class MesSAPDbAdapter { wmsSAPDbReader = new WmsSAPDbReader(mesDataSourceProxy); } + if (groupName.equals(MesInterfaceEnumUtil.DIRECTION_TYPE.PISCES32MES.getCode())) { + wmsSAPDbReader = new WmsSAPDbReader(pisces3DataSourceProxy); + } + + if (groupName.equals(MesInterfaceEnumUtil.DIRECTION_TYPE.MES2PISCES3.getCode())) { + wmsSAPDbReader = new WmsSAPDbReader(mesDataSourceProxy); + } + // if (groupName.equals(MesInterfaceEnumUtil.DIRECTION_TYPE.WMS2MES.getName())) { // wmsSAPDbReader = new WmsSAPDbReader(mesDataSourceProxy); // } @@ -240,11 +261,11 @@ public class MesSAPDbAdapter { // 不需要在这里处理 //initConnection(); - writer = buildWriter(groupName, sapDataSourceProxy, mesDataSourceProxy,piscesDataSourceProxy,pisces1DataSourceProxy,pisces2DataSourceProxy); + writer = buildWriter(groupName, sapDataSourceProxy, mesDataSourceProxy,piscesDataSourceProxy,pisces1DataSourceProxy,pisces2DataSourceProxy,pisces3DataSourceProxy); writer.setSrcConn(this.srcConn); writer.setDestConn(this.destConn); - reader = buildReader(groupName, sapDataSourceProxy, mesDataSourceProxy,piscesDataSourceProxy,pisces1DataSourceProxy,pisces2DataSourceProxy); + reader = buildReader(groupName, sapDataSourceProxy, mesDataSourceProxy,piscesDataSourceProxy,pisces1DataSourceProxy,pisces2DataSourceProxy,pisces3DataSourceProxy); reader.setSrcConn(this.srcConn); @@ -401,11 +422,11 @@ public class MesSAPDbAdapter { // 不需要在这里处理 //initConnection(); - writer = buildWriter(groupName, sapDataSourceProxy, mesDataSourceProxy,piscesDataSourceProxy,pisces1DataSourceProxy,pisces2DataSourceProxy); + writer = buildWriter(groupName, sapDataSourceProxy, mesDataSourceProxy,piscesDataSourceProxy,pisces1DataSourceProxy,pisces2DataSourceProxy,pisces3DataSourceProxy); writer.setSrcConn(this.srcConn); writer.setDestConn(this.destConn); - reader = buildReader(groupName, sapDataSourceProxy, mesDataSourceProxy,piscesDataSourceProxy,pisces1DataSourceProxy,pisces2DataSourceProxy); + reader = buildReader(groupName, sapDataSourceProxy, mesDataSourceProxy,piscesDataSourceProxy,pisces1DataSourceProxy,pisces2DataSourceProxy,pisces3DataSourceProxy); reader.setSrcConn(this.srcConn);