Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datax-cloud
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄营
datax-cloud
Commits
a52c139f
Commit
a52c139f
authored
Sep 15, 2020
by
yuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目初始化
parent
f3940250
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
337 additions
and
42 deletions
+337
-42
DataConstant.java
...core/src/main/java/cn/datax/common/core/DataConstant.java
+1
-1
ProcessInstanceCreateRequest.java
...ervice/workflow/api/dto/ProcessInstanceCreateRequest.java
+5
-8
TaskRequest.java
...n/java/cn/datax/service/workflow/api/dto/TaskRequest.java
+28
-0
ActionEnum.java
.../java/cn/datax/service/workflow/api/enums/ActionEnum.java
+6
-10
VariablesEnum.java
...va/cn/datax/service/workflow/api/enums/VariablesEnum.java
+9
-6
FlowInstanceQuery.java
...n/datax/service/workflow/api/query/FlowInstanceQuery.java
+3
-0
FlowInstanceController.java
...x/service/workflow/controller/FlowInstanceController.java
+30
-2
FlowTaskController.java
...datax/service/workflow/controller/FlowTaskController.java
+13
-3
EndTaskListener.java
...a/cn/datax/service/workflow/flowable/EndTaskListener.java
+15
-0
FinalAuditTaskListener.java
...tax/service/workflow/flowable/FinalAuditTaskListener.java
+23
-0
InitialAuditTaskListener.java
...x/service/workflow/flowable/InitialAuditTaskListener.java
+23
-0
FlowInstanceService.java
...n/datax/service/workflow/service/FlowInstanceService.java
+6
-0
FlowTaskService.java
...va/cn/datax/service/workflow/service/FlowTaskService.java
+8
-0
FlowInstanceServiceImpl.java
...ervice/workflow/service/impl/FlowInstanceServiceImpl.java
+56
-7
FlowTaskServiceImpl.java
...ax/service/workflow/service/impl/FlowTaskServiceImpl.java
+96
-0
DefinitionList.vue
datax-ui/src/views/workflow/definition/DefinitionList.vue
+1
-1
InstanceList.vue
datax-ui/src/views/workflow/instance/InstanceList.vue
+14
-4
No files found.
datax-common/datax-common-core/src/main/java/cn/datax/common/core/DataConstant.java
View file @
a52c139f
...
...
@@ -110,7 +110,7 @@ public class DataConstant {
AUDIT
(
"2"
,
"审核中"
),
AGREE
(
"3"
,
"成功"
),
REJECT
(
"4"
,
"失败"
),
CANCEL
(
"5"
,
"已
取消
"
);
CANCEL
(
"5"
,
"已
撤销
"
);
AuditState
(
String
key
,
String
val
){
this
.
key
=
key
;
this
.
val
=
val
;
...
...
datax-modules/workflow-service-parent/workflow-service-api/src/main/java/cn/datax/service/workflow/api/dto/ProcessInstanceCreateRequest.java
View file @
a52c139f
...
...
@@ -17,6 +17,8 @@ public class ProcessInstanceCreateRequest implements Serializable {
@ApiModelProperty
(
value
=
"流程定义ID"
)
private
String
processDefinitionId
;
@ApiModelProperty
(
value
=
"提交人"
)
private
String
submitter
;
@ApiModelProperty
(
value
=
"业务ID"
)
private
String
businessKey
;
@ApiModelProperty
(
value
=
"业务类型"
)
...
...
@@ -26,16 +28,11 @@ public class ProcessInstanceCreateRequest implements Serializable {
@ApiModelProperty
(
value
=
"流程参数"
)
private
Map
<
String
,
Object
>
variables
=
new
HashMap
<>();
public
ProcessInstanceCreateRequest
()
{}
public
ProcessInstanceCreateRequest
(
String
processDefinitionId
,
String
businessKey
,
String
businessType
,
String
businessName
,
Map
<
String
,
Object
>
var
){
setProcessDefinitionId
(
processDefinitionId
);
setBusinessKey
(
businessKey
);
setBusinessType
(
businessType
);
setBusinessName
(
businessName
);
variables
.
putAll
(
var
);
public
Map
<
String
,
Object
>
getVariables
()
{
variables
.
put
(
VariablesEnum
.
submitter
.
toString
(),
submitter
);
variables
.
put
(
VariablesEnum
.
businessKey
.
toString
(),
businessKey
);
variables
.
put
(
VariablesEnum
.
businessType
.
toString
(),
businessType
);
variables
.
put
(
VariablesEnum
.
businessName
.
toString
(),
businessName
);
return
variables
;
}
}
datax-modules/workflow-service-parent/workflow-service-api/src/main/java/cn/datax/service/workflow/api/dto/TaskRequest.java
0 → 100644
View file @
a52c139f
package
cn
.
datax
.
service
.
workflow
.
api
.
dto
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Map
;
@ApiModel
(
value
=
"任务执行Model"
)
@Data
public
class
TaskRequest
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@ApiModelProperty
(
value
=
"执行任务类型"
)
private
String
action
;
@ApiModelProperty
(
value
=
"任务ID"
)
private
String
taskId
;
@ApiModelProperty
(
value
=
"流程实例ID"
)
private
String
processInstanceId
;
@ApiModelProperty
(
value
=
"用户ID"
)
private
String
userId
;
@ApiModelProperty
(
value
=
"审批意见"
)
private
String
message
;
@ApiModelProperty
(
value
=
"参数"
)
private
Map
<
String
,
Object
>
variables
;
}
datax-modules/workflow-service-parent/workflow-service-api/src/main/java/cn/datax/service/workflow/api/enums/ActionEnum.java
View file @
a52c139f
...
...
@@ -10,20 +10,16 @@ import lombok.Getter;
@AllArgsConstructor
public
enum
ActionEnum
{
COMPLETE
(
"complete"
,
"完成任务成功"
),
CLAIM
(
"claim"
,
"任务签收成功"
),
UNCLAIM
(
"unclaim"
,
"任务反签收成功"
),
DELEGATE
(
"delegate"
,
"任务委派成功"
),
RESOLVE
(
"resolve"
,
" 任务签收完成,返回任务人完成"
),
ASSIGNEE
(
"assignee"
,
"任务转办成功"
),
SUSPEND
(
"suspend"
,
"挂起流程成功"
),
ACTIVATE
(
"activate"
,
"激活流程成功"
);
COMPLETE
(
"complete"
,
"完成任务"
),
CLAIM
(
"claim"
,
"任务签收"
),
UNCLAIM
(
"unclaim"
,
"任务反签收"
),
DELEGATE
(
"delegate"
,
"任务委派"
),
RESOLVE
(
"resolve"
,
"任务归还"
),
ASSIGNEE
(
"assignee"
,
"任务转办"
);
private
String
action
;
private
String
title
;
public
static
ActionEnum
actionOf
(
String
action
)
{
for
(
ActionEnum
actionEnum
:
values
()){
if
(
actionEnum
.
getAction
().
equals
(
action
)){
...
...
datax-modules/workflow-service-parent/workflow-service-api/src/main/java/cn/datax/service/workflow/api/enums/VariablesEnum.java
View file @
a52c139f
...
...
@@ -11,7 +11,7 @@ public enum VariablesEnum {
/** 提交节点 */
submitNode
,
/** 提交人*/
/** 提交人
*/
submitter
,
/** 初审节点 */
...
...
@@ -23,15 +23,18 @@ public enum VariablesEnum {
/** 通过结束节点 */
approveEnd
,
/**
不通过
结束节点 */
/**
失败
结束节点 */
rejectEnd
,
/** 活动主题*/
/** 活动主题
*/
businessName
,
/** 活动类型*/
/** 活动类型
*/
businessType
,
/** 主键id*/
businessKey
;
/** 主键id */
businessKey
,
/** 审核结果 */
approved
;
}
datax-modules/workflow-service-parent/workflow-service-api/src/main/java/cn/datax/service/workflow/api/query/FlowInstanceQuery.java
View file @
a52c139f
...
...
@@ -11,4 +11,7 @@ public class FlowInstanceQuery extends BaseQueryParams {
private
static
final
long
serialVersionUID
=
1L
;
private
String
name
;
private
String
businessKey
;
private
String
businessType
;
private
String
businessName
;
}
datax-modules/workflow-service-parent/workflow-service/src/main/java/cn/datax/service/workflow/controller/FlowInstanceController.java
View file @
a52c139f
...
...
@@ -26,9 +26,9 @@ public class FlowInstanceController extends BaseController {
@Autowired
private
FlowInstanceService
flowInstanceService
;
@PostMapping
@PostMapping
(
"/startById"
)
@ApiOperation
(
value
=
"启动通过流程定义ID流程实例"
)
@ApiImplicitParam
(
name
=
"request"
,
value
=
"
详细
实体request"
,
required
=
true
,
dataType
=
"ProcessInstanceCreateRequest"
)
@ApiImplicitParam
(
name
=
"request"
,
value
=
"
启动流程实例
实体request"
,
required
=
true
,
dataType
=
"ProcessInstanceCreateRequest"
)
public
R
startById
(
@RequestBody
ProcessInstanceCreateRequest
request
)
{
flowInstanceService
.
startProcessInstanceById
(
request
);
return
R
.
ok
();
...
...
@@ -45,6 +45,26 @@ public class FlowInstanceController extends BaseController {
return
R
.
ok
().
setData
(
jsonPage
);
}
@ApiOperation
(
value
=
"分页查询本人发起的流程实例"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"flowInstanceQuery"
,
value
=
"查询实体flowInstanceQuery"
,
required
=
true
,
dataTypeClass
=
FlowInstanceQuery
.
class
)
})
@GetMapping
(
"/pageMyStarted"
)
public
R
pageMyStarted
(
FlowInstanceQuery
flowInstanceQuery
)
{
flowInstanceService
.
pageMyStartedProcessInstance
(
flowInstanceQuery
);
return
R
.
ok
();
}
@ApiOperation
(
value
=
"分页查询本人参与的流程实例"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"flowInstanceQuery"
,
value
=
"查询实体flowInstanceQuery"
,
required
=
true
,
dataTypeClass
=
FlowInstanceQuery
.
class
)
})
@GetMapping
(
"/pageMyInvolved"
)
public
R
pageMyInvolved
(
FlowInstanceQuery
flowInstanceQuery
)
{
flowInstanceService
.
pageMyInvolvedProcessInstance
(
flowInstanceQuery
);
return
R
.
ok
();
}
@ApiOperation
(
value
=
"激活流程实例"
,
notes
=
"根据url的id来指定激活流程实例"
)
@ApiImplicitParam
(
name
=
"processInstanceId"
,
value
=
"流程实例ID"
,
required
=
true
,
dataType
=
"String"
,
paramType
=
"path"
)
@PutMapping
(
"/activate/{processInstanceId}"
)
...
...
@@ -80,4 +100,12 @@ public class FlowInstanceController extends BaseController {
response
.
getOutputStream
().
write
(
b
,
0
,
len
);
}
}
@ApiOperation
(
value
=
"获取审批意见"
)
@ApiImplicitParam
(
name
=
"processInstanceId"
,
value
=
"流程实例ID"
,
required
=
true
,
dataType
=
"String"
,
paramType
=
"path"
)
@GetMapping
(
"/comments"
)
public
R
getComments
(
String
processInstanceId
)
{
flowInstanceService
.
getProcessInstanceComments
(
processInstanceId
);
return
R
.
ok
();
}
}
datax-modules/workflow-service-parent/workflow-service/src/main/java/cn/datax/service/workflow/controller/FlowTaskController.java
View file @
a52c139f
...
...
@@ -3,6 +3,7 @@ package cn.datax.service.workflow.controller;
import
cn.datax.common.base.BaseController
;
import
cn.datax.common.core.JsonPage
;
import
cn.datax.common.core.R
;
import
cn.datax.service.workflow.api.dto.TaskRequest
;
import
cn.datax.service.workflow.api.query.FlowTaskQuery
;
import
cn.datax.service.workflow.api.vo.FlowHistTaskVo
;
import
cn.datax.service.workflow.api.vo.FlowTaskVo
;
...
...
@@ -13,9 +14,7 @@ import io.swagger.annotations.ApiImplicitParam;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
@Api
(
tags
=
{
"流程任务"
})
@RestController
...
...
@@ -46,4 +45,15 @@ public class FlowTaskController extends BaseController {
JsonPage
<
FlowHistTaskVo
>
jsonPage
=
new
JsonPage
<>(
page
.
getCurrent
(),
page
.
getSize
(),
page
.
getTotal
(),
page
.
getRecords
());
return
R
.
ok
().
setData
(
jsonPage
);
}
@ApiOperation
(
value
=
"执行任务"
,
notes
=
"执行任务类型:claim签收 unclaim反签收 complete完成 delegate任务委派 resolve任务归还 assignee任务转办"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"taskId"
,
value
=
"任务ID"
,
required
=
true
,
dataType
=
"String"
,
paramType
=
"path"
),
@ApiImplicitParam
(
name
=
"request"
,
value
=
"执行任务实体request"
,
required
=
true
,
dataType
=
"TaskRequest"
)
})
@PostMapping
(
value
=
"/execute/{taskId}"
)
public
R
executeTask
(
@PathVariable
String
taskId
,
@RequestBody
TaskRequest
request
)
{
flowTaskService
.
execute
(
request
);
return
R
.
ok
();
}
}
datax-modules/workflow-service-parent/workflow-service/src/main/java/cn/datax/service/workflow/flowable/EndTaskListener.java
0 → 100644
View file @
a52c139f
package
cn
.
datax
.
service
.
workflow
.
flowable
;
import
lombok.extern.slf4j.Slf4j
;
import
org.flowable.engine.delegate.DelegateExecution
;
import
org.flowable.engine.delegate.ExecutionListener
;
@Slf4j
public
class
EndTaskListener
implements
ExecutionListener
{
@Override
public
void
notify
(
DelegateExecution
delegateExecution
)
{
log
.
info
(
"业务编号{}"
,
delegateExecution
.
getProcessInstanceBusinessKey
());
log
.
info
(
"节点{},{}"
,
delegateExecution
.
getId
(),
delegateExecution
.
getEventName
());
}
}
datax-modules/workflow-service-parent/workflow-service/src/main/java/cn/datax/service/workflow/flowable/FinalAuditTaskListener.java
0 → 100644
View file @
a52c139f
package
cn
.
datax
.
service
.
workflow
.
flowable
;
import
cn.datax.common.utils.SpringContextHolder
;
import
lombok.extern.slf4j.Slf4j
;
import
org.flowable.engine.TaskService
;
import
org.flowable.task.service.delegate.DelegateTask
;
import
org.flowable.task.service.delegate.TaskListener
;
@Slf4j
public
class
FinalAuditTaskListener
implements
TaskListener
{
@Override
public
void
notify
(
DelegateTask
delegateTask
)
{
log
.
info
(
"进入终审节点用户任务启动监听器"
);
TaskService
taskService
=
SpringContextHolder
.
getBean
(
TaskService
.
class
);
taskService
.
setAssignee
(
delegateTask
.
getId
(),
"1214835832967581698"
);
// taskService.addCandidateUser(delegateTask.getId(), "");
// taskService.addCandidateGroup(delegateTask.getId(), "");
log
.
info
(
"任务执行人:{}"
,
delegateTask
.
getAssignee
());
log
.
info
(
"任务配置ID: {}"
,
delegateTask
.
getTaskDefinitionKey
());
log
.
info
(
"退出终审节点用户任务启动监听器"
);
}
}
datax-modules/workflow-service-parent/workflow-service/src/main/java/cn/datax/service/workflow/flowable/InitialAuditTaskListener.java
0 → 100644
View file @
a52c139f
package
cn
.
datax
.
service
.
workflow
.
flowable
;
import
cn.datax.common.utils.SpringContextHolder
;
import
lombok.extern.slf4j.Slf4j
;
import
org.flowable.engine.TaskService
;
import
org.flowable.task.service.delegate.DelegateTask
;
import
org.flowable.task.service.delegate.TaskListener
;
@Slf4j
public
class
InitialAuditTaskListener
implements
TaskListener
{
@Override
public
void
notify
(
DelegateTask
delegateTask
)
{
log
.
info
(
"进入初审节点用户任务启动监听器"
);
TaskService
taskService
=
SpringContextHolder
.
getBean
(
TaskService
.
class
);
taskService
.
setAssignee
(
delegateTask
.
getId
(),
"1214835832967581698"
);
// taskService.addCandidateUser(delegateTask.getId(), "");
// taskService.addCandidateGroup(delegateTask.getId(), "");
log
.
info
(
"任务执行人:{}"
,
delegateTask
.
getAssignee
());
log
.
info
(
"任务配置ID: {}"
,
delegateTask
.
getTaskDefinitionKey
());
log
.
info
(
"退出初审节点用户任务启动监听器"
);
}
}
datax-modules/workflow-service-parent/workflow-service/src/main/java/cn/datax/service/workflow/service/FlowInstanceService.java
View file @
a52c139f
...
...
@@ -66,4 +66,10 @@ public interface FlowInstanceService {
* @return
*/
void
pageMyInvolvedProcessInstance
(
FlowInstanceQuery
flowInstanceQuery
);
/**
* 获取审批意见
* @param processInstanceId
*/
void
getProcessInstanceComments
(
String
processInstanceId
);
}
datax-modules/workflow-service-parent/workflow-service/src/main/java/cn/datax/service/workflow/service/FlowTaskService.java
View file @
a52c139f
package
cn
.
datax
.
service
.
workflow
.
service
;
import
cn.datax.service.workflow.api.dto.TaskRequest
;
import
cn.datax.service.workflow.api.query.FlowTaskQuery
;
import
cn.datax.service.workflow.api.vo.FlowHistTaskVo
;
import
cn.datax.service.workflow.api.vo.FlowTaskVo
;
...
...
@@ -20,4 +21,11 @@ public interface FlowTaskService {
* @return
*/
Page
<
FlowHistTaskVo
>
pageDone
(
FlowTaskQuery
flowTaskQuery
);
/**
* 执行任务
* 执行任务类型:claim签收 unclaim反签收 complete完成 delegate任务委派 resolve任务归还 assignee任务转办
* @param request
*/
void
execute
(
TaskRequest
request
);
}
datax-modules/workflow-service-parent/workflow-service/src/main/java/cn/datax/service/workflow/service/impl/FlowInstanceServiceImpl.java
View file @
a52c139f
...
...
@@ -2,6 +2,7 @@ package cn.datax.service.workflow.service.impl;
import
cn.datax.common.utils.SecurityUtil
;
import
cn.datax.service.workflow.api.dto.ProcessInstanceCreateRequest
;
import
cn.datax.service.workflow.api.enums.VariablesEnum
;
import
cn.datax.service.workflow.api.query.FlowInstanceQuery
;
import
cn.datax.service.workflow.api.vo.FlowInstanceVo
;
import
cn.datax.service.workflow.service.FlowInstanceService
;
...
...
@@ -15,12 +16,14 @@ import org.flowable.common.engine.impl.identity.Authentication;
import
org.flowable.engine.HistoryService
;
import
org.flowable.engine.RepositoryService
;
import
org.flowable.engine.RuntimeService
;
import
org.flowable.engine.TaskService
;
import
org.flowable.engine.history.HistoricActivityInstance
;
import
org.flowable.engine.history.HistoricProcessInstance
;
import
org.flowable.engine.history.HistoricProcessInstanceQuery
;
import
org.flowable.engine.runtime.ProcessInstance
;
import
org.flowable.engine.runtime.ProcessInstanceBuilder
;
import
org.flowable.engine.runtime.ProcessInstanceQuery
;
import
org.flowable.engine.task.Comment
;
import
org.flowable.image.impl.DefaultProcessDiagramGenerator
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -43,6 +46,9 @@ public class FlowInstanceServiceImpl implements FlowInstanceService {
@Autowired
private
RepositoryService
repositoryService
;
@Autowired
private
TaskService
taskService
;
private
static
final
String
IMAGE_TYPE
=
"png"
;
private
static
final
String
FONT_NAME
=
"宋体"
;
...
...
@@ -52,10 +58,21 @@ public class FlowInstanceServiceImpl implements FlowInstanceService {
if
(
StrUtil
.
isNotBlank
(
flowInstanceQuery
.
getName
())){
processInstanceQuery
.
processInstanceNameLike
(
flowInstanceQuery
.
getName
());
}
long
count
=
processInstanceQuery
.
count
();
List
<
ProcessInstance
>
processInstanceList
=
processInstanceQuery
.
orderByStartTime
().
desc
().
listPage
((
flowInstanceQuery
.
getPageNum
()
-
1
)
*
flowInstanceQuery
.
getPageSize
(),
flowInstanceQuery
.
getPageSize
());
if
(
StrUtil
.
isNotBlank
(
flowInstanceQuery
.
getBusinessKey
())){
processInstanceQuery
.
processInstanceBusinessKey
(
flowInstanceQuery
.
getBusinessKey
());
}
if
(
StrUtil
.
isNotBlank
(
flowInstanceQuery
.
getBusinessType
())){
processInstanceQuery
.
variableValueEquals
(
VariablesEnum
.
businessType
.
toString
(),
flowInstanceQuery
.
getBusinessType
());
}
if
(
StrUtil
.
isNotBlank
(
flowInstanceQuery
.
getBusinessName
())){
processInstanceQuery
.
variableValueEquals
(
VariablesEnum
.
businessName
.
toString
(),
flowInstanceQuery
.
getBusinessName
());
}
List
<
ProcessInstance
>
processInstanceList
=
processInstanceQuery
.
includeProcessVariables
()
.
orderByStartTime
().
desc
()
.
listPage
((
flowInstanceQuery
.
getPageNum
()
-
1
)
*
flowInstanceQuery
.
getPageSize
(),
flowInstanceQuery
.
getPageSize
());
List
<
FlowInstanceVo
>
flowInstanceVoList
=
BeanCopyUtil
.
copyListProperties
(
processInstanceList
,
FlowInstanceVo:
:
new
);
Page
<
FlowInstanceVo
>
page
=
new
Page
<>(
flowInstanceQuery
.
getPageNum
(),
flowInstanceQuery
.
getPageSize
());
long
count
=
processInstanceQuery
.
count
();
page
.
setRecords
(
flowInstanceVoList
);
page
.
setTotal
(
count
);
return
page
;
...
...
@@ -81,6 +98,7 @@ public class FlowInstanceServiceImpl implements FlowInstanceService {
@Override
public
void
startProcessInstanceById
(
ProcessInstanceCreateRequest
request
)
{
Assert
.
notNull
(
request
.
getSubmitter
(),
"请输入提交人"
);
Assert
.
notNull
(
request
.
getBusinessKey
(),
"请输入业务id"
);
Assert
.
notNull
(
request
.
getBusinessType
(),
"请输入业务类型"
);
Assert
.
notNull
(
request
.
getProcessDefinitionId
(),
"请输入流程定义ID"
);
...
...
@@ -91,11 +109,11 @@ public class FlowInstanceServiceImpl implements FlowInstanceService {
if
(
StrUtil
.
isNotBlank
(
request
.
getBusinessKey
())){
processInstanceBuilder
.
businessKey
(
request
.
getBusinessKey
());
}
processInstanceBuilder
.
variables
(
request
.
getVariables
());
// 流程实例标题(动态拼接)
if
(
StrUtil
.
isNotBlank
(
request
.
getBusinessName
())){
processInstanceBuilder
.
name
(
request
.
getBusinessName
());
}
processInstanceBuilder
.
variables
(
request
.
getVariables
());
Authentication
.
setAuthenticatedUserId
(
SecurityUtil
.
getUserId
());
ProcessInstance
processInstance
=
processInstanceBuilder
.
start
();
Authentication
.
setAuthenticatedUserId
(
null
);
...
...
@@ -151,17 +169,48 @@ public class FlowInstanceServiceImpl implements FlowInstanceService {
public
void
pageMyStartedProcessInstance
(
FlowInstanceQuery
flowInstanceQuery
)
{
HistoricProcessInstanceQuery
historicProcessInstanceQuery
=
historyService
.
createHistoricProcessInstanceQuery
();
historicProcessInstanceQuery
.
startedBy
(
SecurityUtil
.
getUserId
());
long
count
=
historicProcessInstanceQuery
.
count
();
List
<
HistoricProcessInstance
>
historicProcessInstanceList
=
historicProcessInstanceQuery
.
orderByProcessInstanceStartTime
().
desc
()
if
(
StrUtil
.
isNotBlank
(
flowInstanceQuery
.
getName
())){
historicProcessInstanceQuery
.
processInstanceNameLike
(
flowInstanceQuery
.
getName
());
}
if
(
StrUtil
.
isNotBlank
(
flowInstanceQuery
.
getBusinessKey
())){
historicProcessInstanceQuery
.
processInstanceBusinessKey
(
flowInstanceQuery
.
getBusinessKey
());
}
if
(
StrUtil
.
isNotBlank
(
flowInstanceQuery
.
getBusinessType
())){
historicProcessInstanceQuery
.
variableValueEquals
(
VariablesEnum
.
businessType
.
toString
(),
flowInstanceQuery
.
getBusinessType
());
}
if
(
StrUtil
.
isNotBlank
(
flowInstanceQuery
.
getBusinessName
())){
historicProcessInstanceQuery
.
variableValueEquals
(
VariablesEnum
.
businessName
.
toString
(),
flowInstanceQuery
.
getBusinessName
());
}
List
<
HistoricProcessInstance
>
historicProcessInstanceList
=
historicProcessInstanceQuery
.
includeProcessVariables
()
.
orderByProcessInstanceStartTime
().
desc
()
.
listPage
((
flowInstanceQuery
.
getPageNum
()
-
1
)
*
flowInstanceQuery
.
getPageSize
(),
flowInstanceQuery
.
getPageSize
());
long
count
=
historicProcessInstanceQuery
.
count
();
}
@Override
public
void
pageMyInvolvedProcessInstance
(
FlowInstanceQuery
flowInstanceQuery
)
{
HistoricProcessInstanceQuery
historicProcessInstanceQuery
=
historyService
.
createHistoricProcessInstanceQuery
();
historicProcessInstanceQuery
.
involvedUser
(
SecurityUtil
.
getUserId
());
long
count
=
historicProcessInstanceQuery
.
count
();
List
<
HistoricProcessInstance
>
historicProcessInstanceList
=
historicProcessInstanceQuery
.
orderByProcessInstanceStartTime
().
desc
()
if
(
StrUtil
.
isNotBlank
(
flowInstanceQuery
.
getName
())){
historicProcessInstanceQuery
.
processInstanceNameLike
(
flowInstanceQuery
.
getName
());
}
if
(
StrUtil
.
isNotBlank
(
flowInstanceQuery
.
getBusinessKey
())){
historicProcessInstanceQuery
.
processInstanceBusinessKey
(
flowInstanceQuery
.
getBusinessKey
());
}
if
(
StrUtil
.
isNotBlank
(
flowInstanceQuery
.
getBusinessType
())){
historicProcessInstanceQuery
.
variableValueEquals
(
VariablesEnum
.
businessType
.
toString
(),
flowInstanceQuery
.
getBusinessType
());
}
if
(
StrUtil
.
isNotBlank
(
flowInstanceQuery
.
getBusinessName
())){
historicProcessInstanceQuery
.
variableValueEquals
(
VariablesEnum
.
businessName
.
toString
(),
flowInstanceQuery
.
getBusinessName
());
}
List
<
HistoricProcessInstance
>
historicProcessInstanceList
=
historicProcessInstanceQuery
.
includeProcessVariables
()
.
orderByProcessInstanceStartTime
().
desc
()
.
listPage
((
flowInstanceQuery
.
getPageNum
()
-
1
)
*
flowInstanceQuery
.
getPageSize
(),
flowInstanceQuery
.
getPageSize
());
long
count
=
historicProcessInstanceQuery
.
count
();
}
@Override
public
void
getProcessInstanceComments
(
String
processInstanceId
)
{
List
<
Comment
>
processInstanceComments
=
taskService
.
getProcessInstanceComments
(
processInstanceId
);
}
}
datax-modules/workflow-service-parent/workflow-service/src/main/java/cn/datax/service/workflow/service/impl/FlowTaskServiceImpl.java
View file @
a52c139f
package
cn
.
datax
.
service
.
workflow
.
service
.
impl
;
import
cn.datax.common.utils.SecurityUtil
;
import
cn.datax.service.workflow.api.dto.TaskRequest
;
import
cn.datax.service.workflow.api.enums.ActionEnum
;
import
cn.datax.service.workflow.api.enums.VariablesEnum
;
import
cn.datax.service.workflow.api.query.FlowTaskQuery
;
import
cn.datax.service.workflow.api.vo.FlowHistTaskVo
;
...
...
@@ -9,18 +11,24 @@ import cn.datax.service.workflow.service.FlowTaskService;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
lombok.extern.slf4j.Slf4j
;
import
org.flowable.engine.HistoryService
;
import
org.flowable.engine.TaskService
;
import
org.flowable.engine.task.Comment
;
import
org.flowable.task.api.Task
;
import
org.flowable.task.api.TaskQuery
;
import
org.flowable.task.api.history.HistoricTaskInstance
;
import
org.flowable.task.api.history.HistoricTaskInstanceQuery
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.Assert
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
@Slf4j
@Service
public
class
FlowTaskServiceImpl
implements
FlowTaskService
{
...
...
@@ -92,4 +100,92 @@ public class FlowTaskServiceImpl implements FlowTaskService {
page
.
setTotal
(
count
);
return
page
;
}
@Override
public
void
execute
(
TaskRequest
request
)
{
String
action
=
request
.
getAction
();
String
processInstanceId
=
request
.
getProcessInstanceId
();
String
taskId
=
request
.
getTaskId
();
String
userId
=
request
.
getUserId
();
String
message
=
request
.
getMessage
();
Map
<
String
,
Object
>
variables
=
request
.
getVariables
();
log
.
info
(
"执行任务类型:{},流程实例ID:{},执行任务ID:{},处理人ID:{},参数:{}"
,
action
,
processInstanceId
,
taskId
,
userId
,
variables
);
Assert
.
notNull
(
action
,
"请输入执行任务类型"
);
Assert
.
notNull
(
processInstanceId
,
"请输入流程实例ID"
);
Assert
.
notNull
(
taskId
,
"请输入任务ID"
);
ActionEnum
actionEnum
=
ActionEnum
.
actionOf
(
action
);
switch
(
actionEnum
)
{
case
COMPLETE:
//完成任务
this
.
completeTask
(
taskId
,
variables
,
processInstanceId
,
message
);
break
;
case
CLAIM:
//签收任务
this
.
claimTask
(
taskId
,
processInstanceId
);
break
;
case
UNCLAIM:
//反签收
this
.
unClaimTask
(
taskId
,
processInstanceId
);
break
;
case
DELEGATE:
//任务委派
this
.
delegateTask
(
taskId
,
userId
,
processInstanceId
);
break
;
case
RESOLVE:
//任务归还
this
.
resolveTask
(
taskId
,
variables
,
processInstanceId
);
break
;
case
ASSIGNEE:
//任务转办
this
.
assigneeTask
(
taskId
,
userId
,
processInstanceId
);
break
;
default
:
break
;
}
}
private
void
completeTask
(
String
taskId
,
Map
<
String
,
Object
>
variables
,
String
processInstanceId
,
String
message
)
{
log
.
info
(
"完成任务ID:{}"
,
taskId
);
Boolean
approved
=
(
Boolean
)
Optional
.
ofNullable
(
variables
).
map
(
s
->
s
.
get
(
VariablesEnum
.
approved
)).
orElse
(
true
);
this
.
addComment
(
ActionEnum
.
COMPLETE
,
taskId
,
processInstanceId
,
StrUtil
.
isBlank
(
message
)
?
(
approved
?
"默认同意"
:
"默认不同意"
)
:
message
);
taskService
.
complete
(
taskId
,
variables
);
}
private
void
claimTask
(
String
taskId
,
String
processInstanceId
)
{
log
.
info
(
"签收任务ID:{},签收人ID:{}"
,
taskId
,
SecurityUtil
.
getUserId
());
this
.
addComment
(
ActionEnum
.
CLAIM
,
taskId
,
processInstanceId
,
null
);
taskService
.
claim
(
taskId
,
SecurityUtil
.
getUserId
());
}
private
void
unClaimTask
(
String
taskId
,
String
processInstanceId
)
{
log
.
info
(
"反签收任务ID:{}"
,
taskId
);
this
.
addComment
(
ActionEnum
.
UNCLAIM
,
taskId
,
processInstanceId
,
null
);
taskService
.
unclaim
(
taskId
);
}
private
void
delegateTask
(
String
taskId
,
String
userId
,
String
processInstanceId
)
{
log
.
info
(
"委派任务ID:{},委派给用户ID:{}"
,
taskId
,
userId
);
this
.
addComment
(
ActionEnum
.
DELEGATE
,
taskId
,
processInstanceId
,
null
);
taskService
.
delegateTask
(
taskId
,
userId
);
}
private
void
resolveTask
(
String
taskId
,
Map
<
String
,
Object
>
variables
,
String
processInstanceId
)
{
log
.
info
(
"任务归还ID:{}"
,
taskId
);
this
.
addComment
(
ActionEnum
.
RESOLVE
,
taskId
,
processInstanceId
,
null
);
taskService
.
resolveTask
(
taskId
);
taskService
.
complete
(
taskId
,
variables
);
}
private
void
assigneeTask
(
String
taskId
,
String
userId
,
String
processInstanceId
)
{
log
.
info
(
"任务转办ID:{},移交给用户ID:{}"
,
taskId
,
userId
);
this
.
addComment
(
ActionEnum
.
ASSIGNEE
,
taskId
,
processInstanceId
,
null
);
taskService
.
setAssignee
(
taskId
,
userId
);
}
private
void
addComment
(
ActionEnum
actionEnum
,
String
taskId
,
String
processInstanceId
,
String
message
)
{
log
.
info
(
"任务或者流程实例添加审批意见:任务ID:{},流程实例ID{}"
,
taskId
,
processInstanceId
);
Comment
comment
=
taskService
.
addComment
(
taskId
,
processInstanceId
,
StrUtil
.
isBlank
(
message
)
?
actionEnum
.
getTitle
()
:
message
);
comment
.
setUserId
(
SecurityUtil
.
getUserId
());
taskService
.
saveComment
(
comment
);
}
}
datax-ui/src/views/workflow/definition/DefinitionList.vue
View file @
a52c139f
...
...
@@ -247,7 +247,7 @@ export default {
// 表格头
tableColumns
:
[
{
prop
:
'id'
,
label
:
'流程定义ID'
,
show
:
true
},
{
prop
:
'
description
'
,
label
:
'流程名称'
,
show
:
true
},
{
prop
:
'
name
'
,
label
:
'流程名称'
,
show
:
true
},
{
prop
:
'version'
,
label
:
'版本'
,
show
:
true
},
{
prop
:
'suspensionState'
,
...
...
datax-ui/src/views/workflow/instance/InstanceList.vue
View file @
a52c139f
...
...
@@ -126,13 +126,16 @@ export default {
multiple
:
true
,
// 表格头
tableColumns
:
[
{
prop
:
'setName'
,
label
:
'数据集名称'
,
show
:
true
},
{
prop
:
'processDefinitionId'
,
label
:
'流程定义ID'
,
show
:
true
},
{
prop
:
'processDefinitionName'
,
label
:
'流程定义名称'
,
show
:
true
},
{
prop
:
'name'
,
label
:
'流程实列名称'
,
show
:
true
},
{
prop
:
's
tatus
'
,
prop
:
's
uspensionState
'
,
label
:
'状态'
,
show
:
true
show
:
true
,
formatter
:
this
.
statusFormatter
},
{
prop
:
'
createTime'
,
label
:
'创建
时间'
,
show
:
true
}
{
prop
:
'
startTime'
,
label
:
'开始
时间'
,
show
:
true
}
],
// 表格数据
tableDataList
:
[],
...
...
@@ -253,6 +256,13 @@ export default {
console
.
log
(
`当前页:
${
val
}
`
)
this
.
queryParams
.
pageNum
=
val
this
.
getList
()
},
statusFormatter
(
row
,
column
,
cellValue
,
index
)
{
if
(
cellValue
===
1
)
{
return
<
el
-
tag
type
=
'success'
>
激活
<
/el-tag
>
}
else
if
(
cellValue
===
2
)
{
return
<
el
-
tag
type
=
'warning'
>
挂起
<
/el-tag
>
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment