Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz4j Spring R7
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7后台标准模板
iBiz4j Spring R7
提交
262933cf
提交
262933cf
编写于
4月 08, 2021
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
处理逻辑优化
上级
fcd34e22
变更
1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
47 行增加
和
23 行删除
+47
-23
DELogicAspect.java.ftl
...ain/java/%SYS_PKGPATH%/util/aspect/DELogicAspect.java.ftl
+47
-23
未找到文件。
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/aspect/DELogicAspect.java.ftl
浏览文件 @
262933cf
...
...
@@ -42,6 +42,7 @@ import org.springframework.expression.ExpressionParser;
import
org
.
springframework
.
expression
.
spel
.
standard
.
SpelExpressionParser
;
import
org
.
springframework
.
expression
.
spel
.
support
.
StandardEvaluationContext
;
import
org
.
springframework
.
stereotype
.
Component
;
import
org
.
springframework
.
util
.
ClassUtils
;
import
org
.
springframework
.
util
.
DigestUtils
;
import
org
.
springframework
.
util
.
ObjectUtils
;
import
org
.
springframework
.
util
.
StringUtils
;
...
...
@@ -94,7 +95,7 @@ public class DELogicAspect {
if
(
!ObjectUtils.isEmpty(entity)) {
String
id
=
DEFieldCacheMap
.
getDEKeyField
(
entity
.
getClass
());
if
(
StringUtils
.
isEmpty
(
id
))
{
log
.
debug
(
"无法获取实体主键属性[{}]"
,
entity
.
getClass
().
getSimpleName
(
));
log
.
debug
(
"无法获取实体主键属性[{}]"
,
getEntityName
(
entity
));
return
point
.
proceed
();
}
entity
.
set
(
id
,
arg
);
...
...
@@ -115,6 +116,17 @@ public class DELogicAspect {
return
point
.
proceed
();
}
/**
*
判断类是否被代理类代理
*/
private
String
getEntityName
(
Object
entity
){
String
entityName
=
entity
.
getClass
().
getSimpleName
();
if
(
entityName
.
contains
(
"$$"
)){
entityName
=
ClassUtils
.
getUserClass
(
entity
.
getClass
()).
getSimpleName
();
}
return
entityName
;
}
/**
*
前附加逻辑
*
...
...
@@ -122,7 +134,7 @@ public class DELogicAspect {
*
@
param
action
*/
private
void
executeBeforeLogic
(
EntityBase
entity
,
String
action
)
{
Resource
bpmnFile
=
getLocalModel
(
entity
.
getClass
().
getSimpleName
(
),
action
,
LogicExecMode
.
BEFORE
);
Resource
bpmnFile
=
getLocalModel
(
getEntityName
(
entity
),
action
,
LogicExecMode
.
BEFORE
);
if
(
bpmnFile
!= null && bpmnFile.exists() && isValid(bpmnFile, entity, action)) {
executeLogic
(
bpmnFile
,
entity
,
action
);
}
...
...
@@ -135,7 +147,7 @@ public class DELogicAspect {
*
@
param
action
*/
private
void
executeAfterLogic
(
EntityBase
entity
,
String
action
)
{
Resource
bpmnFile
=
getLocalModel
(
entity
.
getClass
().
getSimpleName
(
),
action
,
LogicExecMode
.
AFTER
);
Resource
bpmnFile
=
getLocalModel
(
getEntityName
(
entity
),
action
,
LogicExecMode
.
AFTER
);
if
(
bpmnFile
!= null && bpmnFile.exists() && isValid(bpmnFile, entity, action)) {
executeLogic
(
bpmnFile
,
entity
,
action
);
}
...
...
@@ -148,7 +160,7 @@ public class DELogicAspect {
*
@
param
action
*/
private
void
executeLogic
(
EntityBase
entity
,
String
action
)
{
Resource
bpmnFile
=
getLocalModel
(
entity
.
getClass
().
getSimpleName
(
),
action
,
LogicExecMode
.
EXEC
);
Resource
bpmnFile
=
getLocalModel
(
getEntityName
(
entity
),
action
,
LogicExecMode
.
EXEC
);
if
(
bpmnFile
!= null && bpmnFile.exists() && isValid(bpmnFile, entity, action)) {
executeLogic
(
bpmnFile
,
entity
,
action
);
}
...
...
@@ -162,7 +174,7 @@ public class DELogicAspect {
*/
private
void
executeLogic
(
Resource
bpmnFile
,
Object
entity
,
String
action
)
{
try
{
log
.
debug
(
"开始执行实体处理逻辑[{}:{}:{}:本地模式]"
,
entity
.
getClass
().
getSimpleName
(
),
action
,
bpmnFile
.
getFilename
());
log
.
debug
(
"开始执行实体处理逻辑[{}:{}:{}:本地模式]"
,
getEntityName
(
entity
),
action
,
bpmnFile
.
getFilename
());
String
bpmnId
=
DigestUtils
.
md5DigestAsHex
(
bpmnFile
.
getURL
().
getPath
().
getBytes
());
DELogic
logic
=
getDELogic
(
bpmnFile
);
if
(
logic
==
null
)
{
...
...
@@ -186,9 +198,9 @@ public class DELogicAspect {
}
}
kieSession
.
startProcess
(
mainProcess
.
getId
());
log
.
debug
(
"实体处理逻辑[{}:{}:{}:本地模式]执行结束"
,
entity
.
getClass
().
getSimpleName
(
),
action
,
bpmnFile
.
getFilename
());
log
.
debug
(
"实体处理逻辑[{}:{}:{}:本地模式]执行结束"
,
getEntityName
(
entity
),
action
,
bpmnFile
.
getFilename
());
}
catch
(
Exception
e
)
{
log
.
error
(
"实体处理逻辑[{}:{}:{}:本地模式]发生异常"
,
entity
.
getClass
().
getSimpleName
(
),
action
,
bpmnFile
.
getFilename
());
log
.
error
(
"实体处理逻辑[{}:{}:{}:本地模式]发生异常"
,
getEntityName
(
entity
),
action
,
bpmnFile
.
getFilename
());
throw
new
BadRequestAlertException
(
"执行实体处理逻辑发生异常"
+
e
.
getMessage
(),
"DELogicAspect"
,
"executeLogic"
);
}
}
...
...
@@ -428,7 +440,7 @@ public class DELogicAspect {
*
@
return
*/
private
boolean
isValid
(
Resource
bpmn
,
Object
entity
,
Object
action
)
{
String
logicId
=
String
.
format
(
"%s%s%s"
,
entity
.
getClass
().
getSimpleName
(
),
action
,
bpmn
.
getFilename
()).
toLowerCase
();
String
logicId
=
String
.
format
(
"%s%s%s"
,
getEntityName
(
entity
),
action
,
bpmn
.
getFilename
()).
toLowerCase
();
if
(
validLogic
.
containsKey
(
logicId
))
{
return
true
;
}
else
{
...
...
@@ -503,6 +515,7 @@ import org.springframework.expression.ExpressionParser;
import
org
.
springframework
.
expression
.
spel
.
standard
.
SpelExpressionParser
;
import
org
.
springframework
.
expression
.
spel
.
support
.
StandardEvaluationContext
;
import
org
.
springframework
.
stereotype
.
Component
;
import
org
.
springframework
.
util
.
ClassUtils
;
import
org
.
springframework
.
util
.
DigestUtils
;
import
org
.
springframework
.
util
.
ObjectUtils
;
import
org
.
springframework
.
util
.
StringUtils
;
...
...
@@ -605,7 +618,7 @@ public class DELogicAspect {
if
(
!ObjectUtils.isEmpty(entity)) {
String
id
=
DEFieldCacheMap
.
getDEKeyField
(
entity
.
getClass
());
if
(
StringUtils
.
isEmpty
(
id
))
{
log
.
debug
(
"无法获取实体主键属性[{}]"
,
entity
.
getClass
().
getSimpleName
(
));
log
.
debug
(
"无法获取实体主键属性[{}]"
,
getEntityName
(
entity
));
return
point
.
proceed
();
}
entity
.
set
(
id
,
arg
);
...
...
@@ -631,6 +644,17 @@ public class DELogicAspect {
return
point
.
proceed
();
}
/**
*
判断类是否被代理类代理
*/
private
String
getEntityName
(
EntityBase
entity
){
String
entityName
=
entity
.
getClass
().
getSimpleName
();
if
(
entityName
.
contains
(
"$$"
)){
entityName
=
ClassUtils
.
getUserClass
(
entity
.
getClass
()).
getSimpleName
();
}
return
entityName
;
}
/**
*
前附加逻辑
*
...
...
@@ -640,13 +664,13 @@ public class DELogicAspect {
private
void
executeBeforeLogic
(
EntityBase
entity
,
String
action
,
boolean
isDyna
,
String
instanceId
)
{
Resource
bpmnFile
;
if
(
isDyna
)
{
bpmnFile
=
getRemoteModel
(
getDEModule
(
entity
),
entity
.
getClass
().
getSimpleName
(
),
action
,
LogicExecMode
.
BEFORE
,
instanceId
);
bpmnFile
=
getRemoteModel
(
getDEModule
(
entity
),
getEntityName
(
entity
),
action
,
LogicExecMode
.
BEFORE
,
instanceId
);
if
(
bpmnFile
!= null && bpmnFile.exists()) {
executeLogic
(
bpmnFile
,
entity
,
action
,
instanceId
);
return
;
}
}
bpmnFile
=
getLocalModel
(
entity
.
getClass
().
getSimpleName
(
),
action
,
LogicExecMode
.
BEFORE
);
bpmnFile
=
getLocalModel
(
getEntityName
(
entity
),
action
,
LogicExecMode
.
BEFORE
);
if
(
bpmnFile
!= null && bpmnFile.exists() && isValid(bpmnFile, entity, action)) {
executeLogic
(
bpmnFile
,
entity
,
action
,
instanceId
);
}
...
...
@@ -661,13 +685,13 @@ public class DELogicAspect {
private
void
executeAfterLogic
(
EntityBase
entity
,
String
action
,
boolean
isDyna
,
String
instanceId
)
{
Resource
bpmnFile
;
if
(
isDyna
)
{
bpmnFile
=
getRemoteModel
(
getDEModule
(
entity
),
entity
.
getClass
().
getSimpleName
(
),
action
,
LogicExecMode
.
AFTER
,
instanceId
);
bpmnFile
=
getRemoteModel
(
getDEModule
(
entity
),
getEntityName
(
entity
),
action
,
LogicExecMode
.
AFTER
,
instanceId
);
if
(
bpmnFile
!= null && bpmnFile.exists()) {
executeLogic
(
bpmnFile
,
entity
,
action
,
instanceId
);
return
;
}
}
bpmnFile
=
getLocalModel
(
entity
.
getClass
().
getSimpleName
(
),
action
,
LogicExecMode
.
AFTER
);
bpmnFile
=
getLocalModel
(
getEntityName
(
entity
),
action
,
LogicExecMode
.
AFTER
);
if
(
bpmnFile
!= null && bpmnFile.exists() && isValid(bpmnFile, entity, action)) {
executeLogic
(
bpmnFile
,
entity
,
action
,
instanceId
);
}
...
...
@@ -682,13 +706,13 @@ public class DELogicAspect {
private
void
executeLogic
(
EntityBase
entity
,
String
action
,
boolean
isDyna
,
String
instanceId
)
{
Resource
bpmnFile
;
if
(
isDyna
)
{
bpmnFile
=
getRemoteModel
(
getDEModule
(
entity
),
entity
.
getClass
().
getSimpleName
(
),
action
,
LogicExecMode
.
EXEC
,
instanceId
);
bpmnFile
=
getRemoteModel
(
getDEModule
(
entity
),
getEntityName
(
entity
),
action
,
LogicExecMode
.
EXEC
,
instanceId
);
if
(
bpmnFile
!= null && bpmnFile.exists()) {
executeLogic
(
bpmnFile
,
entity
,
action
,
instanceId
);
return
;
}
}
bpmnFile
=
getLocalModel
(
entity
.
getClass
().
getSimpleName
(
),
action
,
LogicExecMode
.
EXEC
);
bpmnFile
=
getLocalModel
(
getEntityName
(
entity
),
action
,
LogicExecMode
.
EXEC
);
if
(
bpmnFile
!= null && bpmnFile.exists() && isValid(bpmnFile, entity, action)) {
executeLogic
(
bpmnFile
,
entity
,
action
,
instanceId
);
}
...
...
@@ -703,7 +727,7 @@ public class DELogicAspect {
private
void
executeLogic
(
Resource
bpmnFile
,
Object
entity
,
String
action
,
String
instanceId
)
{
String
logicMode
=
bpmnFile
instanceof
FileSystemResource
?
String
.
format
(
"远程模式:%s"
,
instanceId
)
:
"本地模式"
;
try
{
log
.
debug
(
"开始执行实体处理逻辑[{}:{}:{}:{}]"
,
entity
.
getClass
().
getSimpleName
(
),
action
,
bpmnFile
.
getFilename
(),
logicMode
);
log
.
debug
(
"开始执行实体处理逻辑[{}:{}:{}:{}]"
,
getEntityName
(
entity
),
action
,
bpmnFile
.
getFilename
(),
logicMode
);
String
bpmnId
=
DigestUtils
.
md5DigestAsHex
(
bpmnFile
.
getURL
().
getPath
().
getBytes
());
DELogic
logic
=
getDELogic
(
bpmnFile
,
entity
,
instanceId
);
if
(
logic
==
null
)
{
...
...
@@ -727,9 +751,9 @@ public class DELogicAspect {
}
}
kieSession
.
startProcess
(
mainProcess
.
getId
());
log
.
debug
(
"实体处理逻辑[{}:{}:{}:{}]执行结束"
,
entity
.
getClass
().
getSimpleName
(
),
action
,
bpmnFile
.
getFilename
(),
logicMode
);
log
.
debug
(
"实体处理逻辑[{}:{}:{}:{}]执行结束"
,
getEntityName
(
entity
),
action
,
bpmnFile
.
getFilename
(),
logicMode
);
}
catch
(
Exception
e
)
{
log
.
error
(
"执行实体处理逻辑[{}:{}:{}:{}]发生异常"
+
e
.
getMessage
(),
entity
.
getClass
().
getSimpleName
(
),
action
,
bpmnFile
.
getFilename
(),
logicMode
);
log
.
error
(
"执行实体处理逻辑[{}:{}:{}:{}]发生异常"
+
e
.
getMessage
(),
getEntityName
(
entity
),
action
,
bpmnFile
.
getFilename
(),
logicMode
);
throw
new
BadRequestAlertException
(
"执行实体处理逻辑发生异常"
+
e
.
getMessage
(),
"DELogicAspect"
,
"executeLogic"
);
}
}
...
...
@@ -829,7 +853,7 @@ public class DELogicAspect {
if
(
item
instanceof
CallActivity
)
{
CallActivity
subBpmn
=
(
CallActivity
)
item
;
String
bpmnFileName
=
subBpmn
.
getName
();
Resource
subBpmnFile
=
getSubBpmn
(
getDEModule
(
entity
),
entity
.
getClass
().
getSimpleName
(
),
bpmnFileName
,
bpmnFile
,
instanceId
);
Resource
subBpmnFile
=
getSubBpmn
(
getDEModule
(
entity
),
getEntityName
(
entity
),
bpmnFileName
,
bpmnFile
,
instanceId
);
DELogic
refLogic
=
getDELogic
(
subBpmnFile
,
entity
,
instanceId
);
if
(
refLogic
!= null) {
refLogics
.
add
(
refLogic
);
...
...
@@ -998,7 +1022,7 @@ public class DELogicAspect {
strModule
=
m
.
group
(
1
);
}
if
(
StringUtils
.
isEmpty
(
strModule
))
{
throw
new
BadRequestAlertException
(
String
.
format
(
"无法获取实体[%s]所属模块信息"
,
entity
.
getClass
().
getSimpleName
()
),
"LogicAspect"
,
"getDEModule"
);
throw
new
BadRequestAlertException
(
String
.
format
(
"无法获取实体[%s]所属模块信息"
,
getEntityName
(
entity
),
"LogicAspect"
,
"getDEModule"
);
}
return
strModule
;
}
...
...
@@ -1089,7 +1113,7 @@ public class DELogicAspect {
String
action
=
String
.
valueOf
(
args
[
1
]);
Object
entity
=
args
[
2
];
if
(
entity
instanceof
EntityBase
)
{
log
.
debug
(
"开始执行实体动态行为[{}:{}]"
,
entity
.
getClass
().
getSimpleName
(
),
action
);
log
.
debug
(
"开始执行实体动态行为[{}:{}]"
,
getEntityName
(
entity
),
action
);
EvaluationContext
context
=
new
StandardEvaluationContext
();
context
.
setVariable
(
"service"
,
point
.
getTarget
());
context
.
setVariable
(
"action"
,
action
);
...
...
@@ -1100,7 +1124,7 @@ public class DELogicAspect {
}
Expression
oldExp
=
parser
.
parseExpression
(
String
.
format
(
"#service.%s(#args)"
,
action
));
oldExp
.
getValue
(
context
);
log
.
debug
(
"实体动态行为[{}:{}]执行结束"
,
entity
.
getClass
().
getSimpleName
(
),
action
);
log
.
debug
(
"实体动态行为[{}:{}]执行结束"
,
getEntityName
(
entity
),
action
);
}
}
}
...
...
@@ -1114,7 +1138,7 @@ public class DELogicAspect {
*
@
return
*/
private
boolean
isValid
(
Resource
bpmn
,
Object
entity
,
Object
action
)
{
String
logicId
=
String
.
format
(
"%s%s%s"
,
entity
.
getClass
().
getSimpleName
(
),
action
,
bpmn
.
getFilename
()).
toLowerCase
();
String
logicId
=
String
.
format
(
"%s%s%s"
,
getEntityName
(
entity
),
action
,
bpmn
.
getFilename
()).
toLowerCase
();
if
(
validLogic
.
containsKey
(
logicId
))
{
return
true
;
}
else
{
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录