Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzwf
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzwf
提交
e8479c03
提交
e8479c03
编写于
3月 15, 2021
作者:
lengyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
工作流多实例、下一步条件
上级
a0f8852c
变更
1
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
229 行增加
和
0 行删除
+229
-0
WFCoreService.java
...izlab/core/workflow/extensions/service/WFCoreService.java
+229
-0
未找到文件。
ibzwf-core/src/main/java/cn/ibizlab/core/workflow/extensions/service/WFCoreService.java
浏览文件 @
e8479c03
...
...
@@ -53,8 +53,14 @@ import org.flowable.ui.modeler.serviceapi.AppDefinitionService;
import
org.flowable.ui.modeler.serviceapi.ModelService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.expression.MapAccessor
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.expression.EvaluationContext
;
import
org.springframework.expression.Expression
;
import
org.springframework.expression.ExpressionParser
;
import
org.springframework.expression.spel.standard.SpelExpressionParser
;
import
org.springframework.expression.spel.support.StandardEvaluationContext
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -119,6 +125,7 @@ public class WFCoreService
private
Map
<
String
,
List
<
Map
<
String
,
Object
>>>
taskMap
=
new
ConcurrentHashMap
<>();
private
final
ExpressionParser
parser
=
new
SpelExpressionParser
();
private
AuthenticationContext
createAuthenticationContext
()
{
...
...
@@ -1271,6 +1278,93 @@ public class WFCoreService
return
strUsers
;
}
/**
* 返回组成员,用于多实例会签( wfroleid = groupid +deptid )
* @param groupIds
* @param delegateExecution
* @return
*/
public
List
<
WFMember
>
getGroupUsers2
(
String
groupIds
,
DelegateExecution
delegateExecution
)
{
List
<
WFMember
>
users
=
new
ArrayList
<>();
if
(
StringUtils
.
isEmpty
(
groupIds
))
return
users
;
String
[]
groups
=
groupIds
.
split
(
","
);
for
(
String
groupId:
groups
)
{
String
userData
=
""
;
String
userData2
=
""
;
String
orgid
=
""
;
String
deptid
=
""
;
if
(
groupId
.
indexOf
(
"|"
)>
0
)
{
String
[]
arg
=
groupId
.
split
(
"[|]"
);
if
(
arg
.
length
==
3
)
{
groupId
=
arg
[
0
];
if
(
arg
[
1
]!=
null
)
userData
=
arg
[
1
].
toLowerCase
();
if
(
arg
[
2
]!=
null
)
userData2
=
arg
[
2
].
toLowerCase
();
}
}
if
((!
StringUtils
.
isEmpty
(
userData
))&&(!
StringUtils
.
isEmpty
(
userData2
)))
{
if
(
userData2
.
indexOf
(
"srf"
)==
0
)
{
FlowUser
curUser
=
FlowUser
.
getCurUser
();
if
(
curUser
!=
null
&&
curUser
.
getUser
()!=
null
)
{
Object
sessionValue
=
curUser
.
getUser
().
getSessionParams
().
get
(
userData2
);
if
(
sessionValue
!=
null
)
userData2
=
sessionValue
.
toString
();
else
userData2
=
""
;
}
else
userData2
=
""
;
}
else
{
Object
activedata
=
delegateExecution
.
getVariable
(
"activedata"
);
if
(
activedata
!=
null
&&
activedata
instanceof
Map
)
{
Map
entity
=
(
Map
)
activedata
;
if
(
entity
.
get
(
userData2
)!=
null
)
userData2
=
entity
.
get
(
userData2
).
toString
();
else
userData2
=
""
;
}
else
userData2
=
""
;
}
if
(!
StringUtils
.
isEmpty
(
userData2
))
{
if
(
userData
.
indexOf
(
"dept"
)>=
0
||
userData
.
indexOf
(
"orgsec"
)>=
0
)
deptid
=
userData2
;
else
if
(
userData
.
indexOf
(
"org"
)>=
0
)
orgid
=
userData2
;
}
}
WFGroup
group
=
iwfGroupService
.
get
(
groupId
);
List
<
WFMember
>
list
=
group
.
getWfmember
();
if
(
list
!=
null
)
{
for
(
WFMember
member
:
list
)
{
if
((!
StringUtils
.
isEmpty
(
deptid
))&&(!
deptid
.
equals
(
member
.
getMdeptid
())))
continue
;
if
((!
StringUtils
.
isEmpty
(
orgid
))&&(!
orgid
.
equals
(
member
.
getOrgid
())))
continue
;
users
.
add
(
member
);
}
}
}
return
users
;
}
private
ByteArrayOutputStream
getBpmnFile
(
InputStream
input
)
{
try
{
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
...
...
@@ -1359,4 +1453,139 @@ public class WFCoreService
}
return
dynainstid
;
}
/**
* 判断是否退出会签
* @param execution
* @return
*/
public
boolean
accessCondition
(
DelegateExecution
execution
)
{
Object
allRolesCnt
=
execution
.
getVariable
(
"all_roles_cnt"
);
Object
completeRolesCnt
=
execution
.
getVariable
(
"complete_roles_cnt"
);
Object
completeInstance
=
execution
.
getVariable
(
"nrOfCompletedInstances"
);
Object
allInstance
=
execution
.
getVariable
(
"nrOfInstances"
);
Object
sequenceFlowId
=
execution
.
getVariable
(
"sequenceFlowId"
);
String
flowAccessCond
=
getNextCondition
(
execution
,
sequenceFlowId
);
// role : any || all
if
(!
ObjectUtils
.
isEmpty
(
allInstance
)
&&
!
ObjectUtils
.
isEmpty
(
completeInstance
)
&&
!
ObjectUtils
.
isEmpty
(
flowAccessCond
))
{
if
(
"ANY"
.
equalsIgnoreCase
(
flowAccessCond
)){
return
true
;
}
else
if
(
"ALL|ROLE:ANY"
.
equalsIgnoreCase
(
flowAccessCond
)
&&
allRolesCnt
==
completeRolesCnt
)
{
return
true
;
}
else
{
return
(
int
)
completeInstance
/
(
int
)
allInstance
==
1
;
}
}
else
{
return
false
;
}
}
/**
* 获取连接线条件 (all/any/all|role:any)
*
* @param execution
* @param sequenceFlowId
* @return
*/
private
String
getNextCondition
(
DelegateExecution
execution
,
Object
sequenceFlowId
)
{
if
(!
ObjectUtils
.
isEmpty
(
execution
.
getCurrentFlowElement
())
&&
execution
.
getCurrentFlowElement
()
instanceof
UserTask
)
{
UserTask
userTask
=
(
UserTask
)
execution
.
getCurrentFlowElement
();
for
(
SequenceFlow
flow
:
userTask
.
getOutgoingFlows
())
{
if
(
sequenceFlowId
.
equals
(
flow
.
getId
())
&&
!
ObjectUtils
.
isEmpty
(
flow
.
getExtensionElements
().
get
(
"form"
)))
{
for
(
ExtensionElement
formProp
:
flow
.
getExtensionElements
().
get
(
"form"
))
{
for
(
String
attribute
:
formProp
.
getAttributes
().
keySet
())
{
List
<
ExtensionAttribute
>
attributes
=
formProp
.
getAttributes
().
get
(
attribute
);
if
(!
ObjectUtils
.
isEmpty
(
attributes
))
{
for
(
ExtensionAttribute
param
:
attributes
)
{
if
(
param
.
getName
().
equalsIgnoreCase
(
"nextCondition"
))
{
return
param
.
getValue
();
}
}
}
}
}
}
}
}
return
null
;
}
/**
* role:any 认领当前任务,挂起将role中其他人任务
* @param execution
*/
public
void
ClaimTask
(
DelegateExecution
execution
)
{
}
/**
* 获取用户所属的工作流角色
* @param userId
* @param execution
* @return
*/
public
Set
<
String
>
getRoleByUserId
(
String
userId
,
DelegateExecution
execution
)
{
Set
roles
=
new
HashSet
();
if
(!
ObjectUtils
.
isEmpty
(
userId
)){
UserTask
task
=
(
UserTask
)
execution
.
getCurrentFlowElement
();
List
fieldList
=
task
.
getExtensionElements
().
get
(
"field"
);
String
strCandidate
=
""
;
if
(!
ObjectUtils
.
isEmpty
(
fieldList
)){
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
;
}
}
}
}
}
LinkedHashMap
executionMap
=
(
LinkedHashMap
)
execution
.
getVariable
(
"activedata"
);
String
[]
groups
=
strCandidate
.
split
(
"\\|\\|"
);
if
(
groups
.
length
>
0
)
{
for
(
String
group
:
groups
)
{
if
(
group
.
contains
(
"activedata"
))
{
for
(
String
elUserId
:
group
.
split
(
"\\|"
))
{
ExpressionParser
parser
=
new
SpelExpressionParser
();
StandardEvaluationContext
context
=
new
StandardEvaluationContext
();
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
);
}
}
}
if
(
group
.
contains
(
"wfCoreService.getGroupUsers"
))
{
String
exp
=
group
;
EvaluationContext
oldContext
=
new
StandardEvaluationContext
();
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
())){
roleId
=
String
.
format
(
"%s_%s"
,
groupMember
.
getGroupid
(),
groupMember
.
getMdeptid
());
}
else
{
roleId
=
groupMember
.
getGroupid
();
}
roles
.
add
(
roleId
);
}
});
}
}
}
}
}
return
roles
;
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录