Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzwf
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzwf
提交
215063f9
提交
215063f9
编写于
3月 24, 2021
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
加签、待阅
上级
fdf1e93d
变更
2
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
149 行增加
和
144 行删除
+149
-144
WFCoreService.java
...izlab/core/workflow/extensions/service/WFCoreService.java
+118
-144
ProcFunction.java
...til/src/main/java/cn/ibizlab/util/enums/ProcFunction.java
+31
-0
未找到文件。
ibzwf-core/src/main/java/cn/ibizlab/core/workflow/extensions/service/WFCoreService.java
浏览文件 @
215063f9
...
@@ -8,6 +8,7 @@ import cn.ibizlab.core.workflow.service.IWFGroupService;
...
@@ -8,6 +8,7 @@ import cn.ibizlab.core.workflow.service.IWFGroupService;
import
cn.ibizlab.core.workflow.service.IWFProcessDefinitionService
;
import
cn.ibizlab.core.workflow.service.IWFProcessDefinitionService
;
import
cn.ibizlab.core.workflow.service.IWFUserService
;
import
cn.ibizlab.core.workflow.service.IWFUserService
;
import
cn.ibizlab.util.client.IBZUAAFeignClient
;
import
cn.ibizlab.util.client.IBZUAAFeignClient
;
import
cn.ibizlab.util.enums.ProcFunction
;
import
cn.ibizlab.util.enums.TaskType
;
import
cn.ibizlab.util.enums.TaskType
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.RuleUtils
;
import
cn.ibizlab.util.helper.RuleUtils
;
...
@@ -33,7 +34,6 @@ import org.flowable.engine.history.HistoricProcessInstance;
...
@@ -33,7 +34,6 @@ import org.flowable.engine.history.HistoricProcessInstance;
import
org.flowable.engine.history.ProcessInstanceHistoryLog
;
import
org.flowable.engine.history.ProcessInstanceHistoryLog
;
import
org.flowable.engine.repository.Deployment
;
import
org.flowable.engine.repository.Deployment
;
import
org.flowable.engine.repository.DeploymentBuilder
;
import
org.flowable.engine.repository.DeploymentBuilder
;
import
org.flowable.engine.repository.ProcessDefinition
;
import
org.flowable.engine.runtime.ProcessInstance
;
import
org.flowable.engine.runtime.ProcessInstance
;
import
org.flowable.engine.task.Comment
;
import
org.flowable.engine.task.Comment
;
import
org.flowable.identitylink.api.IdentityLink
;
import
org.flowable.identitylink.api.IdentityLink
;
...
@@ -429,6 +429,7 @@ public class WFCoreService
...
@@ -429,6 +429,7 @@ public class WFCoreService
Map
<
String
,
Object
>
params
=
new
HashMap
();
Map
<
String
,
Object
>
params
=
new
HashMap
();
params
.
put
(
"srfprocessdefinitionkey"
,
task
.
getProcessdefinitionkey
());
params
.
put
(
"srfprocessdefinitionkey"
,
task
.
getProcessdefinitionkey
());
params
.
put
(
"srftaskdefinitionkey"
,
task
.
getTaskdefinitionkey
());
params
.
put
(
"srftaskdefinitionkey"
,
task
.
getTaskdefinitionkey
());
params
.
put
(
"srftaskid"
,
task
.
getId
());
businessKeys
.
put
(
str
,
params
);
businessKeys
.
put
(
str
,
params
);
}
}
}
}
...
@@ -539,6 +540,20 @@ public class WFCoreService
...
@@ -539,6 +540,20 @@ public class WFCoreService
//设置流程表单
//设置流程表单
setProcessForm
(
userTask
);
setProcessForm
(
userTask
);
if
(
userTask
!=
null
&&
userTask
.
getOutgoingFlows
()!=
null
)
{
if
(
userTask
!=
null
&&
userTask
.
getOutgoingFlows
()!=
null
)
{
//加签逻辑
String
procFuncs
=
getParam
(
userTask
,
"form"
,
"procfunc"
);
if
(
DelegationState
.
PENDING
==
task
.
getDelegationState
()
&&
userId
.
equals
(
task
.
getAssignee
())
&&
!
StringUtils
.
isEmpty
(
procFuncs
)
&&
procFuncs
.
contains
(
ProcFunction
.
BEFORESIGN
.
value
)){
WFTaskWay
way
=
getFuncWay
(
task
,
ProcFunction
.
FINISH
.
value
);
if
(
way
!=
null
)
taskWays
.
add
(
way
);
return
taskWays
;
}
//流程辅助功能
List
<
WFTaskWay
>
functions
=
getProcessFunc
(
task
,
userTask
);
if
(
functions
.
size
()
>
0
)
{
taskWays
.
addAll
(
functions
);
}
for
(
SequenceFlow
sequenceFlow:
userTask
.
getOutgoingFlows
())
{
for
(
SequenceFlow
sequenceFlow:
userTask
.
getOutgoingFlows
())
{
WFTaskWay
way
=
new
WFTaskWay
();
WFTaskWay
way
=
new
WFTaskWay
();
way
.
setSequenceflowid
(
sequenceFlow
.
getId
());
way
.
setSequenceflowid
(
sequenceFlow
.
getId
());
...
@@ -588,101 +603,60 @@ public class WFCoreService
...
@@ -588,101 +603,60 @@ public class WFCoreService
setTaskWayForm
(
sequenceFlow
,
way
);
setTaskWayForm
(
sequenceFlow
,
way
);
taskWays
.
add
(
way
);
taskWays
.
add
(
way
);
}
}
LinkedHashMap
rollBackMap
=
getTaskProcessForm
(
userTask
);
if
(
rollBackMap
.
size
()>
0
){
WFTaskWay
rollBackWay
=
new
WFTaskWay
();
rollBackWay
.
set
(
"rollback"
,
rollBackMap
.
get
(
"rollback"
));
taskWays
.
add
(
rollBackWay
);
}
}
}
}
}
return
taskWays
;
return
taskWays
;
}
}
public
static
LinkedHashMap
getTaskProcessForm
(
UserTask
userTask
){
/**
* 流程辅助功能
if
(
ObjectUtils
.
isEmpty
(
userTask
)){
* @param userTask
return
null
;
* @return
}
*/
List
<
ExtensionElement
>
elements
=
userTask
.
getExtensionElements
().
get
(
"form"
);
private
List
<
WFTaskWay
>
getProcessFunc
(
Task
task
,
UserTask
userTask
)
{
if
(
ObjectUtils
.
isEmpty
(
elements
)){
List
<
WFTaskWay
>
taskWays
=
new
ArrayList
<>();
return
null
;
String
procFuncs
=
getParam
(
userTask
,
"form"
,
"procfunc"
);
}
if
(!
StringUtils
.
isEmpty
(
procFuncs
)){
LinkedHashMap
processMap
=
new
LinkedHashMap
();
for
(
String
func
:
procFuncs
.
split
(
";"
)){
for
(
ExtensionElement
element
:
elements
)
{
WFTaskWay
taskWay
=
getFuncWay
(
task
,
func
);
List
<
ExtensionAttribute
>
extensionAttributes
=
element
.
getAttributes
().
get
(
"process-form"
);
if
(
taskWay
!=
null
)
if
(!
ObjectUtils
.
isEmpty
(
extensionAttributes
)){
taskWays
.
add
(
taskWay
);
for
(
ExtensionAttribute
attribute
:
extensionAttributes
)
{
String
[]
keyValue
=
attribute
.
getValue
().
split
(
":"
);
if
(
keyValue
.
length
>
1
){
processMap
.
put
(
keyValue
[
0
],
keyValue
[
1
]);
}
}
}
}
}
}
return
processMap
;
return
taskWays
;
}
}
/**
/**
* @param taskId 当前需要回退的节点
* 流程辅助功能连接
* @return 回退上一个节点
* @param funcType
* @return
*/
*/
public
boolean
wfback
(
String
system
,
String
appname
,
String
entity
,
String
taskId
)
{
public
WFTaskWay
getFuncWay
(
Task
task
,
String
funcType
){
try
{
WFTaskWay
way
=
new
WFTaskWay
();
Boolean
flag
=
true
;
if
(
funcType
.
equals
(
ProcFunction
.
ROLLBACK
.
value
)){
String
sourceRef
=
null
;
way
.
set
(
"type"
,
ProcFunction
.
ROLLBACK
.
value
);
Task
task
=
taskService
.
createTaskQuery
().
taskId
(
taskId
).
singleResult
();
way
.
setSequenceflowname
(
ProcFunction
.
ROLLBACK
.
text
);
String
taskDefinitionKey
=
task
.
getTaskDefinitionKey
();
if
(
taskDefinitionKey
==
null
)
{
log
.
debug
(
"taskDefinitionKey不存在"
);
return
false
;
}
String
processInstanceId
=
task
.
getProcessInstanceId
();
if
(
processInstanceId
==
null
)
{
log
.
debug
(
"processInstanceId不存在"
);
return
false
;
}
ProcessDefinition
processDefinition
=
repositoryService
.
createProcessDefinitionQuery
().
processDefinitionId
(
task
.
getProcessDefinitionId
()).
singleResult
();
BpmnModel
bpmnModel
=
repositoryService
.
getBpmnModel
(
processDefinition
.
getId
());
FlowNode
flowNode
=
(
FlowNode
)
bpmnModel
.
getFlowElement
(
task
.
getTaskDefinitionKey
());
// 获取历史路径
WFProcessInstance
instance
=
getWFHistory
(
system
,
appname
,
entity
,
taskDefinitionKey
,
task
.
getProcessInstanceId
());
if
(!
ObjectUtils
.
isEmpty
(
flowNode
)
&&
!
ObjectUtils
.
isEmpty
(
instance
))
{
List
<
WFProcessNode
>
usertasks
=
new
ArrayList
((
Collection
<?
extends
WFProcessNode
>)
instance
.
getExtensionparams
().
get
(
"usertasks"
));
for
(
WFProcessNode
node
:
usertasks
)
{
for
(
SequenceFlow
flow
:
flowNode
.
getIncomingFlows
())
{
if
(
node
.
getUsertaskid
().
equals
(
flow
.
getSourceRef
())&&
flow
.
getSourceRef
().
startsWith
(
"tid"
))
{
sourceRef
=
flow
.
getSourceRef
();
flag
=
false
;
break
;
}
}
else
if
(
funcType
.
equals
(
ProcFunction
.
BEFORESIGN
.
value
)){
way
.
set
(
"type"
,
ProcFunction
.
BEFORESIGN
.
value
);
way
.
setSequenceflowname
(
ProcFunction
.
BEFORESIGN
.
text
);
}
}
if
(!
flag
)
{
else
if
(
funcType
.
equals
(
ProcFunction
.
TURN
.
value
)){
break
;
way
.
set
(
"type"
,
ProcFunction
.
TURN
.
value
);
way
.
setSequenceflowname
(
ProcFunction
.
TURN
.
text
);
}
}
else
if
(
funcType
.
equals
(
ProcFunction
.
FINISH
.
value
)){
way
.
set
(
"type"
,
ProcFunction
.
FINISH
.
value
);
way
.
setSequenceflowname
(
ProcFunction
.
FINISH
.
text
);
}
}
}
else
{
else
{
return
false
;
return
null
;
}
// 执行回退
runtimeService
.
createChangeActivityStateBuilder
().
processInstanceId
(
processInstanceId
).
moveActivityIdTo
(
taskDefinitionKey
,
sourceRef
).
changeState
();
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"回退失败"
,
"WFCoreService"
,
"wfback"
);
}
}
return
true
;
way
.
setTaskid
(
task
.
getId
());
way
.
setTaskdefinitionkey
(
task
.
getTaskDefinitionKey
());
return
way
;
}
}
// public void delegateTask(String taskId,String delegater) {
// String userId = SecurityUtils.getCurrentUserObject().getId();
// Task task = permissionService.validateDelegatePermissionOnTask(taskId, userId, delegater);
// taskService.addComment(taskId, processInstanceId, type.toString(), message);
// taskService.delegateTask(task.getId(), delegater);
// }
public
WFProcessInstance
wfsubmit
(
String
system
,
String
appname
,
public
WFProcessInstance
wfsubmit
(
String
system
,
String
appname
,
String
entity
,
String
businessKey
,
String
taskId
,
WFTaskWay
taskWay
)
{
String
entity
,
String
businessKey
,
String
taskId
,
WFTaskWay
taskWay
)
{
...
@@ -1119,7 +1093,7 @@ public class WFCoreService
...
@@ -1119,7 +1093,7 @@ public class WFCoreService
bpmnLayout
.
execute
();
bpmnLayout
.
execute
();
byte
[]
bs
=
bpmnXMLConverter
.
convertToXML
(
entitymodel
);
byte
[]
bs
=
bpmnXMLConverter
.
convertToXML
(
entitymodel
);
bmpmfileId
=
DigestUtils
.
md5DigestAsHex
(
bs
);
bmpmfileId
=
DigestUtils
.
md5DigestAsHex
(
bs
);
if
(
bmpmfileId
.
equals
(
1
))
if
(
bmpmfileId
.
equals
(
old
.
getMd5check
()
))
{
{
log
.
warn
(
"部署流程没有变化,忽略 name:"
+
curProcess
.
getName
()
+
" key "
+
processDefinitionKey
+
" deploy "
+
bmpmfileId
);
log
.
warn
(
"部署流程没有变化,忽略 name:"
+
curProcess
.
getName
()
+
" key "
+
processDefinitionKey
+
" deploy "
+
bmpmfileId
);
deployInfo
+=
curProcess
.
getName
()+
" key:"
+
processDefinitionKey
+
",流程配置没有变化,忽略发布"
+
"\r\n"
;
deployInfo
+=
curProcess
.
getName
()+
" key:"
+
processDefinitionKey
+
",流程配置没有变化,忽略发布"
+
"\r\n"
;
...
@@ -1413,8 +1387,8 @@ public class WFCoreService
...
@@ -1413,8 +1387,8 @@ public class WFCoreService
if
(
StringUtils
.
isEmpty
(
userId
))
if
(
StringUtils
.
isEmpty
(
userId
))
throw
new
BadRequestAlertException
(
"未传入当前用户"
,
entity
,
businessKey
);
throw
new
BadRequestAlertException
(
"未传入当前用户"
,
entity
,
businessKey
);
Object
signUsers
=
taskWay
.
get
(
"users
"
);
Object
signUser
=
taskWay
.
get
(
"srfwfannotator
"
);
if
(
ObjectUtils
.
isEmpty
(
signUsers
))
{
if
(
ObjectUtils
.
isEmpty
(
signUser
))
{
throw
new
BadRequestAlertException
(
"未传入加签用户"
,
entity
,
businessKey
);
throw
new
BadRequestAlertException
(
"未传入加签用户"
,
entity
,
businessKey
);
}
}
Task
curTask
=
taskService
.
createTaskQuery
().
taskId
(
taskId
).
singleResult
();
Task
curTask
=
taskService
.
createTaskQuery
().
taskId
(
taskId
).
singleResult
();
...
@@ -1422,7 +1396,7 @@ public class WFCoreService
...
@@ -1422,7 +1396,7 @@ public class WFCoreService
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
));
taskService
.
delegateTask
(
taskId
,
String
.
valueOf
(
signUser
));
//saveTask(curTask);
//saveTask(curTask);
}
else
{
}
else
{
throw
new
BadRequestAlertException
(
String
.
format
(
"任务正在加签中,无法进行二次加签"
,
curTask
.
getId
()),
""
,
""
);
throw
new
BadRequestAlertException
(
String
.
format
(
"任务正在加签中,无法进行二次加签"
,
curTask
.
getId
()),
""
,
""
);
...
@@ -1445,7 +1419,7 @@ public class WFCoreService
...
@@ -1445,7 +1419,7 @@ public class WFCoreService
if
(
StringUtils
.
isEmpty
(
userId
))
if
(
StringUtils
.
isEmpty
(
userId
))
throw
new
BadRequestAlertException
(
"未传入当前用户"
,
entity
,
businessKey
);
throw
new
BadRequestAlertException
(
"未传入当前用户"
,
entity
,
businessKey
);
Object
signUser
=
taskWay
.
get
(
"
users
"
);
Object
signUser
=
taskWay
.
get
(
"
srfwftransfertor
"
);
if
(
ObjectUtils
.
isEmpty
(
signUser
))
{
if
(
ObjectUtils
.
isEmpty
(
signUser
))
{
throw
new
BadRequestAlertException
(
"未传入转办用户"
,
entity
,
businessKey
);
throw
new
BadRequestAlertException
(
"未传入转办用户"
,
entity
,
businessKey
);
}
}
...
...
ibzwf-util/src/main/java/cn/ibizlab/util/enums/ProcFunction.java
0 → 100644
浏览文件 @
215063f9
package
cn
.
ibizlab
.
util
.
enums
;
/**
* 工作流辅助功能
*/
public
enum
ProcFunction
{
/**
* 退回
*/
ROLLBACK
(
"rollback"
,
"退回"
),
/**
* 前加签
*/
BEFORESIGN
(
"beforesign"
,
"前加签"
),
/**
* 转办
*/
TURN
(
"turn"
,
"转办"
),
/**
* 加签完成
*/
FINISH
(
"finish"
,
"完成"
);
ProcFunction
(
String
value
,
String
text
)
{
this
.
value
=
value
;
this
.
text
=
text
;
}
public
String
value
;
public
String
text
;
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录