Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
workflow
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
2
议题
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
workflow
Commits
656b4923
提交
656b4923
authored
4月 16, 2021
作者:
黄夏豪
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[数据模型] 更新了流程结束的触发器
上级
da15f32d
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
74 行增加
和
28 行删除
+74
-28
VariableStorage.java
.../workflowcore/workflow_editer/entity/VariableStorage.java
+5
-2
InvokeRequestVo.java
...rkflowcore/workflow_editer/entity/vo/InvokeRequestVo.java
+2
-1
SearchVariableStorageVo.java
...re/workflow_editer/entity/vo/SearchVariableStorageVo.java
+4
-1
VariableStorageVo.java
...flowcore/workflow_editer/entity/vo/VariableStorageVo.java
+8
-0
ProcessEndListener.java
...flowcore/workflow_editer/listener/ProcessEndListener.java
+51
-23
VariableStorageServiceImpl.java
...kflow_editer/service/impl/VariableStorageServiceImpl.java
+4
-1
没有找到文件。
src/main/java/com/tykj/workflowcore/workflow_editer/entity/VariableStorage.java
浏览文件 @
656b4923
...
...
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonGetter;
import
com.tykj.workflowcore.base.entity.BaseEntity
;
import
com.tykj.workflowcore.model_layer.annotations.WorkFlowCoreNoScan
;
import
com.tykj.workflowcore.workflow_editer.entity.vo.InvokeRequestVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
...
...
@@ -27,11 +28,12 @@ import javax.persistence.Entity;
@Data
public
class
VariableStorage
extends
BaseEntity
{
@ApiModelProperty
(
"流程主键"
)
private
String
flowKey
;
@ApiModelProperty
(
"流程主键"
)
private
String
activityId
;
@ApiModelProperty
(
"调用类名"
)
private
String
className
;
...
...
@@ -41,6 +43,7 @@ public class VariableStorage extends BaseEntity {
@ApiModelProperty
(
"详情json"
)
private
String
invokeRequest
;
@JsonGetter
public
InvokeRequestVo
getInvokeRequest
()
{
return
JSON
.
parseObject
(
invokeRequest
,
InvokeRequestVo
.
class
);
...
...
src/main/java/com/tykj/workflowcore/workflow_editer/entity/vo/InvokeRequestVo.java
浏览文件 @
656b4923
...
...
@@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModelProperty;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.flowable.engine.delegate.DelegateExecution
;
import
org.flowable.engine.runtime.ProcessInstance
;
import
java.util.List
;
...
...
@@ -26,7 +27,7 @@ import java.util.List;
public
class
InvokeRequestVo
{
@ApiModelProperty
(
"流程实例"
)
private
ProcessInstance
processInstance
;
private
DelegateExecution
processInstance
;
@ApiModelProperty
(
"流程实例id"
)
private
String
processInstanceId
;
...
...
src/main/java/com/tykj/workflowcore/workflow_editer/entity/vo/SearchVariableStorageVo.java
浏览文件 @
656b4923
...
...
@@ -21,7 +21,10 @@ public class SearchVariableStorageVo extends JpaCustomPage {
private
String
flowKey
;
public
SearchVariableStorageVo
(
String
flowKey
)
{
private
String
activityId
;
public
SearchVariableStorageVo
(
String
flowKey
,
String
activityId
)
{
this
.
flowKey
=
flowKey
;
this
.
activityId
=
activityId
;
}
}
src/main/java/com/tykj/workflowcore/workflow_editer/entity/vo/VariableStorageVo.java
浏览文件 @
656b4923
...
...
@@ -3,6 +3,7 @@ package com.tykj.workflowcore.workflow_editer.entity.vo;
import
com.alibaba.fastjson.JSON
;
import
com.fasterxml.jackson.core.JsonParser
;
import
com.tykj.workflowcore.workflow_editer.entity.VariableStorage
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
...
...
@@ -20,12 +21,19 @@ import springfox.documentation.spring.web.json.Json;
@NoArgsConstructor
public
class
VariableStorageVo
{
@ApiModelProperty
(
"主键"
)
private
Integer
id
;
@ApiModelProperty
(
"流程主键"
)
private
String
flowKey
;
@ApiModelProperty
(
"节点Id"
)
private
String
activityId
;
@ApiModelProperty
(
"调用类名"
)
private
String
className
;
@ApiModelProperty
(
"调用方法名"
)
private
String
method
;
private
InvokeRequestVo
invokeRequest
;
...
...
src/main/java/com/tykj/workflowcore/workflow_editer/listener/ProcessEndListener.java
浏览文件 @
656b4923
...
...
@@ -9,11 +9,15 @@ import com.tykj.workflowcore.workflow_editer.entity.VariableStorage;
import
com.tykj.workflowcore.workflow_editer.entity.vo.InvokeRequestVo
;
import
com.tykj.workflowcore.workflow_editer.entity.vo.SearchVariableStorageVo
;
import
com.tykj.workflowcore.workflow_editer.service.VariableStorageService
;
import
org.flowable.bpmn.model.EndEvent
;
import
org.flowable.common.engine.api.delegate.Expression
;
import
org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent
;
import
org.flowable.common.engine.api.delegate.event.FlowableEvent
;
import
org.flowable.engine.*
;
import
org.flowable.engine.delegate.DelegateExecution
;
import
org.flowable.engine.delegate.event.AbstractFlowableEngineEventListener
;
import
org.flowable.engine.delegate.event.FlowableActivityEvent
;
import
org.flowable.engine.delegate.event.impl.FlowableActivityEventImpl
;
import
org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl
;
import
org.flowable.engine.impl.persistence.entity.ExecutionEntity
;
import
org.flowable.engine.runtime.ProcessInstance
;
...
...
@@ -51,26 +55,28 @@ public class ProcessEndListener extends AbstractFlowableEngineEventListener {
@Autowired
ApiController
apiController
;
@Override
protected
void
processCompleted
(
FlowableEngineEntityEvent
event
)
{
//流程结束了
if
(
event
.
getEntity
()
instanceof
ProcessInstance
){
ProcessInstance
processInstance
=
(
ProcessInstance
)
event
.
getEntity
();
String
processDefinitionId
=
processInstance
.
getProcessDefinitionId
();
String
flowKey
=
processDefinitionId
;
if
(
processDefinitionId
.
indexOf
(
":"
)>=
0
){
flowKey
=
processDefinitionId
.
substring
(
0
,
processDefinitionId
.
indexOf
(
":"
));
}
List
<
VariableStorage
>
variableStorageList
=
variableStorageService
.
searchVariableStorageList
(
new
SearchVariableStorageVo
(
flowKey
));
for
(
VariableStorage
variableStorage
:
variableStorageList
)
{
InvokeRequestVo
variableInfo
=
variableStorage
.
getInvokeRequest
();
variableInfo
.
setProcessInstance
(
processInstance
);
//调用服务接口
//1. 获取调用的具体数值
apiController
.
invoke
(
getApiInvokeParam
(
variableInfo
));
}
}
//
if (event.getEntity() instanceof ProcessInstance){
//
ProcessInstance processInstance = (ProcessInstance) event.getEntity();
//
String processDefinitionId = processInstance.getProcessDefinitionId();
//
String flowKey = processDefinitionId;
//
if (processDefinitionId.indexOf(":")>=0){
//
flowKey = processDefinitionId.substring(0,processDefinitionId.indexOf(":"));
//
}
//
List<VariableStorage> variableStorageList = variableStorageService.searchVariableStorageList(new SearchVariableStorageVo(flowKey));
//
for (VariableStorage variableStorage : variableStorageList) {
//
InvokeRequestVo variableInfo = variableStorage.getInvokeRequest();
//
variableInfo.setProcessInstance(processInstance);
//
//调用服务接口
//
//
//1. 获取调用的具体数值
//
apiController.invoke(getApiInvokeParam(variableInfo));
//
}
//
}
// throw new ApiException("强行报错");
}
...
...
@@ -81,10 +87,32 @@ public class ProcessEndListener extends AbstractFlowableEngineEventListener {
@Override
public
void
onEvent
(
FlowableEvent
flowableEvent
)
{
System
.
out
.
println
(
flowableEvent
.
getType
());
super
.
onEvent
(
flowableEvent
);
}
@Override
protected
void
activityCompleted
(
FlowableActivityEvent
event
)
{
super
.
activityCompleted
(
event
);
if
(
event
instanceof
FlowableActivityEventImpl
){
DelegateExecution
execution
=
((
FlowableActivityEventImpl
)
event
).
getExecution
();
if
(
execution
.
getCurrentFlowElement
()
instanceof
EndEvent
){
System
.
out
.
println
(
"流程结束了"
);
String
processDefinitionId
=
execution
.
getProcessDefinitionId
();
String
flowKey
=
processDefinitionId
;
if
(
processDefinitionId
.
indexOf
(
":"
)>=
0
){
flowKey
=
processDefinitionId
.
substring
(
0
,
processDefinitionId
.
indexOf
(
":"
));
}
List
<
VariableStorage
>
variableStorageList
=
variableStorageService
.
searchVariableStorageList
(
new
SearchVariableStorageVo
(
flowKey
,
execution
.
getCurrentActivityId
()));
for
(
VariableStorage
variableStorage
:
variableStorageList
)
{
InvokeRequestVo
variableInfo
=
variableStorage
.
getInvokeRequest
();
variableInfo
.
setProcessInstance
(
execution
);
//调用服务接口
apiController
.
invoke
(
getApiInvokeParam
(
variableInfo
));
}
}
}
}
/**
* 获取调用Api用的参数
*
...
...
@@ -93,21 +121,21 @@ public class ProcessEndListener extends AbstractFlowableEngineEventListener {
*/
public
InvokeRequest
getApiInvokeParam
(
InvokeRequestVo
invokeRequestVo
)
{
//拿出taskId
ProcessInstance
processInstance
=
invokeRequestVo
.
getProcessInstance
();
DelegateExecution
execution
=
invokeRequestVo
.
getProcessInstance
();
List
<
Parameter
>
parameterList
=
invokeRequestVo
.
getParams
();
List
<
Parameter
>
newParameterList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
parameterList
.
size
();
i
++)
{
Parameter
parameter
=
parameterList
.
get
(
i
);
if
(!
StringUtils
.
isEmpty
(
parameter
.
getExp
()))
{
//如果是表示式 如:${people}
parameter
.
setInstance
((
Map
<
String
,
Object
>)
getProcessValue
(
processInstance
,
parameter
.
getExp
()));
parameter
.
setInstance
((
Map
<
String
,
Object
>)
getProcessValue
(
execution
,
parameter
.
getExp
()));
}
else
{
Map
<
String
,
Object
>
instance
=
parameter
.
getInstance
();
JSONObject
newInstance
=
new
JSONObject
();
//遍历param的key
Set
<
String
>
oldInstanceKey
=
instance
.
keySet
();
for
(
String
key
:
oldInstanceKey
)
{
newInstance
.
put
(
key
,
getProcessValue
(
processInstance
,
(
String
)
instance
.
get
(
key
)));
newInstance
.
put
(
key
,
getProcessValue
(
execution
,
(
String
)
instance
.
get
(
key
)));
}
parameter
.
setInstance
(
newInstance
);
}
...
...
@@ -117,10 +145,10 @@ public class ProcessEndListener extends AbstractFlowableEngineEventListener {
return
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
invokeRequestVo
),
InvokeRequest
.
class
);
}
public
Object
getProcessValue
(
ProcessInstance
processInstance
,
String
exp
)
{
public
Object
getProcessValue
(
DelegateExecution
execution
,
String
exp
)
{
// processInstance -> ExecutionEntity
Expression
expression
=
processEngineConfiguration
.
getExpressionManager
().
createExpression
(
exp
);
return
expression
.
getValue
(
(
ExecutionEntity
)
processInstance
);
return
expression
.
getValue
(
execution
);
}
}
src/main/java/com/tykj/workflowcore/workflow_editer/service/impl/VariableStorageServiceImpl.java
浏览文件 @
656b4923
...
...
@@ -7,6 +7,8 @@ import com.tykj.workflowcore.workflow_editer.dao.VariableStorageMapper;
import
com.tykj.workflowcore.workflow_editer.entity.vo.SearchVariableStorageVo
;
import
com.tykj.workflowcore.workflow_editer.service.VariableStorageService
;
import
liquibase.pro.packaged.B
;
import
liquibase.util.StreamUtil
;
import
liquibase.util.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.stereotype.Service
;
...
...
@@ -47,7 +49,8 @@ public class VariableStorageServiceImpl implements VariableStorageService {
PredicateBuilder
predicateBuilder
=
Specifications
.
and
();
if
(
searchVariableStorageVo
!=
null
){
predicateBuilder
.
eq
(
searchVariableStorageVo
.
getId
()!=
null
,
"id"
,
searchVariableStorageVo
.
getId
());
predicateBuilder
.
eq
(
searchVariableStorageVo
.
getFlowKey
()!=
null
,
"flowKey"
,
searchVariableStorageVo
.
getFlowKey
());
predicateBuilder
.
eq
(
StringUtils
.
isEmpty
(
searchVariableStorageVo
.
getFlowKey
()),
"flowKey"
,
searchVariableStorageVo
.
getFlowKey
());
predicateBuilder
.
eq
(
StringUtils
.
isEmpty
(
searchVariableStorageVo
.
getActivityId
()),
"activityId"
,
searchVariableStorageVo
.
getActivityId
());
}
return
variableStorageMapper
.
findAll
(
predicateBuilder
.
build
(),
searchVariableStorageVo
.
getPageable
());
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论