Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
workflow2
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
workflow2
Commits
304442fd
提交
304442fd
authored
9月 02, 2021
作者:
1239068511@qq.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[工作流] 增了 1. 中止流程
2. 流程运行中,页面和流程图无法被修改
上级
9ba8f039
隐藏空白字符变更
内嵌
并排
正在显示
17 个修改的文件
包含
229 行增加
和
61 行删除
+229
-61
BaseEntity.java
...in/java/com/tykj/workflowcore/base/entity/BaseEntity.java
+0
-1
FlowsInfoController.java
...wcore/workflow_editer/controller/FlowsInfoController.java
+16
-4
FormPageController.java
...owcore/workflow_editer/controller/FormPageController.java
+11
-1
WorkFlowController.java
...owcore/workflow_editer/controller/WorkFlowController.java
+9
-0
DataHistory.java
...tykj/workflowcore/workflow_editer/entity/DataHistory.java
+25
-1
FlowsInfo.java
...m/tykj/workflowcore/workflow_editer/entity/FlowsInfo.java
+2
-2
FormPage.java
...om/tykj/workflowcore/workflow_editer/entity/FormPage.java
+0
-6
FlowsInfoVo.java
...j/workflowcore/workflow_editer/entity/vo/FlowsInfoVo.java
+2
-0
FormPageVo.java
...kj/workflowcore/workflow_editer/entity/vo/FormPageVo.java
+3
-0
PageFormPageVo.java
...orkflowcore/workflow_editer/entity/vo/PageFormPageVo.java
+0
-6
SuspendVo.java
...ykj/workflowcore/workflow_editer/entity/vo/SuspendVo.java
+1
-1
FlowInfoService.java
...workflowcore/workflow_editer/service/FlowInfoService.java
+2
-1
FormPageService.java
...workflowcore/workflow_editer/service/FormPageService.java
+5
-15
WorkFlowService.java
...workflowcore/workflow_editer/service/WorkFlowService.java
+13
-0
FlowInfoServiceImpl.java
...ore/workflow_editer/service/impl/FlowInfoServiceImpl.java
+25
-1
FormPageServiceImpl.java
...ore/workflow_editer/service/impl/FormPageServiceImpl.java
+53
-21
WorkFlowServiceImpl.java
...ore/workflow_editer/service/impl/WorkFlowServiceImpl.java
+62
-1
没有找到文件。
src/main/java/com/tykj/workflowcore/base/entity/BaseEntity.java
浏览文件 @
304442fd
...
...
@@ -19,7 +19,6 @@ import java.util.Date;
public
abstract
class
BaseEntity
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@ApiModelProperty
(
"主键"
)
protected
Integer
id
;
...
...
src/main/java/com/tykj/workflowcore/workflow_editer/controller/FlowsInfoController.java
浏览文件 @
304442fd
package
com
.
tykj
.
workflowcore
.
workflow_editer
.
controller
;
import
com.tykj.workflowcore.base.result.ApiException
;
import
com.tykj.workflowcore.base.result.ResultUtil
;
import
com.tykj.workflowcore.workflow_editer.entity.FlowsInfo
;
import
com.tykj.workflowcore.workflow_editer.entity.VariableStorage
;
import
com.tykj.workflowcore.workflow_editer.entity.vo.*
;
import
com.tykj.workflowcore.workflow_editer.service.*
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.flowable.engine.RuntimeService
;
import
org.flowable.engine.history.HistoricProcessInstance
;
import
org.flowable.engine.runtime.ProcessInstance
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.http.ResponseEntity
;
...
...
@@ -15,6 +18,7 @@ import org.springframework.web.multipart.MultipartFile;
import
javax.xml.stream.XMLStreamException
;
import
java.io.IOException
;
import
java.util.List
;
/**
...
...
@@ -34,6 +38,9 @@ public class FlowsInfoController {
@Autowired
private
WorkFlowService
workFlowService
;
@Autowired
private
RuntimeService
runtimeService
;
@PostMapping
(
"/searchAllFlowInfo"
)
...
...
@@ -56,17 +63,21 @@ public class FlowsInfoController {
return
workFlowService
.
upLoadFile
(
file
);
}
@GetMapping
(
"editFlow"
)
@ApiOperation
(
value
=
"
编辑流程
"
)
@GetMapping
(
"
/
editFlow"
)
@ApiOperation
(
value
=
"
根据ID查询流程详情
"
)
public
ResponseEntity
editFlow
(
Integer
id
){
return
ResultUtil
.
success
(
flowInfoService
.
editFlow
(
id
),
"查询成功"
);
}
@PostMapping
(
"/saveXml"
)
@ApiOperation
(
value
=
"保存xml以及其他流程信息"
)
public
ResponseEntity
saveXml
(
@RequestBody
FlowsInfoVo
flowsInfoVo
)
throws
IOException
,
XMLStreamException
{
//验证一下是否为更新,如果为更新的话,先判断该流程是否存在未运行完成的流程,如果的话则拒绝更新
List
<
ProcessInstance
>
list
=
runtimeService
.
createProcessInstanceQuery
().
processDefinitionKey
(
flowsInfoVo
.
getFlowKey
()).
list
();
if
(
list
.
size
()>
0
){
throw
new
ApiException
(
"存在正在运行的流程实例,请先将正在运行的流程实例全部完结后才可以进行修改"
);
}
//保存节点信息
// nodeInfoService.saveNodeInfoList(flowsInfoVo.getNodeInfoList());
//保存xml信息
...
...
@@ -95,4 +106,5 @@ public class FlowsInfoController {
}
}
src/main/java/com/tykj/workflowcore/workflow_editer/controller/FormPageController.java
浏览文件 @
304442fd
package
com
.
tykj
.
workflowcore
.
workflow_editer
.
controller
;
import
com.tykj.workflowcore.base.result.ApiException
;
import
com.tykj.workflowcore.base.result.ResultUtil
;
import
com.tykj.workflowcore.workflow_editer.entity.FormPage
;
import
com.tykj.workflowcore.workflow_editer.entity.vo.FormPageVo
;
...
...
@@ -7,6 +8,7 @@ import com.tykj.workflowcore.workflow_editer.entity.vo.PageFormPageVo;
import
com.tykj.workflowcore.workflow_editer.service.FormPageService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
...
...
@@ -28,10 +30,12 @@ public class FormPageController {
@Autowired
private
FormPageService
formPageService
;
@ApiOperation
(
"保存页面"
)
@PostMapping
(
"/savePage"
)
public
ResponseEntity
savePage
(
@RequestBody
FormPageVo
inFormPageVo
){
if
(
StringUtils
.
isEmpty
(
inFormPageVo
.
getProcessKey
())){
throw
new
ApiException
(
"processKey不能为空"
);
}
if
(
inFormPageVo
.
getId
()
==
null
){
Integer
pageId
=
formPageService
.
savePage
(
inFormPageVo
);
return
ResultUtil
.
success
(
pageId
,
"页面保存成功"
);
...
...
@@ -55,6 +59,12 @@ public class FormPageController {
return
ResultUtil
.
success
(
formPageService
.
getAllPages
(
pageFormPageVo
),
"查询成功"
);
}
@ApiOperation
(
"查看列表"
)
@PostMapping
(
"/findList"
)
public
ResponseEntity
findList
(
@RequestBody
PageFormPageVo
pageFormPageVo
){
return
ResultUtil
.
success
(
formPageService
.
getAllList
(
pageFormPageVo
),
"查询成功"
);
}
@ApiOperation
(
"删除页面"
)
@DeleteMapping
(
"deletePage"
)
public
ResponseEntity
deletePage
(
Integer
id
){
...
...
src/main/java/com/tykj/workflowcore/workflow_editer/controller/WorkFlowController.java
浏览文件 @
304442fd
...
...
@@ -105,4 +105,13 @@ public class WorkFlowController {
return
startByUser
;
}
@GetMapping
(
"/stopProcessInstance"
)
@ApiOperation
(
"中止流程"
)
public
ResponseEntity
stopProcessInstance
(
String
processInstanceId
)
{
workFlowService
.
stopProcessInstanceById
(
processInstanceId
);
return
ResultUtil
.
success
(
"停止成功"
);
}
}
src/main/java/com/tykj/workflowcore/workflow_editer/entity/DataHistory.java
浏览文件 @
304442fd
...
...
@@ -38,13 +38,37 @@ public class DataHistory extends BaseEntity {
@ApiModelProperty
(
"页面id"
)
private
String
pageId
;
@ApiModelProperty
(
"页面名称"
)
private
String
pageName
;
@ApiModelProperty
(
"页面描述"
)
private
String
pageDesc
;
@ApiModelProperty
(
"模板"
)
@Lob
private
String
template
;
@ApiModelProperty
(
"页面js"
)
@Lob
private
String
js
;
@ApiModelProperty
(
"页面css"
)
@Lob
private
String
css
;
@ApiModelProperty
(
"json描述文件"
)
@Lob
private
String
descFile
;
@ApiModelProperty
(
"变量数据"
)
@Lob
private
String
datas
;
@ApiModelProperty
(
"用户id"
)
@ApiModelProperty
(
"
页面操作
用户id"
)
private
Integer
userId
;
}
src/main/java/com/tykj/workflowcore/workflow_editer/entity/FlowsInfo.java
浏览文件 @
304442fd
...
...
@@ -56,8 +56,8 @@ public class FlowsInfo extends BaseEntity {
@ApiModelProperty
(
"流程描述"
)
private
String
flowDescribe
;
// @ApiModelProperty("开始节点的id
")
// private String startId
;
@ApiModelProperty
(
"页面ID,示例 1,2,3,4
"
)
private
String
pageIds
;
@ApiModelProperty
(
"开始节点页面的id"
)
private
Integer
startPageId
;
...
...
src/main/java/com/tykj/workflowcore/workflow_editer/entity/FormPage.java
浏览文件 @
304442fd
...
...
@@ -34,12 +34,6 @@ import java.util.stream.Collectors;
@Api
(
"表单页面"
)
public
class
FormPage
extends
BaseEntity
{
@ApiModelProperty
(
"页面标识,区别与数据库ID 该标识用于区分是否为同一张页面的不同版本"
)
private
String
pageIdentification
;
@ApiModelProperty
(
"版本号"
)
private
Integer
version
;
@ApiModelProperty
(
"页面名称"
)
private
String
pageName
;
...
...
src/main/java/com/tykj/workflowcore/workflow_editer/entity/vo/FlowsInfoVo.java
浏览文件 @
304442fd
...
...
@@ -38,6 +38,8 @@ public class FlowsInfoVo {
@ApiModelProperty
private
String
fileXml
;
public
FlowsInfo
toEntity
(){
FlowsInfo
flowsInfo
=
new
FlowsInfo
();
BeanUtils
.
copyProperties
(
this
,
flowsInfo
);
...
...
src/main/java/com/tykj/workflowcore/workflow_editer/entity/vo/FormPageVo.java
浏览文件 @
304442fd
...
...
@@ -55,6 +55,9 @@ public class FormPageVo {
@Lob
private
String
descFile
;
@ApiModelProperty
(
"所属流程key"
)
private
String
processKey
;
@ApiModelProperty
(
"实体类"
)
private
List
<
String
>
entityIds
;
...
...
src/main/java/com/tykj/workflowcore/workflow_editer/entity/vo/PageFormPageVo.java
浏览文件 @
304442fd
...
...
@@ -32,12 +32,6 @@ public class PageFormPageVo extends JpaCustomPage {
@ApiModelProperty
(
"页面创建时间"
)
private
Date
createTime
;
@ApiModelProperty
(
"页面标识,区别与数据库ID 该标识用于区分是否为同一张页面的不同版本"
)
private
String
pageIdentification
;
@ApiModelProperty
(
"版本号"
)
private
Integer
version
;
@ApiModelProperty
(
"所属流程key"
)
private
String
processKey
;
...
...
src/main/java/com/tykj/workflowcore/workflow_editer/entity/vo/SuspendVo.java
浏览文件 @
304442fd
...
...
@@ -23,7 +23,7 @@ public class SuspendVo {
private
Integer
id
;
/**
* 是否可用 0
挂起 1 激活
* 是否可用 0
激活 1 挂起
*/
private
int
state
;
...
...
src/main/java/com/tykj/workflowcore/workflow_editer/service/FlowInfoService.java
浏览文件 @
304442fd
...
...
@@ -74,11 +74,12 @@ public interface FlowInfoService {
Page
<
FlowsInfo
>
searchFlowInfo
(
SearchFlowInfoVo
searchFlowInfoVo
);
/**
*
编辑流程
*
根据ID查询流程详情
* @param id 流程id
* @return
*/
FlowsInfo
editFlow
(
Integer
id
);
}
src/main/java/com/tykj/workflowcore/workflow_editer/service/FormPageService.java
浏览文件 @
304442fd
...
...
@@ -5,6 +5,7 @@ import com.tykj.workflowcore.workflow_editer.entity.FormPage;
import
com.tykj.workflowcore.workflow_editer.entity.vo.FormPageVo
;
import
com.tykj.workflowcore.workflow_editer.entity.vo.PageFormPageVo
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
java.util.List
;
...
...
@@ -39,21 +40,6 @@ public interface FormPageService {
*/
FormPage
getPage
(
Integer
id
);
/**
* 根据流程Id来进行回显 返回最新的一个版本的列表
* @param processKey 页面id
* @return 页面信息
*/
List
<
FormPage
>
getPageNewByProcessKey
(
String
processKey
);
/**
* 根据页面标识来进行回显 返回最新的一个版本的列表
* @param pageIdentification 页面标识
* @return 页面信息
*/
List
<
FormPage
>
getPageNewByPageIdentification
(
String
pageIdentification
);
/**
* 根据页面id删除页面
* @param id 页面id
...
...
@@ -67,5 +53,9 @@ public interface FormPageService {
*/
Page
<
FormPage
>
getAllPages
(
PageFormPageVo
pageFormPageVo
);
List
<
FormPage
>
getAllList
(
PageFormPageVo
pageFormPageVo
);
Specification
<
FormPage
>
specificationBuild
(
PageFormPageVo
pageFormPageVo
);
}
src/main/java/com/tykj/workflowcore/workflow_editer/service/WorkFlowService.java
浏览文件 @
304442fd
...
...
@@ -3,6 +3,7 @@ package com.tykj.workflowcore.workflow_editer.service;
import
com.tykj.workflowcore.workflow_editer.entity.FlowsInfo
;
import
com.tykj.workflowcore.workflow_editer.entity.vo.*
;
import
org.flowable.engine.history.HistoricProcessInstance
;
import
org.flowable.engine.runtime.ProcessInstance
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.multipart.MultipartFile
;
...
...
@@ -159,6 +160,18 @@ public interface WorkFlowService {
List
<
HistoricProcessInstance
>
findStartByUser
(
String
userId
);
/**
* 中止流程
* @param processInstanceId
*/
void
stopProcessInstanceById
(
String
processInstanceId
);
/**
* 根据processKey 查询正在运行中的流程实例
* @param processKey 流程Key
*/
List
<
ProcessInstance
>
queryUnfinishedProcessInstance
(
String
processKey
);
}
src/main/java/com/tykj/workflowcore/workflow_editer/service/impl/FlowInfoServiceImpl.java
浏览文件 @
304442fd
...
...
@@ -9,12 +9,22 @@ import com.tykj.workflowcore.workflow_editer.entity.vo.FlowsInfoVo;
import
com.tykj.workflowcore.workflow_editer.entity.vo.SearchAllFlowInfoVo
;
import
com.tykj.workflowcore.workflow_editer.entity.vo.SearchFlowInfoVo
;
import
com.tykj.workflowcore.workflow_editer.service.FlowInfoService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.flowable.bpmn.model.EndEvent
;
import
org.flowable.bpmn.model.FlowElement
;
import
org.flowable.bpmn.model.Process
;
import
org.flowable.engine.RepositoryService
;
import
org.flowable.engine.RuntimeService
;
import
org.flowable.engine.runtime.Execution
;
import
org.flowable.engine.runtime.ProcessInstance
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
java.util.Optional
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* ClassName: FlowInfoServiceImpl
...
...
@@ -25,11 +35,18 @@ import java.util.Optional;
* @Author: zsp
*/
@Service
@Slf4j
public
class
FlowInfoServiceImpl
implements
FlowInfoService
{
@Autowired
private
FlowsInfoMapper
flowsInfoMapper
;
@Autowired
private
RepositoryService
repositoryService
;
@Autowired
private
RuntimeService
runtimeService
;
@Override
public
FlowsInfo
findById
(
Integer
id
)
{
return
flowsInfoMapper
.
findById
(
id
).
get
();
...
...
@@ -99,9 +116,16 @@ public class FlowInfoServiceImpl implements FlowInfoService {
return
flowsInfoMapper
.
findAll
(
and
.
build
(),
searchFlowInfoVo
.
getPageable
());
}
/**
* 根据ID查询流程详情
* @param id 流程id
* @return
*/
@Override
public
FlowsInfo
editFlow
(
Integer
id
)
{
return
flowsInfoMapper
.
findById
(
id
).
get
();
}
}
src/main/java/com/tykj/workflowcore/workflow_editer/service/impl/FormPageServiceImpl.java
浏览文件 @
304442fd
package
com
.
tykj
.
workflowcore
.
workflow_editer
.
service
.
impl
;
import
com.alibaba.fastjson.JSONArray
;
import
com.github.wenhao.jpa.PredicateBuilder
;
import
com.github.wenhao.jpa.Specifications
;
import
com.tykj.workflowcore.
model.entity.TableInfo
;
import
com.tykj.workflowcore.
base.result.ApiException
;
import
com.tykj.workflowcore.workflow_editer.dao.FormPageMapper
;
import
com.tykj.workflowcore.workflow_editer.entity.FlowsInfo
;
import
com.tykj.workflowcore.workflow_editer.entity.FormPage
;
import
com.tykj.workflowcore.workflow_editer.entity.vo.FormPageVo
;
import
com.tykj.workflowcore.workflow_editer.entity.vo.PageFormPageVo
;
import
com.tykj.workflowcore.workflow_editer.service.FlowInfoService
;
import
com.tykj.workflowcore.workflow_editer.service.FormPageService
;
import
com.tykj.workflowcore.workflow_editer.service.WorkFlowService
;
import
org.flowable.engine.RepositoryService
;
import
org.flowable.engine.RuntimeService
;
import
org.flowable.engine.runtime.ProcessInstance
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.
domain.Sort
;
import
org.springframework.data.
jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.bind.annotation.RequestBody
;
...
...
@@ -28,21 +35,49 @@ import java.util.*;
@Service
public
class
FormPageServiceImpl
implements
FormPageService
{
@Autowired
RuntimeService
runtimeService
;
@Autowired
private
FormPageMapper
formPageMapper
;
@Autowired
FlowInfoService
flowInfoService
;
@Autowired
RepositoryService
repositoryService
;
@Autowired
WorkFlowService
workFlowService
;
@Override
public
Integer
savePage
(
@RequestBody
FormPageVo
inFormPageVo
)
{
inFormPageVo
.
setCreateTime
(
new
Date
());
FormPage
formPage
=
inFormPageVo
.
toEntity
();
formPage
.
setPageIdentification
(
UUID
.
randomUUID
().
toString
());
FormPage
formPage1
=
formPageMapper
.
save
(
formPage
);
Integer
id
=
formPage1
.
getId
();
FormPage
formPageSave
=
formPageMapper
.
save
(
formPage
);
Integer
id
=
formPageSave
.
getId
();
return
id
;
}
@Override
public
void
update
(
FormPage
formPage
)
{
//查询对应的processKey
FlowsInfo
byFlowKey
=
flowInfoService
.
findByFlowKey
(
formPage
.
getProcessKey
());
JSONArray
pageIdArrays
=
JSONArray
.
parseArray
(
byFlowKey
.
getPageIds
());
if
(
pageIdArrays
.
contains
(
formPage
.
getId
())){
//判断 byFlowKey 是否正在运行
Integer
state
=
byFlowKey
.
getState
();
// 0代表这个流程正在运行过程中
if
(
state
==
0
){
throw
new
ApiException
(
"该页面正在流程中运行,无法被修改"
);
}
//判断该流程是否存在正在运行的流程实例如果存在将不允许修改页面
List
<
ProcessInstance
>
processInstances
=
workFlowService
.
queryUnfinishedProcessInstance
(
formPage
.
getProcessKey
());
if
(
processInstances
.
size
()>
0
){
throw
new
ApiException
(
"该页面正在流程中运行,无法被修改.请先停止所有正在运行的流程实例"
);
}
}
formPageMapper
.
save
(
formPage
);
}
...
...
@@ -53,37 +88,34 @@ public class FormPageServiceImpl implements FormPageService {
}
@Override
public
List
<
FormPage
>
getPageNewByProcessKey
(
String
processKey
)
{
//构建查询Vo
return
formPageMapper
.
findNewFromPageByProcessKey
(
processKey
);
public
void
deletePage
(
Integer
id
)
{
FormPage
formPage
=
formPageMapper
.
findById
(
id
).
get
();
formPageMapper
.
delete
(
formPage
);
}
@Override
public
List
<
FormPage
>
getPageNewByPageIdentification
(
String
pageIdentification
)
{
return
null
;
public
Page
<
FormPage
>
getAllPages
(
PageFormPageVo
pageFormPageVo
)
{
Specification
<
FormPage
>
formPageSpecification
=
specificationBuild
(
pageFormPageVo
);
Page
<
FormPage
>
formPagePage
=
formPageMapper
.
findAll
(
formPageSpecification
,
pageFormPageVo
.
getPageable
());
return
formPagePage
;
}
@Override
public
void
deletePage
(
Integer
id
)
{
FormPage
formPage
=
formPageMapper
.
findById
(
id
).
get
();
formPageMapper
.
delete
(
formPage
);
public
List
<
FormPage
>
getAllList
(
PageFormPageVo
pageFormPageVo
)
{
Specification
<
FormPage
>
formPageSpecification
=
specificationBuild
(
pageFormPageVo
);
List
<
FormPage
>
all
=
formPageMapper
.
findAll
(
formPageSpecification
);
return
all
;
}
@Override
public
Page
<
FormPage
>
getAllPages
(
PageFormPageVo
pageFormPageVo
)
{
public
Specification
<
FormPage
>
specificationBuild
(
PageFormPageVo
pageFormPageVo
)
{
PredicateBuilder
<
FormPage
>
and
=
Specifications
.
and
();
and
.
eq
(
pageFormPageVo
.
getPageName
()!=
null
,
"pageName"
,
pageFormPageVo
.
getPageName
());
and
.
eq
(
pageFormPageVo
.
getPageDesc
()!=
null
,
"pageDesc"
,
pageFormPageVo
.
getPageDesc
());
and
.
eq
(
pageFormPageVo
.
getCreateTime
()!=
null
,
"createTime"
,
pageFormPageVo
.
getCreateTime
());
and
.
eq
(
pageFormPageVo
.
getCreateTime
()!=
null
,
"processKey"
,
pageFormPageVo
.
getProcessKey
());
and
.
eq
(
pageFormPageVo
.
getCreateTime
()!=
null
,
"version"
,
pageFormPageVo
.
getVersion
());
and
.
eq
(
pageFormPageVo
.
getCreateTime
()!=
null
,
"pageIdentification"
,
pageFormPageVo
.
getPageIdentification
());
Page
<
FormPage
>
formPagePage
=
formPageMapper
.
findAll
(
and
.
build
(),
pageFormPageVo
.
getPageable
());
return
formPagePage
;
return
and
.
build
();
}
}
src/main/java/com/tykj/workflowcore/workflow_editer/service/impl/WorkFlowServiceImpl.java
浏览文件 @
304442fd
...
...
@@ -13,6 +13,7 @@ import com.tykj.workflowcore.workflow_editer.service.WorkFlowService;
import
com.tykj.workflowcore.workflow_editer.util.MapUtils
;
import
com.tykj.workflowcore.workflow_editer.util.UserServiceBeanUtil
;
import
com.tykj.workflowcore.workflow_editer.validate.ProcessValidatorFactoryExt
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.flowable.bpmn.converter.BpmnXMLConverter
;
import
org.flowable.bpmn.model.*
;
...
...
@@ -21,6 +22,7 @@ import org.flowable.engine.*;
import
org.flowable.engine.history.HistoricProcessInstance
;
import
org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl
;
import
org.flowable.engine.repository.Deployment
;
import
org.flowable.engine.runtime.Execution
;
import
org.flowable.engine.runtime.ProcessInstance
;
import
org.flowable.task.api.Task
;
import
org.flowable.task.api.TaskQuery
;
...
...
@@ -29,6 +31,7 @@ import org.flowable.validation.ProcessValidator;
import
org.flowable.validation.ValidationError
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.multipart.MultipartFile
;
...
...
@@ -40,6 +43,7 @@ import javax.xml.stream.XMLStreamReader;
import
java.io.*
;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.stream.Collectors
;
/**
* ClassName: FlowableServiceImpl
...
...
@@ -50,6 +54,7 @@ import java.util.concurrent.ConcurrentHashMap;
* @Author: zsp
*/
@Service
@Slf4j
public
class
WorkFlowServiceImpl
implements
WorkFlowService
{
private
static
String
XML_FILE_PATH
=
File
.
separator
+
"xml"
+
File
.
separator
;
...
...
@@ -214,6 +219,9 @@ public class WorkFlowServiceImpl implements WorkFlowService {
FileUtil
.
createFileByString
(
BASE_PATH
+
XML_FILE_PATH
+
CustomFlowXmlResourceName
,
flowsInfoVo
.
getFileXml
());
//获取bmpnModel
BpmnModel
bpmnModel
=
getBpmnModel
(
file
);
//获取流程中所有的页面ID
List
<
String
>
pageIds
=
getPageIds
(
bpmnModel
);
flowsInfo
.
setPageIds
(
pageIds
.
toString
());
//设置开始节点id
flowsInfo
.
setStartPageId
(
getStartPageId
(
bpmnModel
));
//进行第一次的校验
...
...
@@ -224,6 +232,24 @@ public class WorkFlowServiceImpl implements WorkFlowService {
flowsInfoMapper
.
save
(
flowsInfo
);
}
public
List
<
String
>
getPageIds
(
BpmnModel
bpmnModel
){
ArrayList
<
String
>
result
=
new
ArrayList
<>();
List
<
Process
>
processes
=
bpmnModel
.
getProcesses
();
for
(
Process
process
:
processes
)
{
Collection
<
FlowElement
>
flowElements
=
process
.
getFlowElements
();
for
(
FlowElement
flowElement
:
flowElements
)
{
if
(
flowElement
instanceof
StartEvent
){
result
.
add
(((
StartEvent
)
flowElement
).
getFormKey
());
}
if
(
flowElement
instanceof
UserTask
){
result
.
add
(((
UserTask
)
flowElement
).
getFormKey
());
}
}
}
return
result
;
}
/**
* 获取流程开始页面的ID
* @param bpmnModel
...
...
@@ -245,6 +271,7 @@ public class WorkFlowServiceImpl implements WorkFlowService {
return
-
1
;
}
/**
* 获取bpmnModel
* @param xmlFile
...
...
@@ -262,6 +289,7 @@ public class WorkFlowServiceImpl implements WorkFlowService {
return
converter
.
convertToBpmnModel
(
reader
);
}
public
void
checkXml
(
BpmnModel
bpmnModel
){
//做校验
ProcessValidator
defaultProcessValidator
=
processValidatorFactoryExt
.
createDefaultProcessValidator
();
...
...
@@ -392,7 +420,6 @@ public class WorkFlowServiceImpl implements WorkFlowService {
ConcurrentHashMap
flowMap
=
new
ConcurrentHashMap
<>();
ConcurrentHashMap
oldFlowMap
=
new
ConcurrentHashMap
<>();
ConcurrentHashMap
userMap
=
new
ConcurrentHashMap
<>();
Task
task
=
taskService
.
createTaskQuery
().
taskId
(
taskVo
.
getTaskId
()).
singleResult
();
if
(
task
==
null
){
throw
new
ApiException
(
null
,
"该任务已经被完成了"
);
...
...
@@ -573,4 +600,38 @@ public class WorkFlowServiceImpl implements WorkFlowService {
return
map
;
}
@Override
public
void
stopProcessInstanceById
(
String
processInstanceId
)
{
ProcessInstance
processInstance
=
runtimeService
.
createProcessInstanceQuery
().
processInstanceId
(
processInstanceId
).
singleResult
();
if
(
processInstance
!=
null
)
{
//1、获取终止节点
List
<
EndEvent
>
endNodes
=
findEndFlowElement
(
processInstance
.
getProcessDefinitionId
());
String
endId
=
endNodes
.
get
(
0
).
getId
();
//2、执行终止
List
<
Execution
>
executions
=
runtimeService
.
createExecutionQuery
().
parentId
(
processInstanceId
).
list
();
List
<
String
>
executionIds
=
new
ArrayList
<>();
executions
.
forEach
(
execution
->
executionIds
.
add
(
execution
.
getId
()));
runtimeService
.
createChangeActivityStateBuilder
().
moveExecutionsToSingleActivityId
(
executionIds
,
endId
).
changeState
();
log
.
info
(
"终止processInstanceId:{}胜利"
,
processInstanceId
);
}
else
{
log
.
info
(
"不存在运行的流程实例processInstanceId:{},请确认!"
,
processInstanceId
);
}
}
public
List
findEndFlowElement
(
String
processDefId
)
{
Process
mainProcess
=
repositoryService
.
getBpmnModel
(
processDefId
).
getMainProcess
();
Collection
<
FlowElement
>
list
=
mainProcess
.
getFlowElements
();
if
(
CollectionUtils
.
isEmpty
(
list
))
{
return
Collections
.
EMPTY_LIST
;
}
return
list
.
stream
().
filter
(
f
->
f
instanceof
EndEvent
).
collect
(
Collectors
.
toList
());
}
@Override
public
List
<
ProcessInstance
>
queryUnfinishedProcessInstance
(
String
processKey
){
List
<
ProcessInstance
>
list
=
runtimeService
.
createProcessInstanceQuery
().
processDefinitionKey
(
processKey
).
list
();
return
list
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论