Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gjjs-bd-common
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
s_guodong
gjjs-bd-common
Commits
c266a268
Commit
c266a268
authored
May 24, 2023
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试多数据源
parent
880890a7
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
235 additions
and
87 deletions
+235
-87
pom.xml
gjjs-bd-business/pom.xml
+0
-4
Rcvp.java
...s/src/main/java/com/ceb/gjjs/mda/manager/module/Rcvp.java
+70
-80
application-oracle.yml
gjjs-bd-business/src/main/resources/application-oracle.yml
+46
-0
DataSourceConfiguration.java
...illiance/mda/support/mybatis/DataSourceConfiguration.java
+59
-0
DynamicDataSource.java
...com/brilliance/mda/support/mybatis/DynamicDataSource.java
+19
-0
DynamicDataSourceContextHolder.java
...e/mda/support/mybatis/DynamicDataSourceContextHolder.java
+38
-0
DbExecuteMapper.java
...ance/mda/support/mybatis/dync/mapper/DbExecuteMapper.java
+2
-0
pom.xml
gjjs-bd-runtime/pom.xml
+1
-3
No files found.
gjjs-bd-business/pom.xml
View file @
c266a268
...
@@ -79,15 +79,11 @@
...
@@ -79,15 +79,11 @@
<groupId>
com.brilliance
</groupId>
<groupId>
com.brilliance
</groupId>
<artifactId>
jrxx-bean
</artifactId>
<artifactId>
jrxx-bean
</artifactId>
<version>
0.0.1
</version>
<version>
0.0.1
</version>
<scope>
system
</scope>
<systemPath>
${pom.basedir}/lib/jrxx-bean.jar
</systemPath>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.brilliance
</groupId>
<groupId>
com.brilliance
</groupId>
<artifactId>
jrxx
</artifactId>
<artifactId>
jrxx
</artifactId>
<version>
0.0.1
</version>
<version>
0.0.1
</version>
<scope>
system
</scope>
<systemPath>
${pom.basedir}/lib/jrxx.jar
</systemPath>
</dependency>
</dependency>
</dependencies>
</dependencies>
...
...
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/manager/module/Rcvp.java
View file @
c266a268
...
@@ -11,6 +11,7 @@ import com.brilliance.mda.runtime.mda.impl.AbstractModule;
...
@@ -11,6 +11,7 @@ import com.brilliance.mda.runtime.mda.impl.AbstractModule;
import
com.brilliance.mda.runtime.mda.impl.Argument
;
import
com.brilliance.mda.runtime.mda.impl.Argument
;
import
com.brilliance.mda.runtime.mda.impl.StreamImpl
;
import
com.brilliance.mda.runtime.mda.impl.StreamImpl
;
import
com.brilliance.mda.runtime.mda.util.MdaUtils
;
import
com.brilliance.mda.runtime.mda.util.MdaUtils
;
import
com.brilliance.mda.support.mybatis.DynamicDataSourceContextHolder
;
import
com.ceb.gjjs.mda.bo.Chn
;
import
com.ceb.gjjs.mda.bo.Chn
;
import
com.ceb.gjjs.mda.bo.Wanrec
;
import
com.ceb.gjjs.mda.bo.Wanrec
;
import
com.ceb.gjjs.mda.global.Platform
;
import
com.ceb.gjjs.mda.global.Platform
;
...
@@ -831,11 +832,13 @@ public class Rcvp extends AbstractModule{
...
@@ -831,11 +832,13 @@ public class Rcvp extends AbstractModule{
//20190827新增电子信用证查询语句
//20190827新增电子信用证查询语句
else
if
(
"exl"
.
equals
(
this
.
getMsgtyp
()))
else
if
(
"exl"
.
equals
(
this
.
getMsgtyp
()))
{
{
DynamicDataSourceContextHolder
.
setDataSourceType
(
"datasource1"
);
// sql = " WHERE m1.inr=m2.inr AND m1.dir='>' AND m1.pntinr IS NULL AND m2.subtyp<>'990' and m2.subtyp<>'900'";
// sql = " WHERE m1.inr=m2.inr AND m1.dir='>' AND m1.pntinr IS NULL AND m2.subtyp<>'990' and m2.subtyp<>'900'";
sql
=
" WHERE m1.inr=m2.inr AND m1.dir='>' AND m1.pntinr IS NULL AND m2.subtyp<>'990'"
;
sql
=
" WHERE m1.inr=m2.inr AND m1.dir='>' AND m1.pntinr IS NULL AND m2.subtyp<>'990'"
;
}
}
else
else
{
{
DynamicDataSourceContextHolder
.
setDataSourceType
(
"datasource2"
);
//sql = " WHERE m1.inr=m2.inr AND m1.dir='>' AND m1.pntinr IS NULL AND m2.subtyp<>'601' AND m2.subtyp<>'900' ";
//sql = " WHERE m1.inr=m2.inr AND m1.dir='>' AND m1.pntinr IS NULL AND m2.subtyp<>'601' AND m2.subtyp<>'900' ";
sql
=
" WHERE m1.inr=m2.inr AND m1.dir='>' AND m1.pntinr IS NULL AND m2.subtyp<>'NCK' AND m2.subtyp<>'ACK' AND m2.subtyp<>'010' AND m2.subtyp<>'020' "
;
sql
=
" WHERE m1.inr=m2.inr AND m1.dir='>' AND m1.pntinr IS NULL AND m2.subtyp<>'NCK' AND m2.subtyp<>'ACK' AND m2.subtyp<>'010' AND m2.subtyp<>'020' "
;
}
}
...
@@ -1248,6 +1251,8 @@ public class Rcvp extends AbstractModule{
...
@@ -1248,6 +1251,8 @@ public class Rcvp extends AbstractModule{
}
}
return
true
;
return
true
;
}
}
...
@@ -2087,107 +2092,92 @@ public class Rcvp extends AbstractModule{
...
@@ -2087,107 +2092,92 @@ public class Rcvp extends AbstractModule{
*/
*/
@Check
(
target
=
"msgtyp"
,
order
=
100
)
@Check
(
target
=
"msgtyp"
,
order
=
100
)
public
boolean
checkMsgtypN100
(){
public
boolean
checkMsgtypN100
(){
DynamicDataSourceContextHolder
.
setDataSourceType
(
"datasource2"
);
IContext
ctx
=
MdaEnv
.
getContext
();
IContext
ctx
=
MdaEnv
.
getContext
();
if
(
MdaUtils
.
isEmpty
(
this
.
getMsgtyp
()))
/*if(Platform.isEmpty($msgtyp.getValue()))
{
{
Platform.error($msgtyp,#CT000221
);
ctx
.
setFieldError
(
this
,
"msgtyp"
,
MdaUtils
.
getI18NString
(
"rcvp"
,
"CT000221"
)
);
return
false
;
return
false
;
}
}
else if("sf2".equals($msgtyp.getValue()))
else
{
if
(
"sf2"
.
equals
(
this
.
getMsgtyp
()))
Platform.setDefaultDB("swd");
Platform.setValues($subtyp,getMtyList());
Platform.setModified($subtyp);
Platform.enable($subtyp);
Platform.disable($sty);
Platform.clear($sty);
Platform.setModified($sty);
Platform.enable($gpi);
Platform.enable($uetr);
Platform.disable($lcnb);
}
else if("mx".equals($msgtyp.getValue()))
{
{
Platform
.
setDefaultDB
(
"swd"
);
Platform
.
setDefaultDB
(
"swd"
);
Platform.setValues($subtyp,getMxList());//将码表的值动态绑定给subtyp
MdaUtils
.
setValues
(
this
,
"subtyp"
,
getMtyList
());
Platform.setModified($subtyp);
Platform.enable($subtyp);
Platform.disable($sty);
Platform.clear($sty
);
this
.
setSty
(
NULLSTR
);
Platform.setModified($sty);
Platform.enable($gpi);
Platform.enable($uetr);
Platform.disable($lcnb);
}
}
else if("txt".equals($msgtyp.getValue()))
else
if
(
"txt"
.
equals
(
this
.
getMsgtyp
()))
{
//境内外币业务数据库更换为swd
Platform.setDefaultDB("swd");
Platform.setValues($subtyp,getFmtList());
Platform.setModified($subtyp);
Platform.enable($subtyp);
Platform.disable($sty);
Platform.clear($sty);
Platform.setModified($sty);
Platform.disable($gpi);
Platform.clear($gpi);
Platform.setModified($gpi);
Platform.enable($uetr);
Platform.disable($lcnb);
}
else if("fxl".equals($msgtyp.getValue()))
{
{
//境内外币业务数据库更换为swd
//境内外币业务数据库更换为swd
Platform
.
setDefaultDB
(
"swd"
);
Platform
.
setDefaultDB
(
"swd"
);
Platform.setValues($subtyp,getFxps
List());
MdaUtils
.
setValues
(
this
,
"subtyp"
,
getFmt
List
());
Platform.setModified($subtyp);
Platform.enable($subtyp);
Platform.disable($sty);
Platform.clear($sty
);
this
.
setSty
(
NULLSTR
);
Platform.setModified($sty);
Platform.disable($gpi);
Platform.clear($gpi
);
this
.
setGpi
(
NULLSTR
);
Platform.setModified($gpi);
Platform.enable($uetr);
Platform.disable($lcnb);
}
}
else if("xml".equals($msgtyp.getValue
()))
else
if
(
"xml"
.
equals
(
this
.
getMsgtyp
()))
{
{
Platform
.
setDefaultDB
(
"fxd"
);
Platform
.
setDefaultDB
(
"fxd"
);
Platform.setValues($subtyp
,getCipsList());
MdaUtils
.
setValues
(
this
,
"subtyp"
,
getCipsList
());
Platform.setModified($subtyp);
Platform.enable($subtyp);
Platform.disable($sty);
Platform.clear($sty
);
this
.
setSty
(
NULLSTR
);
Platform.setModified($sty);
Platform.disable($gpi);
Platform.clear($gpi
);
this
.
setGpi
(
NULLSTR
);
Platform.setModified($gpi);
Platform.enable($uetr);
Platform.disable($lcnb);
}
}
//20190827CCJ新增 电子信用证报文查询
//20190827CCJ新增 电子信用证报文查询
else if("exl".equals($msgtyp.getValue
()))
else
if
(
"exl"
.
equals
(
this
.
getMsgtyp
()))
{
{
$this.elcsCfg();
this
.
elcsCfg
();
}
else
if
(
"mx"
.
equals
(
this
.
getMsgtyp
()))
{
Platform
.
setDefaultDB
(
"swd"
);
this
.
setSubtyp
(
NULLSTR
);
this
.
setGpi
(
NULLSTR
);
}
}
else
else
{
{
Platform.clear($subtyp
);
this
.
setSubtyp
(
NULLSTR
);
Platform.setModified($subtyp);
Platform.disable($sty);
Platform.clear($sty
);
this
.
setSty
(
NULLSTR
);
Platform.setModified($sty);
Platform.disable($gpi);
Platform.clear($gpi
);
this
.
setGpi
(
NULLSTR
);
Platform.setModified($gpi);
Platform.disable($lcnb);
}*/
}
return
true
;
return
true
;
}
}
/**
/**
* source:rcvp.@0014.script
* source:rcvp.@0014.script
*/
*/
...
@@ -2953,7 +2943,7 @@ public class Rcvp extends AbstractModule{
...
@@ -2953,7 +2943,7 @@ public class Rcvp extends AbstractModule{
Platform
.
setDefaultDB
(
"fxd"
);
Platform
.
setDefaultDB
(
"fxd"
);
MdaUtils
.
setValues
(
this
,
"subtyp"
,
getElcsList
());
MdaUtils
.
setValues
(
this
,
"subtyp"
,
getElcsList
());
logger
.
info
(
"设置之后的db:{}"
,
Platform
.
getDefaultDB
());
this
.
setSty
(
NULLSTR
);
this
.
setSty
(
NULLSTR
);
...
...
gjjs-bd-business/src/main/resources/application-oracle.yml
View file @
c266a268
...
@@ -45,6 +45,50 @@ spring:
...
@@ -45,6 +45,50 @@ spring:
password
:
password
:
datasource1
:
driver-class-name
:
oracle.jdbc.driver.OracleDriver
url
:
jdbc:oracle:thin:@114.115.138.98:9400:XE
username
:
TEST
password
:
test
type
:
com.alibaba.druid.pool.DruidDataSource
# 下面为连接池的补充设置,应用到上面所有数据源中
# 初始化大小,最小,最大
# druid 配置: https://github.com/alibaba/druid/wiki/
#初始化链接数
initialSize
:
1
minIdle
:
1
maxActive
:
20
# 配置获取连接等待超时的时间
maxWait
:
60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis
:
60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis
:
300000
validationQuery
:
select 1 from dual
testWhileIdle
:
true
testOnBorrow
:
false
testOnReturn
:
false
# 打开PSCache,并且指定每个连接上PSCache的大小
poolPreparedStatements
:
true
maxPoolPreparedStatementPerConnectionSize
:
20
# 配置监控统计拦截的filters,stat用于监控界面,'wall'用于防火墙防御sql注入, slf4j用于druid记录sql日志
filters
:
stat,slf4j
#,wall
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录
connectionProperties
:
druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
# 合并多个DruidDataSource的监控数据
useGlobalDataSourceStat
:
false
datasource2
:
url
:
jdbc:mysql://localhost:3306/test?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false
username
:
root
password
:
123456
#driverClassName: com.mysql.jdbc.Driver
driver-class-name
:
com.mysql.jdbc.Driver
envConfig
:
envConfig
:
rootPath
:
workRoot
rootPath
:
workRoot
cache
:
cache
:
...
@@ -54,3 +98,5 @@ envConfig:
...
@@ -54,3 +98,5 @@ envConfig:
expireAfterAccess
:
3600
expireAfterAccess
:
3600
#序列化方式
#序列化方式
serializer
:
kryo
serializer
:
kryo
gjjs-bd-mybatis-support/src/main/java/com/brilliance/mda/support/mybatis/DataSourceConfiguration.java
0 → 100644
View file @
c266a268
package
com
.
brilliance
.
mda
.
support
.
mybatis
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
javax.sql.DataSource
;
import
java.util.HashMap
;
/**
* @Description 注册数据源头
* @Author s_guodong
* @Date 2023/5/24
*/
@Configuration
@EnableAutoConfiguration
(
exclude
=
{
DataSourceAutoConfiguration
.
class
})
public
class
DataSourceConfiguration
{
/**
* 数据源1
*/
@Bean
(
name
=
"datasource1"
)
@Qualifier
(
"datasource1"
)
@ConfigurationProperties
(
prefix
=
"spring.datasource1"
)
public
DruidDataSource
datasource1
()
{
return
new
DruidDataSource
();
}
/**
* 数据源2
*/
@Bean
(
name
=
"datasource2"
)
@Qualifier
(
"datasource2"
)
@ConfigurationProperties
(
prefix
=
"spring.datasource2"
)
public
DruidDataSource
datasource2
()
{
return
new
DruidDataSource
();
}
@Bean
(
name
=
"dynamicDataSource"
)
@Primary
public
DataSource
dynamicDataSource
()
{
DynamicDataSource
dynamicDataSource
=
new
DynamicDataSource
();
dynamicDataSource
.
myMap
=
new
HashMap
<>(
2
);
dynamicDataSource
.
myMap
.
put
(
"datasource1"
,
datasource1
());
dynamicDataSource
.
myMap
.
put
(
"datasource2"
,
datasource2
());
dynamicDataSource
.
setTargetDataSources
(
dynamicDataSource
.
myMap
);
dynamicDataSource
.
setDefaultTargetDataSource
(
datasource1
());
DynamicDataSourceContextHolder
.
dataSourceIds
.
addAll
(
dynamicDataSource
.
myMap
.
keySet
());
return
dynamicDataSource
;
}
}
gjjs-bd-mybatis-support/src/main/java/com/brilliance/mda/support/mybatis/DynamicDataSource.java
0 → 100644
View file @
c266a268
package
com
.
brilliance
.
mda
.
support
.
mybatis
;
import
org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource
;
import
java.util.Map
;
/**
* @Description
* @Author s_guodong
* @Date 2023/5/24
*/
public
class
DynamicDataSource
extends
AbstractRoutingDataSource
{
public
Map
<
Object
,
Object
>
myMap
=
null
;
@Override
protected
Object
determineCurrentLookupKey
()
{
return
DynamicDataSourceContextHolder
.
getDataSourceType
();
}
}
gjjs-bd-mybatis-support/src/main/java/com/brilliance/mda/support/mybatis/DynamicDataSourceContextHolder.java
0 → 100644
View file @
c266a268
package
com
.
brilliance
.
mda
.
support
.
mybatis
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @Description
* @Author s_guodong
* @Date 2023/5/24
*/
public
class
DynamicDataSourceContextHolder
{
private
static
final
ThreadLocal
<
String
>
contextHolder
=
new
ThreadLocal
<
String
>();
public
static
List
<
Object
>
dataSourceIds
=
new
ArrayList
<
Object
>();
public
static
void
setDataSourceType
(
String
dataSourceType
)
{
contextHolder
.
set
(
dataSourceType
);
}
public
static
String
getDataSourceType
()
{
return
contextHolder
.
get
();
}
public
static
void
clearDataSourceType
()
{
contextHolder
.
remove
();
}
public
static
boolean
containsDataSource
(
String
dataSourceId
)
{
return
dataSourceIds
.
contains
(
dataSourceId
);
}
}
gjjs-bd-mybatis-support/src/main/java/com/brilliance/mda/support/mybatis/dync/mapper/DbExecuteMapper.java
View file @
c266a268
package
com
.
brilliance
.
mda
.
support
.
mybatis
.
dync
.
mapper
;
package
com
.
brilliance
.
mda
.
support
.
mybatis
.
dync
.
mapper
;
import
com.brilliance.mda.support.mybatis.DynamicDataSourceContextHolder
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -16,6 +17,7 @@ public class DbExecuteMapper {
...
@@ -16,6 +17,7 @@ public class DbExecuteMapper {
final
String
FNAME
=
this
.
getClass
().
getName
();
final
String
FNAME
=
this
.
getClass
().
getName
();
public
List
<
Map
<
String
,
Object
>>
dyncReadForMap
(
Map
<
String
,
Object
>
params
){
public
List
<
Map
<
String
,
Object
>>
dyncReadForMap
(
Map
<
String
,
Object
>
params
){
DynamicDataSourceContextHolder
.
setDataSourceType
(
"datasource2"
);
return
sqlSessionTemplate
.
selectList
(
FNAME
+
".dyncReadForMap"
,
params
);
return
sqlSessionTemplate
.
selectList
(
FNAME
+
".dyncReadForMap"
,
params
);
}
}
public
int
dyncUpdateForMap
(
Map
<
String
,
Object
>
params
){
public
int
dyncUpdateForMap
(
Map
<
String
,
Object
>
params
){
...
...
gjjs-bd-runtime/pom.xml
View file @
c266a268
...
@@ -86,9 +86,7 @@
...
@@ -86,9 +86,7 @@
<dependency>
<dependency>
<groupId>
com.oracle
</groupId>
<groupId>
com.oracle
</groupId>
<artifactId>
ojdbc6
</artifactId>
<artifactId>
ojdbc6
</artifactId>
<version>
12.1.0.2
</version>
<version>
11.2.0.3
</version>
<scope>
system
</scope>
<systemPath>
${basedir}/../lib/ojdbc6-12.1.0.2.jar
</systemPath>
</dependency>
</dependency>
</dependencies>
</dependencies>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment