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
50ca4183
Commit
50ca4183
authored
Jun 30, 2023
by
gechengyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决Oracle数据库表字段类型为Long的dbRead缺陷
parent
e11a7235
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
123 additions
and
10 deletions
+123
-10
Acd.java
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/bo/Acd.java
+9
-2
AcdMapper.java
...usiness/src/main/java/com/ceb/gjjs/mda/dao/AcdMapper.java
+2
-0
Mardav.java
...siness/src/main/java/com/ceb/gjjs/mda/manager/Mardav.java
+1
-1
acdmapper.xml
...usiness/src/main/resources/META-INF/orm/mda/acdmapper.xml
+4
-3
application.yml
gjjs-bd-business/src/main/resources/application.yml
+2
-1
pom.xml
gjjs-bd-mybatis-support/pom.xml
+7
-0
MyBatisDaoSession.java
...com/brilliance/mda/support/mybatis/MyBatisDaoSession.java
+48
-1
OracleLongTypeHandle.java
.../mda/support/mybatis/typehandle/OracleLongTypeHandle.java
+44
-0
IDaoSession.java
...main/java/com/brilliance/mda/runtime/mda/IDaoSession.java
+3
-0
MdaUtils.java
...in/java/com/brilliance/mda/runtime/mda/util/MdaUtils.java
+2
-2
transdb.properties
workRoot/cfg/transdb.properties
+1
-0
No files found.
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/bo/Acd.java
View file @
50ca4183
...
...
@@ -4,6 +4,7 @@ import java.util.*;
import
java.math.BigDecimal
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.brilliance.mda.runtime.mda.*
;
import
com.brilliance.mda.runtime.mda.impl.*
;
import
com.brilliance.mda.runtime.annotation.*
;
...
...
@@ -17,6 +18,7 @@ import lombok.Getter;
import
lombok.Setter
;
import
com.ceb.gjjs.mda.global.Platform
;
import
org.apache.ibatis.type.JdbcType
;
/**
...
...
@@ -42,6 +44,10 @@ public class Acd extends AbstractModule
return
"acd"
;
}
//经营范围
@TableField
(
jdbcType
=
JdbcType
.
LONGVARBINARY
)
private
String
busiscope
;
//唯一索引
private
String
inr
;
//业务参号
...
...
@@ -97,8 +103,6 @@ public class Acd extends AbstractModule
private
String
enttype
;
//注册地址
private
String
regaddr
;
//经营范围
private
String
busiscope
;
//经营状态
private
String
busistatus
;
//行业代码
...
...
@@ -203,4 +207,6 @@ public class Acd extends AbstractModule
}
\ No newline at end of file
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/dao/AcdMapper.java
View file @
50ca4183
...
...
@@ -2,6 +2,8 @@ package com.ceb.gjjs.mda.dao;
import
org.apache.ibatis.annotations.Mapper
;
import
com.ceb.gjjs.mda.bo.Acd
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.Collection
;
import
java.util.Map
;
import
java.util.List
;
...
...
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/manager/Mardav.java
View file @
50ca4183
...
...
@@ -72,7 +72,7 @@ public class Mardav extends AbstractTransaction{
{
this
.
getMarp
().
setMargrpHolder
(()->
this
.
getMargrp
());
this
.
getTrnmod
().
setCurHolder
(
new
FieldConstantHolder
<>(
""
));
this
.
getTrnmod
().
setAmtHolder
(
new
FieldConstantHolder
<>(
new
BigDecimal
(
"
0"
)));
this
.
getTrnmod
().
setAmtHolder
(
new
FieldConstantHolder
<>(
new
BigDecimal
(
"0"
)));
this
.
getTrnmod
().
setOwnrefHolder
(
new
FieldHolder
<
String
>(){
public
String
getPath
(){
return
Mardav
.
this
.
getFieldPath
(
"margrp.mar.ownref"
);}
public
void
setValue
(
String
arg
){
Mardav
.
this
.
getMargrp
().
getMar
().
setOwnref
(
arg
);}
...
...
gjjs-bd-business/src/main/resources/META-INF/orm/mda/acdmapper.xml
View file @
50ca4183
...
...
@@ -3,6 +3,7 @@
<mapper
namespace=
"com.ceb.gjjs.mda.dao.AcdMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.ceb.gjjs.mda.bo.Acd"
>
<result
property=
"inr"
column=
"inr"
jdbcType=
"VARCHAR"
/>
<result
property=
"ownref"
column=
"ownref"
jdbcType=
"VARCHAR"
/>
<result
property=
"transid"
column=
"transid"
jdbcType=
"VARCHAR"
/>
...
...
@@ -29,7 +30,7 @@
<result
property=
"industry"
column=
"industry"
jdbcType=
"VARCHAR"
/>
<result
property=
"enttype"
column=
"enttype"
jdbcType=
"VARCHAR"
/>
<result
property=
"regaddr"
column=
"regaddr"
jdbcType=
"VARCHAR"
/>
<result
property=
"busiscope"
column=
"busiscope"
jdbcType=
"
VARCHAR"
/>
<result
property=
"busiscope"
column=
"busiscope"
jdbcType=
"
LONGVARCHAR"
/>
<result
property=
"busistatus"
column=
"busistatus"
jdbcType=
"VARCHAR"
/>
<result
property=
"industrycode"
column=
"industrycode"
jdbcType=
"VARCHAR"
/>
<result
property=
"msgref"
column=
"msgref"
jdbcType=
"VARCHAR"
/>
...
...
@@ -41,10 +42,11 @@
<result
property=
"reason"
column=
"reason"
jdbcType=
"VARCHAR"
/>
<result
property=
"account"
column=
"account"
jdbcType=
"VARCHAR"
/>
<result
property=
"senddat"
column=
"senddat"
jdbcType=
"DATE"
/>
<!--<result property="busiscope" column="busiscope" jdbcType="LONGVARCHAR" typeHandler="com.brilliance.mda.support.mybatis.typehandle.OracleLongTypeHandle"/>-->
</resultMap>
<sql
id=
"Base_Column_List"
>
inr,ownref,transid,entname,accounttype,contactaddress,enttel,openoutletibk,legalrepresentative,financialadmin,transactor,transverifier1,transverifier2,producttype,openfea,socialcrdtcd,legalname,registerfund,registercurrency,appointmentdate,opendate,operatefrom,operateend,industry,enttype,regaddr,busis
cope,busistatus,industrycode,msgref,bchcod,credat,ncid,status,acdno,reason,account,senddat
inr,ownref,transid,entname,accounttype,contactaddress,enttel,openoutletibk,legalrepresentative,financialadmin,transactor,transverifier1,transverifier2,producttype,openfea,socialcrdtcd,legalname,registerfund,registercurrency,appointmentdate,opendate,operatefrom,operateend,industry,enttype,regaddr,busis
tatus,industrycode,msgref,bchcod,credat,ncid,status,acdno,reason,account,senddat,busiscope
</sql>
<select
id=
"selectByPrimaryKey"
resultMap=
"BaseResultMap"
>
...
...
@@ -289,7 +291,6 @@
<select
id=
"dyncRead"
resultMap=
"BaseResultMap"
>
${sql}
</select>
</mapper>
gjjs-bd-business/src/main/resources/application.yml
View file @
50ca4183
...
...
@@ -20,4 +20,4 @@ mybatis:
counter
:
name
:
oracleSequence
start
:
1500
setp
:
1
setp
:
1
\ No newline at end of file
gjjs-bd-mybatis-support/pom.xml
View file @
50ca4183
...
...
@@ -48,6 +48,12 @@
<artifactId>
pagehelper-spring-boot-starter
</artifactId>
<version>
1.2.5
</version>
</dependency>
<dependency>
<groupId>
com.baomidou
</groupId>
<artifactId>
mybatis-plus-annotation
</artifactId>
<version>
3.5.3.1
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
gjjs-bd-mybatis-support/src/main/java/com/brilliance/mda/support/mybatis/MyBatisDaoSession.java
View file @
50ca4183
...
...
@@ -11,6 +11,7 @@ import com.brilliance.mda.runtime.request.BaseVO;
import
com.brilliance.mda.support.mybatis.count.CounterService
;
import
com.brilliance.mda.support.mybatis.dync.mapper.DbExecuteMapper
;
import
com.github.pagehelper.PageHelper
;
import
org.apache.commons.beanutils.MethodUtils
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -18,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
java.io.Serializable
;
import
java.lang.reflect.InvocationTargetException
;
import
java.sql.SQLException
;
import
java.util.*
;
...
...
@@ -66,6 +68,8 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
private
static
final
String
SQLID_DELBYIDS
=
"deleteByIds"
;
private
static
final
String
SQLID_DYNCREAD
=
"dyncRead"
;
private
static
final
String
SQLID_DYNCDEL
=
"dyncDelete"
;
private
static
final
String
SQLID_SELECTBYID
=
"selectByInr"
;
private
static
final
String
SQLID_SELECTBYPRIMARYKEY
=
"selectByPrimaryKey"
;
@Autowired
...
...
@@ -161,6 +165,19 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
return
entity
;
}
@Override
public
<
T
extends
IModule
>
T
dbReadByInr
(
T
module
,
String
inr
)
{
String
moduleDB
=
MdaUtils
.
getModuleDB
(
module
);
DynamicDataSourceContextHolder
.
setDataSourceType
(
moduleDB
);
Map
<
String
,
Object
>
dyncMap
=
new
HashMap
<>();
dyncMap
.
put
(
"inr"
,
inr
);
T
entity
=
this
.
dyncReadByInr
(
module
.
getClass
(),
dyncMap
);
if
(
entity
!=
null
)
{
MdaDriver
.
copyValues
(
module
,
entity
);
}
return
entity
;
}
@Override
public
<
T
extends
IModule
>
int
dbReadset
(
ModuleList
<
T
>
list
,
CacheOption
cacheOption
,
Argument
...
args
)
{
...
...
@@ -364,7 +381,6 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
private
<
T
>
T
dyncReadOne
(
Class
<?
extends
IModule
>
clazz
,
MybatisArgumentAdapter
adapter
)
{
String
sqlId
=
getSqlId
(
clazz
,
SQLID_DYNCREAD
);
T
entity
=
sqlSessionTemplate
.
selectOne
(
sqlId
,
adapter
.
getSqlParams
());
if
(
entity
==
null
)
{
...
...
@@ -373,6 +389,37 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
return
entity
;
}
private
<
T
>
T
dyncReadByInr
(
Class
<?
extends
IModule
>
clazz
,
Map
<
String
,
Object
>
dyncMap
)
{
String
sqlId
=
getSqlId
(
clazz
,
SQLID_SELECTBYPRIMARYKEY
);
try
{
Object
obj
=
clazz
.
newInstance
();
MethodUtils
.
invokeMethod
(
obj
,
"setInr"
,
dyncMap
.
get
(
"inr"
));
T
entity
=
sqlSessionTemplate
.
selectOne
(
sqlId
,
obj
);
if
(
entity
==
null
)
{
setNoMoreRow
();
}
return
entity
;
}
catch
(
InvocationTargetException
e
)
{
throw
new
RuntimeException
(
e
.
getMessage
());
}
catch
(
InstantiationException
e
)
{
throw
new
RuntimeException
(
e
.
getMessage
());
}
catch
(
IllegalAccessException
e
)
{
throw
new
RuntimeException
(
e
.
getMessage
());
}
catch
(
NoSuchMethodException
e
)
{
throw
new
RuntimeException
(
e
.
getMessage
());
}
}
private
<
T
>
T
readByInr
(
Class
<?
extends
IModule
>
clazz
,
MybatisArgumentAdapter
adapter
)
{
String
sqlId
=
getSqlId
(
clazz
,
SQLID_SELECTBYID
);
T
entity
=
sqlSessionTemplate
.
selectOne
(
sqlId
,
adapter
.
getSqlParams
());
if
(
entity
==
null
)
{
setNoMoreRow
();
}
return
entity
;
}
private
<
T
>
List
<
T
>
dyncRead
(
Class
<
T
>
clazz
,
MybatisArgumentAdapter
adapter
)
{
String
sqlId
=
getSqlId
(
clazz
,
SQLID_DYNCREAD
);
...
...
gjjs-bd-mybatis-support/src/main/java/com/brilliance/mda/support/mybatis/typehandle/OracleLongTypeHandle.java
0 → 100644
View file @
50ca4183
package
com
.
brilliance
.
mda
.
support
.
mybatis
.
typehandle
;
import
org.apache.ibatis.type.BaseTypeHandler
;
import
org.apache.ibatis.type.JdbcType
;
import
org.apache.ibatis.type.MappedJdbcTypes
;
import
org.apache.ibatis.type.MappedTypes
;
import
java.io.StringReader
;
import
java.sql.CallableStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
@MappedTypes
({
Object
.
class
,
String
.
class
})
@MappedJdbcTypes
(
value
=
{
JdbcType
.
LONGVARCHAR
})
public
class
OracleLongTypeHandle
extends
BaseTypeHandler
<
Object
>
{
@Override
public
void
setNonNullParameter
(
PreparedStatement
preparedStatement
,
int
i
,
Object
parameter
,
JdbcType
jdbcType
)
throws
SQLException
{
String
parameterStr
=
(
String
)
parameter
;
StringReader
reader
=
new
StringReader
(
parameterStr
);
preparedStatement
.
setCharacterStream
(
i
,
reader
,
parameterStr
.
length
());
}
@Override
public
Object
getNullableResult
(
ResultSet
resultSet
,
String
columnName
)
throws
SQLException
{
String
str
=
resultSet
.
getString
(
columnName
);
return
str
!=
null
?
str
:
""
;
}
@Override
public
Object
getNullableResult
(
ResultSet
resultSet
,
int
columnIndex
)
throws
SQLException
{
String
str
=
resultSet
.
getString
(
columnIndex
);
return
str
!=
null
?
str
:
""
;
}
@Override
public
Object
getNullableResult
(
CallableStatement
callableStatement
,
int
columnIndex
)
throws
SQLException
{
String
str
=
callableStatement
.
getString
(
columnIndex
);
return
str
!=
null
?
str
:
""
;
}
}
\ No newline at end of file
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/IDaoSession.java
View file @
50ca4183
...
...
@@ -17,6 +17,9 @@ public interface IDaoSession {
@SuppressWarnings
(
"rawtypes"
)
<
T
extends
IModule
>
T
dbRead
(
T
module
,
Argument
...
args
);
<
T
extends
IModule
>
T
dbReadByInr
(
T
module
,
String
inr
);
@SuppressWarnings
(
"rawtypes"
)
<
T
extends
IModule
>
int
dbDelete
(
T
module
,
Argument
...
args
);
@SuppressWarnings
(
"rawtypes"
)
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/util/MdaUtils.java
View file @
50ca4183
...
...
@@ -1445,7 +1445,7 @@ public class MdaUtils {
log
.
debug
(
"{}"
,
"transdb.properties DefaultDB="
+
db
);
setDefaultDB
(
db
);
}
else
{
db
=
"
eibs
"
;
db
=
"
ipsnew
"
;
}
}
}
...
...
@@ -1511,7 +1511,7 @@ public class MdaUtils {
String
db
=
null
;
for
(
IModuleList
list
:
lists
)
{
db
=
getModuleListDB
(
list
);
if
(!
"
eibs
"
.
equals
(
db
))
if
(!
"
ipsnew
"
.
equals
(
db
))
return
db
;
}
return
db
;
...
...
workRoot/cfg/transdb.properties
View file @
50ca4183
...
...
@@ -187,3 +187,4 @@ emepcap=fxd
stachk
=
swd
dyctsk
=
swd
sxitsk
=
swd
acdopn
=
ipsnew
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