Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
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
项目统一框架
amos-boot-biz
Commits
72d28df8
Commit
72d28df8
authored
Sep 23, 2021
by
chenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加公共的工作流执行方法
parent
4e2ce70d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
248 additions
and
18 deletions
+248
-18
IWorkflowExcuteService.java
.../amos/boot/biz/common/service/IWorkflowExcuteService.java
+45
-0
WorkflowExcuteServiceImpl.java
...ot/biz/common/service/impl/WorkflowExcuteServiceImpl.java
+142
-0
WorkflowFeignService.java
.../boot/biz/common/workflow/feign/WorkflowFeignService.java
+61
-18
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/service/IWorkflowExcuteService.java
0 → 100644
View file @
72d28df8
package
com
.
yeejoin
.
amos
.
boot
.
biz
.
common
.
service
;
import
java.util.Map
;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
public
interface
IWorkflowExcuteService
{
/**
* 启动流程,并执行完成任务
* @param key 流程定义的key
* @param condition 执行控制条件
*/
void
startAndComplete
(
String
key
,
String
condition
)
throws
Exception
;
/**
* 检查当前登录人有没有流程操作权限
* @param processInstanceId 流程定义的ID
* @return true 可以执行,false 无执行权限
*/
boolean
checkTaskAuth
(
String
processInstanceId
,
ReginParams
userInfo
);
/**
* 检查当前登录人有没有流程操作权限
* @param processInstanceId 流程定义的ID
* @return 包含是否执行的角色权限flag,以及当前任务的id
*/
Map
<
String
,
Object
>
checkTaskAuthMap
(
String
processInstanceId
,
ReginParams
userInfo
);
/**
* 设置当前任务的执行人,只支持当前节点流程拥有单个可执行任务的情况,不支持并行网关产生的多条任务设置人的任务情况
* @param processInstanceId
* @return
*/
Object
setTaskAssign
(
String
processInstanceId
,
String
userId
);
/**
* 完成task节点任务
* @param processInstanceId
* @param condition
* @param userInfo
* @return
*/
boolean
CompleteTask
(
String
processInstanceId
,
String
condition
,
ReginParams
userInfo
);
}
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/service/impl/WorkflowExcuteServiceImpl.java
0 → 100644
View file @
72d28df8
package
com
.
yeejoin
.
amos
.
boot
.
biz
.
common
.
service
.
impl
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
import
com.yeejoin.amos.boot.biz.common.service.IWorkflowExcuteService
;
import
com.yeejoin.amos.boot.biz.common.workflow.feign.WorkflowFeignService
;
@Service
public
class
WorkflowExcuteServiceImpl
implements
IWorkflowExcuteService
{
@Autowired
WorkflowFeignService
workflowFeignService
;
@Transactional
@Override
public
void
startAndComplete
(
String
key
,
String
condition
)
throws
Exception
{
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"processDefinitionKey"
,
key
);
JSONObject
jsonObject
=
workflowFeignService
.
startByVariable
(
body
);
if
(
jsonObject
==
null
||
jsonObject
.
getJSONObject
(
"data"
)
==
null
)
{
throw
new
RuntimeException
(
"启动流程失败"
);
}
if
(
jsonObject
!=
null
)
{
JSONObject
instance
=
jsonObject
.
getJSONObject
(
"data"
);
if
(!
excuteTask
(
instance
.
getString
(
"id"
),
condition
))
{
throw
new
RuntimeException
(
"初始执行任务失败"
);
}
}
}
@Override
public
boolean
checkTaskAuth
(
String
processInstanceId
,
ReginParams
userInfo
)
{
Map
<
String
,
Object
>
map
=
checkTaskAuthMap
(
processInstanceId
,
userInfo
);
return
Boolean
.
parseBoolean
(
map
.
get
(
"checkFlag"
).
toString
());
}
@Override
public
Map
<
String
,
Object
>
checkTaskAuthMap
(
String
processInstanceId
,
ReginParams
userInfo
)
{
// 获取当前登录用户的角色
String
currentLoginUserRole
=
userInfo
.
getRole
().
getRoleName
();
String
currentLoginUserId
=
userInfo
.
getUserModel
().
getUserId
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"checkFlag"
,
false
);
JSONObject
teskObject
=
workflowFeignService
.
getTaskList
(
processInstanceId
);
if
(
ObjectUtils
.
isNotEmpty
(
teskObject
))
{
JSONArray
taskDetailArray
=
teskObject
.
getJSONArray
(
"data"
);
for
(
Object
obj
:
taskDetailArray
)
{
JSONObject
detail
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
obj
));
JSONObject
taskGroupNameObject
=
workflowFeignService
.
getTaskGroupName
(
detail
.
getString
(
"id"
));
// 获取流程中原本设置的当前节点的执行权限
JSONArray
taskGroupNameDetail
=
taskGroupNameObject
.
getJSONArray
(
"data"
);
// 如果拿不到当前任务的执行角色,再去获取当前任务有没有默认的执行人,如果都没有则返回校验失败
if
(
ObjectUtils
.
isEmpty
(
taskGroupNameDetail
))
{
JSONObject
taskAssignObject
=
workflowFeignService
.
getTaskAssign
(
detail
.
getString
(
"id"
));
String
assignUser
=
taskAssignObject
.
getJSONObject
(
"data"
).
getString
(
"assignee"
);
if
(
StringUtils
.
isNotBlank
(
assignUser
))
{
// 如果当前登录人与当前任务的设定人不一定,则直接返回权限校验失败
if
(!
currentLoginUserId
.
equals
(
assignUser
))
{
return
map
;
}
else
{
map
.
put
(
"taskId"
,
detail
.
getString
(
"id"
));
map
.
put
(
"checkFlag"
,
true
);
map
.
put
(
"name"
,
detail
.
getString
(
"name"
));
map
.
put
(
"assign"
,
assignUser
);
return
map
;
}
}
continue
;
}
String
defaultExecutionRoleProcess
=
taskGroupNameDetail
.
getJSONObject
(
0
).
getString
(
"groupId"
);
// 判断当前登录人的角色是不是与流程中设置的当前任务节点权限一致,一致则执行,不一致则退出
if
(!
defaultExecutionRoleProcess
.
equals
(
currentLoginUserRole
))
{
continue
;
}
map
.
put
(
"taskId"
,
detail
.
getString
(
"id"
));
map
.
put
(
"checkFlag"
,
true
);
map
.
put
(
"name"
,
detail
.
getString
(
"name"
));
map
.
put
(
"groupName"
,
currentLoginUserRole
);
}
}
return
map
;
}
public
boolean
excuteTask
(
String
procressId
,
String
condition
)
throws
Exception
{
HashMap
<
String
,
Object
>
conditionMap
=
new
HashMap
<
String
,
Object
>();
conditionMap
.
put
(
"condition"
,
condition
);
JSONObject
teskObject
=
workflowFeignService
.
getTaskList
(
procressId
);
if
(
ObjectUtils
.
isNotEmpty
(
teskObject
))
{
JSONArray
taskDetailArray
=
teskObject
.
getJSONArray
(
"data"
);
for
(
Object
obj
:
taskDetailArray
)
{
JSONObject
detail
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
obj
));
workflowFeignService
.
pickupAndCompleteTask
(
detail
.
getString
(
"id"
),
conditionMap
);
}
}
return
true
;
}
@Override
public
Object
setTaskAssign
(
String
processInstanceId
,
String
userId
)
{
JSONObject
teskObject
=
workflowFeignService
.
getTaskList
(
processInstanceId
);
if
(
ObjectUtils
.
isNotEmpty
(
teskObject
))
{
JSONArray
taskDetailArray
=
teskObject
.
getJSONArray
(
"data"
);
for
(
Object
obj
:
taskDetailArray
)
{
JSONObject
detail
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
obj
));
try
{
workflowFeignService
.
setTaskUser
(
detail
.
getString
(
"id"
),
userId
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"设置任务执行人失败"
);
}
}
}
return
true
;
}
@Override
public
boolean
CompleteTask
(
String
processInstanceId
,
String
condition
,
ReginParams
userInfo
)
{
Map
<
String
,
Object
>
map
=
checkTaskAuthMap
(
processInstanceId
,
userInfo
);
if
(
Boolean
.
parseBoolean
(
map
.
get
(
"checkFlag"
).
toString
()))
{
HashMap
<
String
,
Object
>
conditionMap
=
new
HashMap
<
String
,
Object
>();
conditionMap
.
put
(
"condition"
,
condition
);
try
{
workflowFeignService
.
completeNoExecuteFromInstanceAdd
(
map
.
get
(
"taskId"
).
toString
(),
conditionMap
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"完成任务失败"
);
}
}
else
{
throw
new
RuntimeException
(
"没有执行权限"
);
}
return
true
;
}
}
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/workflow/feign/WorkflowFeignService.java
View file @
72d28df8
...
@@ -25,7 +25,7 @@ public interface WorkflowFeignService {
...
@@ -25,7 +25,7 @@ public interface WorkflowFeignService {
JSONObject
startByVariable
(
@RequestBody
Object
params
);
JSONObject
startByVariable
(
@RequestBody
Object
params
);
/**
/**
*
完成任务
*
以当前登录人作为任务完成人的完成任务操作
*
*
* @param taskID
* @param taskID
* @param variable
* @param variable
...
@@ -55,65 +55,108 @@ public interface WorkflowFeignService {
...
@@ -55,65 +55,108 @@ public interface WorkflowFeignService {
JSONObject
getTaskGroupName
(
@PathVariable
(
"taskId"
)
String
taskId
);
JSONObject
getTaskGroupName
(
@PathVariable
(
"taskId"
)
String
taskId
);
/**
/**
* 我的待办
* 查询当前登录人可执行的任务集合,-------我的待办
*
* @param processDefinitionKey
* @param processDefinitionKey
* @param userId
* @param userId
* @return
* @return
*/
*/
@RequestMapping
(
value
=
"/task/all-list"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/task/all-list"
,
method
=
RequestMethod
.
GET
)
JSONObject
getTasksNoAuth
(
@RequestParam
(
value
=
"processDefinitionKey"
,
required
=
false
)
String
processDefinitionKey
,
JSONObject
getTasksNoAuth
(
@RequestParam
(
value
=
"userId"
,
required
=
false
)
String
userId
)
;
@RequestParam
(
value
=
"processDefinitionKey"
,
required
=
false
)
String
processDefinitionKey
,
@RequestParam
(
value
=
"userId"
,
required
=
false
)
String
userId
);
/**
/**
* 流程信息
* 查询历史流程信息
*
* @param processDefinitionKey
* @param processDefinitionKey
* @param userId
* @param userId
* @return
* @return
*/
*/
@RequestMapping
(
value
=
"/activitiHistory/processes/historytasks/list/{processInstanceId}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/activitiHistory/processes/historytasks/list/{processInstanceId}"
,
method
=
RequestMethod
.
GET
)
JSONObject
queryHistoryTaskListByProcessId
(
@PathVariable
(
"processInstanceId"
)
String
processInstanceId
);
JSONObject
queryHistoryTaskListByProcessId
(
@PathVariable
(
"processInstanceId"
)
String
processInstanceId
);
/**
/**
* 查询当前流程已经执行的任务
* 查询当前流程已经执行的任务
*
* @param processInstanceId
* @param processInstanceId
* @return
* @return
*/
*/
@RequestMapping
(
value
=
"/activitiHistory/historyTask/{processInstanceId}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/activitiHistory/historyTask/{processInstanceId}"
,
method
=
RequestMethod
.
GET
)
JSONObject
queryHistoryTasksByProcessInstanceId
(
@PathVariable
(
"processInstanceId"
)
String
processInstanceId
);
JSONObject
queryHistoryTasksByProcessInstanceId
(
@PathVariable
(
"processInstanceId"
)
String
processInstanceId
);
/**
/**
* 拾取任务
* 拾取任务
*
* @param taskID
* @param taskID
* @return
* @return
*/
*/
@RequestMapping
(
value
=
"/task/pickuptask/{taskID}"
,
method
=
RequestMethod
.
PUT
)
@RequestMapping
(
value
=
"/task/pickuptask/{taskID}"
,
method
=
RequestMethod
.
PUT
)
JSONObject
pickuptask
(
@PathVariable
(
"taskID"
)
String
taskID
)
;
JSONObject
pickuptask
(
@PathVariable
(
"taskID"
)
String
taskID
);
/**
/**
* 直接完成任务
* 直接完成任务
*
* @param taskId
* @param taskId
* @param variable
* @param variable
* @return
* @return
*/
*/
@RequestMapping
(
value
=
"/task/complete/{taskId}"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/task/complete/{taskId}"
,
method
=
RequestMethod
.
POST
)
JSONObject
completeByVariable
(
@PathVariable
(
"taskId"
)
String
taskId
,
@RequestBody
HashMap
<
String
,
Object
>
variable
);
JSONObject
completeByVariable
(
@PathVariable
(
"taskId"
)
String
taskId
,
@RequestBody
HashMap
<
String
,
Object
>
variable
);
/**
* 获取当前任务的设定执行人
*
* @param taskId
* @return
*/
@RequestMapping
(
value
=
"/task/getTaskAssign/{taskId}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/task/getTaskAssign/{taskId}"
,
method
=
RequestMethod
.
GET
)
JSONObject
getTaskAssign
(
@PathVariable
(
"taskId"
)
String
taskId
)
;
JSONObject
getTaskAssign
(
@PathVariable
(
"taskId"
)
String
taskId
);
/**
/**
* 不操作FormInstance直接完成任务
* 不操作FormInstance直接完成任务
*
* @param taskID
* @param taskID
* @param variable
* @param variable
* @return
* @return
* @throws Exception
* @throws Exception
*/
*/
@RequestMapping
(
value
=
"/task/completeTask/noFromInstanceAdd/{taskID}"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/task/completeTask/noFromInstanceAdd/{taskID}"
,
method
=
RequestMethod
.
POST
)
JSONObject
completeNoExecuteFromInstanceAdd
(
@PathVariable
(
"taskID"
)
String
taskID
,
@RequestBody
(
required
=
false
)
HashMap
<
String
,
Object
>
variable
)
throws
Exception
;
JSONObject
completeNoExecuteFromInstanceAdd
(
@PathVariable
(
"taskID"
)
String
taskID
,
@RequestBody
(
required
=
false
)
HashMap
<
String
,
Object
>
variable
)
throws
Exception
;
/**
/**
* 流程图高亮
* 流程图高亮
*
*/
*/
@RequestMapping
(
value
=
"/activitiHistory/gethighLineImg/{processInstanceId}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/activitiHistory/gethighLineImg/{processInstanceId}"
,
method
=
RequestMethod
.
GET
)
Response
thighLineImg
(
@PathVariable
(
"processInstanceId"
)
String
processInstanceId
)
;
Response
thighLineImg
(
@PathVariable
(
"processInstanceId"
)
String
processInstanceId
);
/**
* 流程图高亮图片
/**
* */
* 流程图高亮图片
@RequestMapping
(
value
=
"/activitiHistory/gethighLine"
,
method
=
RequestMethod
.
GET
)
*/
@RequestMapping
(
value
=
"/activitiHistory/gethighLine"
,
method
=
RequestMethod
.
GET
)
Response
thighLine
(
@RequestParam
(
"instanceId"
)
String
instanceId
);
Response
thighLine
(
@RequestParam
(
"instanceId"
)
String
instanceId
);
/**
* 设置当前任务的执行组
*
* @param taskId
* @param groupName
* @return
* @throws Exception
*/
@RequestMapping
(
value
=
"/setTaskGroupName/{taskId}/{groupName}"
,
method
=
RequestMethod
.
GET
)
Response
setTaskGroupName
(
@PathVariable
(
"taskId"
)
String
taskId
,
@PathVariable
(
"groupName"
)
String
groupName
)
throws
Exception
;
/**
* 设置当前任务的执行人
*
* @param taskId
* @param userId
* @return
* @throws Exception
*/
@RequestMapping
(
value
=
"/setTaskAssignUser/{taskId}/{userId}"
,
method
=
RequestMethod
.
GET
)
Response
setTaskUser
(
@PathVariable
(
"taskId"
)
String
taskId
,
@PathVariable
(
"userId"
)
String
userId
)
throws
Exception
;
}
}
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