Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzwf
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzwf
提交
41ace484
提交
41ace484
编写于
5月 22, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
工作流审批意见
上级
dd174a92
变更
4
展开全部
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
266 行增加
和
60 行删除
+266
-60
FlowUser.java
...main/java/cn/ibizlab/core/extensions/domain/FlowUser.java
+49
-0
ProcessInstanceListener.java
...lab/core/extensions/listener/ProcessInstanceListener.java
+42
-34
WFCoreService.java
...ava/cn/ibizlab/core/extensions/service/WFCoreService.java
+165
-26
WFCoreResource.java
...n/java/cn/ibizlab/api/rest/extensions/WFCoreResource.java
+10
-0
未找到文件。
ibzwf-core/src/main/java/cn/ibizlab/core/extensions/domain/FlowUser.java
0 → 100644
浏览文件 @
41ace484
package
cn
.
ibizlab
.
core
.
extensions
.
domain
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
org.flowable.common.engine.api.identity.AuthenticationContext
;
import
org.flowable.common.engine.impl.identity.Authentication
;
import
java.security.Principal
;
public
class
FlowUser
implements
Principal
{
public
String
getName
()
{
return
this
.
user
.
getUserid
();
}
private
AuthenticationUser
user
;
private
String
token
;
public
AuthenticationUser
getUser
()
{
return
user
;
}
public
void
setUser
(
AuthenticationUser
user
)
{
this
.
user
=
user
;
}
public
String
getToken
()
{
return
token
;
}
public
void
setToken
(
String
token
)
{
this
.
token
=
token
;
}
public
static
FlowUser
getCurUser
()
{
AuthenticationContext
context
=
Authentication
.
getAuthenticationContext
();
if
(
context
!=
null
&&
context
.
getPrincipal
()!=
null
&&
context
.
getPrincipal
()
instanceof
FlowUser
)
return
(
FlowUser
)
context
.
getPrincipal
();
else
{
FlowUser
user
=
new
FlowUser
();
user
.
setUser
(
AuthenticationUser
.
getAuthenticationUser
());
return
user
;
}
}
}
ibzwf-core/src/main/java/cn/ibizlab/core/extensions/listener/ProcessInstanceListener.java
浏览文件 @
41ace484
package
cn
.
ibizlab
.
core
.
extensions
.
listener
;
import
cn.ibizlab.core.extensions.domain.FlowUser
;
import
cn.ibizlab.core.extensions.service.WFCoreService
;
import
cn.ibizlab.core.extensions.service.WFModelService
;
import
cn.ibizlab.util.security.AuthTokenUtil
;
...
...
@@ -11,7 +12,9 @@ import org.flowable.bpmn.model.UserTask;
import
org.flowable.common.engine.api.delegate.event.*
;
import
org.flowable.common.engine.api.delegate.event.FlowableEngineEventType
;
import
org.flowable.common.engine.impl.event.FlowableEntityEventImpl
;
import
org.flowable.engine.TaskService
;
import
org.flowable.engine.delegate.event.impl.FlowableActivityEventImpl
;
import
org.flowable.engine.delegate.event.impl.FlowableEntityWithVariablesEventImpl
;
import
org.flowable.engine.delegate.event.impl.FlowableProcessStartedEventImpl
;
import
org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl
;
import
org.flowable.task.service.impl.persistence.entity.TaskEntity
;
...
...
@@ -27,11 +30,6 @@ import java.util.LinkedHashMap;
import
java.util.List
;
import
java.util.Map
;
/**
* 流程实例监听器,监听流程实例启动、流转、结束状态
* 1.流程状态发生变化时,将实例信息同步到统一工作流平台
* 2.到达流程节点时,调用统一接口,查询当前节点办理人并设置到引擎中
*/
@Slf4j
@Component
public
class
ProcessInstanceListener
implements
FlowableEventListener
{
...
...
@@ -45,11 +43,37 @@ public class ProcessInstanceListener implements FlowableEventListener {
@Lazy
private
RemoteService
remoteService
;
@Autowired
@Lazy
private
TaskService
taskService
;
@Override
public
void
onEvent
(
FlowableEvent
evt
)
{
if
(
evt
instanceof
FlowableProcessStartedEventImpl
)
if
(
evt
instanceof
FlowableEntityWithVariablesEventImpl
)
{
FlowableEntityWithVariablesEventImpl
event
=
(
FlowableEntityWithVariablesEventImpl
)
evt
;
if
(
event
.
getType
()
==
FlowableEngineEventType
.
TASK_COMPLETED
)
{
TaskEntity
taskEntity
=
(
TaskEntity
)
event
.
getEntity
();
if
(
taskEntity
.
getTaskDefinitionKey
().
startsWith
(
"tid-"
))
{
Object
data
=
taskEntity
.
getVariable
(
"activedata"
);
Object
link
=
taskEntity
.
getVariable
(
"sequenceFlowName"
);
if
(
data
!=
null
&&(
data
instanceof
Map
)&&
link
!=
null
)
{
Map
activedata
=(
Map
)
data
;
String
wfprocdesc
=
""
;
if
(
activedata
.
get
(
"wfprocdesc"
)!=
null
)
wfprocdesc
=
activedata
.
get
(
"wfprocdesc"
).
toString
();
taskService
.
addComment
(
taskEntity
.
getId
(),
taskEntity
.
getProcessInstanceId
(),
link
.
toString
(),
wfprocdesc
);
}
}
}
}
else
if
(
evt
instanceof
FlowableProcessStartedEventImpl
)
{
FlowableProcessStartedEventImpl
event
=(
FlowableProcessStartedEventImpl
)
evt
;
if
(
event
.
getEntity
()
instanceof
ExecutionEntityImpl
){
...
...
@@ -57,9 +81,9 @@ public class ProcessInstanceListener implements FlowableEventListener {
if
(
executionEntity
.
getVariable
(
"cloud-serviceid"
)==
null
)
return
;
String
businessKey
=(
String
)
executionEntity
.
getVariable
(
"businessKey"
);
HashMap
curUser
=(
HashMap
)
executionEntity
.
getVariable
(
"curuser"
);
//HashMap curUser=(HashMap) executionEntity.getVariable("curuser");
FlowUser
curUser
=
FlowUser
.
getCurUser
();
String
entity
=
executionEntity
.
getVariable
(
"entitys"
).
toString
();
String
cloudServiceid
=
executionEntity
.
getVariable
(
"cloud-serviceid"
).
toString
();
Map
setting
=
wfModelService
.
getProcessGlobalSetting
(
executionEntity
.
getProcessDefinitionId
());
String
wfstepfield
=
""
;
...
...
@@ -103,9 +127,9 @@ public class ProcessInstanceListener implements FlowableEventListener {
callbackArg
.
put
(
wfverfield
,
Integer
.
parseInt
(
executionEntity
.
getVariable
(
"wfversion"
).
toString
()));
if
(
callbackArg
.
size
()>
0
)
{
if
(
curUser
.
get
(
"bearer-token"
)==
null
)
if
(
StringUtils
.
isEmpty
(
curUser
.
getToken
())
)
return
;
String
token
=
curUser
.
get
(
"bearer-token"
).
toString
();
String
token
=
curUser
.
get
Token
();
remoteService
.
getClient
(
cloudServiceid
).
put
(
entity
+
"/"
+
businessKey
,
token
,
callbackArg
);
}
}
...
...
@@ -113,18 +137,14 @@ public class ProcessInstanceListener implements FlowableEventListener {
else
if
(
evt
instanceof
FlowableEntityEventImpl
)
{
FlowableEntityEventImpl
event
=((
FlowableEntityEventImpl
)
evt
);
// 当前节点任务实体
// TODO 获取到了taskEntity 自己做每个节点的前置操作
FlowableEventType
eventType
=
event
.
getType
();
//待办创建
if
(
eventType
==
FlowableEngineEventType
.
PROCESS_COMPLETED
){
ExecutionEntityImpl
executionEntity
=
(
ExecutionEntityImpl
)
event
.
getEntity
();
if
(
executionEntity
.
getVariable
(
"cloud-serviceid"
)==
null
)
return
;
String
businessKey
=(
String
)
executionEntity
.
getVariable
(
"businessKey"
);
HashMap
curUser
=(
HashMap
)
executionEntity
.
getVariable
(
"curuser"
);
//HashMap curUser=(HashMap) executionEntity.getVariable("curuser");
FlowUser
curUser
=
FlowUser
.
getCurUser
();
String
entity
=
executionEntity
.
getVariable
(
"entitys"
).
toString
();
String
cloudServiceid
=
executionEntity
.
getVariable
(
"cloud-serviceid"
).
toString
();
String
wfstepfield
=
executionEntity
.
getVariable
(
"wfstepfield"
).
toString
();
...
...
@@ -138,23 +158,14 @@ public class ProcessInstanceListener implements FlowableEventListener {
if
(!
StringUtils
.
isEmpty
(
wfstepfield
))
callbackArg
.
put
(
wfstepfield
,
""
);
if
(
callbackArg
.
size
()>
0
)
{
if
(
curUser
.
get
(
"bearer-token"
)==
null
)
if
(
StringUtils
.
isEmpty
(
curUser
.
getToken
())
)
return
;
String
token
=
curUser
.
get
(
"bearer-token"
).
toString
();
String
token
=
curUser
.
get
Token
();
remoteService
.
getClient
(
cloudServiceid
).
put
(
entity
+
"/"
+
businessKey
,
token
,
callbackArg
);
}
System
.
out
.
println
(
"流程结束"
);
}
if
(
eventType
==
FlowableEngineEventType
.
PROCESS_COMPLETED_WITH_ERROR_END_EVENT
){
event
.
getEntity
();
System
.
out
.
println
(
"流程异常结束"
);
}
if
(
eventType
==
FlowableEngineEventType
.
TASK_COMPLETED
){
TaskEntity
taskEntity
=
(
TaskEntity
)
event
.
getEntity
();
event
.
getEntity
();
System
.
out
.
println
(
"流程异常结束"
);
}
...
...
@@ -162,15 +173,13 @@ public class ProcessInstanceListener implements FlowableEventListener {
else
if
(
evt
instanceof
FlowableActivityEventImpl
)
{
FlowableActivityEventImpl
event
=((
FlowableActivityEventImpl
)
evt
);
// 当前节点任务实体
// TODO 获取到了taskEntity 自己做每个节点的前置操作
FlowableEventType
eventType
=
event
.
getType
();
if
(
eventType
==
FlowableEngineEventType
.
ACTIVITY_STARTED
&&
"userTask"
.
equals
(
event
.
getActivityType
())){
if
(
event
.
getExecution
().
getVariable
(
"cloud-serviceid"
)==
null
)
return
;
String
businessKey
=(
String
)
event
.
getExecution
().
getVariable
(
"businessKey"
);
HashMap
curUser
=(
HashMap
)
event
.
getExecution
().
getVariable
(
"curuser"
);
//HashMap curUser=(HashMap) event.getExecution().getVariable("curuser");
FlowUser
curUser
=
FlowUser
.
getCurUser
();
String
entity
=
event
.
getExecution
().
getVariable
(
"entitys"
).
toString
();
String
cloudServiceid
=
event
.
getExecution
().
getVariable
(
"cloud-serviceid"
).
toString
();
String
wfstepfield
=
event
.
getExecution
().
getVariable
(
"wfstepfield"
).
toString
();
...
...
@@ -178,12 +187,11 @@ public class ProcessInstanceListener implements FlowableEventListener {
if
(!
StringUtils
.
isEmpty
(
wfstepfield
)&&
event
.
getActivityId
().
startsWith
(
"tid-"
))
callbackArg
.
put
(
wfstepfield
,
event
.
getActivityId
().
split
(
"-"
)[
1
]);
if
(
callbackArg
.
size
()>
0
)
{
if
(
curUser
.
get
(
"bearer-token"
)==
null
)
if
(
StringUtils
.
isEmpty
(
curUser
.
getToken
())
)
return
;
String
token
=
curUser
.
get
(
"bearer-token"
).
toString
();
String
token
=
curUser
.
get
Token
();
remoteService
.
getClient
(
cloudServiceid
).
put
(
entity
+
"/"
+
businessKey
,
token
,
callbackArg
);
}
}
}
...
...
ibzwf-core/src/main/java/cn/ibizlab/core/extensions/service/WFCoreService.java
浏览文件 @
41ace484
此差异已折叠。
点击以展开。
ibzwf-provider/ibzwf-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/WFCoreResource.java
浏览文件 @
41ace484
...
...
@@ -65,6 +65,16 @@ public class WFCoreResource
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
wfCoreService
.
getTaskLink
(
system
,
appname
,
entity
,
businessKey
,
taskId
));
}
@ApiOperation
(
value
=
"getWFHistory"
,
tags
=
{
"getWFHistory"
},
notes
=
"根据业务主键获取审批意见记录"
)
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/{system}-app-{appname}/{entity}/{businessKey}/process-instances/{processInstanceId}/history"
)
public
ResponseEntity
<
WFProcessInstance
>
getWFHistory
(
@PathVariable
(
"system"
)
String
system
,
@PathVariable
(
"appname"
)
String
appname
,
@PathVariable
(
"entity"
)
String
entity
,
@PathVariable
(
"businessKey"
)
String
businessKey
,
@PathVariable
(
"processInstanceId"
)
String
processInstanceId
)
{
if
(
StringUtils
.
isEmpty
(
processInstanceId
)||
"null"
.
equals
(
processInstanceId
)||
"alls"
.
equals
(
processInstanceId
))
processInstanceId
=
""
;
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
wfCoreService
.
getWFHistory
(
system
,
appname
,
entity
,
businessKey
,
processInstanceId
));
}
//@PreAuthorize("hasPermission(#entity,'WFSTART',this.getEntity())")
@ApiOperation
(
value
=
"wfsubmit"
,
tags
=
{
"WFProcessInstance"
},
notes
=
"工作流执行步骤"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/{system}-app-{appname}/{entity}/{businessKey}/tasks/{taskId}"
)
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录