Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz4j Spring R7
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7后台标准模板
iBiz4j Spring R7
提交
60cef721
提交
60cef721
编写于
1月 25, 2021
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
行为附加逻辑优化
上级
4c12710d
变更
3
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
59 行增加
和
31 行删除
+59
-31
after.drl.ftl
...%-core/src/main/resources/rules/%DE%/%ITEM%/after.drl.ftl
+6
-6
before.drl.ftl
...-core/src/main/resources/rules/%DE%/%ITEM%/before.drl.ftl
+3
-4
DELogicAspect.java.ftl
...ain/java/%SYS_PKGPATH%/util/aspect/DELogicAspect.java.ftl
+50
-21
未找到文件。
SLN/%PUBPRJ%-core/src/main/resources/rules/%DE%/%ITEM%/after.drl.ftl
浏览文件 @
60cef721
...
...
@@ -20,7 +20,6 @@ global ${pub.getPKGCodeName()}.core.${dataentity.getPSSystemModule().codeName?lo
</#if>
<#if hasAfterLogic>
global ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.domain.${de.getCodeName()} et;
global org.slf4j.Logger logger;
<#if item.getAfterPSDEActionLogics?? && item.getAfterPSDEActionLogics()??>
no-loop
...
...
@@ -31,13 +30,12 @@ global org.slf4j.Logger logger;
<#assign deaction = afterlogic.getDstPSDEAction()>
<#assign dataentityCodeName = afterlogic.getDstPSDE().codeName>
<#assign deactionCodeName = srfmethodname(afterlogic.getDstPSDEAction().codeName)>
rule "${afterlogic.getId()}"
ruleflow-group "${afterlogic.getId()}"
<#assign target = (dataentity.codeName + deaction.codeName)?lower_case>
rule "${target}"
ruleflow-group "${target}"
when
then
System.out.println("开始执行[${dataentity.codeName}:${deactionCodeName}]实体[${afterlogic.getName()}]附加逻辑");
<@addActionLogic deaction afterlogic/>
System.out.println("[${dataentity.codeName}:${deactionCodeName}]实体[${afterlogic.getName()}]附加逻辑执行结束");
end
</#if>
</#list>
...
...
@@ -94,6 +92,8 @@ global org.slf4j.Logger logger;
<#comment>实体行为附加逻辑-remove</#comment>
<#macro actionLogic_remove actionlogic>
<#if de.getKeyPSDEField().getStdDataType()==actionLogicDE.getKeyPSDEField().getStdDataType()>
${srfcaseformat(actionLogicDE.getCodeName(),'l_u2lC')}Service.remove(key);
<#assign privateCodeName = srfcaseformat(actionLogicDE.getKeyPSDEField().getCodeName(),'l_u2lC') >
<#assign publicCodeName = privateCodeName?cap_first >
${srfcaseformat(actionLogicDE.getCodeName(),'l_u2lC')}Service.remove(et.get${publicCodeName}());
</#if>
</#macro>
\ No newline at end of file
SLN/%PUBPRJ%-core/src/main/resources/rules/%DE%/%ITEM%/before.drl.ftl
浏览文件 @
60cef721
...
...
@@ -20,7 +20,6 @@ global ${pub.getPKGCodeName()}.core.${dataentity.getPSSystemModule().codeName?lo
</#if>
<#if hasBeforeLogic>
global ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower_case}.domain.${de.getCodeName()} et;
global org.slf4j.Logger logger;
<#if item.getBeforePSDEActionLogics?? && item.getBeforePSDEActionLogics()??>
no-loop
...
...
@@ -36,9 +35,7 @@ global org.slf4j.Logger logger;
ruleflow-group "${target}"
when
then
System.out.println("开始执行实体附加逻辑[${dataentity.codeName}:${deactionCodeName}]");
<@addActionLogic deaction beforelogic/>
System.out.println("实体附加逻辑[${dataentity.codeName}:${deactionCodeName}]执行结束");
end
</#if>
</#list>
...
...
@@ -94,6 +91,8 @@ global org.slf4j.Logger logger;
<#comment>实体行为附加逻辑-remove</#comment>
<#macro actionLogic_remove actionlogic>
<#if de.getKeyPSDEField().getStdDataType()==actionLogicDE.getKeyPSDEField().getStdDataType()>
${srfcaseformat(actionLogicDE.getCodeName(),'l_u2lC')}Service.remove(key);
<#assign privateCodeName = srfcaseformat(actionLogicDE.getKeyPSDEField().getCodeName(),'l_u2lC') >
<#assign publicCodeName = privateCodeName?cap_first >
${srfcaseformat(actionLogicDE.getCodeName(),'l_u2lC')}Service.remove(et.get${publicCodeName}());
</#if>
</#macro>
\ No newline at end of file
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/aspect/DELogicAspect.java.ftl
浏览文件 @
60cef721
...
...
@@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
import
${
pub
.
getPKGCodeName
()}.
util
.
domain
.
DELogic
;
import
${
pub
.
getPKGCodeName
()}.
util
.
domain
.
EntityBase
;
import
${
pub
.
getPKGCodeName
()}.
util
.
errors
.
BadRequestAlertException
;
import
${
pub
.
getPKGCodeName
()}.
util
.
helper
.
DEFieldCacheMap
;
import
org
.
apache
.
commons
.
io
.
IOUtils
;
import
org
.
aspectj
.
lang
.
JoinPoint
;
import
org
.
aspectj
.
lang
.
ProceedingJoinPoint
;
...
...
@@ -16,6 +17,8 @@ import org.aspectj.lang.annotation.AfterReturning;
import
org
.
aspectj
.
lang
.
annotation
.
Around
;
import
org
.
aspectj
.
lang
.
annotation
.
Aspect
;
import
org
.
flowable
.
bpmn
.
converter
.
BpmnXMLConverter
;
import
org
.
flowable
.
bpmn
.
model
.*;
import
org
.
flowable
.
bpmn
.
model
.
Process
;
import
org
.
kie
.
api
.
KieServices
;
import
org
.
kie
.
api
.
builder
.
KieBuilder
;
import
org
.
kie
.
api
.
builder
.
KieFileSystem
;
...
...
@@ -24,8 +27,6 @@ import org.kie.api.builder.Results;
import
org
.
kie
.
api
.
runtime
.
KieContainer
;
import
org
.
kie
.
api
.
runtime
.
KieSession
;
import
org
.
kie
.
internal
.
io
.
ResourceFactory
;
import
org
.
slf4j
.
LoggerFactory
;
import
org
.
slf4j
.
Logger
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Value
;
import
org
.
springframework
.
expression
.
EvaluationContext
;
import
org
.
springframework
.
expression
.
Expression
;
...
...
@@ -36,14 +37,13 @@ import org.springframework.stereotype.Component;
import
org
.
springframework
.
util
.
DigestUtils
;
import
org
.
springframework
.
util
.
ObjectUtils
;
import
org
.
springframework
.
util
.
StringUtils
;
import
org
.
flowable
.
bpmn
.
model
.*;
import
org
.
flowable
.
bpmn
.
model
.
Process
;
import
javax
.
xml
.
stream
.
XMLInputFactory
;
import
javax
.
xml
.
stream
.
XMLStreamReader
;
import
java
.
io
.
File
;
import
java
.
io
.
FileInputStream
;
import
java
.
io
.
InputStream
;
import
java
.
lang
.
reflect
.
Method
;
import
java
.
net
.
URL
;
import
java
.
util
.
ArrayList
;
import
java
.
util
.
List
;
...
...
@@ -65,7 +65,7 @@ public class DELogicAspect {
/**
*
本地
*/
LOCAL
(
"0"
,
"本地模
型
"
),
LOCAL
(
"0"
,
"本地模
式
"
),
/**
*
远程
*/
...
...
@@ -80,7 +80,6 @@ public class DELogicAspect {
private
String
text
;
}
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
DELogicAspect
.
class
);
private
static
BpmnXMLConverter
bpmnXMLConverter
=
new
BpmnXMLConverter
();
private
final
ExpressionParser
parser
=
new
SpelExpressionParser
();
private
ConcurrentMap
<
String
,
DELogic
>
deLogicMap
=
new
ConcurrentHashMap
<>();
...
...
@@ -98,14 +97,14 @@ public class DELogicAspect {
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
));
oldExp
.
getValue
(
context
);
log
.
debug
(
"
[{}]实体[{}]动态行为
执行结束"
,
entity
.
getClass
().
getSimpleName
(),
action
);
log
.
debug
(
"
实体[{}]动态行为[{}]
执行结束"
,
entity
.
getClass
().
getSimpleName
(),
action
);
}
}
...
...
@@ -122,10 +121,19 @@ public class DELogicAspect {
if
(
ObjectUtils
.
isEmpty
(
args
)
||
args
.
length
==
0
)
{
return
point
.
proceed
();
}
Object
service
=
point
.
getTarget
();
Object
arg
=
args
[
0
];
if
(
arg
instanceof
EntityBase
)
{
String
action
=
point
.
getSignature
().
getName
();
EntityBase
entity
=
(
EntityBase
)
arg
;
String
action
=
point
.
getSignature
().
getName
();
EntityBase
entity
=
null
;
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
=
(
EntityBase
)
arg
;
}
if
(
entity
!= null){
executeBeforeLogic
(
entity
,
action
);
Object
result
=
point
.
proceed
();
executeLogic
(
entity
,
action
);
...
...
@@ -135,6 +143,28 @@ public class DELogicAspect {
return
point
.
proceed
();
}
/**
*
获取实体
*
@
param
service
*
@
return
*
@
throws
Exception
*/
private
EntityBase
getEntity
(
Object
service
)
throws
Exception
{
Method
[]
methods
=
service
.
getClass
().
getDeclaredMethods
();
for
(
Method
method
:
methods
){
for
(
Class
cls
:
method
.
getParameterTypes
()){
try
{
Object
arg
=
cls
.
newInstance
();
if
(
arg
instanceof
EntityBase
){
return
(
EntityBase
)
arg
;
}
}
catch
(
InstantiationException
e
)
{
}
}
}
throw
new
BadRequestAlertException
(
"获取实体信息失败"
,
"DELogicAspect"
,
"getEntity"
);
}
/**
*
前附加逻辑
*
...
...
@@ -146,13 +176,13 @@ public class DELogicAspect {
if
(
dynamicMode
)
{
bpmnFile
=
getRemoteModel
(
getDEModule
(
entity
),
entity
.
getClass
().
getSimpleName
(),
action
,
"before"
);
if
(
bpmnFile
.
exists
())
{
executeLogic
(
bpmnFile
,
entity
,
LogicMode
.
REMOTE
);
executeLogic
(
bpmnFile
,
entity
,
action
,
LogicMode
.
REMOTE
);
return
;
}
}
bpmnFile
=
getLocalModel
(
entity
.
getClass
().
getSimpleName
(),
action
,
"before"
);
if
(
bpmnFile
!= null && bpmnFile.exists()) {
executeLogic
(
bpmnFile
,
entity
,
LogicMode
.
LOCAL
);
executeLogic
(
bpmnFile
,
entity
,
action
,
LogicMode
.
LOCAL
);
}
}
...
...
@@ -167,13 +197,13 @@ public class DELogicAspect {
if
(
dynamicMode
)
{
bpmnFile
=
getRemoteModel
(
getDEModule
(
entity
),
entity
.
getClass
().
getSimpleName
(),
action
,
"after"
);
if
(
bpmnFile
.
exists
())
{
executeLogic
(
bpmnFile
,
entity
,
LogicMode
.
REMOTE
);
executeLogic
(
bpmnFile
,
entity
,
action
,
LogicMode
.
REMOTE
);
return
;
}
}
bpmnFile
=
getLocalModel
(
entity
.
getClass
().
getSimpleName
(),
action
,
"after"
);
if
(
bpmnFile
!= null && bpmnFile.exists()) {
executeLogic
(
bpmnFile
,
entity
,
LogicMode
.
LOCAL
);
executeLogic
(
bpmnFile
,
entity
,
action
,
LogicMode
.
LOCAL
);
}
}
...
...
@@ -188,13 +218,13 @@ public class DELogicAspect {
if
(
dynamicMode
)
{
bpmnFile
=
getRemoteModel
(
getDEModule
(
entity
),
entity
.
getClass
().
getSimpleName
(),
action
,
"exec"
);
if
(
bpmnFile
.
exists
())
{
executeLogic
(
bpmnFile
,
entity
,
LogicMode
.
REMOTE
);
executeLogic
(
bpmnFile
,
entity
,
action
,
LogicMode
.
REMOTE
);
return
;
}
}
bpmnFile
=
getLocalModel
(
entity
.
getClass
().
getSimpleName
(),
action
,
"exec"
);
if
(
bpmnFile
!= null && bpmnFile.exists()) {
executeLogic
(
bpmnFile
,
entity
,
LogicMode
.
LOCAL
);
executeLogic
(
bpmnFile
,
entity
,
action
,
LogicMode
.
LOCAL
);
}
}
...
...
@@ -204,8 +234,8 @@ public class DELogicAspect {
*
@
param
bpmnFile
*
@
param
entity
*/
private
void
executeLogic
(
File
bpmnFile
,
Object
entity
,
LogicMode
logicMode
)
{
log
.
debug
(
"开始执行
[{}]实体[{}]处理逻辑,模式为[{}]"
,
entity
.
getClass
().
getSimpleName
()
,
bpmnFile
.
getName
(),
logicMode
.
text
);
private
void
executeLogic
(
File
bpmnFile
,
Object
entity
,
String
action
,
LogicMode
logicMode
)
{
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
)
{
...
...
@@ -228,9 +258,8 @@ public class DELogicAspect {
fillGlobalParam
(
kieSession
,
subLogic
.
getProcess
(),
entity
);
}
}
kieSession
.
setGlobal
(
"logger"
,
logger
);
kieSession
.
startProcess
(
mainProcess
.
getId
());
log
.
debug
(
"
[{}]实体[{}]处理逻辑执行结束,模式为[{}]"
,
entity
.
getClass
().
getSimpleName
(),
bpmnFile
.
getName
(),
bpmnFile
.
getName
(),
logicMode
.
text
);
log
.
debug
(
"
实体处理逻辑[{}:{}:{}:{}]执行结束"
,
entity
.
getClass
().
getSimpleName
(),
action
,
bpmnFile
.
getName
(),
logicMode
.
text
);
}
/**
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录