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
b370961e
Commit
b370961e
authored
Sep 13, 2023
by
s_guodong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
流程控制和日志打印
parent
14788401
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
135 additions
and
81 deletions
+135
-81
AbstractAutoCompileEmitter.java
.../driver/compile/component/AbstractAutoCompileEmitter.java
+9
-4
AbstractAutoCompileScopeEmitter.java
...er/compile/component/AbstractAutoCompileScopeEmitter.java
+63
-51
AbstractRuleEmitter.java
.../brilliance/mda/runtime/mda/impl/AbstractRuleEmitter.java
+18
-10
AbstractRouteService.java
.../brilliance/mda/support/service/AbstractRouteService.java
+45
-16
No files found.
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/driver/compile/component/AbstractAutoCompileEmitter.java
View file @
b370961e
...
...
@@ -61,20 +61,24 @@ public abstract class AbstractAutoCompileEmitter extends AbstractRuleEmitter {
continue
;
}
try
{
boolean
b
=
true
;
switch
(
ruleItem
.
getRuleType
())
{
case
RuleItem
.
INIT
:
execInitItem
(
ruleItem
.
getOrder
(),
ruleItem
.
getDotPath
(),
new
RuleItemExecutor
(
ruleItem
,
this
,
MdaEnv
.
getContext
().
getRoot
()));
b
=
execInitItem
(
ruleItem
.
getOrder
(),
ruleItem
.
getDotPath
(),
new
RuleItemExecutor
(
ruleItem
,
this
,
MdaEnv
.
getContext
().
getRoot
()));
break
;
case
RuleItem
.
CHECK
:
execCheckItem
(
ruleItem
.
getOrder
(),
ruleItem
.
getDotPath
(),
new
RuleItemExecutor
(
ruleItem
,
this
,
MdaEnv
.
getContext
().
getRoot
()));
b
=
execCheckItem
(
ruleItem
.
getOrder
(),
ruleItem
.
getDotPath
(),
new
RuleItemExecutor
(
ruleItem
,
this
,
MdaEnv
.
getContext
().
getRoot
()));
break
;
case
RuleItem
.
DEFAULT
:
execDefaultItem
(
ruleItem
.
getOrder
(),
ruleItem
.
getDotPath
(),
new
RuleItemExecutor
(
ruleItem
,
this
,
MdaEnv
.
getContext
().
getRoot
()));
b
=
execDefaultItem
(
ruleItem
.
getOrder
(),
ruleItem
.
getDotPath
(),
new
RuleItemExecutor
(
ruleItem
,
this
,
MdaEnv
.
getContext
().
getRoot
()));
break
;
case
RuleItem
.
RULE
:
execRuleItem
(
ruleItem
.
getOrder
(),
ruleItem
.
getDotPath
(),
new
RuleItemExecutor
(
ruleItem
,
this
,
MdaEnv
.
getContext
().
getRoot
()));
b
=
execRuleItem
(
ruleItem
.
getOrder
(),
ruleItem
.
getDotPath
(),
new
RuleItemExecutor
(
ruleItem
,
this
,
MdaEnv
.
getContext
().
getRoot
()));
break
;
}
if
(!
b
)
{
return
false
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"execute Rule Exception"
,
e
);
throw
e
;
...
...
@@ -164,6 +168,7 @@ public abstract class AbstractAutoCompileEmitter extends AbstractRuleEmitter {
boolean
result
=
invokeRuleList
(
RuleItem
.
CHECK
,
entry
.
getKey
(),
order
);
if
(!
result
)
{
log
.
warn
(
String
.
format
(
"execute @Check[%s,%d] return false"
,
entry
.
getKey
(),
order
));
return
false
;
}
}
return
true
;
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/driver/compile/component/AbstractAutoCompileScopeEmitter.java
View file @
b370961e
This diff is collapsed.
Click to expand it.
gjjs-bd-runtime/src/main/java/com/brilliance/mda/runtime/mda/impl/AbstractRuleEmitter.java
View file @
b370961e
...
...
@@ -109,7 +109,7 @@ public abstract class AbstractRuleEmitter implements IRuleEmitter {
protected
boolean
checkPathMatch
(
String
path
,
String
target
)
{
if
(
target
.
startsWith
(
"\\"
))
{
if
(
target
.
startsWith
(
"\\"
))
{
target
=
target
.
substring
(
1
).
toLowerCase
();
}
int
targetLen
=
target
.
length
();
...
...
@@ -322,7 +322,7 @@ public abstract class AbstractRuleEmitter implements IRuleEmitter {
Boolean
result
=
executeInit
(-
1
);
return
result
;
}
catch
(
RuleExitException
e
)
{
throw
new
RuleExecuteException
(
"Init执行
返回false
"
,
e
);
throw
new
RuleExecuteException
(
"Init执行
异常
"
,
e
);
// return false;
}
catch
(
Exception
ex
)
{
DCR
.
emptyDefaultQueue
();
...
...
@@ -346,7 +346,7 @@ public abstract class AbstractRuleEmitter implements IRuleEmitter {
}
}
public
void
execInitItem
(
int
order
,
String
path
,
Ruleable
<
Boolean
>
ruleHolder
)
{
public
boolean
execInitItem
(
int
order
,
String
path
,
Ruleable
<
Boolean
>
ruleHolder
)
{
boolean
ignore
=
false
;
if
(
ruleHolder
instanceof
RuleItemExecutor
)
{
RuleItemExecutor
executor
=
(
RuleItemExecutor
)
ruleHolder
;
...
...
@@ -365,14 +365,16 @@ public abstract class AbstractRuleEmitter implements IRuleEmitter {
if
(!
ruleHolder
.
exec
())
{
stopWatch
.
stop
();
addSlowExecutionLog
(
stopWatch
.
getLastTaskTimeMillis
(),
"execInitItem"
,
path
,
order
);
throw
new
RuleExitException
(
String
.
format
(
"%s init %d %s exit"
,
MdaEnv
.
getContext
().
getTransName
(),
order
,
path
));
// throw new RuleExitException(String.format("%s init %d %s exit", MdaEnv.getContext().getTransName(), order, path));
return
false
;
}
stopWatch
.
stop
();
addSlowExecutionLog
(
stopWatch
.
getLastTaskTimeMillis
(),
"execInitItem"
,
path
,
order
);
}
return
true
;
}
public
void
execRuleItem
(
int
order
,
String
path
,
Ruleable
<
Boolean
>
ruleHolder
)
{
public
boolean
execRuleItem
(
int
order
,
String
path
,
Ruleable
<
Boolean
>
ruleHolder
)
{
boolean
ignore
=
false
;
String
eventPath
=
MdaEnv
.
getContext
().
getEventPath
();
if
(
ruleHolder
instanceof
RuleItemExecutor
)
{
...
...
@@ -394,7 +396,8 @@ public abstract class AbstractRuleEmitter implements IRuleEmitter {
if
(!
b
)
{
stopWatch
.
stop
();
addSlowExecutionLog
(
stopWatch
.
getLastTaskTimeMillis
(),
"execRuleItem"
,
path
,
order
);
throw
new
RuleExitException
(
String
.
format
(
"%s rule %d %s exit"
,
MdaEnv
.
getContext
().
getTransName
(),
order
,
eventPath
));
return
false
;
// throw new RuleExitException(String.format("%s rule %d %s exit", MdaEnv.getContext().getTransName(), order, eventPath));
}
if
(
MdaEnv
.
getContext
().
getFieldErrors
().
size
()
>
oldLength
)
{
log
.
warn
(
"{} rule [{}] [{}] set fieldError"
,
MdaEnv
.
getContext
().
getTransName
(),
order
,
eventPath
);
...
...
@@ -402,10 +405,11 @@ public abstract class AbstractRuleEmitter implements IRuleEmitter {
stopWatch
.
stop
();
addSlowExecutionLog
(
stopWatch
.
getLastTaskTimeMillis
(),
"execRuleItem"
,
path
,
order
);
}
return
true
;
//log.debug("rule [{}] [{}] finished",order,eventPath);
}
public
void
execCheckItem
(
int
order
,
String
path
,
Ruleable
<
Boolean
>
ruleHolder
)
{
public
boolean
execCheckItem
(
int
order
,
String
path
,
Ruleable
<
Boolean
>
ruleHolder
)
{
boolean
ignore
=
false
;
String
eventPath
=
MdaEnv
.
getContext
().
getEventPath
();
if
(
ruleHolder
instanceof
RuleItemExecutor
)
{
...
...
@@ -426,7 +430,8 @@ public abstract class AbstractRuleEmitter implements IRuleEmitter {
if
(!
ruleHolder
.
exec
())
{
stopWatch
.
stop
();
addSlowExecutionLog
(
stopWatch
.
getLastTaskTimeMillis
(),
"execCheckItem"
,
path
,
order
);
throw
new
RuleExitException
(
String
.
format
(
"check [%d] [%s] exit"
,
order
,
eventPath
));
// throw new RuleExitException(String.format("check [%d] [%s] exit", order, eventPath));
return
false
;
}
if
(
MdaEnv
.
getContext
().
getFieldErrors
().
size
()
>
oldLength
)
{
log
.
warn
(
String
.
format
(
"%s check [%d] [%s] set fieldError"
,
MdaEnv
.
getContext
().
getTransName
(),
order
,
eventPath
));
...
...
@@ -435,9 +440,10 @@ public abstract class AbstractRuleEmitter implements IRuleEmitter {
addSlowExecutionLog
(
stopWatch
.
getLastTaskTimeMillis
(),
"execCheckItem"
,
path
,
order
);
//log.debug("check [{}] [{}] finished",order,eventPath);
}
return
true
;
}
public
void
execDefaultItem
(
int
order
,
String
path
,
Ruleable
<
Boolean
>
ruleHolder
)
{
public
boolean
execDefaultItem
(
int
order
,
String
path
,
Ruleable
<
Boolean
>
ruleHolder
)
{
boolean
ignore
=
false
;
String
eventPath
=
MdaEnv
.
getContext
().
getEventPath
();
if
(
ruleHolder
instanceof
RuleItemExecutor
)
{
...
...
@@ -457,12 +463,14 @@ public abstract class AbstractRuleEmitter implements IRuleEmitter {
if
(!
ruleHolder
.
exec
())
{
stopWatch
.
stop
();
addSlowExecutionLog
(
stopWatch
.
getLastTaskTimeMillis
(),
"execDefaultItem"
,
path
,
order
);
throw
new
RuleExitException
(
String
.
format
(
"%s default [%d] [%s] exit"
,
MdaEnv
.
getContext
().
getTransName
(),
order
,
eventPath
));
// throw new RuleExitException(String.format("%s default [%d] [%s] exit", MdaEnv.getContext().getTransName(), order, eventPath));
return
false
;
}
stopWatch
.
stop
();
addSlowExecutionLog
(
stopWatch
.
getLastTaskTimeMillis
(),
"execDefaultItem"
,
path
,
order
);
//log.debug("default [{}] [{}] finished",order,eventPath);
}
return
true
;
}
public
List
<
IModuleList
>
getAllModuleList
()
{
...
...
gjjs-bd-runtime/src/main/java/com/brilliance/mda/support/service/AbstractRouteService.java
View file @
b370961e
...
...
@@ -157,19 +157,26 @@ public abstract class AbstractRouteService<V extends BaseVO> {
try
{
StopWatch
stopWatch
=
new
StopWatch
(
"executeCheck:"
+
StringUtils
.
join
(
rulePathArr
,
','
));
stopWatch
.
start
(
"enterTransaction"
);
enterTransaction
(
req
);
boolean
b
=
enterTransaction
(
req
);
stopWatch
.
stop
();
IContext
ctx
=
MdaEnv
.
getContext
();
if
(!
b
)
{
return
new
ResponseSet
<
V
>(
ctx
,
req
);
}
synchronized
(
ctx
)
{
stopWatch
.
start
(
"setValueFromVO"
);
setValueFromVO
(
req
);
stopWatch
.
stop
();
stopWatch
.
start
(
"executeStepWithCheckList"
);
executeStepWithCheckList
(
rulePathArr
);
boolean
[]
step
=
executeStepWithCheckList
(
rulePathArr
);
stopWatch
.
stop
();
boolean
continueFlag
=
summarizeResult
(
step
);
if
(!
continueFlag
)
{
return
new
ResponseSet
<
V
>(
ctx
.
getErrorNo
(),
ctx
.
getErrorMessage
(),
req
);
}
stopWatch
.
start
(
"afterExecute"
);
boolean
result
=
ctx
.
getFieldErrors
().
size
()
<=
0
;
afterExecute
(
rulePathArr
);
...
...
@@ -199,10 +206,13 @@ public abstract class AbstractRouteService<V extends BaseVO> {
try
{
StopWatch
stopWatch
=
new
StopWatch
(
"executeRule:"
+
StringUtils
.
join
(
rulePathArr
,
','
));
stopWatch
.
start
(
"enterTransaction"
);
enterTransaction
(
req
);
boolean
b
=
enterTransaction
(
req
);
stopWatch
.
stop
();
IContext
ctx
=
MdaEnv
.
getContext
();
if
(!
b
)
{
return
new
ResponseSet
<
V
>(
ctx
.
getErrorNo
(),
ctx
.
getErrorMessage
(),
req
);
}
synchronized
(
ctx
)
{
stopWatch
.
start
(
"setValueFromVO"
);
setValueFromVO
(
req
);
...
...
@@ -212,6 +222,11 @@ public abstract class AbstractRouteService<V extends BaseVO> {
boolean
[]
step
=
executeStepWithRuleList
(
rulePathArr
);
stopWatch
.
stop
();
boolean
continueFlag
=
summarizeResult
(
step
);
if
(!
continueFlag
)
{
return
new
ResponseSet
<
V
>(
ctx
.
getErrorNo
(),
ctx
.
getErrorMessage
(),
req
);
}
// checkAll时对ModuleList进行check
if
(
rulePathArr
.
length
==
1
&&
CHEK_PATH
.
equals
(
rulePathArr
[
0
]))
{
stopWatch
.
start
(
"executeCheckAll"
);
...
...
@@ -240,14 +255,13 @@ public abstract class AbstractRouteService<V extends BaseVO> {
//return new ResponseSet<V>(ctx.getErrorNo(), ctx.getErrorMessage(), ctx.getFieldErrors());
}
}
catch
(
Exception
e
)
{
// throw new RuleExecuteException(e.getMessage(), e);
IContext
ctx
=
MdaEnv
.
getContext
();
return
new
ResponseSet
<
V
>(
ctx
.
getErrorNo
(),
ctx
.
getErrorMessage
());
return
ResponseSet
.
fail
(
e
.
getMessage
());
}
finally
{
DCR
.
emptyDefaultQueue
();
}
}
/**
* 执行defaultRule
*/
...
...
@@ -328,16 +342,11 @@ public abstract class AbstractRouteService<V extends BaseVO> {
/**
* 初始化步骤
*/
public
void
initTrans
(
V
req
)
{
public
boolean
initTrans
(
V
req
)
{
IContext
ctx
=
MdaEnv
.
getContext
();
if
(
req
!=
null
)
{
ctx
.
setVo
(
req
);
}
// if (!req.isNeedInit()) {
// logger.info("不需要初始化");
// return;
// }
// logger.info("开始初始化...");
StopWatch
watch
=
new
StopWatch
(
"initTrans"
);
IRuleEmitter
emitter
=
getEmitter
();
//将认证信息(usr、usg、ety)放入sysStream
...
...
@@ -349,8 +358,12 @@ public abstract class AbstractRouteService<V extends BaseVO> {
//一阶段,构造与初始化
// DCR.emptyDefaultQueue();
watch
.
start
(
"executeInit"
);
emitter
.
executeInit
();
// 执行初始
boolean
b
=
emitter
.
executeInit
();
// 执行初始
watch
.
stop
();
// 初始化返回false就不往下执行了
if
(!
b
)
{
return
false
;
}
DCR
.
enNotify
(
true
);
watch
.
start
(
"executeDefaultAfterInit"
);
emitter
.
executeDefaultAfterInit
();
...
...
@@ -362,6 +375,7 @@ public abstract class AbstractRouteService<V extends BaseVO> {
logger
.
info
(
watch
.
prettyPrint
());
//执行Default
DCR
.
executeQueue
();
return
true
;
}
/**
...
...
@@ -393,6 +407,9 @@ public abstract class AbstractRouteService<V extends BaseVO> {
String
path
=
ruleList
[
i
];
Argument
<
String
>
pathBox
=
Argument
.
box
(
path
);
result
[
i
]
=
getEmitterByPath
(
pathBox
).
executeRule
(
pathBox
.
value
);
if
(!
result
[
i
])
{
return
result
;
}
//todo 判断是否列表数据,例如机构选择,如果是则不执行后续的default,
Map
<
String
,
Object
>
gridData
=
MdaEnv
.
getGridData
();
if
(
gridData
!=
null
&&
ruleList
.
length
==
1
)
{
...
...
@@ -417,6 +434,9 @@ public abstract class AbstractRouteService<V extends BaseVO> {
String
path
=
ruleList
[
i
];
Argument
<
String
>
pathBox
=
Argument
.
box
(
path
);
result
[
i
]
=
getEmitterByPath
(
pathBox
).
executeCheck
(
pathBox
.
value
);
if
(!
result
[
i
])
{
return
result
;
}
//执行Default
DCR
.
executeQueue
();
executeAndClearPostQueue
();
...
...
@@ -476,7 +496,7 @@ public abstract class AbstractRouteService<V extends BaseVO> {
}
ctx
.
storeData
(
IContext
.
DISPLAY_KEY
,
req
);
initTrans
(
req
);
return
initTrans
(
req
);
}
return
true
;
}
...
...
@@ -490,4 +510,13 @@ public abstract class AbstractRouteService<V extends BaseVO> {
// DCR.executeQueue(false);
beforeExecute
();
}
private
boolean
summarizeResult
(
boolean
[]
step
)
{
for
(
boolean
b
:
step
)
{
if
(!
b
)
{
return
b
;
}
}
return
true
;
}
}
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