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
7371e304
Commit
7371e304
authored
Nov 29, 2022
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
连表查询
parent
ee9542a7
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
204 additions
and
113 deletions
+204
-113
Rcvp.java
...s/src/main/java/com/ceb/gjjs/mda/manager/module/Rcvp.java
+62
-14
MyBatisDaoSession.java
...com/brilliance/mda/support/mybatis/MyBatisDaoSession.java
+13
-2
MybatisArgumentAdapter.java
...rilliance/mda/support/mybatis/MybatisArgumentAdapter.java
+126
-94
IDaoSession.java
...main/java/com/brilliance/mda/runtime/mda/IDaoSession.java
+1
-1
ModuleList.java
.../java/com/brilliance/mda/runtime/mda/impl/ModuleList.java
+2
-2
No files found.
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/manager/module/Rcvp.java
View file @
7371e304
package
com
.
ceb
.
gjjs
.
mda
.
manager
.
module
;
import
java.util.*
;
import
java.math.BigDecimal
;
import
com.brilliance.mda.runtime.annotation.BDGetter
;
import
com.brilliance.mda.runtime.annotation.Check
;
import
com.brilliance.mda.runtime.annotation.Init
;
import
com.brilliance.mda.runtime.annotation.Rule
;
import
com.brilliance.mda.runtime.mda.*
;
import
com.brilliance.mda.runtime.mda.impl.*
;
import
com.brilliance.mda.runtime.annotation.*
;
import
com.brilliance.mda.runtime.mda.driver.*
;
import
static
com
.
brilliance
.
mda
.
runtime
.
mda
.
Constants
.*;
import
com.brilliance.mda.runtime.mda.util.*
;
import
com.fasterxml.jackson.annotation.*
;
import
java.util.regex.*
;
import
lombok.Getter
;
import
lombok.Setter
;
import
com.brilliance.mda.runtime.mda.driver.MdaDriver
;
import
com.brilliance.mda.runtime.mda.driver.MdaEnv
;
import
com.brilliance.mda.runtime.mda.impl.AbstractModule
;
import
com.brilliance.mda.runtime.mda.impl.Argument
;
import
com.brilliance.mda.runtime.mda.impl.StreamImpl
;
import
com.brilliance.mda.runtime.mda.util.MdaUtils
;
import
com.ceb.gjjs.mda.bo.Chn
;
import
com.ceb.gjjs.mda.bo.Wanrec
;
import
com.ceb.gjjs.mda.global.Platform
;
import
com.ceb.gjjs.mda.bo.Chn
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
static
com
.
brilliance
.
mda
.
runtime
.
mda
.
Constants
.*;
/**
*
*/
...
...
@@ -1151,7 +1160,46 @@ public class Rcvp extends AbstractModule{
if
(!
"blksel"
.
equals
(
ctx
.
getTransName
()))
{
log
.
debug
(
"{}"
,
"将查询结果添加至rcvlst中"
);
this
.
getMsggrp
().
getRcvlst
().
add
(
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getInr
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getDir
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getSrcchncod
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getChncod
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getNxtchncod
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getTgtchncod
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getSmhinr
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getSta
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getRspsta
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getRcvdattim
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getLstdattim
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getSttdattim
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getTgtdattime
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getSnddattim
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getRspdattim
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getOwnref
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getOthref
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getSndbic
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getRcvbic
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getAct
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getDtlchg
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getCur
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getAmt
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getValdat
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getMsgtyp
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getSubtyp
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getActbic
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getT53bic
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getGpi
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getUetr
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getLstdattim
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getLcnb
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getSweflg
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getBlktyp
(),
this
.
getMsggrp
().
getMpss
().
getElement
(
i
).
getXhxflg
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getLoginoprtp
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getSid
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getMtp
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getTxtpcd
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getCtgpcd
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getMid
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getCredat
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getInsgdp
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getInsdpl
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getInsgty
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getInsgpl
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getInsddp
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getInsddl
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getInsdty
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getInspdl
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getSyscod
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getRmk
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getOrgmid
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getOrginspty
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getOrginapty
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getOrgmsgtyp
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getOrgsnddat
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getStscod
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getPrcmsgdig
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getRspmsg
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getPrcsts
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getProccd
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getRjcinf
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getSstdat
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getRcvdat
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getTrndat
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getOrpmid
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getOrpinspty
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getOrpinapty
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getOrityp
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getOridat
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getOrists
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getOpinfo
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getOriaccdat
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getTrasts
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getBllpaysts
(),
this
.
getMsggrp
().
getMpis
().
getElement
(
i
).
getRemark
());
// this.getMsggrp().getRcvlst().add( this.getMsggrp().getMpss().getElement(i).getDatafields().toArray(new IDatafield[0]));
this
.
getMsggrp
().
getRcvlst
().
add
(
MdaDriver
.
getDatafield
(
this
.
getMsggrp
().
getMpss
().
getElement
(
i
),
"inr"
),
MdaDriver
.
getDatafield
(
this
.
getMsggrp
().
getMpss
().
getElement
(
i
),
"dir"
),
MdaDriver
.
getDatafield
(
this
.
getMsggrp
().
getMpss
().
getElement
(
i
),
"srcchncod"
),
MdaDriver
.
getDatafield
(
this
.
getMsggrp
().
getMpss
().
getElement
(
i
),
"chncod"
),
MdaDriver
.
getDatafield
(
this
.
getMsggrp
().
getMpss
().
getElement
(
i
),
"nxtchncod"
),
MdaDriver
.
getDatafield
(
this
.
getMsggrp
().
getMpss
().
getElement
(
i
),
"tgtchncod"
),
MdaDriver
.
getDatafield
(
this
.
getMsggrp
().
getMpss
().
getElement
(
i
),
"smhinr"
),
MdaDriver
.
getDatafield
(
this
.
getMsggrp
().
getMpss
().
getElement
(
i
),
"sta"
),
MdaDriver
.
getDatafield
(
this
.
getMsggrp
().
getMpss
().
getElement
(
i
),
"rspsta"
),
MdaDriver
.
getDatafield
(
this
.
getMsggrp
().
getMpss
().
getElement
(
i
),
"rcvdattim"
),
MdaDriver
.
getDatafield
(
this
.
getMsggrp
().
getMpss
().
getElement
(
i
),
"lstdattim"
),
MdaDriver
.
getDatafield
(
this
.
getMsggrp
().
getMpss
().
getElement
(
i
),
"tgtdattime"
),
MdaDriver
.
getDatafield
(
this
.
getMsggrp
().
getMpss
().
getElement
(
i
),
"sttdattim"
),
MdaDriver
.
getDatafield
(
this
.
getMsggrp
().
getMpss
().
getElement
(
i
),
"snddattim"
),
MdaDriver
.
getDatafield
(
this
.
getMsggrp
().
getMpss
().
getElement
(
i
),
"rspdattim"
),
MdaDriver
.
getDatafield
(
this
.
getMsggrp
().
getMpis
().
getElement
(
i
),
"ownref"
),
MdaDriver
.
getDatafield
(
this
.
getMsggrp
().
getMpis
().
getElement
(
i
),
"othref"
)
);
//$msggrp\\rcvlst.add($msggrp\\mpss[i]\\inr,$msggrp\\mpss[i]\\dir,$msggrp\\mpss[i]\\srcchncod
// ,$msggrp\\mpss[i]\\chncod,$msggrp\\mpss[i]\\nxtchncod,$msggrp\\mpss[i]\\tgtchncod
// ,$msggrp\\mpss[i]\\smhinr,$msggrp\\mpss[i]\\sta,$msggrp\\mpss[i]\\rspsta
// ,$msggrp\\mpss[i]\\rcvdattim,$msggrp\\mpss[i]\\lstdattim,$msggrp\\mpss[i]\\sttdattim
// ,$msggrp\\mpss[i]\\tgtdattime,$msggrp\\mpss[i]\\snddattim,$msggrp\\mpss[i]\\rspdattim
// ,$msggrp\\mpis[i]\\ownref,$msggrp\\mpis[i]\\othref,$msggrp\\mpis[i]\\sndbic,$msggrp\\mpis[i]\\rcvbic
// ,$msggrp\\mpis[i]\\act,$msggrp\\mpis[i]\\dtlchg,$msggrp\\mpis[i]\\cur,$msggrp\\mpis[i]\\amt,$msggrp\\mpis[i]\\valdat
// ,$msggrp\\mpis[i]\\msgtyp,$msggrp\\mpis[i]\\subtyp,$msggrp\\mpis[i]\\actbic,$msggrp\\mpis[i]\\t53bic,$msggrp\\mpis[i]\\gpi
// ,$msggrp\\mpis[i]\\uetr,$msggrp\\mpss[i]\\lstdattim,$msggrp\\mpis[i]\\lcnb, $msggrp\\mpss[i]\\sweflg,$msggrp\\mpss[i]\\blktyp,$msggrp\\mpss[i]\\xhxflg
// ,$msggrp\\mpis[i]\\loginoprtp,$msggrp\\mpis[i]\\sid,$msggrp\\mpis[i]\\mtp,$msggrp\\mpis[i]\\txtpcd,$msggrp\\mpis[i]\\ctgpcd
// ,$msggrp\\mpis[i]\\mid,$msggrp\\mpis[i]\\credat,$msggrp\\mpis[i]\\insgdp,$msggrp\\mpis[i]\\insdpl,$msggrp\\mpis[i]\\insgty
// ,$msggrp\\mpis[i]\\insgpl,$msggrp\\mpis[i]\\insddp,$msggrp\\mpis[i]\\insddl,$msggrp\\mpis[i]\\insdty,$msggrp\\mpis[i]\\inspdl
// ,$msggrp\\mpis[i]\\syscod,$msggrp\\mpis[i]\\rmk,$msggrp\\mpis[i]\\orgmid,$msggrp\\mpis[i]\\orginspty,$msggrp\\mpis[i]\\orginapty
// ,$msggrp\\mpis[i]\\orgmsgtyp,$msggrp\\mpis[i]\\orgsnddat,$msggrp\\mpis[i]\\stscod,$msggrp\\mpis[i]\\prcmsgdig,$msggrp\\mpis[i]\\rspmsg
// ,$msggrp\\mpis[i]\\prcsts,$msggrp\\mpis[i]\\proccd,$msggrp\\mpis[i]\\rjcinf,$msggrp\\mpis[i]\\sstdat,$msggrp\\mpis[i]\\rcvdat
// ,$msggrp\\mpis[i]\\trndat,$msggrp\\mpis[i]\\orpmid,$msggrp\\mpis[i]\\orpinspty,$msggrp\\mpis[i]\\orpinapty,$msggrp\\mpis[i]\\orityp
// ,$msggrp\\mpis[i]\\oridat,$msggrp\\mpis[i]\\orists,$msggrp\\mpis[i]\\opinfo,$msggrp\\mpis[i]\\oriaccdat,$msggrp\\mpis[i]\\trasts
// ,$msggrp\\mpis[i]\\bllpaysts,$msggrp\\mpis[i]\\remark);
if
(
"mx"
.
equals
(
this
.
getMsgtyp
()))
{
this
.
getMsggrp
().
getRcvlst
().
getElement
(
i
).
setMsgtyp
(
this
.
getMsgtyp
());
...
...
gjjs-bd-mybatis-support/src/main/java/com/brilliance/mda/support/mybatis/MyBatisDaoSession.java
View file @
7371e304
...
...
@@ -217,8 +217,17 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
}
@Override
public
void
dbReadset
(
IModuleList
[]
lists
,
int
maxSize
,
String
whereClause
,
Object
[]
datas
)
{
public
<
T
extends
IModule
>
int
dbReadset
(
IModuleList
<
T
>[]
lists
,
int
maxSize
,
String
whereClause
,
Object
[]
datas
)
{
List
<
Class
<?
extends
IModule
>>
clazzList
=
new
ArrayList
<>();
for
(
IModuleList
iModule
:
lists
)
{
clazzList
.
add
(
iModule
.
getDataClass
());
}
MybatisArgumentAdapter
adapter
=
new
MybatisArgumentAdapter
(
SELECT
,
clazzList
,
whereClause
,
datas
);
for
(
IModuleList
iModule
:
lists
)
{
List
<
T
>
result
=
this
.
dyncRead
(
iModule
.
getDataClass
(),
adapter
);
iModule
.
addAll
(
result
);
}
return
lists
[
0
].
size
();
}
@Override
...
...
@@ -296,6 +305,7 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
return
String
.
format
(
sqlIdTemplate
,
namespacePackage
,
clazz
.
getSimpleName
(),
sid
);
}
private
<
T
>
T
dyncReadOne
(
Class
<?
extends
IModule
>
clazz
,
MybatisArgumentAdapter
adapter
)
{
String
sqlId
=
getSqlId
(
clazz
,
SQLID_DYNCREAD
);
...
...
@@ -316,6 +326,7 @@ public class MyBatisDaoSession extends AbstractDaoSession implements IDaoSession
return
new
ArrayList
<>(
list
);
}
private
<
T
>
List
<
T
>
dyncRead
(
Class
<
T
>
clazz
,
Map
params
)
{
String
sqlId
=
getSqlId
(
clazz
,
SQLID_DYNCREAD
);
...
...
gjjs-bd-mybatis-support/src/main/java/com/brilliance/mda/support/mybatis/MybatisArgumentAdapter.java
View file @
7371e304
...
...
@@ -6,18 +6,18 @@ import com.brilliance.mda.support.mybatis.entity.Column;
import
com.brilliance.mda.support.mybatis.entity.Table
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.asm.Type
;
import
org.springframework.util.StringUtils
;
import
java.lang.reflect.Field
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
static
com
.
brilliance
.
mda
.
runtime
.
mda
.
OpType
.
AND
;
import
static
com
.
brilliance
.
mda
.
runtime
.
mda
.
OpType
.
ASC
;
import
static
com
.
brilliance
.
mda
.
runtime
.
mda
.
OpType
.
DESC
;
import
static
com
.
brilliance
.
mda
.
runtime
.
mda
.
OpType
.*;
/**
* @author hulei
...
...
@@ -25,105 +25,116 @@ import static com.brilliance.mda.runtime.mda.OpType.DESC;
*/
public
class
MybatisArgumentAdapter
{
private
static
Map
<
String
,
String
>
annotCache
=
new
ConcurrentHashMap
<>();
private
static
Map
<
String
,
String
>
annotCache
=
new
ConcurrentHashMap
<>();
public
static
final
String
HOLDER_SQL
=
"sql"
;
public
static
final
String
HOLDER_CONDS
=
"conditions"
;
public
static
enum
AdaType
{
public
static
enum
AdaType
{
SELECT
(
"SELECT * FROM %s WHERE %s"
),
DELETE
(
"DELETE FROM %s WHERE %s"
);
private
String
value
;
private
AdaType
(
String
val
){
private
AdaType
(
String
val
)
{
this
.
value
=
val
;
}
public
String
getValue
(){
public
String
getValue
()
{
return
value
;
}
}
private
Logger
log
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
private
Class
<?
extends
IModule
>
clazz
;
private
Class
<?
extends
IModule
>
clazz
;
private
List
<
Class
<?
extends
IModule
>>
clazzList
;
private
Argument
[]
args
;
private
String
sqlTemplate
;
private
Map
<
String
,
Object
>
sqlParams
;
private
Map
<
String
,
Object
>
sqlParams
;
private
int
idx
=
0
;
private
String
whereSql
;
private
String
pattern
;
private
Object
[]
params
;
private
String
tableName
;
public
MybatisArgumentAdapter
(
AdaType
type
,
Class
<?
extends
IModule
>
clazz
,
Argument
...
args
){
public
MybatisArgumentAdapter
(
AdaType
type
,
Class
<?
extends
IModule
>
clazz
,
Argument
...
args
)
{
this
.
clazz
=
clazz
;
this
.
pattern
=
type
.
getValue
();
this
.
args
=
args
;
this
.
tableName
=
convertTableName
();
this
.
init
();
}
public
MybatisArgumentAdapter
(
AdaType
type
,
Class
<?
extends
IModule
>
clazz
,
String
whereSql
)
{
this
(
type
,
clazz
,
whereSql
,
null
);
public
MybatisArgumentAdapter
(
AdaType
type
,
Class
<?
extends
IModule
>
clazz
,
String
whereSql
)
{
this
(
type
,
clazz
,
whereSql
,
null
);
}
public
MybatisArgumentAdapter
(
AdaType
type
,
Class
<?
extends
IModule
>
clazz
,
String
whereSql
,
Object
[]
params
)
{
public
MybatisArgumentAdapter
(
AdaType
type
,
Class
<?
extends
IModule
>
clazz
,
String
whereSql
,
Object
[]
params
)
{
this
.
clazz
=
clazz
;
this
.
pattern
=
type
.
getValue
();
this
.
whereSql
=
whereSql
;
this
.
params
=
params
;
this
.
tableName
=
convertTableName
();
this
.
init
();
}
public
MybatisArgumentAdapter
(
AdaType
type
,
List
<
Class
<?
extends
IModule
>>
clazzList
,
String
whereSql
,
Object
[]
params
)
{
this
.
clazzList
=
clazzList
;
this
.
pattern
=
type
.
getValue
();
this
.
whereSql
=
whereSql
;
this
.
params
=
params
;
this
.
tableName
=
convertTableNames
();
this
.
init
();
}
public
void
init
(){
public
void
init
()
{
sqlParams
=
new
HashMap
<>();
String
tableName
=
convertTableName
();
String
conditions
=
""
;
if
(
whereSql
!=
null
&&
!
whereSql
.
trim
().
equals
(
""
))
{
if
(
whereSql
.
toUpperCase
().
indexOf
(
"WHERE"
)
>
-
1
)
{
pattern
=
pattern
.
replace
(
"WHERE"
,
""
);
if
(
whereSql
!=
null
&&
!
whereSql
.
trim
().
equals
(
""
))
{
if
(
whereSql
.
toUpperCase
().
indexOf
(
"WHERE"
)
>
-
1
)
{
pattern
=
pattern
.
replace
(
"WHERE"
,
""
);
}
if
(
params
!=
null
&&
params
.
length
>
0
)
{
conditions
=
convertPlaceHolder
(
whereSql
,
params
,
sqlParams
);
}
else
{
if
(
params
!=
null
&&
params
.
length
>
0
)
{
conditions
=
convertPlaceHolder
(
whereSql
,
params
,
sqlParams
);
}
else
{
conditions
=
whereSql
;
}
}
else
{
if
(
this
.
args
!=
null
&&
this
.
args
.
length
>
0
)
{
}
else
{
if
(
this
.
args
!=
null
&&
this
.
args
.
length
>
0
)
{
conditions
=
parserArgument
(
this
.
args
);
}
else
{
}
else
{
conditions
=
" 1=1 "
;
}
}
this
.
sqlTemplate
=
String
.
format
(
pattern
,
tableName
,
conditions
);
this
.
sqlParams
.
put
(
HOLDER_SQL
,
this
.
sqlTemplate
);
this
.
sqlParams
.
put
(
HOLDER_CONDS
,
conditions
);
this
.
sqlTemplate
=
String
.
format
(
pattern
,
tableName
,
conditions
);
this
.
sqlParams
.
put
(
HOLDER_SQL
,
this
.
sqlTemplate
);
this
.
sqlParams
.
put
(
HOLDER_CONDS
,
conditions
);
}
public
String
getSqlTemplate
(){
public
String
getSqlTemplate
()
{
return
sqlTemplate
;
}
public
Map
<
String
,
Object
>
getSqlParams
()
{
public
Map
<
String
,
Object
>
getSqlParams
()
{
return
sqlParams
;
}
/**
* 获取直接WHERE条件进行参数替换
*/
protected
final
String
parserArgument
(
String
whereClause
,
Object
[]
args
)
{
protected
final
String
parserArgument
(
String
whereClause
,
Object
[]
args
)
{
StringBuffer
sb
=
new
StringBuffer
(
" "
);
Matcher
m
=
Pattern
.
compile
(
"\\?"
).
matcher
(
whereClause
);
int
offset
=
0
,
i
=
0
;
while
(
m
.
find
())
{
while
(
m
.
find
())
{
sb
.
append
(
whereClause
.
substring
(
offset
,
m
.
start
()));
sb
.
append
(
"#{args["
+
i
+
"]}"
);
i
++;
...
...
@@ -138,22 +149,19 @@ public class MybatisArgumentAdapter {
/**
* 获取生成对应的SQL条件(这里完成最终的组装)
*/
protected
final
String
parserArgument
(
Argument
...
arguments
)
{
protected
final
String
parserArgument
(
Argument
...
arguments
)
{
List
<
String
>
orders
=
new
ArrayList
();
List
<
String
>
criterions
=
new
ArrayList
();
for
(
int
i
=
0
;
i
<
arguments
.
length
;
i
++)
process
(
arguments
[
i
],
i
,
orders
,
criterions
);
StringBuffer
sb
=
new
StringBuffer
();
String
conn
=
""
;
for
(
String
criterion
:
criterions
)
{
for
(
String
criterion
:
criterions
)
{
sb
.
append
(
conn
).
append
(
criterion
);
conn
=
" AND "
;
}
conn
=
" ORDER BY "
;
for
(
String
criterion
:
orders
)
{
for
(
String
criterion
:
orders
)
{
sb
.
append
(
conn
).
append
(
criterion
);
conn
=
","
;
}
...
...
@@ -165,75 +173,71 @@ public class MybatisArgumentAdapter {
/**
* 按Order和Criterion来处理Argument
*/
private
final
void
process
(
Argument
argument
,
int
index
,
List
orders
,
List
criterions
)
{
private
final
void
process
(
Argument
argument
,
int
index
,
List
orders
,
List
criterions
)
{
if
(
argument
.
opType
==
ASC
)
orders
.
add
(
argument
.
fieldName
);
else
if
(
argument
.
opType
==
DESC
)
orders
.
add
(
argument
.
fieldName
+
" DESC"
);
else
{
String
criterion
=
processCriterion
(
argument
,
index
);
else
{
String
criterion
=
processCriterion
(
argument
,
index
);
if
(
criterion
!=
null
)
criterions
.
add
(
criterion
);
}
}
private
final
String
processCriterion
(
Argument
argument
,
int
idx
)
{
private
final
String
processCriterion
(
Argument
argument
,
int
idx
)
{
if
(
argument
==
null
||
argument
.
opType
==
null
)
return
null
;
StringBuffer
sb
;
String
conn
;
String
holderName
;
switch
(
argument
.
opType
)
{
String
holderName
;
switch
(
argument
.
opType
)
{
case
ISNULL:
return
convertColumn
(
argument
.
fieldName
)
+
" IS NULL"
;
case
ISNOTNULL:
return
convertColumn
(
argument
.
fieldName
)
+
" IS NOT NULL"
;
case
NE:
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
sqlParams
.
put
(
holderName
,
argument
.
value
);
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
sqlParams
.
put
(
holderName
,
argument
.
value
);
return
convertColumn
(
argument
.
fieldName
)
+
"!="
+
placeholder
(
argument
.
value
,
holderName
);
case
LE:
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
sqlParams
.
put
(
holderName
,
argument
.
value
);
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
sqlParams
.
put
(
holderName
,
argument
.
value
);
return
convertColumn
(
argument
.
fieldName
)
+
"<="
+
placeholder
(
argument
.
value
,
holderName
);
case
GE:
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
sqlParams
.
put
(
holderName
,
argument
.
value
);
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
sqlParams
.
put
(
holderName
,
argument
.
value
);
return
convertColumn
(
argument
.
fieldName
)
+
">="
+
placeholder
(
argument
.
value
,
holderName
);
case
LT:
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
sqlParams
.
put
(
holderName
,
argument
.
value
);
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
sqlParams
.
put
(
holderName
,
argument
.
value
);
return
convertColumn
(
argument
.
fieldName
)
+
"<"
+
placeholder
(
argument
.
value
,
holderName
);
case
GT:
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
sqlParams
.
put
(
holderName
,
argument
.
value
);
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
sqlParams
.
put
(
holderName
,
argument
.
value
);
return
convertColumn
(
argument
.
fieldName
)
+
">"
+
placeholder
(
argument
.
value
,
holderName
);
case
NOTLIKE:
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
sqlParams
.
put
(
holderName
,
argument
.
value
);
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
sqlParams
.
put
(
holderName
,
argument
.
value
);
return
convertColumn
(
argument
.
fieldName
)
+
" NOT LIKE "
+
placeholder
(
argument
.
value
,
holderName
);
case
LIKE:
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
sqlParams
.
put
(
holderName
,
argument
.
value
);
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
sqlParams
.
put
(
holderName
,
argument
.
value
);
return
convertColumn
(
argument
.
fieldName
)
+
" LIKE "
+
placeholder
(
argument
.
value
,
holderName
);
case
BETWEEN:
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
Object
[]
ary
=
(
Object
[])
argument
.
value
;
sqlParams
.
put
(
holderName
+
"_0"
,
ary
[
0
]);
sqlParams
.
put
(
holderName
+
"_1"
,
ary
[
1
]);
return
convertColumn
(
argument
.
fieldName
)
+
" BETWEEN "
+
placeholder
(
ary
[
0
],
holderName
+
"_0"
)
+
" AND "
+
placeholder
(
ary
[
1
],
holderName
+
"_1"
);
sqlParams
.
put
(
holderName
+
"_0"
,
ary
[
0
]);
sqlParams
.
put
(
holderName
+
"_1"
,
ary
[
1
]);
return
convertColumn
(
argument
.
fieldName
)
+
" BETWEEN "
+
placeholder
(
ary
[
0
],
holderName
+
"_0"
)
+
" AND "
+
placeholder
(
ary
[
1
],
holderName
+
"_1"
);
case
IN:
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
sb
=
new
StringBuffer
(
convertColumn
(
argument
.
fieldName
)).
append
(
" IN ("
);
conn
=
""
;
Object
[]
values
=
(
Object
[])
argument
.
value
;
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
sqlParams
.
put
(
holderName
+
"_"
+
i
,
values
[
i
]);
sb
.
append
(
conn
).
append
(
placeholder
(
values
[
i
],
holderName
+
"_"
+
i
));
sqlParams
.
put
(
holderName
+
"_"
+
i
,
values
[
i
]);
sb
.
append
(
conn
).
append
(
placeholder
(
values
[
i
],
holderName
+
"_"
+
i
));
conn
=
","
;
}
return
sb
.
append
(
")"
).
toString
();
...
...
@@ -242,8 +246,7 @@ public class MybatisArgumentAdapter {
sb
=
new
StringBuffer
(
"("
);
conn
=
""
;
Argument
[]
arguments
=
(
Argument
[])
argument
.
value
;
for
(
int
i
=
0
;
i
<
arguments
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
arguments
.
length
;
i
++)
{
sb
.
append
(
conn
).
append
(
processCriterion
(
arguments
[
i
],
i
));
conn
=
argument
.
opType
==
AND
?
" AND "
:
" OR "
;
}
...
...
@@ -251,15 +254,14 @@ public class MybatisArgumentAdapter {
case
NOT:
return
"!("
+
processCriterion
((
Argument
)
argument
.
value
,
idx
)
+
")"
;
default
:
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
sqlParams
.
put
(
holderName
,
argument
.
value
);
holderName
=
argument
.
fieldName
+
"_"
+
this
.
idx
++;
sqlParams
.
put
(
holderName
,
argument
.
value
);
return
convertColumn
(
argument
.
fieldName
)
+
"="
+
placeholder
(
argument
.
value
,
holderName
);
}
}
private
final
String
placeholder
(
Object
value
,
String
name
)
{
return
String
.
format
(
"#{%s}"
,
name
);
private
final
String
placeholder
(
Object
value
,
String
name
)
{
return
String
.
format
(
"#{%s}"
,
name
);
}
...
...
@@ -275,28 +277,29 @@ public class MybatisArgumentAdapter {
/**
* 将标准SQL占位符替换为mybatis格式的占位符,并将参数数组转换为HashMap
*
* @param sql
* @param objects
* @param map
* @return
*/
public
static
String
convertPlaceHolder
(
String
sql
,
Object
[]
objects
,
Map
<
String
,
Object
>
map
)
{
public
static
String
convertPlaceHolder
(
String
sql
,
Object
[]
objects
,
Map
<
String
,
Object
>
map
)
{
Pattern
p
=
Pattern
.
compile
(
"[?]"
);
Matcher
m
=
p
.
matcher
(
sql
);
StringBuffer
buf
=
new
StringBuffer
();
for
(
int
i
=
0
;
m
.
find
()
&&
i
<
objects
.
length
;
i
++)
{
String
holder
=
"var_"
+
i
;
m
.
appendReplacement
(
buf
,
String
.
format
(
"#{%s}"
,
holder
));
map
.
put
(
holder
,
objects
[
i
]);
for
(
int
i
=
0
;
m
.
find
()
&&
i
<
objects
.
length
;
i
++)
{
String
holder
=
"var_"
+
i
;
m
.
appendReplacement
(
buf
,
String
.
format
(
"#{%s}"
,
holder
));
map
.
put
(
holder
,
objects
[
i
]);
}
m
.
appendTail
(
buf
);
return
buf
.
toString
();
}
public
String
convertTableName
(){
if
(
annotCache
.
containsKey
(
clazz
.
getName
()))
{
public
String
convertTableName
()
{
if
(
annotCache
.
containsKey
(
clazz
.
getName
()))
{
return
annotCache
.
get
(
clazz
.
getName
());
}
String
value
=
clazz
.
getSimpleName
();
...
...
@@ -310,24 +313,53 @@ public class MybatisArgumentAdapter {
return
value
;
}
public
String
convertColumn
(
String
fieldName
){
String
key
=
String
.
format
(
"%s.%s"
,
clazz
.
getName
(),
fieldName
);
if
(
annotCache
.
containsKey
(
key
)){
private
String
convertTableNames
()
{
StringBuffer
sb
=
new
StringBuffer
(
""
);
for
(
Class
c
:
clazzList
)
{
sb
.
append
(
c
.
getName
());
}
if
(
annotCache
.
containsKey
(
sb
.
toString
()))
{
return
annotCache
.
get
(
sb
.
toString
());
}
List
<
String
>
tb
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
clazzList
.
size
();
i
++)
{
int
idx
=
i
+
1
;
Class
<?
extends
IModule
>
c
=
clazzList
.
get
(
i
);
String
value
=
c
.
getSimpleName
();
if
(
c
.
isAnnotationPresent
(
Table
.
class
))
{
Table
t
=
c
.
getAnnotation
(
Table
.
class
);
if
(
t
.
value
()
!=
null
)
{
value
=
t
.
value
();
}
}
tb
.
add
(
value
+
" m"
+
idx
);
}
String
value
=
String
.
join
(
","
,
tb
);
annotCache
.
put
(
sb
.
toString
(),
value
);
return
value
;
}
public
String
convertColumn
(
String
fieldName
)
{
String
key
=
String
.
format
(
"%s.%s"
,
clazz
.
getName
(),
fieldName
);
if
(
annotCache
.
containsKey
(
key
))
{
return
annotCache
.
get
(
key
);
}
try
{
Field
field
=
clazz
.
getDeclaredField
(
fieldName
);
String
value
=
fieldName
;
if
(
field
.
isAnnotationPresent
(
Column
.
class
))
{
if
(
field
.
isAnnotationPresent
(
Column
.
class
))
{
Column
col
=
field
.
getAnnotation
(
Column
.
class
);
if
(!
StringUtils
.
isEmpty
(
col
.
value
()))
{
if
(!
StringUtils
.
isEmpty
(
col
.
value
()))
{
value
=
col
.
value
();
}
}
annotCache
.
put
(
key
,
value
);
annotCache
.
put
(
key
,
value
);
}
catch
(
NoSuchFieldException
e
)
{
annotCache
.
put
(
key
,
fieldName
);
annotCache
.
put
(
key
,
fieldName
);
return
fieldName
;
}
return
annotCache
.
get
(
key
);
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/IDaoSession.java
View file @
7371e304
...
...
@@ -24,7 +24,7 @@ public interface IDaoSession {
<
T
extends
IModule
>
int
dbReadset
(
IModuleList
<
T
>
list
,
String
whereSql
,
Object
[]
params
);
void
dbReadset
(
IModuleList
[]
lists
,
int
maxSize
,
String
whereClause
,
Object
[]
datas
);
<
T
extends
IModule
>
int
dbReadset
(
IModuleList
<
T
>
[]
lists
,
int
maxSize
,
String
whereClause
,
Object
[]
datas
);
void
dbReadset
(
IModuleList
[]
lists
,
String
whereClause
,
Object
[]
datas
);
void
dbExecuteSQL
(
String
sql
,
Object
...
params
);
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/impl/ModuleList.java
View file @
7371e304
...
...
@@ -166,12 +166,12 @@ public class ModuleList<T extends IModule> extends ArrayList<T> implements IModu
@JsonIgnore
public
T
getElement
(
int
idx
)
{
return
super
.
get
(
--
idx
);
return
super
.
get
(
idx
--
);
}
private
void
setFieldValue
(
String
name
,
Object
value
,
T
bean
)
{
try
{
Field
f
=
this
.
getDataClass
().
getField
(
name
);
Field
f
=
this
.
getDataClass
().
get
Declared
Field
(
name
);
f
.
setAccessible
(
true
);
f
.
set
(
bean
,
value
);
}
catch
(
Exception
e
)
{
...
...
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