Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzwf
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzwf
提交
2a201452
提交
2a201452
编写于
3月 22, 2021
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
加签、获取流程参数逻辑优化
上级
6aaf6ad3
变更
2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
206 行增加
和
238 行删除
+206
-238
ProcessInstanceListener.java
...workflow/extensions/listener/ProcessInstanceListener.java
+3
-17
WFCoreService.java
...izlab/core/workflow/extensions/service/WFCoreService.java
+203
-221
未找到文件。
ibzwf-core/src/main/java/cn/ibizlab/core/workflow/extensions/listener/ProcessInstanceListener.java
浏览文件 @
2a201452
...
@@ -142,26 +142,13 @@ public class ProcessInstanceListener extends AbstractFlowableEventListener {
...
@@ -142,26 +142,13 @@ public class ProcessInstanceListener extends AbstractFlowableEventListener {
// 多实例(会签)
// 多实例(会签)
if
(
event
.
getType
()
==
FlowableEngineEventType
.
MULTI_INSTANCE_ACTIVITY_STARTED
){
if
(
event
.
getType
()
==
FlowableEngineEventType
.
MULTI_INSTANCE_ACTIVITY_STARTED
){
UserTask
task
=
(
UserTask
)
event
.
getExecution
().
getCurrentFlowElement
();
UserTask
task
=
(
UserTask
)
event
.
getExecution
().
getCurrentFlowElement
();
List
fieldList
=
task
.
getExtensionElements
().
get
(
"field"
);
String
strCandidate
=
wfCoreService
.
getParam
(
task
,
"form"
,
"candidateUsersList"
);
String
strCandidate
=
""
;
if
(
StringUtils
.
isEmpty
(
strCandidate
)){
if
(!
ObjectUtils
.
isEmpty
(
fieldList
)){
throw
new
BadRequestAlertException
(
"获取流程用户失败"
,
""
,
""
);
for
(
Object
field
:
fieldList
)
{
if
(!
ObjectUtils
.
isEmpty
(((
ExtensionElement
)
field
).
getAttributes
())){
List
<
ExtensionAttribute
>
attributes
=
((
ExtensionElement
)
field
).
getAttributes
().
get
(
"name"
);
if
(
attributes
.
size
()
>
0
){
if
(
attributes
.
get
(
0
).
getValue
().
equals
(
"candidateUsersList"
)){
strCandidate
=
((
ExtensionElement
)
field
).
getChildElements
().
get
(
"string"
).
get
(
0
).
getElementText
();
break
;
}
}
}
}
}
}
DelegateExecution
execution
=
event
.
getExecution
();
DelegateExecution
execution
=
event
.
getExecution
();
Set
processRoles
=
new
HashSet
();
Set
processRoles
=
new
HashSet
();
Set
processUserIds
=
new
HashSet
();
Set
processUserIds
=
new
HashSet
();
LinkedHashMap
executionMap
=
(
LinkedHashMap
)
execution
.
getVariable
(
"activedata"
);
LinkedHashMap
executionMap
=
(
LinkedHashMap
)
execution
.
getVariable
(
"activedata"
);
String
[]
groups
=
strCandidate
.
split
(
"\\|\\|"
);
String
[]
groups
=
strCandidate
.
split
(
"\\|\\|"
);
if
(
groups
.
length
>
0
)
{
if
(
groups
.
length
>
0
)
{
...
@@ -203,7 +190,6 @@ public class ProcessInstanceListener extends AbstractFlowableEventListener {
...
@@ -203,7 +190,6 @@ public class ProcessInstanceListener extends AbstractFlowableEventListener {
}
}
}
}
}
}
//设置会签用户
//设置会签用户
if
(!
ObjectUtils
.
isEmpty
(
processUserIds
)){
if
(!
ObjectUtils
.
isEmpty
(
processUserIds
)){
event
.
getExecution
().
setVariableLocal
(
"candidateUsersList"
,
processUserIds
);
event
.
getExecution
().
setVariableLocal
(
"candidateUsersList"
,
processUserIds
);
...
...
ibzwf-core/src/main/java/cn/ibizlab/core/workflow/extensions/service/WFCoreService.java
浏览文件 @
2a201452
...
@@ -613,22 +613,24 @@ public class WFCoreService
...
@@ -613,22 +613,24 @@ public class WFCoreService
Authentication
.
setAuthenticatedUserId
(
userId
);
Authentication
.
setAuthenticatedUserId
(
userId
);
Authentication
.
setAuthenticationContext
(
createAuthenticationContext
());
Authentication
.
setAuthenticationContext
(
createAuthenticationContext
());
Task
curTask
=
taskService
.
createTaskQuery
().
taskId
(
taskId
).
singleResult
();
WFProcessInstance
instance
=
new
WFProcessInstance
();
taskService
.
complete
(
taskId
,
variables
,
transientVariables
);
Task
curTask
=
taskService
.
createTaskQuery
().
taskId
(
taskId
).
singleResult
();
WFProcessInstance
instance
=
new
WFProcessInstance
();
instance
.
setBusinesskey
(
processInstanceBusinessKey
);
//加签任务处理
if
(
curTask
!=
null
&&
DelegationState
.
PENDING
==
curTask
.
getDelegationState
())
{
//加签处理
if
(
userId
.
equals
(
curTask
.
getAssignee
())){
if
(
curTask
!=
null
&&
DelegationState
.
PENDING
!=
curTask
.
getDelegationState
()
&&
!
StringUtils
.
isEmpty
(
curTask
.
getParentTaskId
()))
{
taskService
.
resolveTask
(
taskId
);
String
tableName
=
managementService
.
getTableName
(
TaskEntity
.
class
);
//saveTask(curTask);
String
sql
=
"select count(1) from "
+
tableName
+
" where PARENT_TASK_ID_=#{parentTaskId}"
;
}
long
subTaskCount
=
taskService
.
createNativeTaskQuery
().
sql
(
sql
).
parameter
(
"parentTaskId"
,
curTask
.
getParentTaskId
()).
count
();
else
{
//完成加签任务,激活主任务
throw
new
BadRequestAlertException
(
"当前任务正在加签中"
,
""
,
""
);
if
(
subTaskCount
==
0
)
{
}
taskService
.
resolveTask
(
curTask
.
getParentTaskId
());
}
log
.
info
(
"加签任务结束,激活主任务[{}]"
,
curTask
.
getParentTaskId
());
else
{
}
//常规任务处理
}
taskService
.
complete
(
taskId
,
variables
,
transientVariables
);
instance
.
setBusinesskey
(
processInstanceBusinessKey
);
}
return
instance
;
return
instance
;
}
}
...
@@ -1303,39 +1305,28 @@ public class WFCoreService
...
@@ -1303,39 +1305,28 @@ public class WFCoreService
* @param taskId
* @param taskId
* @param taskWay
* @param taskWay
*/
*/
public
boolean
beforeSign
(
String
system
,
String
appname
,
public
boolean
beforeSign
(
String
system
,
String
appname
,
String
entity
,
String
businessKey
,
String
taskId
,
WFTaskWay
taskWay
)
{
String
entity
,
String
businessKey
,
String
taskId
,
WFTaskWay
taskWay
)
{
String
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
String
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
if
(
StringUtils
.
isEmpty
(
userId
))
if
(
StringUtils
.
isEmpty
(
userId
))
if
(
StringUtils
.
isEmpty
(
userId
))
throw
new
BadRequestAlertException
(
"未传入当前用户"
,
entity
,
businessKey
);
throw
new
BadRequestAlertException
(
"未传入当前用户"
,
entity
,
businessKey
);
Object
signUsers
=
taskWay
.
get
(
"users"
);
Object
signUsers
=
taskWay
.
get
(
"users"
);
if
(
ObjectUtils
.
isEmpty
(
signUsers
))
{
if
(
ObjectUtils
.
isEmpty
(
signUsers
))
{
throw
new
BadRequestAlertException
(
"未传入加签用户"
,
entity
,
businessKey
);
throw
new
BadRequestAlertException
(
"未传入加签用户"
,
entity
,
businessKey
);
}
}
//当前任务
Task
curTask
=
taskService
.
createTaskQuery
().
taskId
(
taskId
).
singleResult
();
Task
curTask
=
taskService
.
createTaskQuery
().
taskId
(
taskId
).
singleResult
();
if
(
curTask
==
null
)
{
if
(
curTask
==
null
){
throw
new
BadRequestAlertException
(
String
.
format
(
"未能获取到[%s]运行任务"
,
curTask
.
getId
()),
""
,
""
);
throw
new
BadRequestAlertException
(
String
.
format
(
"未能获取到[%s]运行任务"
,
curTask
.
getId
()),
""
,
""
);
}
}
if
(
DelegationState
.
PENDING
!=
curTask
.
getDelegationState
())
{
if
(
DelegationState
.
PENDING
!=
curTask
.
getDelegationState
()){
taskService
.
delegateTask
(
taskId
,
String
.
valueOf
(
signUsers
));
//生成加签任务
//saveTask(curTask);
for
(
String
signUser
:
((
String
)
signUsers
).
split
(
","
))
{
}
else
{
Task
signTask
=
createTask
(
curTask
);
throw
new
BadRequestAlertException
(
String
.
format
(
"任务正在加签中,无法进行二次加签"
,
curTask
.
getId
()),
""
,
""
);
signTask
.
setParentTaskId
(
curTask
.
getId
());
}
taskService
.
saveTask
(
signTask
);
return
true
;
taskService
.
addUserIdentityLink
(
signTask
.
getId
(),
signUser
,
"candidate"
);
}
}
//挂起主任务
taskService
.
delegateTask
(
taskId
,
userId
);
log
.
info
(
"用户[{}]发起加签操作,挂起[{}]主任务"
,
userId
,
taskId
);
}
else
{
throw
new
BadRequestAlertException
(
String
.
format
(
"任务正在加签中,无法进行二次加签"
,
curTask
.
getId
()),
""
,
""
);
}
return
true
;
}
/**
/**
* 后加签 (转办)
* 后加签 (转办)
...
@@ -1349,7 +1340,6 @@ public class WFCoreService
...
@@ -1349,7 +1340,6 @@ public class WFCoreService
public
boolean
afterSign
(
String
system
,
String
appname
,
public
boolean
afterSign
(
String
system
,
String
appname
,
String
entity
,
String
businessKey
,
String
taskId
,
WFTaskWay
taskWay
){
String
entity
,
String
businessKey
,
String
taskId
,
WFTaskWay
taskWay
){
String
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
String
userId
=
AuthenticationUser
.
getAuthenticationUser
().
getUserid
();
if
(
StringUtils
.
isEmpty
(
userId
))
if
(
StringUtils
.
isEmpty
(
userId
))
if
(
StringUtils
.
isEmpty
(
userId
))
throw
new
BadRequestAlertException
(
"未传入当前用户"
,
entity
,
businessKey
);
throw
new
BadRequestAlertException
(
"未传入当前用户"
,
entity
,
businessKey
);
...
@@ -1362,16 +1352,11 @@ public class WFCoreService
...
@@ -1362,16 +1352,11 @@ public class WFCoreService
throw
new
BadRequestAlertException
(
String
.
format
(
"未能获取到[%s]运行任务"
,
taskId
),
""
,
""
);
throw
new
BadRequestAlertException
(
String
.
format
(
"未能获取到[%s]运行任务"
,
taskId
),
""
,
""
);
}
}
log
.
info
(
"用户[{}]发起转办操作,将任务[{}]转办至[{}]用户"
,
userId
,
taskId
,
signUser
);
//转办任务
//转办任务
taskService
.
deleteUserIdentityLink
(
curTask
.
getId
(),
userId
,
"candidate"
);
taskService
.
deleteUserIdentityLink
(
curTask
.
getId
(),
userId
,
"candidate"
);
taskService
.
addUserIdentityLink
(
curTask
.
getId
(),
(
String
)
signUser
,
"candidate"
);
taskService
.
addUserIdentityLink
(
curTask
.
getId
(),
(
String
)
signUser
,
"candidate"
);
//提交当前任务
//saveTask(curTask);
Task
signTask
=
createTask
(
curTask
);
taskService
.
saveTask
(
signTask
);
// taskService.addUserIdentityLink(signTask.getId(), String.valueOf(signUser), "candidate");
taskService
.
complete
(
signTask
.
getId
());
return
true
;
return
true
;
}
}
...
@@ -1478,59 +1463,87 @@ public class WFCoreService
...
@@ -1478,59 +1463,87 @@ public class WFCoreService
}
}
}
}
/**
/**
* 设置流程表单
* 设置流程表单
* @param sequenceFlow
*
* @param way
* @param sequenceFlow
*/
* @param way
private
void
setTaskWayForm
(
SequenceFlow
sequenceFlow
,
WFTaskWay
way
){
*/
if
(!
ObjectUtils
.
isEmpty
(
sequenceFlow
.
getExtensionElements
())){
private
void
setTaskWayForm
(
SequenceFlow
sequenceFlow
,
WFTaskWay
way
)
{
List
<
ExtensionElement
>
formProps
=
sequenceFlow
.
getExtensionElements
().
get
(
"form"
);
Map
<
String
,
String
>
attributes
=
getAllParam
(
sequenceFlow
,
"form"
);
if
(!
ObjectUtils
.
isEmpty
(
formProps
)){
if
(!
ObjectUtils
.
isEmpty
(
attributes
))
{
for
(
ExtensionElement
prop
:
formProps
){
for
(
Map
.
Entry
<
String
,
String
>
entry
:
attributes
.
entrySet
())
{
if
(!
ObjectUtils
.
isEmpty
(
prop
.
getAttributes
())){
way
.
set
(
entry
.
getKey
(),
entry
.
getValue
());
for
(
String
attribute
:
prop
.
getAttributes
().
keySet
()){
}
List
<
ExtensionAttribute
>
attributes
=
prop
.
getAttributes
().
get
(
attribute
);
}
if
(!
ObjectUtils
.
isEmpty
(
attributes
)){
}
for
(
ExtensionAttribute
param:
attributes
){
way
.
set
(
param
.
getName
(),
param
.
getValue
());
}
}
}
}
}
}
}
}
/**
/**
* 将流程表单设置到请求头中
* 将流程表单设置到请求头中
* @param userTask
*
*/
* @param userTask
private
void
setProcessForm
(
UserTask
userTask
){
*/
Object
objReq
=
RequestContextHolder
.
currentRequestAttributes
();
private
void
setProcessForm
(
UserTask
userTask
)
{
if
(!
ObjectUtils
.
isEmpty
(
objReq
)
&&
objReq
instanceof
ServletRequestAttributes
){
Object
objReq
=
RequestContextHolder
.
currentRequestAttributes
();
ServletRequestAttributes
attr
=
(
ServletRequestAttributes
)
RequestContextHolder
.
currentRequestAttributes
();
if
(!
ObjectUtils
.
isEmpty
(
objReq
)
&&
objReq
instanceof
ServletRequestAttributes
)
{
HttpServletRequest
req
=
attr
.
getRequest
();
ServletRequestAttributes
attr
=
(
ServletRequestAttributes
)
RequestContextHolder
.
currentRequestAttributes
();
if
(!
ObjectUtils
.
isEmpty
(
userTask
)
&&
!
ObjectUtils
.
isEmpty
(
userTask
.
getExtensionElements
())){
HttpServletRequest
req
=
attr
.
getRequest
();
List
<
ExtensionElement
>
formProps
=
userTask
.
getExtensionElements
().
get
(
"form"
);
Map
<
String
,
String
>
attributes
=
getAllParam
(
userTask
,
"form"
);
if
(!
ObjectUtils
.
isEmpty
(
formProps
)){
if
(!
ObjectUtils
.
isEmpty
(
attributes
))
{
for
(
ExtensionElement
prop
:
formProps
){
for
(
Map
.
Entry
<
String
,
String
>
entry
:
attributes
.
entrySet
())
{
if
(!
ObjectUtils
.
isEmpty
(
prop
.
getAttributes
())){
req
.
setAttribute
(
entry
.
getKey
(),
entry
.
getValue
());
for
(
String
attribute
:
prop
.
getAttributes
().
keySet
()){
}
List
<
ExtensionAttribute
>
attributes
=
prop
.
getAttributes
().
get
(
attribute
);
}
if
(!
ObjectUtils
.
isEmpty
(
attributes
)){
}
for
(
ExtensionAttribute
param:
attributes
){
}
req
.
setAttribute
(
param
.
getName
(),
param
.
getValue
());
}
/**
}
* 获取流程节点指定参数
}
* @param element
}
* @param property
}
* @param attribute
}
* @return
}
*/
}
public
String
getParam
(
FlowElement
element
,
String
property
,
String
attribute
)
{
}
List
<
ExtensionElement
>
formProps
=
element
.
getExtensionElements
().
get
(
property
);
if
(
formProps
==
null
)
{
return
null
;
}
for
(
ExtensionElement
prop
:
formProps
)
{
if
(
prop
.
getAttributes
()
==
null
)
return
null
;
Map
<
String
,
List
<
ExtensionAttribute
>>
attributes
=
prop
.
getAttributes
();
if
(
attributes
.
containsKey
(
attribute
))
{
return
ObjectUtils
.
isEmpty
(
attributes
.
get
(
attribute
))
?
null
:
String
.
valueOf
(
attributes
.
get
(
attribute
).
get
(
0
).
getValue
());
}
}
return
null
;
}
/**
* 获取流程节点所有参数
* @param element
* @param property
* @return
*/
public
Map
<
String
,
String
>
getAllParam
(
FlowElement
element
,
String
property
)
{
Map
<
String
,
String
>
params
=
new
HashMap
();
List
<
ExtensionElement
>
formProps
=
element
.
getExtensionElements
().
get
(
property
);
if
(
formProps
==
null
)
{
return
null
;
}
for
(
ExtensionElement
prop
:
formProps
)
{
if
(
prop
.
getAttributes
()
==
null
)
return
null
;
Map
<
String
,
List
<
ExtensionAttribute
>>
attributes
=
prop
.
getAttributes
();
for
(
String
attribute
:
attributes
.
keySet
())
{
if
(!
ObjectUtils
.
isEmpty
(
attributes
.
get
(
attribute
)))
{
params
.
put
(
attribute
,
attributes
.
get
(
attribute
).
get
(
0
).
getValue
());
}
}
}
return
params
;
}
/**
/**
* 获取动态实例标识
* 获取动态实例标识
...
@@ -1578,35 +1591,24 @@ public class WFCoreService
...
@@ -1578,35 +1591,24 @@ public class WFCoreService
}
}
}
}
/**
/**
* 获取连接线条件 (all/any/all|role:any)
* 获取连接线条件 (all/any/all|role:any)
*
*
* @param execution
* @param execution
* @param sequenceFlowId
* @param sequenceFlowId
* @return
* @return
*/
*/
public
String
getNextCondition
(
DelegateExecution
execution
,
Object
sequenceFlowId
)
{
public
String
getNextCondition
(
DelegateExecution
execution
,
Object
sequenceFlowId
)
{
if
(!
ObjectUtils
.
isEmpty
(
execution
.
getCurrentFlowElement
())
&&
execution
.
getCurrentFlowElement
()
instanceof
UserTask
)
{
if
(!
ObjectUtils
.
isEmpty
(
execution
.
getCurrentFlowElement
())
&&
execution
.
getCurrentFlowElement
()
instanceof
UserTask
)
{
UserTask
userTask
=
(
UserTask
)
execution
.
getCurrentFlowElement
();
UserTask
userTask
=
(
UserTask
)
execution
.
getCurrentFlowElement
();
for
(
SequenceFlow
flow
:
userTask
.
getOutgoingFlows
())
{
for
(
SequenceFlow
flow
:
userTask
.
getOutgoingFlows
())
{
if
(
sequenceFlowId
.
equals
(
flow
.
getId
())
&&
!
ObjectUtils
.
isEmpty
(
flow
.
getExtensionElements
().
get
(
"form"
)))
{
if
(
sequenceFlowId
.
equals
(
flow
.
getId
()))
{
for
(
ExtensionElement
formProp
:
flow
.
getExtensionElements
().
get
(
"form"
))
{
return
getParam
(
flow
,
"form"
,
"nextCondition"
);
for
(
String
attribute
:
formProp
.
getAttributes
().
keySet
())
{
}
List
<
ExtensionAttribute
>
attributes
=
formProp
.
getAttributes
().
get
(
attribute
);
}
if
(!
ObjectUtils
.
isEmpty
(
attributes
))
{
}
for
(
ExtensionAttribute
param
:
attributes
)
{
return
null
;
if
(
param
.
getName
().
equalsIgnoreCase
(
"nextCondition"
))
{
}
return
param
.
getValue
();
}
}
}
}
}
}
}
}
return
null
;
}
/**
/**
* 获取用户所属的工作流角色
* 获取用户所属的工作流角色
...
@@ -1614,69 +1616,55 @@ public class WFCoreService
...
@@ -1614,69 +1616,55 @@ public class WFCoreService
* @param execution
* @param execution
* @return
* @return
*/
*/
public
Set
<
String
>
getRoleByUserId
(
String
userId
,
DelegateExecution
execution
)
{
public
Set
<
String
>
getRoleByUserId
(
String
userId
,
DelegateExecution
execution
)
{
Set
roles
=
new
HashSet
();
Set
roles
=
new
HashSet
();
if
(!
ObjectUtils
.
isEmpty
(
userId
)){
if
(!
ObjectUtils
.
isEmpty
(
userId
))
{
UserTask
task
=
(
UserTask
)
execution
.
getCurrentFlowElement
();
String
candidateUsers
=
getParam
(
execution
.
getCurrentFlowElement
(),
"form"
,
"candidateUsersList"
);
List
fieldList
=
task
.
getExtensionElements
().
get
(
"field"
);
if
(!
StringUtils
.
isEmpty
(
candidateUsers
))
{
String
strCandidate
=
""
;
LinkedHashMap
executionMap
=
(
LinkedHashMap
)
execution
.
getVariable
(
"activedata"
);
if
(!
ObjectUtils
.
isEmpty
(
fieldList
)){
String
[]
groups
=
candidateUsers
.
split
(
"\\|\\|"
);
for
(
Object
field
:
fieldList
)
{
if
(
groups
.
length
>
0
)
{
if
(!
ObjectUtils
.
isEmpty
(((
ExtensionElement
)
field
).
getAttributes
())){
for
(
String
group
:
groups
)
{
List
<
ExtensionAttribute
>
attributes
=
((
ExtensionElement
)
field
).
getAttributes
().
get
(
"name"
);
if
(
group
.
contains
(
"activedata"
))
{
if
(
attributes
.
size
()
>
0
){
for
(
String
elUserId
:
group
.
split
(
"\\|"
))
{
if
(
attributes
.
get
(
0
).
getValue
().
equals
(
"candidateUsersList"
)){
ExpressionParser
parser
=
new
SpelExpressionParser
();
strCandidate
=
((
ExtensionElement
)
field
).
getChildElements
().
get
(
"string"
).
get
(
0
).
getElementText
();
StandardEvaluationContext
context
=
new
StandardEvaluationContext
();
break
;
Expression
exp
=
parser
.
parseExpression
(
elUserId
);
}
context
.
addPropertyAccessor
(
new
MapAccessor
());
}
context
.
setVariable
(
"activedata"
,
executionMap
);
}
String
processUserId
=
exp
.
getValue
(
context
,
String
.
class
);
}
if
(!
StringUtils
.
isEmpty
(
processUserId
)
&&
processUserId
.
contains
(
userId
))
{
}
roles
.
add
(
group
);
LinkedHashMap
executionMap
=
(
LinkedHashMap
)
execution
.
getVariable
(
"activedata"
);
}
String
[]
groups
=
strCandidate
.
split
(
"\\|\\|"
);
}
if
(
groups
.
length
>
0
)
{
}
for
(
String
group
:
groups
)
{
if
(
group
.
contains
(
"wfCoreService.getGroupUsers"
))
{
if
(
group
.
contains
(
"activedata"
))
{
String
exp
=
group
;
for
(
String
elUserId
:
group
.
split
(
"\\|"
))
{
EvaluationContext
oldContext
=
new
StandardEvaluationContext
();
ExpressionParser
parser
=
new
SpelExpressionParser
();
oldContext
.
setVariable
(
"wfCoreService"
,
this
);
StandardEvaluationContext
context
=
new
StandardEvaluationContext
();
oldContext
.
setVariable
(
"execution"
,
execution
);
Expression
exp
=
parser
.
parseExpression
(
elUserId
);
Expression
oldExp
=
parser
.
parseExpression
(
exp
);
context
.
addPropertyAccessor
(
new
MapAccessor
());
List
<
WFMember
>
users
=
oldExp
.
getValue
(
oldContext
,
List
.
class
);
context
.
setVariable
(
"activedata"
,
executionMap
);
if
(!
StringUtils
.
isEmpty
(
users
))
{
String
processUserId
=
exp
.
getValue
(
context
,
String
.
class
);
users
.
forEach
(
groupMember
->
{
if
(!
StringUtils
.
isEmpty
(
processUserId
)
&&
processUserId
.
contains
(
userId
)){
if
(!
ObjectUtils
.
isEmpty
(
groupMember
.
getUserid
())
&&
userId
.
equals
(
groupMember
.
getUserid
()))
{
roles
.
add
(
group
);
String
roleId
;
}
if
(!
ObjectUtils
.
isEmpty
(
groupMember
.
getMdeptid
()))
{
}
roleId
=
String
.
format
(
"%s_%s"
,
groupMember
.
getGroupid
(),
groupMember
.
getMdeptid
());
}
}
else
{
if
(
group
.
contains
(
"wfCoreService.getGroupUsers"
))
{
roleId
=
groupMember
.
getGroupid
();
String
exp
=
group
;
}
EvaluationContext
oldContext
=
new
StandardEvaluationContext
();
roles
.
add
(
roleId
);
oldContext
.
setVariable
(
"wfCoreService"
,
this
);
}
oldContext
.
setVariable
(
"execution"
,
execution
);
});
Expression
oldExp
=
parser
.
parseExpression
(
exp
);
}
List
<
WFMember
>
users
=
oldExp
.
getValue
(
oldContext
,
List
.
class
);
}
if
(!
StringUtils
.
isEmpty
(
users
))
{
}
users
.
forEach
(
groupMember
->{
}
if
(!
ObjectUtils
.
isEmpty
(
groupMember
.
getUserid
())
&&
userId
.
equals
(
groupMember
.
getUserid
())){
}
String
roleId
;
}
if
(!
ObjectUtils
.
isEmpty
(
groupMember
.
getMdeptid
())){
return
roles
;
roleId
=
String
.
format
(
"%s_%s"
,
groupMember
.
getGroupid
(),
groupMember
.
getMdeptid
());
}
}
else
{
roleId
=
groupMember
.
getGroupid
();
}
roles
.
add
(
roleId
);
}
});
}
}
}
}
}
return
roles
;
}
/**
/**
* 创建任务
* 创建任务
...
@@ -1739,7 +1727,7 @@ public class WFCoreService
...
@@ -1739,7 +1727,7 @@ public class WFCoreService
public
Set
<
String
>
getUsersByRole
(
Set
roles
,
DelegateExecution
execution
)
{
public
Set
<
String
>
getUsersByRole
(
Set
roles
,
DelegateExecution
execution
)
{
Set
userIds
=
new
HashSet
();
Set
userIds
=
new
HashSet
();
if
(!
ObjectUtils
.
isEmpty
(
roles
))
{
if
(!
ObjectUtils
.
isEmpty
(
roles
))
{
String
candidateUsers
=
getCandidateUsers
(
execution
);
String
candidateUsers
=
getParam
(
execution
.
getCurrentFlowElement
(),
"form"
,
"candidateUsersList"
);
if
(!
StringUtils
.
isEmpty
(
candidateUsers
))
{
if
(!
StringUtils
.
isEmpty
(
candidateUsers
))
{
LinkedHashMap
executionMap
=
(
LinkedHashMap
)
execution
.
getVariable
(
"activedata"
);
LinkedHashMap
executionMap
=
(
LinkedHashMap
)
execution
.
getVariable
(
"activedata"
);
String
[]
groups
=
candidateUsers
.
split
(
"\\|\\|"
);
String
[]
groups
=
candidateUsers
.
split
(
"\\|\\|"
);
...
@@ -1787,29 +1775,23 @@ public class WFCoreService
...
@@ -1787,29 +1775,23 @@ public class WFCoreService
return
userIds
;
return
userIds
;
}
}
/**
/**
* 获取步骤审批用户
* 审批记录
* @param execution
* @param curTask
* @return
* @return
*/
*/
private
String
getCandidateUsers
(
DelegateExecution
execution
){
private
Task
saveTask
(
Task
curTask
){
String
strCandidateUsers
=
""
;
String
userId
=
"0100"
;
UserTask
task
=
(
UserTask
)
execution
.
getCurrentFlowElement
();
if
(
StringUtils
.
isEmpty
(
userId
))
List
fieldList
=
task
.
getExtensionElements
().
get
(
"field"
);
if
(
StringUtils
.
isEmpty
(
userId
))
if
(!
ObjectUtils
.
isEmpty
(
fieldList
)){
throw
new
BadRequestAlertException
(
"未传入当前用户"
,
""
,
""
);
for
(
Object
field
:
fieldList
)
{
if
(!
ObjectUtils
.
isEmpty
(((
ExtensionElement
)
field
).
getAttributes
())){
Task
signTask
=
createTask
(
curTask
);
List
<
ExtensionAttribute
>
attributes
=
((
ExtensionElement
)
field
).
getAttributes
().
get
(
"name"
);
signTask
.
setParentTaskId
(
curTask
.
getId
());
if
(
attributes
.
size
()
>
0
){
taskService
.
saveTask
(
signTask
);
if
(
attributes
.
get
(
0
).
getValue
().
equals
(
"candidateUsersList"
)){
taskService
.
addUserIdentityLink
(
signTask
.
getId
(),
userId
,
"candidate"
);
strCandidateUsers
=
((
ExtensionElement
)
field
).
getChildElements
().
get
(
"string"
).
get
(
0
).
getElementText
();
taskService
.
complete
(
signTask
.
getId
());
break
;
return
signTask
;
}
}
}
}
}
}
return
strCandidateUsers
;
}
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录