Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz4j Spring R7
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7后台标准模板
iBiz4j Spring R7
提交
8290978f
提交
8290978f
编写于
1月 25, 2021
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
补充有效逻辑
上级
7835622f
变更
1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
82 行增加
和
29 行删除
+82
-29
DELogicAspect.java.ftl
...ain/java/%SYS_PKGPATH%/util/aspect/DELogicAspect.java.ftl
+82
-29
未找到文件。
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/aspect/DELogicAspect.java.ftl
浏览文件 @
8290978f
...
...
@@ -46,6 +46,7 @@ import java.io.InputStream;
import
java
.
lang
.
reflect
.
Method
;
import
java
.
net
.
URL
;
import
java
.
util
.
ArrayList
;
import
java
.
util
.
HashMap
;
import
java
.
util
.
List
;
import
java
.
util
.
Map
;
import
java
.
util
.
concurrent
.
ConcurrentHashMap
;
...
...
@@ -65,14 +66,14 @@ public class DELogicAspect {
/**
*
本地
*/
LOCAL
(
"0"
,
"本地模式"
),
LOCAL
(
"0"
,
"本地模式"
),
/**
*
远程
*/
REMOTE
(
"1"
,
"远程模式"
);
REMOTE
(
"1"
,
"远程模式"
);
LogicMode
(
String
value
,
String
text
)
{
this
.
value
=
value
;
LogicMode
(
String
value
,
String
text
)
{
this
.
value
=
value
;
this
.
text
=
text
;
}
...
...
@@ -90,21 +91,22 @@ public class DELogicAspect {
private
String
dynamicPath
;
@
Value
(
"${r'$'}{ibiz.systemid:${sys.getCodeName()}}"
)
private
String
systemId
;
private
static
Map
<
String
,
Object
>
validLogic
=
new
HashMap
<>();
@
AfterReturning
(
value
=
"execution(* ${pub.getPKGCodeName()}.core.*.service.*.dynamicCall(..))"
)
public
void
dynamicCall
(
JoinPoint
point
){
public
void
dynamicCall
(
JoinPoint
point
)
{
Object
args
[]
=
point
.
getArgs
();
if
(
!ObjectUtils.isEmpty(args) || args.length == 3) {
Object
action
=
args
[
1
];
Object
entity
=
args
[
2
];
log
.
debug
(
"开始执行实体
[{}]动态行为[{}]"
,
entity
.
getClass
().
getSimpleName
(),
action
);
log
.
debug
(
"开始执行实体
动态行为[{}:{}]"
,
entity
.
getClass
().
getSimpleName
(),
action
);
EvaluationContext
context
=
new
StandardEvaluationContext
();
context
.
setVariable
(
"service"
,
point
.
getTarget
());
context
.
setVariable
(
"action"
,
action
);
context
.
setVariable
(
"entity"
,
entity
);
Expression
oldExp
=
parser
.
parseExpression
(
String
.
format
(
"#service.%s(#entity)"
,
action
));
Expression
oldExp
=
parser
.
parseExpression
(
String
.
format
(
"#service.%s(#entity)"
,
action
));
oldExp
.
getValue
(
context
);
log
.
debug
(
"实体
[{}]动态行为[{}]执行结束"
,
entity
.
getClass
().
getSimpleName
(),
action
);
log
.
debug
(
"实体
动态行为[{}:{}]执行结束"
,
entity
.
getClass
().
getSimpleName
(),
action
);
}
}
...
...
@@ -125,15 +127,14 @@ public class DELogicAspect {
Object
arg
=
args
[
0
];
String
action
=
point
.
getSignature
().
getName
();
EntityBase
entity
=
null
;
if
(
"remove"
.
equalsIgnoreCase
(
action
)
||
"get"
.
equalsIgnoreCase
(
action
))
{
if
(
"remove"
.
equalsIgnoreCase
(
action
)
||
"get"
.
equalsIgnoreCase
(
action
))
{
entity
=
getEntity
(
service
);
String
id
=
DEFieldCacheMap
.
getDEKeyField
(
entity
.
getClass
());
entity
.
set
(
id
,
arg
);
}
else
if
(
arg
instanceof
EntityBase
){
entity
.
set
(
id
,
arg
);
}
else
if
(
arg
instanceof
EntityBase
)
{
entity
=
(
EntityBase
)
arg
;
}
if
(
entity
!= null)
{
if
(
entity
!= null)
{
executeBeforeLogic
(
entity
,
action
);
Object
result
=
point
.
proceed
();
executeLogic
(
entity
,
action
);
...
...
@@ -145,24 +146,25 @@ public class DELogicAspect {
/**
*
获取实体
*
*
@
param
service
*
@
return
*
@
throws
Exception
*/
private
EntityBase
getEntity
(
Object
service
)
throws
Exception
{
private
EntityBase
getEntity
(
Object
service
)
throws
Exception
{
Method
[]
methods
=
service
.
getClass
().
getDeclaredMethods
();
for
(
Method
method
:
methods
)
{
for
(
Class
cls
:
method
.
getParameterTypes
())
{
for
(
Method
method
:
methods
)
{
for
(
Class
cls
:
method
.
getParameterTypes
())
{
try
{
Object
arg
=
cls
.
newInstance
();
if
(
arg
instanceof
EntityBase
)
{
if
(
arg
instanceof
EntityBase
)
{
return
(
EntityBase
)
arg
;
}
}
catch
(
InstantiationException
e
)
{
}
}
}
throw
new
BadRequestAlertException
(
"获取实体信息失败"
,
"DELogicAspect"
,
"getEntity"
);
throw
new
BadRequestAlertException
(
"获取实体信息失败"
,
"DELogicAspect"
,
"getEntity"
);
}
/**
...
...
@@ -176,13 +178,13 @@ public class DELogicAspect {
if
(
dynamicMode
)
{
bpmnFile
=
getRemoteModel
(
getDEModule
(
entity
),
entity
.
getClass
().
getSimpleName
(),
action
,
"before"
);
if
(
bpmnFile
.
exists
())
{
executeLogic
(
bpmnFile
,
entity
,
action
,
LogicMode
.
REMOTE
);
executeLogic
(
bpmnFile
,
entity
,
action
,
LogicMode
.
REMOTE
);
return
;
}
}
bpmnFile
=
getLocalModel
(
entity
.
getClass
().
getSimpleName
(),
action
,
"before"
);
if
(
bpmnFile
!= null && bpmnFile.exists()) {
executeLogic
(
bpmnFile
,
entity
,
action
,
LogicMode
.
LOCAL
);
if
(
bpmnFile
!= null && bpmnFile.exists()
&& isValid(bpmnFile, entity, action)
) {
executeLogic
(
bpmnFile
,
entity
,
action
,
LogicMode
.
LOCAL
);
}
}
...
...
@@ -197,12 +199,12 @@ public class DELogicAspect {
if
(
dynamicMode
)
{
bpmnFile
=
getRemoteModel
(
getDEModule
(
entity
),
entity
.
getClass
().
getSimpleName
(),
action
,
"after"
);
if
(
bpmnFile
.
exists
())
{
executeLogic
(
bpmnFile
,
entity
,
action
,
LogicMode
.
REMOTE
);
executeLogic
(
bpmnFile
,
entity
,
action
,
LogicMode
.
REMOTE
);
return
;
}
}
bpmnFile
=
getLocalModel
(
entity
.
getClass
().
getSimpleName
(),
action
,
"after"
);
if
(
bpmnFile
!= null && bpmnFile.exists()) {
if
(
bpmnFile
!= null && bpmnFile.exists()
&& isValid(bpmnFile, entity, action)
) {
executeLogic
(
bpmnFile
,
entity
,
action
,
LogicMode
.
LOCAL
);
}
}
...
...
@@ -218,13 +220,13 @@ public class DELogicAspect {
if
(
dynamicMode
)
{
bpmnFile
=
getRemoteModel
(
getDEModule
(
entity
),
entity
.
getClass
().
getSimpleName
(),
action
,
"exec"
);
if
(
bpmnFile
.
exists
())
{
executeLogic
(
bpmnFile
,
entity
,
action
,
LogicMode
.
REMOTE
);
executeLogic
(
bpmnFile
,
entity
,
action
,
LogicMode
.
REMOTE
);
return
;
}
}
bpmnFile
=
getLocalModel
(
entity
.
getClass
().
getSimpleName
(),
action
,
"exec"
);
if
(
bpmnFile
!= null && bpmnFile.exists()) {
executeLogic
(
bpmnFile
,
entity
,
action
,
LogicMode
.
LOCAL
);
if
(
bpmnFile
!= null && bpmnFile.exists()
&& isValid(bpmnFile, entity, action)
) {
executeLogic
(
bpmnFile
,
entity
,
action
,
LogicMode
.
LOCAL
);
}
}
...
...
@@ -235,7 +237,7 @@ public class DELogicAspect {
*
@
param
entity
*/
private
void
executeLogic
(
File
bpmnFile
,
Object
entity
,
String
action
,
LogicMode
logicMode
)
{
log
.
debug
(
"开始执行实体处理逻辑[{}:{}:{}:{}]"
,
entity
.
getClass
().
getSimpleName
(),
action
,
bpmnFile
.
getName
(),
logicMode
.
text
);
log
.
debug
(
"开始执行实体处理逻辑[{}:{}:{}:{}]"
,
entity
.
getClass
().
getSimpleName
(),
action
,
bpmnFile
.
getName
(),
logicMode
.
text
);
String
bpmnId
=
DigestUtils
.
md5DigestAsHex
(
bpmnFile
.
getName
().
getBytes
());
DELogic
logic
=
getDELogic
(
bpmnFile
,
entity
,
logicMode
);
if
(
logic
==
null
)
{
...
...
@@ -259,7 +261,7 @@ public class DELogicAspect {
}
}
kieSession
.
startProcess
(
mainProcess
.
getId
());
log
.
debug
(
"实体处理逻辑[{}:{}:{}:{}]执行结束"
,
entity
.
getClass
().
getSimpleName
(),
action
,
bpmnFile
.
getName
(),
logicMode
.
text
);
log
.
debug
(
"实体处理逻辑[{}:{}:{}:{}]执行结束"
,
entity
.
getClass
().
getSimpleName
(),
action
,
bpmnFile
.
getName
(),
logicMode
.
text
);
}
/**
...
...
@@ -309,7 +311,7 @@ public class DELogicAspect {
Expression
oldExp
=
parser
.
parseExpression
(
express_value
);
value
=
oldExp
.
getValue
(
oldContext
);
}
if
(
"entity"
.
equalsIgnoreCase
(
type
.
getValue
())
||
"refentity"
.
equalsIgnoreCase
(
type
.
getValue
()))
{
if
(
"entity"
.
equalsIgnoreCase
(
type
.
getValue
())
||
"refentity"
.
equalsIgnoreCase
(
type
.
getValue
()))
{
kieSession
.
insert
(
value
);
}
kieSession
.
setGlobal
(
name
.
getValue
(),
value
);
...
...
@@ -501,5 +503,56 @@ public class DELogicAspect {
}
return
strModule
;
}
/**
*
逻辑是否有效
*
*
@
param
bpmn
*
@
param
entity
*
@
param
action
*
@
return
*/
private
boolean
isValid
(
File
bpmn
,
Object
entity
,
Object
action
)
{
String
logicId
=
String
.
format
(
"%s%s%s"
,
entity
.
getClass
().
getSimpleName
(),
action
,
bpmn
.
getName
()).
toLowerCase
();
if
(
validLogic
.
containsKey
(
logicId
))
{
return
true
;
}
else
{
return
false
;
}
}
static
{
<#
if
sys
.
getAllPSDataEntities
()??>
<#
list
sys
.
getAllPSDataEntities
()
as
dataEntity
>
<#
if
dataEntity
.
getAllPSDEActions
()??>
<#
list
dataEntity
.
getAllPSDEActions
()
as
deaction
>
<#
comment
>
前附加逻辑
</#
comment
>
<#
if
deaction
.
getBeforePSDEActionLogics
()??>
<#
list
deaction
.
getBeforePSDEActionLogics
()
as
beforeLogic
>
<#
if
(
beforeLogic
.
isValid
()==
true
&&
beforeLogic
.
isInternalLogic
()
&&
beforeLogic
.
getPSDELogic
().
isEnableBackend
())
||
(
beforeLogic
.
getDstPSDE
()
!'')!='' && (beforeLogic.getDstPSDEAction()!'')!='' && beforeLogic.getDstPSDEAction().isEnableBackend() >
validLogic
.
put
(
"${(de.codeName+deaction.codeName)?lower_case}before.bpmn"
,
1
);
</#
if
>
</#
list
>
</#
if
>
<#
comment
>
后附加逻辑
</#
comment
>
<#
if
deaction
.
getAfterPSDEActionLogics
()??>
<#
list
deaction
.
getAfterPSDEActionLogics
()
as
afterLogic
>
<#
if
(
afterLogic
.
isValid
()==
true
&&
afterLogic
.
isInternalLogic
()
&&
afterLogic
.
getPSDELogic
().
isEnableBackend
())
||
(
afterLogic
.
getDstPSDE
()
!'')!='' && (afterLogic.getDstPSDEAction()!'')!='' && afterLogic.getDstPSDEAction().isEnableBackend() >
validLogic
.
put
(
"${(de.codeName+deaction.codeName)?lower_case}after.bpmn"
,
1
);
</#
if
>
</#
list
>
</#
if
>
<#
comment
>
行为调用逻辑
</#
comment
>
<#
if
deaction
.
getActionType
()
==
'DELOGIC'
&&
deaction
.
getPSDELogic
().
isEnableBackend
()>
validLogic
.
put
(
"${(de.codeName+deaction.codeName)?lower_case}exec.bpmn"
,
1
);
</#
if
>
</#
list
>
</#
if
>
</#
list
>
</#
if
>
}
}
</#
if
>
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录