Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
workflow
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
2
议题
2
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
workflow
Commits
c42911a4
提交
c42911a4
authored
4月 19, 2021
作者:
黄夏豪
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[流程编辑器] 修改了保存流程的逻辑
[流程编辑器] 更新了回调函数的逻辑-》支持回调函数
上级
656b4923
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
243 行增加
和
178 行删除
+243
-178
Parameter.java
...main/java/com/tykj/workflowcore/api/entity/Parameter.java
+0
-3
AggregationController.java
...lowcore/model_layer/controller/AggregationController.java
+6
-0
AggregationDao.java
...com/tykj/workflowcore/model_layer/dao/AggregationDao.java
+2
-1
AggregationImpl.java
...orkflowcore/model_layer/service/impl/AggregationImpl.java
+0
-52
FlowsInfoController.java
...wcore/workflow_editer/controller/FlowsInfoController.java
+1
-1
VariableStorage.java
.../workflowcore/workflow_editer/entity/VariableStorage.java
+6
-4
FlowsInfoVo.java
...j/workflowcore/workflow_editer/entity/vo/FlowsInfoVo.java
+11
-20
ParameterVo.java
...j/workflowcore/workflow_editer/entity/vo/ParameterVo.java
+29
-0
VariableStorageVo.java
...flowcore/workflow_editer/entity/vo/VariableStorageVo.java
+4
-2
ProcessEndListener.java
...flowcore/workflow_editer/listener/ProcessEndListener.java
+39
-31
VariableStorageServiceImpl.java
...kflow_editer/service/impl/VariableStorageServiceImpl.java
+1
-0
WorkFlowServiceImpl.java
...ore/workflow_editer/service/impl/WorkFlowServiceImpl.java
+144
-64
没有找到文件。
src/main/java/com/tykj/workflowcore/api/entity/Parameter.java
浏览文件 @
c42911a4
...
@@ -18,9 +18,6 @@ public class Parameter {
...
@@ -18,9 +18,6 @@ public class Parameter {
@ApiModelProperty
(
value
=
"类名"
)
@ApiModelProperty
(
value
=
"类名"
)
private
String
className
;
private
String
className
;
@ApiModelProperty
(
"流程表达式"
)
private
String
exp
;
/**
/**
* Map形式的实例对象
* Map形式的实例对象
* key为字段名 value为字段值
* key为字段名 value为字段值
...
...
src/main/java/com/tykj/workflowcore/model_layer/controller/AggregationController.java
浏览文件 @
c42911a4
...
@@ -43,6 +43,12 @@ public class AggregationController {
...
@@ -43,6 +43,12 @@ public class AggregationController {
return
ResultUtil
.
success
(
""
,
"保存成功!"
);
return
ResultUtil
.
success
(
""
,
"保存成功!"
);
}
}
@PostMapping
(
"/findTest"
)
public
ResponseEntity
findTest
(
Integer
id
)
{
return
ResultUtil
.
success
(
aggregationDao
.
findAllByTableInfoExIdAndParentId
(
id
,
null
),
"保存成功!"
);
}
@PostMapping
(
"/test"
)
@PostMapping
(
"/test"
)
public
ResponseEntity
test
(
@RequestBody
AggregationVO
AggregationVO
)
{
public
ResponseEntity
test
(
@RequestBody
AggregationVO
AggregationVO
)
{
String
result
=
""
;
String
result
=
""
;
...
...
src/main/java/com/tykj/workflowcore/model_layer/dao/AggregationDao.java
浏览文件 @
c42911a4
...
@@ -15,6 +15,7 @@ import java.util.List;
...
@@ -15,6 +15,7 @@ import java.util.List;
*/
*/
public
interface
AggregationDao
extends
JpaRepository
<
Aggregation
,
Integer
>,
JpaSpecificationExecutor
<
Aggregation
>
{
public
interface
AggregationDao
extends
JpaRepository
<
Aggregation
,
Integer
>,
JpaSpecificationExecutor
<
Aggregation
>
{
List
<
Aggregation
>
findAllByTableInfoExIdAndParentId
(
Integer
tableExId
,
Integer
parentId
);
List
<
Aggregation
>
findAllByTableInfoExIdAndParentId
(
Integer
tableExId
,
Integer
parrentId
);
}
}
src/main/java/com/tykj/workflowcore/model_layer/service/impl/AggregationImpl.java
浏览文件 @
c42911a4
...
@@ -88,7 +88,6 @@ public class AggregationImpl implements AggregationService {
...
@@ -88,7 +88,6 @@ public class AggregationImpl implements AggregationService {
}
else
{
}
else
{
throw
new
ApiException
(
"id为:"
+
parentAggregation
.
getSideTableId
()+
"的副表不存在"
);
throw
new
ApiException
(
"id为:"
+
parentAggregation
.
getSideTableId
()+
"的副表不存在"
);
}
}
parentModeName
=
sideTableInfoOptional
.
get
().
getModelName
();
parentModeName
=
sideTableInfoOptional
.
get
().
getModelName
();
}
else
{
}
else
{
//如果是第一层 则通过rootElement 查出副表的XML字符串
//如果是第一层 则通过rootElement 查出副表的XML字符串
...
@@ -157,55 +156,4 @@ public class AggregationImpl implements AggregationService {
...
@@ -157,55 +156,4 @@ public class AggregationImpl implements AggregationService {
return
null
;
return
null
;
}
}
// 假设获得的是一份XML
// public Element testDG(List<Aggregation> aggregations, Aggregation parentAggregation, Integer mainId, Element element){
// //循环
// Element elementCLass = DocumentHelper.createElement("class");
// if (parentAggregation!=null){
// elementCLass.addAttribute("name",parentAggregation.getSideTableId()+"_");
// }else {
// elementCLass.addAttribute("name",mainId+"_");
// }
// for (int i = 0; i < aggregations.size(); i++) {
// Aggregation aggregationChild = aggregations.get(i);
// if (aggregationChild.getAggregations()!=null&&aggregationChild.getAggregations().size()>0){
// Element elementClassChild = testDG(aggregationChild.getAggregations(), aggregationChild, mainId, element);
// Element elementSet = DocumentHelper.createElement("set");
// elementSet.addAttribute("setName","c"+elementClassChild.attribute("name").getValue());
// elementCLass.add(elementSet);
// }else {
// Element elementSet = DocumentHelper.createElement("set");
// elementSet.addAttribute("setName","c"+aggregationChild.getSideTableId());
// elementCLass.add(elementSet);
// }
// }
// element.add(elementCLass);
// return elementCLass;
// }
// Optional<TableInfo> sideTableById = tableInfoDao.findById(aggregationChild.getSideTableId());
// aggregationChild.setTableInfoExId(tableExId);
// if (!sideTableById.isPresent()){
// throw new ApiException("id为:"+aggregationChild.getSideTableId()+"的副表不存在");
// }
// if (aggregationChild.getRelationship().equals(AggregationType.ONE_TO_ONE)){
// AggregationUtil.addOneToOne(aggregationChild.getSideTableConnectionKey(), sideTableById.get().getModelName(), document);
// }
// if (aggregationChild.getRelationship().equals(AggregationType.ONE_TO_MANY)){
// //如果是一对多需要 为 aggregationRelationship 生成连接的KEY
// String mainTableConnectionKey = sideTableById.get().getModelName();
// AggregationUtil.addOneToMany(sideTableById.get().getModelName(), mainTableConnectionKey, aggregationChild.getSideTableConnectionKey(), document);
// }
// if (aggregationChild.getRelationship().equals(AggregationType.MANY_TO_MANY)){
// //如果是多对多需要 为 aggregationRelationship 生成连接的KEY
// String mainTableConnectionKey = mainTableInfo.getModelName()+"_Id";
// String sideTableConnectionKey = sideTableById.get().getModelName()+"_Id";
// aggregationChild.setMainTableConnectionKey(mainTableConnectionKey);
// aggregationChild.setSideTableConnectionKey(sideTableConnectionKey);
// //如果是多对多需要 为 aggregationRelationship 生成连接的中间表名
// String connectionTableName = mainTableInfo.getModelName()+"_"+sideTableById.get().getModelName()+"_"+ (UUID.randomUUID().toString().substring(0,8));
// aggregationChild.setConnectionTableName(connectionTableName);
// //Util.addManyToMany
// AggregationUtil.addManyToMany(sideTableById.get().getModelName(),connectionTableName,mainTableConnectionKey,sideTableConnectionKey,document);
// }
}
}
src/main/java/com/tykj/workflowcore/workflow_editer/controller/FlowsInfoController.java
浏览文件 @
c42911a4
...
@@ -76,7 +76,7 @@ public class FlowsInfoController {
...
@@ -76,7 +76,7 @@ public class FlowsInfoController {
@ApiOperation
(
value
=
"保存xml以及其他流程信息"
)
@ApiOperation
(
value
=
"保存xml以及其他流程信息"
)
public
ResponseEntity
saveXml
(
@RequestBody
FlowsInfoVo
flowsInfoVo
)
throws
IOException
,
XMLStreamException
{
public
ResponseEntity
saveXml
(
@RequestBody
FlowsInfoVo
flowsInfoVo
)
throws
IOException
,
XMLStreamException
{
//保存节点信息
//保存节点信息
nodeInfoService
.
saveNodeInfoList
(
flowsInfoVo
.
getNodeInfoList
());
//
nodeInfoService.saveNodeInfoList(flowsInfoVo.getNodeInfoList());
//保存xml信息
//保存xml信息
workFlowService
.
flowXml
(
flowsInfoVo
);
workFlowService
.
flowXml
(
flowsInfoVo
);
return
ResultUtil
.
success
(
"文件保存成功"
);
return
ResultUtil
.
success
(
"文件保存成功"
);
...
...
src/main/java/com/tykj/workflowcore/workflow_editer/entity/VariableStorage.java
浏览文件 @
c42911a4
package
com
.
tykj
.
workflowcore
.
workflow_editer
.
entity
;
package
com
.
tykj
.
workflowcore
.
workflow_editer
.
entity
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
import
com.fasterxml.jackson.annotation.JsonGetter
;
import
com.fasterxml.jackson.annotation.JsonGetter
;
import
com.tykj.workflowcore.base.entity.BaseEntity
;
import
com.tykj.workflowcore.base.entity.BaseEntity
;
import
com.tykj.workflowcore.model_layer.annotations.WorkFlowCoreNoScan
;
import
com.tykj.workflowcore.model_layer.annotations.WorkFlowCoreNoScan
;
import
com.tykj.workflowcore.workflow_editer.entity.vo.InvokeRequestVo
;
import
com.tykj.workflowcore.workflow_editer.entity.vo.InvokeRequestVo
;
import
com.tykj.workflowcore.workflow_editer.entity.vo.ParameterVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
...
@@ -12,6 +14,7 @@ import lombok.Data;
...
@@ -12,6 +14,7 @@ import lombok.Data;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
javax.persistence.Entity
;
import
javax.persistence.Entity
;
import
java.util.List
;
/**
/**
* ClassName: VariableStorage
* ClassName: VariableStorage
...
@@ -41,12 +44,11 @@ public class VariableStorage extends BaseEntity {
...
@@ -41,12 +44,11 @@ public class VariableStorage extends BaseEntity {
private
String
method
;
private
String
method
;
@ApiModelProperty
(
"详情json"
)
@ApiModelProperty
(
"详情json"
)
private
String
invokeRequest
;
private
String
parameterInfo
;
@JsonGetter
@JsonGetter
public
InvokeRequestVo
getInvokeRequest
()
{
public
List
<
ParameterVo
>
getParameterInfo
()
{
return
JSON
.
parseObject
(
invokeRequest
,
InvokeRequestVo
.
class
);
return
JSON
.
parseObject
(
parameterInfo
,
new
TypeReference
<
List
<
ParameterVo
>>(){}
);
}
}
}
}
src/main/java/com/tykj/workflowcore/workflow_editer/entity/vo/FlowsInfoVo.java
浏览文件 @
c42911a4
package
com
.
tykj
.
workflowcore
.
workflow_editer
.
entity
.
vo
;
package
com
.
tykj
.
workflowcore
.
workflow_editer
.
entity
.
vo
;
import
cn.hutool.core.util.StrUtil
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.tykj.workflowcore.workflow_editer.entity.FlowsInfo
;
import
com.tykj.workflowcore.workflow_editer.entity.FlowsInfo
;
import
com.tykj.workflowcore.workflow_editer.entity.NodeInfo
;
import
com.tykj.workflowcore.workflow_editer.entity.NodeInfo
;
...
@@ -28,9 +29,6 @@ public class FlowsInfoVo {
...
@@ -28,9 +29,6 @@ public class FlowsInfoVo {
@ApiModelProperty
(
"主键id"
)
@ApiModelProperty
(
"主键id"
)
private
Integer
id
;
private
Integer
id
;
@ApiModelProperty
(
"发起人的名字"
)
private
Integer
userName
;
@ApiModelProperty
(
"流程名称"
)
@ApiModelProperty
(
"流程名称"
)
private
String
flowName
;
private
String
flowName
;
...
@@ -40,32 +38,25 @@ public class FlowsInfoVo {
...
@@ -40,32 +38,25 @@ public class FlowsInfoVo {
@ApiModelProperty
(
value
=
"部署状态"
,
notes
=
"0 已部署,1 未部署"
)
@ApiModelProperty
(
value
=
"部署状态"
,
notes
=
"0 已部署,1 未部署"
)
private
Integer
state
=
1
;
private
Integer
state
=
1
;
@ApiModelProperty
(
"流程创建时间"
)
private
Date
createTime
;
@ApiModelProperty
(
"流程修改时间"
)
private
Date
updateTime
;
@ApiModelProperty
(
"流程描述"
)
@ApiModelProperty
(
"流程描述"
)
private
String
flowDescribe
;
private
String
flowDescribe
;
@ApiModelProperty
@ApiModelProperty
private
String
fileXml
;
private
String
fileXml
;
@ApiModelProperty
(
"开始节点的id"
)
private
String
startId
;
@ApiModelProperty
(
"开始节点的id"
)
private
String
startPageId
;
@ApiModelProperty
(
"是否和之前一样 0是一样 1不一样"
)
private
Integer
isOld
=
1
;
@ApiModelProperty
()
private
List
<
NodeInfo
>
nodeInfoList
;
public
FlowsInfo
toEntity
(){
public
FlowsInfo
toEntity
(){
FlowsInfo
flowsInfo
=
new
FlowsInfo
();
FlowsInfo
flowsInfo
=
new
FlowsInfo
();
BeanUtils
.
copyProperties
(
this
,
flowsInfo
);
BeanUtils
.
copyProperties
(
this
,
flowsInfo
);
return
flowsInfo
;
return
flowsInfo
;
}
}
public
FlowsInfo
toEntity
(
FlowsInfo
oldFlowsInfo
){
if
(!
StrUtil
.
isEmpty
(
flowName
)){
oldFlowsInfo
.
setFlowName
(
flowName
);
}
if
(!
StrUtil
.
isEmpty
(
flowDescribe
)){
oldFlowsInfo
.
setFlowDescribe
(
flowDescribe
);
}
return
oldFlowsInfo
;
}
}
}
src/main/java/com/tykj/workflowcore/workflow_editer/entity/vo/ParameterVo.java
0 → 100644
浏览文件 @
c42911a4
package
com
.
tykj
.
workflowcore
.
workflow_editer
.
entity
.
vo
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
/**
* 回调接口配置Vo
* @author HuangXiahao
* @version V1.0
* @class parameterVo
* @packageName com.tykj.workflowcore.workflow_editer.entity.vo
**/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
ParameterVo
{
private
String
className
;
private
String
exp
;
private
String
name
;
private
List
<
ParameterVo
>
parameterVoList
;
}
src/main/java/com/tykj/workflowcore/workflow_editer/entity/vo/VariableStorageVo.java
浏览文件 @
c42911a4
...
@@ -10,6 +10,8 @@ import lombok.NoArgsConstructor;
...
@@ -10,6 +10,8 @@ import lombok.NoArgsConstructor;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
springfox.documentation.spring.web.json.Json
;
import
springfox.documentation.spring.web.json.Json
;
import
java.util.List
;
/**
/**
* @author HuangXiahao
* @author HuangXiahao
* @version V1.0
* @version V1.0
...
@@ -36,12 +38,12 @@ public class VariableStorageVo {
...
@@ -36,12 +38,12 @@ public class VariableStorageVo {
@ApiModelProperty
(
"调用方法名"
)
@ApiModelProperty
(
"调用方法名"
)
private
String
method
;
private
String
method
;
private
InvokeRequestVo
invokeReque
st
;
private
List
<
ParameterVo
>
parameterLi
st
;
public
VariableStorage
toEntity
(){
public
VariableStorage
toEntity
(){
VariableStorage
variableStorage
=
new
VariableStorage
();
VariableStorage
variableStorage
=
new
VariableStorage
();
BeanUtils
.
copyProperties
(
this
,
variableStorage
);
BeanUtils
.
copyProperties
(
this
,
variableStorage
);
variableStorage
.
set
InvokeRequest
(
JSON
.
toJSONString
(
invokeReque
st
));
variableStorage
.
set
ParameterInfo
(
JSON
.
toJSONString
(
parameterLi
st
));
return
variableStorage
;
return
variableStorage
;
}
}
}
}
src/main/java/com/tykj/workflowcore/workflow_editer/listener/ProcessEndListener.java
浏览文件 @
c42911a4
...
@@ -7,8 +7,10 @@ import com.tykj.workflowcore.api.entity.Parameter;
...
@@ -7,8 +7,10 @@ import com.tykj.workflowcore.api.entity.Parameter;
import
com.tykj.workflowcore.workflow_editer.entity.CommandGetValue
;
import
com.tykj.workflowcore.workflow_editer.entity.CommandGetValue
;
import
com.tykj.workflowcore.workflow_editer.entity.VariableStorage
;
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.InvokeRequestVo
;
import
com.tykj.workflowcore.workflow_editer.entity.vo.ParameterVo
;
import
com.tykj.workflowcore.workflow_editer.entity.vo.SearchVariableStorageVo
;
import
com.tykj.workflowcore.workflow_editer.entity.vo.SearchVariableStorageVo
;
import
com.tykj.workflowcore.workflow_editer.service.VariableStorageService
;
import
com.tykj.workflowcore.workflow_editer.service.VariableStorageService
;
import
liquibase.pro.packaged.I
;
import
org.flowable.bpmn.model.EndEvent
;
import
org.flowable.bpmn.model.EndEvent
;
import
org.flowable.common.engine.api.delegate.Expression
;
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.FlowableEngineEntityEvent
;
...
@@ -20,16 +22,14 @@ import org.flowable.engine.delegate.event.FlowableActivityEvent;
...
@@ -20,16 +22,14 @@ import org.flowable.engine.delegate.event.FlowableActivityEvent;
import
org.flowable.engine.delegate.event.impl.FlowableActivityEventImpl
;
import
org.flowable.engine.delegate.event.impl.FlowableActivityEventImpl
;
import
org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl
;
import
org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl
;
import
org.flowable.engine.impl.persistence.entity.ExecutionEntity
;
import
org.flowable.engine.impl.persistence.entity.ExecutionEntity
;
import
org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl
;
import
org.flowable.engine.runtime.ProcessInstance
;
import
org.flowable.engine.runtime.ProcessInstance
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
/**
/**
* @author HuangXiahao
* @author HuangXiahao
...
@@ -97,17 +97,20 @@ public class ProcessEndListener extends AbstractFlowableEngineEventListener {
...
@@ -97,17 +97,20 @@ public class ProcessEndListener extends AbstractFlowableEngineEventListener {
DelegateExecution
execution
=
((
FlowableActivityEventImpl
)
event
).
getExecution
();
DelegateExecution
execution
=
((
FlowableActivityEventImpl
)
event
).
getExecution
();
if
(
execution
.
getCurrentFlowElement
()
instanceof
EndEvent
){
if
(
execution
.
getCurrentFlowElement
()
instanceof
EndEvent
){
System
.
out
.
println
(
"流程结束了"
);
System
.
out
.
println
(
"流程结束了"
);
String
processDefinitionId
=
execution
.
getProcessDefinitionId
();
String
processDefinitionId
=
((
ExecutionEntityImpl
)
execution
).
getProcessDefinitionKey
();
String
flowKey
=
processDefinitionId
;
String
flowKey
=
processDefinitionId
;
if
(
processDefinitionId
.
indexOf
(
":"
)>=
0
){
if
(
processDefinitionId
.
indexOf
(
":"
)>=
0
){
flowKey
=
processDefinitionId
.
substring
(
0
,
processDefinitionId
.
indexOf
(
":"
));
flowKey
=
processDefinitionId
.
substring
(
0
,
processDefinitionId
.
indexOf
(
":"
));
}
}
List
<
VariableStorage
>
variableStorageList
=
variableStorageService
.
searchVariableStorageList
(
new
SearchVariableStorageVo
(
flowKey
,
execution
.
getCurrentActivityId
()));
List
<
VariableStorage
>
variableStorageList
=
variableStorageService
.
searchVariableStorageList
(
new
SearchVariableStorageVo
(
flowKey
,
execution
.
getCurrentActivityId
()));
for
(
VariableStorage
variableStorage
:
variableStorageList
)
{
for
(
VariableStorage
variableStorage
:
variableStorageList
)
{
InvokeRequestVo
variableInfo
=
variableStorage
.
getInvokeRequest
();
List
<
ParameterVo
>
parameterVoList
=
variableStorage
.
getParameterInfo
();
variableInfo
.
setProcessInstance
(
execution
);
InvokeRequest
invokeRequest
=
new
InvokeRequest
();
invokeRequest
.
setClassName
(
variableStorage
.
getClassName
());
invokeRequest
.
setName
(
variableStorage
.
getMethod
());
invokeRequest
.
setParams
(
getApiInvokeParam
(
parameterVoList
,
execution
));
//调用服务接口
//调用服务接口
apiController
.
invoke
(
getApiInvokeParam
(
variableInfo
)
);
apiController
.
invoke
(
invokeRequest
);
}
}
}
}
}
}
...
@@ -116,33 +119,38 @@ public class ProcessEndListener extends AbstractFlowableEngineEventListener {
...
@@ -116,33 +119,38 @@ public class ProcessEndListener extends AbstractFlowableEngineEventListener {
/**
/**
* 获取调用Api用的参数
* 获取调用Api用的参数
*
*
* @param
invokeRequestVo
调用服务接口vo
* @param
parameterVoList
调用服务接口vo
* @return 调用服务接口实体
* @return 调用服务接口实体
*/
*/
public
InvokeRequest
getApiInvokeParam
(
InvokeRequestVo
invokeRequestVo
)
{
public
List
<
Parameter
>
getApiInvokeParam
(
List
<
ParameterVo
>
parameterVoList
,
DelegateExecution
execution
)
{
//拿出taskId
//拿出taskId
DelegateExecution
execution
=
invokeRequestVo
.
getProcessInstance
();
List
<
Parameter
>
parameterList
=
new
ArrayList
<>();
List
<
Parameter
>
parameterList
=
invokeRequestVo
.
getParams
();
for
(
int
i
=
0
;
i
<
parameterVoList
.
size
();
i
++)
{
List
<
Parameter
>
newParameterList
=
new
ArrayList
<>();
ParameterVo
parameterVo
=
parameterVoList
.
get
(
i
);
for
(
int
i
=
0
;
i
<
parameterList
.
size
();
i
++)
{
Parameter
parameter
=
new
Parameter
();
Parameter
parameter
=
parameterList
.
get
(
i
);
parameter
.
setClassName
(
parameterVo
.
getClassName
());
if
(!
StringUtils
.
isEmpty
(
parameter
.
getExp
()))
{
Map
<
String
,
Object
>
instance
=
new
HashMap
<>();
//如果是表示式 如:${people}
FillParameter
(
instance
,
parameterVoList
.
get
(
i
),
execution
);
parameter
.
setInstance
((
Map
<
String
,
Object
>)
getProcessValue
(
execution
,
parameter
.
getExp
()));
parameter
.
setInstance
((
Map
<
String
,
Object
>)
instance
.
get
(
parameterVo
.
getName
()));
}
else
{
parameterList
.
add
(
parameter
);
Map
<
String
,
Object
>
instance
=
parameter
.
getInstance
();
}
JSONObject
newInstance
=
new
JSONObject
();
return
parameterList
;
//遍历param的key
}
Set
<
String
>
oldInstanceKey
=
instance
.
keySet
();
for
(
String
key
:
oldInstanceKey
)
{
public
Map
<
String
,
Object
>
FillParameter
(
Map
<
String
,
Object
>
instance
,
ParameterVo
parameterVo
,
DelegateExecution
execution
){
newInstance
.
put
(
key
,
getProcessValue
(
execution
,
(
String
)
instance
.
get
(
key
)));
if
(!
StringUtils
.
isEmpty
(
parameterVo
.
getExp
()))
{
}
//如果是表示式 如:${people}
parameter
.
setInstance
(
newInstance
);
instance
.
put
(
parameterVo
.
getName
(),
getProcessValue
(
execution
,
parameterVo
.
getExp
()));
}
else
{
instance
.
put
(
parameterVo
.
getName
(),
""
);
}
List
<
ParameterVo
>
parameterVoList
=
parameterVo
.
getParameterVoList
();
if
(
parameterVoList
!=
null
&&
parameterVoList
.
size
()>
0
){
for
(
int
i
=
0
;
i
<
parameterVoList
.
size
()
;
i
++)
{
FillParameter
(
instance
,
parameterVoList
.
get
(
i
),
execution
);
}
}
newParameterList
.
add
(
i
,
parameter
);
}
}
invokeRequestVo
.
setParams
(
newParameterList
);
return
instance
;
return
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
invokeRequestVo
),
InvokeRequest
.
class
);
}
}
public
Object
getProcessValue
(
DelegateExecution
execution
,
String
exp
)
{
public
Object
getProcessValue
(
DelegateExecution
execution
,
String
exp
)
{
...
...
src/main/java/com/tykj/workflowcore/workflow_editer/service/impl/VariableStorageServiceImpl.java
浏览文件 @
c42911a4
...
@@ -40,6 +40,7 @@ public class VariableStorageServiceImpl implements VariableStorageService {
...
@@ -40,6 +40,7 @@ public class VariableStorageServiceImpl implements VariableStorageService {
if
(
searchVariableStorageVo
!=
null
){
if
(
searchVariableStorageVo
!=
null
){
predicateBuilder
.
eq
(
searchVariableStorageVo
.
getId
()!=
null
,
"id"
,
searchVariableStorageVo
.
getId
());
predicateBuilder
.
eq
(
searchVariableStorageVo
.
getId
()!=
null
,
"id"
,
searchVariableStorageVo
.
getId
());
predicateBuilder
.
eq
(
searchVariableStorageVo
.
getFlowKey
()!=
null
,
"flowKey"
,
searchVariableStorageVo
.
getFlowKey
());
predicateBuilder
.
eq
(
searchVariableStorageVo
.
getFlowKey
()!=
null
,
"flowKey"
,
searchVariableStorageVo
.
getFlowKey
());
predicateBuilder
.
eq
(
searchVariableStorageVo
.
getActivityId
()!=
null
,
"activityId"
,
searchVariableStorageVo
.
getActivityId
());
}
}
return
variableStorageMapper
.
findAll
(
predicateBuilder
.
build
());
return
variableStorageMapper
.
findAll
(
predicateBuilder
.
build
());
}
}
...
...
src/main/java/com/tykj/workflowcore/workflow_editer/service/impl/WorkFlowServiceImpl.java
浏览文件 @
c42911a4
package
com
.
tykj
.
workflowcore
.
workflow_editer
.
service
.
impl
;
package
com
.
tykj
.
workflowcore
.
workflow_editer
.
service
.
impl
;
import
cn.hutool.core.util.StrUtil
;
import
com.tykj.workflowcore.api.service.SpringBeanService
;
import
com.tykj.workflowcore.api.service.SpringBeanService
;
import
com.tykj.workflowcore.base.result.ApiException
;
import
com.tykj.workflowcore.base.result.ApiException
;
import
com.tykj.workflowcore.base.util.FileUtil
;
import
com.tykj.workflowcore.base.util.FileUtil
;
...
@@ -15,10 +16,12 @@ import com.tykj.workflowcore.workflow_editer.service.VariableStorageService;
...
@@ -15,10 +16,12 @@ import com.tykj.workflowcore.workflow_editer.service.VariableStorageService;
import
com.tykj.workflowcore.workflow_editer.service.WorkFlowService
;
import
com.tykj.workflowcore.workflow_editer.service.WorkFlowService
;
import
com.tykj.workflowcore.workflow_editer.util.UserServiceBeanUtil
;
import
com.tykj.workflowcore.workflow_editer.util.UserServiceBeanUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
liquibase.pro.packaged.E
;
import
org.dom4j.*
;
import
org.dom4j.*
;
import
org.dom4j.io.SAXReader
;
import
org.dom4j.io.SAXReader
;
import
org.flowable.bpmn.converter.BpmnXMLConverter
;
import
org.flowable.bpmn.converter.BpmnXMLConverter
;
import
org.flowable.bpmn.model.*
;
import
org.flowable.bpmn.model.*
;
import
org.flowable.bpmn.model.Process
;
import
org.flowable.common.engine.impl.identity.Authentication
;
import
org.flowable.common.engine.impl.identity.Authentication
;
import
org.flowable.engine.*
;
import
org.flowable.engine.*
;
import
org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl
;
import
org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl
;
...
@@ -56,7 +59,8 @@ import java.util.concurrent.ConcurrentHashMap;
...
@@ -56,7 +59,8 @@ import java.util.concurrent.ConcurrentHashMap;
@Service
@Service
public
class
WorkFlowServiceImpl
implements
WorkFlowService
{
public
class
WorkFlowServiceImpl
implements
WorkFlowService
{
private
static
String
XML_FILE_PATH
=
"\\xml\\"
;
private
static
String
BASE_PATH
=
System
.
getProperty
(
"user.dir"
);
private
final
RepositoryService
repositoryService
;
private
final
RepositoryService
repositoryService
;
private
final
RuntimeService
runtimeService
;
private
final
RuntimeService
runtimeService
;
private
final
TaskService
taskService
;
private
final
TaskService
taskService
;
...
@@ -117,58 +121,149 @@ public class WorkFlowServiceImpl implements WorkFlowService {
...
@@ -117,58 +121,149 @@ public class WorkFlowServiceImpl implements WorkFlowService {
return
realPath
;
return
realPath
;
}
}
// @Override
// public void flowXml(@RequestBody FlowsInfoVo flowsInfoVo) throws XMLStreamException, IOException {
// String basePath = System.getProperty("user.dir") + "\\xml\\";
// Integer id = flowsInfoVo.getId();
// String flowKey = flowsInfoVo.getFlowKey();
// String fileXml = flowsInfoVo.getFileXml();
// //根据ID查询出一个flowsinfo
// if (id != null){
// FlowsInfo oldFlowInfo = flowsInfoMapper.findById(id).get();
// //得到老的fileXml
// String filePath = System.getProperty("user.dir")+oldFlowInfo.getFilePath();
// File oldFile = new File(filePath);
// File file = new File(filePath);
// if(!file.exists()){
// flowsInfoVo.setIsOld(1);
// }else {
// FileInputStream inputStream = new FileInputStream(file);
// int length = inputStream.available();
// byte bytes[] = new byte[length];
// inputStream.read(bytes);
// inputStream.close();
// String oldXml =new String(bytes, StandardCharsets.UTF_8);
// if (oldXml.equals(fileXml)){
// flowsInfoVo.setIsOld(0);
// }else {
// flowsInfoVo.setIsOld(1);
// }
// }
// }else {
// flowsInfoVo.setIsOld(1);
// }
// //end
//
// //生成xml文件
// File file = FileUtil.createFileByString(basePath + flowKey + "bpmn20.xml",
// flowsInfoVo.getFileXml().replaceAll("\\[\\?\\?[^\\]]+\\?\\?\\]", "").replaceAll("<","<").replaceAll(">",">"));
//
// FileUtil.createFileByString(basePath + flowKey + "bpmnCustom20.xml", flowsInfoVo.getFileXml());
//
// FlowsInfo flowsInfo = new FlowsInfo();
// BeanUtils.copyProperties(flowsInfoVo, flowsInfo);
// flowsInfo.setResourceName(flowKey + "bpmn20.xml");
// flowsInfo.setFilePath("\\xml\\" + flowKey + "bpmn20.xml");
// flowsInfo.setFileCustomPath("\\xml\\" + flowKey + "bpmnCustom20.xml");
// flowsInfo.setId(id);
// //进行第一部的校验
// InputStream inputStream = new FileInputStream(file);//实例化FileInputStream
// BpmnXMLConverter converter = new BpmnXMLConverter();
// XMLInputFactory factory = XMLInputFactory.newInstance();
// XMLStreamReader reader = factory.createXMLStreamReader(inputStream);//createXmlStreamReader
// //将xml文件转换成BpmnModel
// BpmnModel bpmnModel = converter.convertToBpmnModel(reader);
// //做校验
// ProcessValidator defaultProcessValidator = processValidatorFactoryExt.createDefaultProcessValidator();
// List<ValidationError> validate = defaultProcessValidator.validate(bpmnModel);
// StringBuffer message = new StringBuffer();
// if (validate.size()!=0){
// for (int i =0;i<validate.size();i++){
// ValidationError validationError = validate.get(i);
// String problem = validationError.getProblem();
// message.append(i+1+""+problem);
// message.append("\r\n");
// }
// throw new ApiException(null,message.toString());
// }
// //更新并保存
// flowsInfoMapper.save(flowsInfo);
//// else {
//// //自动部署
//// deployXml(save);
////
//// }
//
// }
@Override
@Override
public
void
flowXml
(
@RequestBody
FlowsInfoVo
flowsInfoVo
)
throws
XMLStreamException
,
IOException
{
public
void
flowXml
(
@RequestBody
FlowsInfoVo
flowsInfoVo
)
throws
XMLStreamException
,
IOException
{
String
basePath
=
System
.
getProperty
(
"user.dir"
)
+
"\\xml\\"
;
Integer
id
=
flowsInfoVo
.
getId
();
String
flowKey
=
flowsInfoVo
.
getFlowKey
();
String
flowKey
=
flowsInfoVo
.
getFlowKey
();
String
fileXml
=
flowsInfoVo
.
getFileXml
();
String
flowXmlResourceName
=
flowKey
+
"bpmn20.xml"
;
//根据ID查询出一个flowsinfo
String
CustomFlowXmlResourceName
=
flowKey
+
"bpmnCustom20.xml"
;
if
(
id
!=
null
){
//从数据库里查处来
FlowsInfo
oldFlowInfo
=
flowsInfoMapper
.
findById
(
id
).
get
();
FlowsInfo
flowsInfo
=
flowsInfoMapper
.
getOne
(
flowsInfoVo
.
getId
());
//得到老的fileXml
if
(
StrUtil
.
isEmpty
(
flowsInfo
.
getFilePath
())){
String
filePath
=
System
.
getProperty
(
"user.dir"
)+
oldFlowInfo
.
getFilePath
();
//生成xml文件
File
oldFile
=
new
File
(
filePath
);
flowsInfo
=
flowsInfoVo
.
toEntity
(
flowsInfo
);
File
file
=
new
File
(
filePath
);
flowsInfo
.
setResourceName
(
flowXmlResourceName
);
if
(!
file
.
exists
()){
flowsInfo
.
setFilePath
(
XML_FILE_PATH
+
flowXmlResourceName
);
flowsInfoVo
.
setIsOld
(
1
);
flowsInfo
.
setFileCustomPath
(
XML_FILE_PATH
+
CustomFlowXmlResourceName
);
}
else
{
}
FileInputStream
inputStream
=
new
FileInputStream
(
file
);
File
file
=
FileUtil
.
createFileByString
(
BASE_PATH
+
XML_FILE_PATH
+
flowXmlResourceName
,
int
length
=
inputStream
.
available
();
flowsInfoVo
.
getFileXml
().
replaceAll
(
"\\[\\?\\?[^\\]]+\\?\\?\\]"
,
""
).
replaceAll
(
"<"
,
"<"
).
replaceAll
(
">"
,
">"
));
byte
bytes
[]
=
new
byte
[
length
];
FileUtil
.
createFileByString
(
BASE_PATH
+
XML_FILE_PATH
+
CustomFlowXmlResourceName
,
flowsInfoVo
.
getFileXml
());
inputStream
.
read
(
bytes
);
//获取bmpnModel
inputStream
.
close
();
BpmnModel
bpmnModel
=
getBpmnModel
(
file
);
String
oldXml
=
new
String
(
bytes
,
StandardCharsets
.
UTF_8
);
//设置开始节点id
if
(
oldXml
.
equals
(
fileXml
)){
flowsInfo
.
setStartPageId
(
getStartPageId
(
bpmnModel
));
flowsInfoVo
.
setIsOld
(
0
);
//进行第一次的校验
checkXml
(
bpmnModel
);
//自动部署
deployXml
(
flowsInfo
.
getId
());
//更新并保存
flowsInfoMapper
.
save
(
flowsInfo
);
}
/**
* 获取流程开始页面的ID
* @param bpmnModel
* @return
*/
public
Integer
getStartPageId
(
BpmnModel
bpmnModel
){
Process
process
=
bpmnModel
.
getProcesses
().
get
(
0
);
Collection
<
FlowElement
>
flowElements
=
process
.
getFlowElements
();
for
(
FlowElement
flowElement
:
flowElements
)
{
if
(
flowElement
instanceof
StartEvent
){
String
formKey
=
((
StartEvent
)
flowElement
).
getFormKey
();
if
(
formKey
==
null
){
throw
new
ApiException
(
"开始节点表单不能为空"
);
}
else
{
}
else
{
flowsInfoVo
.
setIsOld
(
1
);
return
Integer
.
valueOf
(
formKey
);
}
}
}
}
}
else
{
flowsInfoVo
.
setIsOld
(
1
);
}
}
//end
return
-
1
;
}
//生成xml文件
File
file
=
FileUtil
.
createFileByString
(
basePath
+
flowKey
+
"bpmn20.xml"
,
flowsInfoVo
.
getFileXml
().
replaceAll
(
"\\[\\?\\?[^\\]]+\\?\\?\\]"
,
""
).
replaceAll
(
"<"
,
"<"
).
replaceAll
(
">"
,
">"
));
FileUtil
.
createFileByString
(
basePath
+
flowKey
+
"bpmnCustom20.xml"
,
flowsInfoVo
.
getFileXml
());
FlowsInfo
flowsInfo
=
new
FlowsInfo
();
/**
BeanUtils
.
copyProperties
(
flowsInfoVo
,
flowsInfo
);
* 获取bpmnModel
flowsInfo
.
setResourceName
(
flowKey
+
"bpmn20.xml"
);
* @param xmlFile
flowsInfo
.
setFilePath
(
"\\xml\\"
+
flowKey
+
"bpmn20.xml"
);
* @return
flowsInfo
.
setFileCustomPath
(
"\\xml\\"
+
flowKey
+
"bpmnCustom20.xml"
);
* @throws FileNotFoundException
flowsInfo
.
setId
(
id
);
* @throws XMLStreamException
//进行第一部的校验
*/
InputStream
inputStream
=
new
FileInputStream
(
file
);
//实例化FileInputStream
public
BpmnModel
getBpmnModel
(
File
xmlFile
)
throws
FileNotFoundException
,
XMLStreamException
{
InputStream
inputStream
=
new
FileInputStream
(
xmlFile
);
BpmnXMLConverter
converter
=
new
BpmnXMLConverter
();
BpmnXMLConverter
converter
=
new
BpmnXMLConverter
();
XMLInputFactory
factory
=
XMLInputFactory
.
newInstance
();
XMLInputFactory
factory
=
XMLInputFactory
.
newInstance
();
XMLStreamReader
reader
=
factory
.
createXMLStreamReader
(
inputStream
);
//createXmlStreamReader
//createXmlStreamReader
XMLStreamReader
reader
=
factory
.
createXMLStreamReader
(
inputStream
);
//将xml文件转换成BpmnModel
//将xml文件转换成BpmnModel
BpmnModel
bpmnModel
=
converter
.
convertToBpmnModel
(
reader
);
return
converter
.
convertToBpmnModel
(
reader
);
}
public
void
checkXml
(
BpmnModel
bpmnModel
){
//做校验
//做校验
ProcessValidator
defaultProcessValidator
=
processValidatorFactoryExt
.
createDefaultProcessValidator
();
ProcessValidator
defaultProcessValidator
=
processValidatorFactoryExt
.
createDefaultProcessValidator
();
List
<
ValidationError
>
validate
=
defaultProcessValidator
.
validate
(
bpmnModel
);
List
<
ValidationError
>
validate
=
defaultProcessValidator
.
validate
(
bpmnModel
);
...
@@ -182,14 +277,6 @@ public class WorkFlowServiceImpl implements WorkFlowService {
...
@@ -182,14 +277,6 @@ public class WorkFlowServiceImpl implements WorkFlowService {
}
}
throw
new
ApiException
(
null
,
message
.
toString
());
throw
new
ApiException
(
null
,
message
.
toString
());
}
}
//更新并保存
flowsInfoMapper
.
save
(
flowsInfo
);
// else {
// //自动部署
// deployXml(save);
//
// }
}
}
...
@@ -209,14 +296,15 @@ public class WorkFlowServiceImpl implements WorkFlowService {
...
@@ -209,14 +296,15 @@ public class WorkFlowServiceImpl implements WorkFlowService {
deploy
=
repositoryService
.
createDeployment
().
addInputStream
(
System
.
getProperty
(
"user.dir"
)
+
flowsInfo
.
getResourceName
(),
deploy
=
repositoryService
.
createDeployment
().
addInputStream
(
System
.
getProperty
(
"user.dir"
)
+
flowsInfo
.
getResourceName
(),
new
FileInputStream
(
System
.
getProperty
(
"user.dir"
)
+
flowsInfo
.
getFilePath
())).
deploy
();
new
FileInputStream
(
System
.
getProperty
(
"user.dir"
)
+
flowsInfo
.
getFilePath
())).
deploy
();
}
catch
(
FileNotFound
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
throw
new
ApiException
(
"流程图不符合规范"
);
}
}
//将流程自动挂起
repositoryService
.
suspendProcessDefinitionByKey
(
flowsInfo
.
getFlowKey
(),
true
,
new
Date
());
//修改状态
//修改状态
flowsInfo
.
setState
(
0
);
flowsInfo
.
setState
(
1
);
flowsInfo
.
setDeployId
(
deploy
.
getId
());
flowsInfo
.
setDeployId
(
deploy
.
getId
());
flowsInfoMapper
.
save
(
flowsInfo
);
flowsInfoMapper
.
save
(
flowsInfo
);
}
}
@Override
@Override
...
@@ -360,20 +448,12 @@ public class WorkFlowServiceImpl implements WorkFlowService {
...
@@ -360,20 +448,12 @@ public class WorkFlowServiceImpl implements WorkFlowService {
repositoryService
.
suspendProcessDefinitionByKey
(
flowKey
,
true
,
new
Date
());
repositoryService
.
suspendProcessDefinitionByKey
(
flowKey
,
true
,
new
Date
());
flowsInfo
.
setState
(
1
);
flowsInfo
.
setState
(
1
);
}
else
{
}
else
{
if
(
flowsInfo
.
getIsOld
()
==
1
){
//激活
deployXml
(
id
);
repositoryService
.
activateProcessDefinitionByKey
(
flowKey
,
true
,
new
Date
());
//还原标志位
flowsInfo
.
setIsOld
(
0
);
}
else
{
//激活
repositoryService
.
activateProcessDefinitionByKey
(
flowKey
,
true
,
new
Date
());
}
flowsInfo
.
setState
(
0
);
flowsInfo
.
setState
(
0
);
}
}
}
else
{
}
else
{
deployXml
(
id
);
deployXml
(
id
);
flowsInfo
.
setState
(
0
);
flowsInfo
.
setIsOld
(
0
);
}
}
flowsInfoMapper
.
save
(
flowsInfo
);
flowsInfoMapper
.
save
(
flowsInfo
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论