增加pisces数据源

tags/yfai-mes-ext-v1.0
jun 10 months ago
parent 52d1519a91
commit bdeb76d456

@ -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;
}
}

@ -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);

Loading…
Cancel
Save