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
0a2c7bb0
Commit
0a2c7bb0
authored
Aug 11, 2021
by
chenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加任務角色控制的代碼
parent
a8c7b7d9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
55 deletions
+83
-55
WorkflowFeignService.java
.../boot/biz/common/workflow/feign/WorkflowFeignService.java
+35
-23
FailureDetailsServiceImpl.java
...le/common/biz/service/impl/FailureDetailsServiceImpl.java
+48
-32
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/workflow/feign/WorkflowFeignService.java
View file @
0a2c7bb0
...
...
@@ -10,33 +10,45 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
com.alibaba.fastjson.JSONObject
;
@FeignClient
(
name
=
"AMOS-API-WORKFLOW"
,
path
=
"workflow"
,
configuration
=
{
CommonMultipartSupportConfig
.
class
})
@FeignClient
(
name
=
"AMOS-API-WORKFLOW"
,
path
=
"workflow"
,
configuration
=
{
CommonMultipartSupportConfig
.
class
})
public
interface
WorkflowFeignService
{
/**
* 发起流程
* @param params
* @return
*/
@RequestMapping
(
value
=
"/task/startProcess"
,
method
=
RequestMethod
.
POST
)
JSONObject
startByVariable
(
@RequestBody
Object
params
)
;
/**
* 完成任务
* @param taskID
* @param variable
* @return
* @throws Exception
*/
@RequestMapping
(
value
=
"/task/pickupAndCompleteTask/{taskId}"
,
method
=
RequestMethod
.
POST
)
JSONObject
pickupAndCompleteTask
(
@PathVariable
(
"taskId"
)
String
taskID
,
@RequestBody
(
required
=
false
)
HashMap
<
String
,
Object
>
variable
)
throws
Exception
;
/**
* 发起流程
*
* @param params
* @return
*/
@RequestMapping
(
value
=
"/task/startProcess"
,
method
=
RequestMethod
.
POST
)
JSONObject
startByVariable
(
@RequestBody
Object
params
);
/**
* 完成任务
*
* @param taskID
* @param variable
* @return
* @throws Exception
*/
@RequestMapping
(
value
=
"/task/pickupAndCompleteTask/{taskId}"
,
method
=
RequestMethod
.
POST
)
JSONObject
pickupAndCompleteTask
(
@PathVariable
(
"taskId"
)
String
taskID
,
@RequestBody
(
required
=
false
)
HashMap
<
String
,
Object
>
variable
)
throws
Exception
;
/**
* 查询当前流程下所有的可执行任务
*
* @param processInstanceId
* @return
*/
@RequestMapping
(
value
=
"/task/list/all/{processInstanceId}"
,
method
=
RequestMethod
.
GET
)
JSONObject
getTaskList
(
@PathVariable
(
"processInstanceId"
)
String
processInstanceId
)
;
@RequestMapping
(
value
=
"/task/list/all/{processInstanceId}"
,
method
=
RequestMethod
.
GET
)
JSONObject
getTaskList
(
@PathVariable
(
"processInstanceId"
)
String
processInstanceId
);
/**
* 查询当前任务的执行用户组
*
* @param processInstanceId
* @return
*/
@RequestMapping
(
value
=
"/getTaskGroupName/{taskId}"
,
method
=
RequestMethod
.
GET
)
JSONObject
getTaskGroupName
(
@PathVariable
(
"taskId"
)
String
taskId
);
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-common-biz/src/main/java/com/yeejoin/amos/boot/module/common/biz/service/impl/FailureDetailsServiceImpl.java
View file @
0a2c7bb0
...
...
@@ -43,7 +43,7 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
@Autowired
SourceFileServiceImpl
sourceFileServiceImpl
;
@Autowired
WorkflowFeignService
workflowFeignService
;
...
...
@@ -83,15 +83,16 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
/**
* 发起故障保修单
* @throws Exception
*
* @throws Exception
*/
@Transactional
public
Object
savemodel
(
FailureDetailsDto
failureDetailsDto
,
ReginParams
userInfo
)
throws
Exception
{
String
businessKey
=
buildOrderNo
();
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"businessKey"
,
businessKey
);
body
.
put
(
"processDefinitionKey"
,
processDefinitionKey
);
JSONObject
jsonObject
=
workflowFeignService
.
startByVariable
(
body
);
JSONObject
body
=
new
JSONObject
();
body
.
put
(
"businessKey"
,
businessKey
);
body
.
put
(
"processDefinitionKey"
,
processDefinitionKey
);
JSONObject
jsonObject
=
workflowFeignService
.
startByVariable
(
body
);
if
(
jsonObject
==
null
)
{
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
// return CommonResponseUtil.failure("启动流程失败");
...
...
@@ -116,31 +117,29 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
// return CommonResponseUtil.failure("添加失败");
}
if
(
ObjectUtils
.
isNotEmpty
(
model
))
{
excuteTask
(
instance
.
getString
(
"id"
),
userInfo
,
null
);
excuteTask
(
instance
.
getString
(
"id"
),
userInfo
,
null
);
}
return
true
;
}
public
boolean
excuteTask
(
Long
sequenceNbr
,
ReginParams
userInfo
,
String
condition
)
{
public
boolean
excuteTask
(
Long
sequenceNbr
,
ReginParams
userInfo
,
String
condition
)
{
HashMap
<
String
,
Object
>
conditionMap
=
new
HashMap
<
String
,
Object
>();
conditionMap
.
put
(
"condition"
,
condition
);
Map
<
String
,
Object
>
map
=
checkExcuteTaskAuthMap
(
sequenceNbr
,
userInfo
);
try
{
if
(
Boolean
.
parseBoolean
(
map
.
get
(
"checkFlag"
).
toString
()))
{
workflowFeignService
.
pickupAndCompleteTask
(
map
.
get
(
"taskId"
).
toString
(),
conditionMap
);
}
Map
<
String
,
Object
>
map
=
checkExcuteTaskAuthMap
(
sequenceNbr
,
userInfo
);
try
{
if
(
Boolean
.
parseBoolean
(
map
.
get
(
"checkFlag"
).
toString
()))
{
workflowFeignService
.
pickupAndCompleteTask
(
map
.
get
(
"taskId"
).
toString
(),
conditionMap
);
}
}
catch
(
Exception
e
)
{
return
false
;
}
return
true
;
}
public
boolean
excuteTask
(
String
procressId
,
ReginParams
userInfo
,
String
condition
)
throws
Exception
{
public
boolean
excuteTask
(
String
procressId
,
ReginParams
userInfo
,
String
condition
)
throws
Exception
{
HashMap
<
String
,
Object
>
conditionMap
=
new
HashMap
<
String
,
Object
>();
conditionMap
.
put
(
"condition"
,
condition
);
JSONObject
teskObject
=
workflowFeignService
.
getTaskList
(
procressId
);
JSONObject
teskObject
=
workflowFeignService
.
getTaskList
(
procressId
);
if
(
ObjectUtils
.
isNotEmpty
(
teskObject
))
{
JSONArray
taskDetailArray
=
teskObject
.
getJSONArray
(
"data"
);
for
(
Object
obj
:
taskDetailArray
)
{
...
...
@@ -150,43 +149,60 @@ public class FailureDetailsServiceImpl extends BaseService<FailureDetailsDto, Fa
}
return
true
;
}
public
boolean
checkExcuteTaskAuth
(
Long
sequenceNbr
,
ReginParams
userInfo
)
{
Map
<
String
,
Object
>
map
=
this
.
checkExcuteTaskAuthMap
(
sequenceNbr
,
userInfo
);
Map
<
String
,
Object
>
map
=
this
.
checkExcuteTaskAuthMap
(
sequenceNbr
,
userInfo
);
return
Boolean
.
parseBoolean
(
map
.
get
(
"checkFlag"
).
toString
());
}
public
Map
<
String
,
Object
>
checkExcuteTaskAuthMap
(
Long
sequenceNbr
,
ReginParams
userInfo
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
public
Map
<
String
,
Object
>
checkExcuteTaskAuthMap
(
Long
sequenceNbr
,
ReginParams
userInfo
)
{
String
currentLoginUserRole
=
userInfo
.
getRole
().
getRoleName
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"checkFlag"
,
false
);
FailureDetailsDto
failureDetailsDto
=
this
.
queryBySeq
(
sequenceNbr
);
// 获取送达部门的ID
Integer
failureEquipmentId
=
failureDetailsDto
.
getFailureEquipmentId
();
//获取上一级操作部门的Id
//
获取上一级操作部门的Id
FailureDetails
details
=
this
.
baseMapper
.
selectById
(
sequenceNbr
);
String
procressId
=
details
.
getProcessId
();
Long
seq
=
userInfo
.
getDepartment
().
getSequenceNbr
();
JSONObject
teskObject
=
workflowFeignService
.
getTaskList
(
procressId
);
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
));
String
name
=
detail
.
getString
(
"name"
);
if
(
name
.
contains
(
EMERGENCY_COMMAND
)
)
{
JSONObject
taskGroupNameObject
=
workflowFeignService
.
getTaskGroupName
(
detail
.
getString
(
"id"
));
// 获取流程中原本设置的当前节点的执行权限
JSONArray
taskGroupNameDetail
=
taskGroupNameObject
.
getJSONArray
(
"data"
);
// 如果拿不到当前任务的执行角色,则返回校验失败
if
(
ObjectUtils
.
isEmpty
(
taskGroupNameDetail
))
{
continue
;
}
String
defaultExecutionRoleProcess
=
taskGroupNameDetail
.
getJSONObject
(
0
).
getString
(
"groupId"
);
// 判断当前登录人的角色是不是与流程中设置的当前任务节点权限一致,一致则执行,不一致则退出
if
(!
defaultExecutionRoleProcess
.
equals
(
currentLoginUserRole
))
{
continue
;
}
// 当流程节点为应急指挥科时,需要判断当前用户所在的部门id和前面处理的用户部门id是否一致
if
(
name
.
contains
(
EMERGENCY_COMMAND
))
{
FailureAudit
failureAuditDetail
=
failureAuditService
.
findByFaultId
(
sequenceNbr
);
Long
auditDepartmentId
=
failureAuditDetail
.
getAuditDepartmentId
();
if
(
auditDepartmentId
.
intValue
()
==
seq
.
intValue
())
{
map
.
put
(
"taskId"
,
detail
.
getString
(
"id"
));
map
.
put
(
"checkFlag"
,
true
);
return
map
;
}
Long
auditDepartmentId
=
failureAuditDetail
.
getAuditDepartmentId
();
if
(
auditDepartmentId
.
intValue
()
==
seq
.
intValue
())
{
map
.
put
(
"taskId"
,
detail
.
getString
(
"id"
));
map
.
put
(
"checkFlag"
,
true
);
break
;
}
}
else
{
// 判断当前节点任务属于送达部门节点时需要判断当前登录人所在的部门id是否与表单发起时设置的送达部门一致
if
(
failureEquipmentId
.
intValue
()
==
seq
.
intValue
())
{
map
.
put
(
"taskId"
,
detail
.
getString
(
"id"
));
map
.
put
(
"checkFlag"
,
true
);
return
map
;
break
;
}
}
}
}
map
.
put
(
"checkFlag"
,
false
);
return
map
;
}
...
...
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