Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
b1ce664f
Commit
b1ce664f
authored
Aug 29, 2022
by
284718418@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
节点新增,移除审批人
parent
bfcc235e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
624 additions
and
1 deletions
+624
-1
src/main/java/cn/timer/api/controller/spmk/AdminSpmkController.java
+222
-0
src/main/java/cn/timer/api/dto/spmk/AdminApprovingDto.java
+53
-0
src/main/java/cn/timer/api/utils/router/RouterUtils.java
+349
-1
No files found.
src/main/java/cn/timer/api/controller/spmk/AdminSpmkController.java
0 → 100644
View file @
b1ce664f
package
cn
.
timer
.
api
.
controller
.
spmk
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.timer.api.aspect.lang.annotation.Log
;
import
cn.timer.api.aspect.lang.annotation.Role
;
import
cn.timer.api.aspect.lang.enums.BusinessType
;
import
cn.timer.api.bean.jxgl.JxglAppraisalT
;
import
cn.timer.api.bean.qyzx.QyzxEmpEntAsso
;
import
cn.timer.api.bean.spmk.*
;
import
cn.timer.api.bean.zzgl.ZzglAuth
;
import
cn.timer.api.config.annotation.CurrentUser
;
import
cn.timer.api.config.annotation.UserBean
;
import
cn.timer.api.config.enuminterface.SpmkEnumInterface.ApproveSummarySts
;
import
cn.timer.api.config.enuminterface.SpmkEnumInterface.ExecutorSts
;
import
cn.timer.api.config.enums.CommonEnum
;
import
cn.timer.api.config.enums.SysRoleType
;
import
cn.timer.api.controller.spmk.service.SpmkService
;
import
cn.timer.api.controller.zzgl.service.ZzglBmgwMService
;
import
cn.timer.api.dao.qyzx.QyzxEmpEntAssoMapper
;
import
cn.timer.api.dao.spmk.*
;
import
cn.timer.api.dto.spmk.*
;
import
cn.timer.api.utils.Result
;
import
cn.timer.api.utils.ResultUtil
;
import
cn.timer.api.utils.redis.RedisUtil
;
import
cn.timer.api.utils.router.RequestDataUtils
;
import
cn.timer.api.utils.router.RouterUtils
;
import
cn.timer.api.utils.router.business.SpmkAssoBusiness
;
import
cn.timer.api.utils.router.business.SpmkAssoBusinessFactory
;
import
cn.timer.api.utils.router.enums.ApproveEnum
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper
;
import
com.github.xiaoymin.knife4j.annotations.ApiOperationSupport
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
net.sf.json.JSONArray
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.annotation.Resource
;
import
java.util.*
;
@Slf4j
@Api
(
tags
=
"3.0Admin审批模块"
)
@RestController
@Transactional
@RequestMapping
(
value
=
"/admin/spmk"
,
produces
=
{
"application/json"
,
"multipart/form-data"
})
public
class
AdminSpmkController
{
@Autowired
private
QyzxEmpEntAssoMapper
qyzxEmpEntAssoMapper
;
@Autowired
private
SpmkApproveSummaryMapper
spmkApproveSummaryMapper
;
@Autowired
private
SpmkExecutorMapper
spmkExecutorMapper
;
@Autowired
private
SpmkAssoBusinessFactory
spmkAssoBusinessFactory
;
private
static
com
.
alibaba
.
fastjson
.
JSONObject
jsonObject
=
new
com
.
alibaba
.
fastjson
.
JSONObject
();
@Resource
private
RedisUtil
redisUtil
;
//TODO 管理员审批
/**
* 管理员审批
*/
@PostMapping
(
value
=
"/approving"
)
@ApiOperation
(
value
=
"1.审批人审批"
,
httpMethod
=
"POST"
,
notes
=
"审批人审批"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ApiOperationSupport
(
order
=
20
)
@Log
(
title
=
"审批-审批流程"
,
businessType
=
BusinessType
.
UPDATE
)
public
Result
<
Object
>
approving
(
@CurrentUser
UserBean
userBean
,
@Validated
@RequestBody
AdminApprovingDto
approvingDto
)
throws
Exception
{
/*判断是否有权限转派*/
//if(approvingDto.getSts()==4){
QyzxEmpEntAsso
ent
=
QyzxEmpEntAsso
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
QyzxEmpEntAsso
>().
lambda
().
eq
(
QyzxEmpEntAsso:
:
getOrgCode
,
userBean
.
getOrgCode
()).
eq
(
QyzxEmpEntAsso:
:
getEmpNum
,
userBean
.
getEmpNum
()));
if
(
ent
!=
null
)
{
/*超管和管理员不受权限控制*/
if
(
ent
.
getUserType
()
==
2
)
{
ZzglAuth
zzglAuth
=
ZzglAuth
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
ZzglAuth
>().
lambda
().
eq
(
ZzglAuth:
:
getBmgwId
,
userBean
.
getUserInfo
().
getBmgwId
())
.
eq
(
ZzglAuth:
:
getMenuId
,
"/Approvalspbutonspbuton020102"
));
if
(
zzglAuth
==
null
)
{
return
ResultUtil
.
error
(
"您没有权限"
);
}
}
}
//}
Integer
asId
=
approvingDto
.
getAsId
();
//查询redis中当前有没有在被审批执行中,0是没有在执行,1是在执行
Integer
approStatus
=
Integer
.
parseInt
(
redisUtil
.
get
(
asId
.
toString
())==
null
?
"0"
:
redisUtil
.
get
(
asId
.
toString
()).
toString
());
if
(
approStatus
==
1
){
return
ResultUtil
.
error
(
"该审批已在审批中!"
);
}
else
{
redisUtil
.
set
(
asId
.
toString
(),
1
,
2
);
}
SpmkApproveDetailSummary
ad
=
SpmkApproveDetailSummary
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
SpmkApproveDetailSummary
>()
.
lambda
()
.
select
(
SpmkApproveDetailSummary:
:
getId
,
SpmkApproveDetailSummary:
:
getRequestData
,
SpmkApproveDetailSummary:
:
getFroms
,
SpmkApproveDetailSummary:
:
getFlowChildren
)
.
eq
(
SpmkApproveDetailSummary:
:
getApproveSummaryId
,
asId
));
// 查询 SpmkApproveSummary 状态,
SpmkApproveSummary
aSummary
=
spmkApproveSummaryMapper
.
selectOne
(
new
QueryWrapper
<
SpmkApproveSummary
>().
lambda
()
.
select
(
SpmkApproveSummary:
:
getSts
)
.
eq
(
SpmkApproveSummary:
:
getId
,
asId
));
// if (aSummary.getSts() > ApproveSummarySts.IN.ordinal()) {
// redisUtil.set(asId.toString(),0,500);
// return ResultUtil.error("该审批已结束!");
// }
//
// // 查询该 审批的状态 是否为 1 审批中
// Integer count = SpmkExecutor.builder().build().selectCount(new QueryWrapper<SpmkExecutor>().lambda()
// .eq(SpmkExecutor::getId, approvingDto.getExecutorId())
// .eq(SpmkExecutor::getSts, ExecutorSts.IN_EXECUTION.ordinal()));
//
// if (count == 0) {
// redisUtil.set(asId.toString(),0,500);
// return ResultUtil.error("您已审批过!");
// }
if
(
spmkExecutorMapper
.
selectCount
(
new
QueryWrapper
<
SpmkExecutor
>().
lambda
()
.
eq
(
SpmkExecutor:
:
getId
,
approvingDto
.
getExecutorId
())
.
eq
(
SpmkExecutor:
:
getEmpNum
,
userBean
.
getEmpNum
())
.
eq
(
SpmkExecutor:
:
getSts
,
ExecutorSts
.
IN_EXECUTION
.
ordinal
()))
==
0
)
{
Integer
adminNum
=
new
LambdaQueryChainWrapper
<
QyzxEmpEntAsso
>(
qyzxEmpEntAssoMapper
)
.
eq
(
QyzxEmpEntAsso:
:
getEmpNum
,
userBean
.
getEmpNum
())
.
eq
(
QyzxEmpEntAsso:
:
getOrgCode
,
userBean
.
getOrgCode
())
.
in
(
QyzxEmpEntAsso:
:
getUserType
,
SysRoleType
.
U_TYPE_ADMIN
,
SysRoleType
.
U_TYPE_C_ADMIN
)
.
count
();
if
(
adminNum
<=
0
)
{
redisUtil
.
set
(
asId
.
toString
(),
0
,
500
);
return
ResultUtil
.
error
(
"非当前审批人 或 管理员,无法操作!"
);
}
}
List
<
FlowChildren
>
listFlowChildren
=
jsonObject
.
parseArray
(
ad
.
getFlowChildren
(),
FlowChildren
.
class
);
RouterUtils
.
updateRefuseToAgree
(
listFlowChildren
,
asId
,
approvingDto
.
getExecuteRecordId
(),
approvingDto
.
getExecutorId
(),
approvingDto
.
getOpinion
(),
approvingDto
.
getSts
(),
aSummary
.
getSts
(),
approvingDto
.
getUser
(),
approvingDto
.
getSignatureImg
(),
userBean
.
getEmpNum
(),
approvingDto
.
getUserList
()
);
// 更新 flowChildren
SpmkApproveDetailSummary
sadsUpdate
=
SpmkApproveDetailSummary
.
builder
().
id
(
ad
.
getId
()).
flowChildren
(
JSONArray
.
fromObject
(
listFlowChildren
).
toString
()).
build
();
/*// 审批详情 审批时添加 附件
if(RequestDataUtils.addFileList(ad,approvingDto.getFileList())){
sadsUpdate.setRequestData(ad.getRequestData());
}*/
sadsUpdate
.
updateById
();
//最后一条数据
FlowChildren
fc
=
CollUtil
.
getLast
(
listFlowChildren
);
if
(
fc
.
getExecute
()
==
"2"
)
{
// 查询 SpmkApproveSummary 状态
aSummary
=
spmkApproveSummaryMapper
.
selectOne
(
new
QueryWrapper
<
SpmkApproveSummary
>().
lambda
()
.
select
(
SpmkApproveSummary:
:
getSts
,
SpmkApproveSummary:
:
getAssoType
)
.
eq
(
SpmkApproveSummary:
:
getId
,
asId
));
// if (aSummary.getSts() != ApproveSummarySts.REFUSE.ordinal()) {
SpmkApproveSummary
.
builder
().
id
(
asId
).
currentApprover
(
CommonEnum
.
NULL_STR
.
getDesc
()).
endTime
(
new
Date
()).
sts
(
ApproveSummarySts
.
FINISH
.
ordinal
()).
build
().
updateById
();
JSONObject
jSONObject
=
jsonObject
.
parseObject
(
ad
.
getRequestData
(),
JSONObject
.
class
);
jSONObject
.
set
(
"approveId"
,
FromData
.
builder
().
value
(
String
.
valueOf
(
asId
)).
build
());
jSONObject
.
set
(
"orgCode"
,
userBean
.
getOrgCode
());
//审批完成后 业务
SpmkAssoBusiness
sab
=
spmkAssoBusinessFactory
.
createSpmkService
(
ApproveEnum
.
getEnums
(
aSummary
.
getAssoType
()));
if
(
sab
!=
null
){
log
.
info
(
"1----------{}"
,
sab
);
}
log
.
info
(
"2----------{}"
,
jSONObject
);
sab
.
handleApprove
(
jSONObject
);
}
// }
// }else {
// redisUtil.set(asId.toString(),0,500);
// return ResultUtil.error("该审批已结束!");
// }
redisUtil
.
set
(
asId
.
toString
(),
0
,
500
);
return
ResultUtil
.
success
();
}
/**
* 删除-考核模板
@DeleteMapping(value = "/del_appraisal_t/{id}")
@ApiOperation(value = "2.移除-审批人", httpMethod = "DELETE", notes = "移除-审批人")
@ApiOperationSupport(order = 6)
@Role
public Result<Object> delAT(@CurrentUser UserBean userBean,@Validated @RequestBody AdminApprovingDto approvingDto) throws Exception {
jxglAppraisalTMapper.delete(new QueryWrapper<JxglAppraisalT>().lambda().eq(JxglAppraisalT::getId, id)
.eq(JxglAppraisalT::getOrgCode, userBean.getOrgCode()));
return ResultUtil.success();
}*/
}
src/main/java/cn/timer/api/dto/spmk/AdminApprovingDto.java
0 → 100644
View file @
b1ce664f
package
cn
.
timer
.
api
.
dto
.
spmk
;
import
cn.timer.api.config.exception.ValidationMsg
;
import
cn.timer.api.dto.spmk.User
;
import
com.alibaba.fastjson.JSONObject
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
javax.validation.constraints.NotNull
;
import
java.util.List
;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public
class
AdminApprovingDto
{
@NotNull
(
message
=
ValidationMsg
.
NOTNULL
)
@ApiModelProperty
(
value
=
"审批汇总id"
,
example
=
"2"
,
required
=
true
)
private
Integer
asId
;
@NotNull
(
message
=
ValidationMsg
.
NOTNULL
)
@ApiModelProperty
(
value
=
"审批执行记录id"
,
example
=
"10"
,
required
=
true
)
private
Integer
executeRecordId
;
@NotNull
(
message
=
ValidationMsg
.
NOTNULL
)
@ApiModelProperty
(
value
=
"执行人记录id"
,
example
=
"10"
,
required
=
true
)
private
Integer
executorId
;
@ApiModelProperty
(
value
=
"意见"
,
example
=
"同意、拒绝"
)
private
String
opinion
;
@NotNull
(
message
=
ValidationMsg
.
NOTNULL
)
@ApiModelProperty
(
value
=
"状态 2同意 3拒绝 4转派"
,
example
=
"2"
,
required
=
true
)
private
Integer
sts
;
@ApiModelProperty
(
value
=
"被转派人 "
,
example
=
"对象"
)
private
User
user
;
@ApiModelProperty
(
value
=
"签字图片 "
,
example
=
"签字图片"
)
private
String
signatureImg
;
@ApiModelProperty
(
value
=
"被转派人数组 "
,
example
=
"数组"
)
private
List
<
User
>
userList
;
@NotNull
(
message
=
ValidationMsg
.
NOTNULL
)
@ApiModelProperty
(
value
=
"申请数据 "
,
example
=
"申请数据"
,
required
=
true
)
private
Integer
execute
;
}
src/main/java/cn/timer/api/utils/router/RouterUtils.java
View file @
b1ce664f
...
@@ -8,6 +8,7 @@ import java.util.stream.Collectors;
...
@@ -8,6 +8,7 @@ import java.util.stream.Collectors;
import
cn.hutool.core.lang.UUID
;
import
cn.hutool.core.lang.UUID
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
cn.timer.api.config.enuminterface.SpmkEnumInterface
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.ListUtils
;
import
org.apache.commons.collections4.ListUtils
;
...
@@ -574,7 +575,7 @@ public class RouterUtils {
...
@@ -574,7 +575,7 @@ public class RouterUtils {
* @param asId 审批汇总Id
* @param asId 审批汇总Id
* @param executorId 执行人记录Id
* @param executorId 执行人记录Id
* @param opinion 意见
* @param opinion 意见
* @param sts 状态 1执行中 2通过 3拒绝
* @param sts 状态 1执行中 2通过 3拒绝
4转派
*/
*/
public
static
void
approving
(
List
<
FlowChildren
>
listFlowChildren
,
Integer
asId
,
Integer
executeRecordId
,
Integer
executorId
,
String
opinion
,
Integer
sts
,
User
redeployUser
,
String
signatureImg
,
Integer
empNum
,
List
<
User
>
redeployUserList
)
throws
Exception
{
public
static
void
approving
(
List
<
FlowChildren
>
listFlowChildren
,
Integer
asId
,
Integer
executeRecordId
,
Integer
executorId
,
String
opinion
,
Integer
sts
,
User
redeployUser
,
String
signatureImg
,
Integer
empNum
,
List
<
User
>
redeployUserList
)
throws
Exception
{
...
@@ -915,5 +916,352 @@ public class RouterUtils {
...
@@ -915,5 +916,352 @@ public class RouterUtils {
return
routers
;
return
routers
;
}
}
/**
* 被拒审批 管理员修改为同意审批
* @param listFlowChildren 节点
* @param asId 审批汇总Id
* @param executorId 执行人记录Id
* @param opinion 意见
* @param sts 状态 1执行中 2通过 3拒绝 4转派
*/
public
static
void
updateRefuseToAgree
(
List
<
FlowChildren
>
listFlowChildren
,
Integer
asId
,
Integer
executeRecordId
,
Integer
executorId
,
String
opinion
,
Integer
sts
,
Integer
currentSts
,
User
redeployUser
,
String
signatureImg
,
Integer
empNum
,
List
<
User
>
redeployUserList
)
throws
Exception
{
if
(
currentSts
==
3
){
SpmkExecutor
.
builder
().
id
(
executorId
).
sts
(
sts
).
opinion
(
opinion
).
build
().
updateById
();
SpmkApproveExecuteRecord
.
builder
().
id
(
executeRecordId
).
sts
(
sts
).
build
().
updateById
();
// 更新 审批汇总 状态
SpmkApproveSummary
.
builder
().
id
(
asId
).
currentApprover
(
CommonEnum
.
NULL_STR
.
getDesc
()).
updateTime
(
new
Date
()).
sts
(
SpmkEnumInterface
.
ApproveSummarySts
.
IN
.
ordinal
()).
build
().
updateById
();
}
//是否有下一个审批人
boolean
hasNextApprover
=
false
;
//统计并序审批 还有几个执行中的
int
es
=
0
;
//操作人是否在审批名单里
boolean
isExist
=
false
;
List
<
FlowChildren
>
flowChildrenList
=
new
ArrayList
<>();
int
redeployIndex
=
-
1
;
//当前转派人所在节点下标
//初始化转派人数据 用于转派
String
flowChildrenJson
=
"{\"className\":\"audit\",\"execute\":\"0\",\"flow\":true,\"relation\":[{\"approvalOrder\":\"0\",\"departmentId\":\"\",\"down\":0,\"empty\":0,\"name\":\"\",\"signature\":0,\"type\":\"users\",\"upward\":0,\"users\":[{\"execute\":\"0\",\"headUrl\":\"\",\"id\":\"\",\"name\":\"\"}]}]}"
;
FlowChildren
flowChildren
=
jsonObject
.
parseObject
(
flowChildrenJson
,
FlowChildren
.
class
);
for
(
int
i
=
0
,
n
=
listFlowChildren
.
size
();
i
<
n
;
i
++)
{
// 新增 执行人
List
<
User
>
listUser
=
CollUtil
.
toList
();
boolean
aobl
=
false
;
//用于判断是 否并序审批
List
<
Relation
>
listR
=
listFlowChildren
.
get
(
i
).
getRelation
();
if
(
CollectionUtil
.
isNotEmpty
(
listR
))
{
listUser
=
listR
.
get
(
0
).
getUsers
();
for
(
User
user:
listR
.
get
(
0
).
getUsers
()
)
{
if
(
Integer
.
parseInt
(
user
.
getId
())
==
empNum
&&
listFlowChildren
.
get
(
i
).
getClassName
().
equals
(
AUDIT
)){
isExist
=
true
;
}
//判断是顺序还是并序 0顺序 1并序
if
(
"1"
.
equals
(
listR
.
get
(
0
).
getApprovalOrder
())){
aobl
=
true
;
if
(
"1"
.
equals
(
user
.
getExecute
())){
es
++;
}
}
}
}
//判断大节点的执行状态 0 未执行 1 执行中 2 已执行
//执行中
if
(
EXECUTING
.
equals
(
listFlowChildren
.
get
(
i
).
getExecute
()))
{
String
currentApprover
=
""
;
//存放当前审批人名称
int
num
=
0
;
//遍历当前节点审批人
outloop:
// 标识 (若内层满足条件直接跳到该层循环)
for
(
int
i_user
=
0
,
n_user
=
listUser
.
size
();
i_user
<
n_user
;
i_user
++)
{
//判断用户执行状态 0 未执行 1 执行中 2 已执行
//已执行
if
(
EXECUTED
.
equals
(
listUser
.
get
(
i_user
).
getExecute
()))
{
//执行中
}
else
if
(
EXECUTING
.
equals
(
listUser
.
get
(
i_user
).
getExecute
()))
{
//判断当前节点审批人id 等于 操作用户id 则更新执行人信息:审批意见、状态(0未执行 1执行中 2同意 3拒接 4转派)
if
((
Integer
.
parseInt
(
redeployUser
.
getId
())
==
Integer
.
parseInt
(
listUser
.
get
(
i_user
).
getId
())
&&
num
==
0
)
||
(!
isExist
&&
num
==
0
)){
num
++;
SpmkExecutor
.
builder
()
.
id
(
executorId
)
.
opinion
(
opinion
)
.
empNum
(
Integer
.
parseInt
(
listUser
.
get
(
i_user
).
getId
()))
.
executorName
(
listUser
.
get
(
i_user
).
getName
())
.
operatorHeaderUrl
(
listUser
.
get
(
i_user
).
getHeadUrl
())
.
sts
(
sts
)
.
signatureImg
(
signatureImg
)
.
build
()
.
updateById
();
listUser
.
get
(
i_user
).
setExecute
(
EXECUTED
);
// 历史审批人
SpmkApproveSummary
.
builder
()
.
id
(
asId
)
.
historyApprover
(
listUser
.
get
(
i_user
).
getName
())
.
build
()
.
updateById
();
//拒绝处理
// 0未执行 1执行中 2同意 3拒绝 4 转派
if
(
sts
==
ExecutorSts
.
REFUSE
.
ordinal
())
{
// 更新 审批汇总 状态
SpmkApproveSummary
.
builder
().
id
(
asId
).
currentApprover
(
CommonEnum
.
NULL_STR
.
getDesc
()).
endTime
(
new
Date
()).
sts
(
sts
).
build
().
updateById
();
SpmkApproveExecuteRecord
.
builder
()
.
id
(
executeRecordId
)
.
sts
(
sts
)
.
build
()
// 更新 审批执行记录
.
updateById
();
listFlowChildren
.
get
(
i_user
).
setExecute
(
EXECUTED
);
return
;
//转派 处理
//在 原审批人 列表中 插入 一个或多个被转派人(审批人)
}
else
if
(
sts
==
ExecutorSts
.
REDEPLOY
.
ordinal
())
{
List
<
User
>
users1
=
CollectionUtil
.
sub
(
listUser
,
0
,
i_user
+
1
);
//新增转派多个人功能
//判断是走派多个人的 否则走旧逻辑
if
(!
CollectionUtils
.
isEmpty
(
redeployUserList
)){
//List<User> users1 = CollectionUtil.sub(listUser, 0, i_user+1); 第一次修改
//redeployUserList.add(users1.get(users1.size() - 1)); 第二次修改
flowChildren
.
getRelation
().
get
(
0
).
setName
(
users1
.
get
(
users1
.
size
()
-
1
).
getName
());
flowChildren
.
getRelation
().
get
(
0
).
getUsers
().
get
(
0
).
setName
(
users1
.
get
(
users1
.
size
()
-
1
).
getName
());
flowChildren
.
getRelation
().
get
(
0
).
getUsers
().
get
(
0
).
setId
(
users1
.
get
(
users1
.
size
()
-
1
).
getId
());
redeployIndex
=
i
;
for
(
User
ruser:
redeployUserList
)
{
ruser
.
setExecute
(
UNEXECUTED
);
users1
.
add
(
ruser
);
n_user
=
listUser
.
size
();
}
// List<User> users2 = CollectionUtil.sub(listUser, i_user+1, listUser.size());
// listUser = ListUtils.union(users1, users2);//并集
//listR.get(0).setApprovalOrder("1");
listFlowChildren
.
get
(
i
).
getRelation
().
get
(
0
).
setApprovalOrder
(
"1"
);
}
else
{
//List<User> users1 = CollectionUtil.sub(listUser, 0, i_user+1);
redeployUser
.
setExecute
(
UNEXECUTED
);
users1
.
add
(
redeployUser
);
//新加的 把转派人跟在后面说
User
user
=
users1
.
get
(
users1
.
size
()
-
2
);
// User us = new User();
// us.setExecute(UNEXECUTED);
// us.setName(user.getName());
// us.setId(user.getId());
// users1.add(us);
flowChildren
.
getRelation
().
get
(
0
).
setName
(
user
.
getName
());
flowChildren
.
getRelation
().
get
(
0
).
getUsers
().
get
(
0
).
setName
(
user
.
getName
());
flowChildren
.
getRelation
().
get
(
0
).
getUsers
().
get
(
0
).
setId
(
user
.
getId
());
redeployIndex
=
i
;
List
<
User
>
users2
=
CollectionUtil
.
sub
(
listUser
,
i_user
+
1
,
listUser
.
size
());
redeployUserList
=
users2
;
//listUser = ListUtils.union(users1, users2);
n_user
=
listUser
.
size
();
}
// System.out.println(users1);
// System.out.println(users2);
//
// System.out.println(listUser);
}
//break outloop;
}
//未执行
}
else
if
(
UNEXECUTED
.
equals
(
listUser
.
get
(
i_user
).
getExecute
()))
{
//新增执行人 执行状态为执行中
SpmkExecutor
.
builder
()
.
approveExecuteRecordId
(
executeRecordId
)
.
empNum
(
Integer
.
parseInt
(
listUser
.
get
(
i_user
).
getId
()))
.
executorName
(
listUser
.
get
(
i_user
).
getName
())
.
operatorHeaderUrl
(
listUser
.
get
(
i_user
).
getHeadUrl
())
.
sts
(
ExecutorSts
.
IN_EXECUTION
.
ordinal
())
.
build
()
.
insert
();
hasNextApprover
=
true
;
//标记为有下个审批人
listUser
.
get
(
i_user
).
setExecute
(
EXECUTING
);
// 当前审批人
SpmkApproveSummary
.
builder
().
id
(
asId
).
currentApprover
(
listUser
.
get
(
i_user
).
getName
()).
build
().
updateById
();
// 处理了 下一个审批人 则跳出循环
if
(
CollectionUtils
.
isEmpty
(
redeployUserList
)){
break
outloop
;
}
}
}
// 无下一个审批人 则更新 节点状态 为 EXECUTED(已执行)
if
(!
hasNextApprover
&&
es
<=
1
)
{
SpmkApproveExecuteRecord
aer
=
SpmkApproveExecuteRecord
.
builder
()
.
id
(
executeRecordId
)
.
sts
(
ExecutorSts
.
AGREE
.
ordinal
())
.
build
();
// 更新 审批执行记录
aer
.
updateById
();
// if(es<=1){
// listFlowChildren.get(i).setExecute(EXECUTED);
// }
listFlowChildren
.
get
(
i
).
setExecute
(
EXECUTED
);
}
//判断大节点为未执行
}
else
if
(
UNEXECUTED
.
equals
(
listFlowChildren
.
get
(
i
).
getExecute
()))
{
//判断无下一个审批人 并且 执行中的小于等于1
if
(!
hasNextApprover
&&
es
<=
1
)
{
switch
(
listFlowChildren
.
get
(
i
).
getClassName
())
{
case
CREATOR:
//发起审批人
SpmkApproveExecuteRecord
aer
=
SpmkApproveExecuteRecord
.
builder
()
.
approveSummaryId
(
asId
)
.
name
(
ParticipatorType
.
INITIATOR
.
getName
())
.
type
(
ParticipatorType
.
INITIATOR
.
ordinal
())
.
sts
(
ExecuteRecordSts
.
AGREE
.
ordinal
())
.
build
();
// 新增 审批执行记录
aer
.
insert
();
// 新增 执行人
User
user
=
listFlowChildren
.
get
(
i
).
getRelation
().
get
(
0
).
getUsers
().
get
(
0
);
SpmkExecutor
.
builder
()
.
approveExecuteRecordId
(
aer
.
getId
())
.
empNum
(
Integer
.
parseInt
(
user
.
getId
()))
.
executorName
(
user
.
getName
())
.
operatorHeaderUrl
(
user
.
getHeadUrl
())
.
sts
(
ExecutorSts
.
AGREE
.
ordinal
())
.
build
()
.
insert
();
listFlowChildren
.
get
(
i
).
setExecute
(
EXECUTED
);
break
;
case
AUDIT:
//审批中
//判断是否是并序
if
(
aobl
){
String
currentApprover
=
""
;
//遍历当前节点审批人
for
(
int
i_user2
=
0
,
n_user2
=
listUser
.
size
();
i_user2
<
n_user2
;
i_user2
++)
{
SpmkApproveExecuteRecord
aer2
=
SpmkApproveExecuteRecord
.
builder
()
.
approveSummaryId
(
asId
)
.
name
(
ParticipatorType
.
APPROVER
.
getName
())
.
type
(
ParticipatorType
.
APPROVER
.
ordinal
())
.
sts
(
ExecuteRecordSts
.
IN_EXECUTION
.
ordinal
())
.
build
();
// 新增 审批执行记录
aer2
.
insert
();
//新增执行人 并设置状态为执行中
SpmkExecutor
executor
=
SpmkExecutor
.
builder
()
.
approveExecuteRecordId
(
aer2
.
getId
())
.
empNum
(
Integer
.
parseInt
(
listUser
.
get
(
i_user2
).
getId
()))
.
executorName
(
listUser
.
get
(
i_user2
).
getName
())
.
operatorHeaderUrl
(
listUser
.
get
(
i_user2
).
getHeadUrl
())
.
sts
(
ExecutorSts
.
IN_EXECUTION
.
ordinal
())
.
build
();
executor
.
insert
();
listUser
.
get
(
i_user2
).
setExecute
(
EXECUTING
);
hasNextApprover
=
true
;
currentApprover
=
currentApprover
!=
""
?
currentApprover
+
","
+
listUser
.
get
(
i_user2
).
getName
():
listUser
.
get
(
i_user2
).
getName
();
// 当前审批人
SpmkApproveSummary
.
builder
().
id
(
asId
).
currentApprover
(
currentApprover
).
build
().
updateById
();
}
listFlowChildren
.
get
(
i
).
setExecute
(
EXECUTING
);
}
else
{
SpmkApproveExecuteRecord
aer2
=
SpmkApproveExecuteRecord
.
builder
()
.
approveSummaryId
(
asId
)
.
name
(
ParticipatorType
.
APPROVER
.
getName
())
.
type
(
ParticipatorType
.
APPROVER
.
ordinal
())
.
sts
(
ExecuteRecordSts
.
IN_EXECUTION
.
ordinal
())
.
build
();
// 新增 审批执行记录
aer2
.
insert
();
//遍历当前节点审批人
for
(
int
i_user2
=
0
,
n_user2
=
listUser
.
size
();
i_user2
<
n_user2
;
i_user2
++)
{
SpmkExecutor
executor
=
SpmkExecutor
.
builder
()
.
approveExecuteRecordId
(
aer2
.
getId
())
.
empNum
(
Integer
.
parseInt
(
listUser
.
get
(
i_user2
).
getId
()))
.
executorName
(
listUser
.
get
(
i_user2
).
getName
())
.
operatorHeaderUrl
(
listUser
.
get
(
i_user2
).
getHeadUrl
())
.
sts
(
ExecutorSts
.
IN_EXECUTION
.
ordinal
())
.
build
();
executor
.
insert
();
listUser
.
get
(
i_user2
).
setExecute
(
EXECUTING
);
hasNextApprover
=
true
;
// 当前审批人
SpmkApproveSummary
.
builder
().
id
(
asId
).
currentApprover
(
listUser
.
get
(
i_user2
).
getName
()).
build
().
updateById
();
// 处理了 下一个审批人 则跳出循环
break
;
}
listFlowChildren
.
get
(
i
).
setExecute
(
EXECUTING
);
}
break
;
case
COPY:
//抄送人
SpmkApproveExecuteRecord
aer3
=
SpmkApproveExecuteRecord
.
builder
()
.
approveSummaryId
(
asId
)
.
name
(
ParticipatorType
.
COPY
.
getName
())
.
type
(
ParticipatorType
.
COPY
.
ordinal
())
.
sts
(
ExecuteRecordSts
.
AGREE
.
ordinal
())
.
build
();
// 新增 审批执行记录
aer3
.
insert
();
List
<
Relation
>
listRelation
=
listFlowChildren
.
get
(
i
).
getRelation
();
for
(
Relation
relation
:
listRelation
)
{
List
<
User
>
listUser2
=
relation
.
getUsers
();
if
(
listUser2
!=
null
)
{
// 新增 执行人
for
(
User
user2
:
listUser2
)
{
SpmkExecutor
executor
=
SpmkExecutor
.
builder
()
.
approveExecuteRecordId
(
aer3
.
getId
())
.
empNum
(
Integer
.
parseInt
(
user2
.
getId
()))
.
executorName
(
user2
.
getName
())
.
operatorHeaderUrl
(
user2
.
getHeadUrl
())
.
sts
(
ExecutorSts
.
AGREE
.
ordinal
())
.
build
();
executor
.
insert
();
}
}
}
listFlowChildren
.
get
(
i
).
setExecute
(
EXECUTED
);
break
;
}
}
}
}
for
(
int
i
=
0
;
i
<
listFlowChildren
.
size
();
i
++)
{
flowChildrenList
.
add
(
listFlowChildren
.
get
(
i
));
if
(
i
==
redeployIndex
){
flowChildrenList
.
add
(
flowChildren
);
}
}
if
(
flowChildrenList
.
size
()
>
0
){
listFlowChildren
.
clear
();
listFlowChildren
.
addAll
(
flowChildrenList
);
}
}
}
}
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