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
ac386e79
Commit
ac386e79
authored
Sep 07, 2021
by
陶湘宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
防止重复提交审批
parent
182d832f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1070 additions
and
1055 deletions
+1070
-1055
src/main/java/cn/timer/api/controller/spmk/SpmkController.java
+1070
-1055
No files found.
src/main/java/cn/timer/api/controller/spmk/SpmkController.java
View file @
ac386e79
package
cn
.
timer
.
api
.
controller
.
spmk
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
cn.timer.api.bean.spmk.*
;
import
cn.timer.api.dao.spmk.*
;
import
cn.timer.api.dto.spmk.*
;
import
com.baomidou.mybatisplus.core.toolkit.SerializationUtils
;
import
net.sf.json.JSONArray
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.github.xiaoymin.knife4j.annotations.ApiOperationSupport
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.lang.Console
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.timer.api.aspect.lang.annotation.Log
;
import
cn.timer.api.aspect.lang.enums.BusinessType
;
import
cn.timer.api.bean.kqgl.PunchRecord
;
import
cn.timer.api.bean.kqmk.KqglAssoLeaveRules
;
import
cn.timer.api.bean.qyzx.QyzxEmpEntAsso
;
import
cn.timer.api.bean.yggl.YgglMainEmp
;
import
cn.timer.api.bean.zzgl.ZzglBmgwM
;
import
cn.timer.api.config.annotation.CurrentUser
;
import
cn.timer.api.config.annotation.UserBean
;
import
cn.timer.api.config.enuminterface.SpmkEnumInterface
;
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.config.exception.CustomException
;
import
cn.timer.api.config.validation.Insert
;
import
cn.timer.api.config.validation.Ranks
;
import
cn.timer.api.config.validation.Update
;
import
cn.timer.api.config.validation.ValidList
;
import
cn.timer.api.controller.spmk.service.SpmkService
;
import
cn.timer.api.controller.yggl.service.YgglService
;
import
cn.timer.api.controller.zzgl.service.ZzglBmgwMService
;
import
cn.timer.api.dao.kqgl.PunchRecordMapper
;
import
cn.timer.api.dao.qyzx.QyzxEmpEntAssoMapper
;
import
cn.timer.api.utils.Result
;
import
cn.timer.api.utils.ResultUtil
;
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
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
@Api
(
tags
=
"3.0审批模块"
)
@RestController
@Transactional
@RequestMapping
(
value
=
"/spmk"
,
produces
=
{
"application/json"
,
"multipart/form-data"
})
public
class
SpmkController
{
@Autowired
private
SpmkService
spmkService
;
@Autowired
private
ZzglBmgwMService
zzglBmgwMService
;
@Autowired
private
QyzxEmpEntAssoMapper
qyzxEmpEntAssoMapper
;
@Autowired
private
SpmkApprovalTemplateGMapper
spmkApprovalTemplateGMapper
;
@Autowired
private
SpmkApprovalTemplateMapper
spmkApprovalTemplateMapper
;
@Autowired
private
SpmkApprovalGMapper
spmkApprovalGMapper
;
@Autowired
private
SpmkCustomApprovalMapper
spmkCustomApprovalMapper
;
@Autowired
private
SpmkApproveSummaryMapper
spmkApproveSummaryMapper
;
@Autowired
private
SpmkApproveExecuteRecordMapper
spmkApproveExecuteRecordMapper
;
@Autowired
private
SpmkExecutorMapper
spmkExecutorMapper
;
@Autowired
private
SpmkInitiatorConfigMapper
spmkInitiatorConfigMapper
;
@Autowired
private
SpmkApproveDetailSummaryMapper
spmkApproveDetailSummaryMapper
;
@Autowired
private
SpmkAssoBusinessFactory
spmkAssoBusinessFactory
;
private
static
com
.
alibaba
.
fastjson
.
JSONObject
jsonObject
=
new
com
.
alibaba
.
fastjson
.
JSONObject
();
private
boolean
ISFIRST
=
true
;
// 第一次启动审批流程
//TODO 审批模板组
/**
* 新增或编辑-审批模板组
*/
@PostMapping
(
value
=
"/save_approval_template_g"
)
@ApiOperation
(
value
=
"1.新增或编辑-审批模板组"
,
httpMethod
=
"POST"
,
notes
=
"新增或编辑-审批模板组"
)
@ApiOperationSupport
(
order
=
1
)
public
Result
<
Object
>
saveAtg
(
@Validated
({
Insert
.
class
,
Update
.
class
})
@RequestBody
SpmkApprovalTemplateG
spmkApprovalTemplateG
){
if
(
spmkApprovalTemplateG
.
selectCount
(
new
QueryWrapper
<
SpmkApprovalTemplateG
>().
lambda
()
.
ne
(
spmkApprovalTemplateG
.
getId
()
!=
null
,
SpmkApprovalTemplateG:
:
getId
,
spmkApprovalTemplateG
.
getId
())
.
eq
(
SpmkApprovalTemplateG:
:
getName
,
spmkApprovalTemplateG
.
getName
()))
>
0
)
{
return
ResultUtil
.
error
(
"审批模板组名重复!"
);
}
return
spmkApprovalTemplateG
.
insertOrUpdate
()
?
ResultUtil
.
data
(
spmkApprovalTemplateG
)
:
ResultUtil
.
error
();
}
/**
* 删除-审批模板组
*/
@DeleteMapping
(
value
=
"/delete_approval_template_g/{id}"
)
@ApiOperation
(
value
=
"2.删除-审批模板组"
,
httpMethod
=
"DELETE"
,
notes
=
"删除-审批模板组"
)
@ApiOperationSupport
(
order
=
2
)
public
Result
<
Object
>
deleteAtgById
(
@PathVariable
int
id
){
if
(
spmkApprovalTemplateMapper
.
selectCount
(
new
QueryWrapper
<
SpmkApprovalTemplate
>().
lambda
().
eq
(
SpmkApprovalTemplate:
:
getApprovalTemplateGId
,
id
))
>
0
)
return
ResultUtil
.
error
(
"审批模板组存在 模板,不可直接删除!"
);
return
SpmkApprovalTemplateG
.
builder
().
id
(
id
).
build
().
deleteById
()
?
ResultUtil
.
success
()
:
ResultUtil
.
error
(
"没有找到该对象"
);
}
/**
* 查询列表-审批模板组
*/
@GetMapping
(
value
=
"/list_approval_template_g"
)
@ApiOperation
(
value
=
"3.查询列表-审批模板组"
,
httpMethod
=
"GET"
,
notes
=
"查询列表-审批模板组"
)
@ApiOperationSupport
(
order
=
3
)
public
Result
<
Object
>
selectListAtg
(){
return
ResultUtil
.
data
(
spmkApprovalTemplateGMapper
.
selectListAtInAtg
());
}
/**
* 排序-审批模板组
*/
@PutMapping
(
value
=
"/update_approval_template_g"
)
@ApiOperation
(
value
=
"4.排序-审批模板组"
,
httpMethod
=
"PUT"
,
notes
=
"排序-审批模板组"
)
@ApiOperationSupport
(
order
=
4
)
public
Result
<
Object
>
ranksAtg
(
@Validated
(
Ranks
.
class
)
@RequestBody
ValidList
<
SpmkApprovalTemplateG
>
list
){
if
(
list
==
null
||
(
list
!=
null
&&
list
.
size
()
<=
0
))
{
return
ResultUtil
.
success
();
}
return
spmkApprovalTemplateGMapper
.
updateListRandsById
(
list
)
?
ResultUtil
.
success
()
:
ResultUtil
.
error
();
}
//TODO 审批模板
/**
* 新增或编辑-审批模板
*/
@PostMapping
(
value
=
"/save_approval_template"
)
@ApiOperation
(
value
=
"5.新增或编辑-审批模板"
,
httpMethod
=
"POST"
,
notes
=
"新增或编辑-审批模板"
)
@ApiOperationSupport
(
order
=
5
)
public
Result
<
Object
>
saveAt
(
@Validated
@RequestBody
SpmkApprovalTemplateDto
spmkApprovalTemplateDto
){
Integer
approvalTemplateGId
=
spmkApprovalTemplateDto
.
getApprovalTemplateGId
();
if
(
ObjectUtil
.
isNull
(
approvalTemplateGId
))
return
ResultUtil
.
error
(
"审批模板ID不为空"
);
SpmkApprovalTemplate
at
=
SpmkApprovalTemplate
.
builder
().
build
();
// 克隆 SpmkApprovalTemplateDto对象 到 SpmkApprovalTemplate对象,排除属性froms,router
BeanUtil
.
copyProperties
(
spmkApprovalTemplateDto
,
at
,
"froms"
,
"router"
);
// 序列化 后 写入 SpmkApprovalTemplate对象
at
.
setFroms
(
ObjectUtil
.
serialize
((
List
<
JSONObject
>)
spmkApprovalTemplateDto
.
getFroms
()));
at
.
setRouter
(
ObjectUtil
.
serialize
(
spmkApprovalTemplateDto
.
getRouter
()));
if
(
at
.
selectCount
(
new
QueryWrapper
<
SpmkApprovalTemplate
>().
lambda
()
.
ne
(
at
.
getId
()
!=
null
,
SpmkApprovalTemplate:
:
getId
,
at
.
getId
())
.
eq
(
SpmkApprovalTemplate:
:
getName
,
at
.
getName
()))
>
0
)
{
return
ResultUtil
.
error
(
"审批模板名重复!"
);
}
if
(!
at
.
insertOrUpdate
())
return
ResultUtil
.
error
(
"数据库操作失败"
);
// 清空前端不需要的字段再返回,节省流量
at
.
setFroms
(
null
);
at
.
setRouter
(
null
);
return
ResultUtil
.
data
(
at
);
}
/**
* 删除-审批模板
*/
@DeleteMapping
(
value
=
"/delete_approval_template/{id}"
)
@ApiOperation
(
value
=
"6.删除-审批模板"
,
httpMethod
=
"DELETE"
,
notes
=
"删除-审批模板"
)
@ApiOperationSupport
(
order
=
6
)
public
Result
<
Object
>
deleteAtById
(
@PathVariable
int
id
){
return
SpmkApprovalTemplate
.
builder
().
id
(
id
).
build
().
deleteById
()
?
ResultUtil
.
success
()
:
ResultUtil
.
error
(
"没有找到该对象"
);
}
/**
* id查询-审批模板
*/
@GetMapping
(
value
=
"/select_approval_template/{id}"
)
@ApiOperation
(
value
=
"7.id查询-审批模板"
,
httpMethod
=
"GET"
,
notes
=
"id查询-审批模板"
)
@ApiOperationSupport
(
order
=
7
)
public
Result
<
Object
>
selectAtById
(
@PathVariable
int
id
){
SpmkApprovalTemplate
at
=
SpmkApprovalTemplate
.
builder
().
id
(
id
).
build
().
selectById
();
SpmkApprovalTemplateDto
atd
=
SpmkApprovalTemplateDto
.
builder
().
build
();
BeanUtil
.
copyProperties
(
at
,
atd
,
"froms"
,
"router"
);
atd
.
setFroms
(
ObjectUtil
.
deserialize
(
at
.
getFroms
()));
atd
.
setRouter
(
ObjectUtil
.
deserialize
(
at
.
getRouter
()));
return
ResultUtil
.
data
(
atd
);
}
/**
* 排序-审批模板
*/
@PutMapping
(
value
=
"/update_approval_template"
)
@ApiOperation
(
value
=
"8.排序-审批模板"
,
httpMethod
=
"PUT"
,
notes
=
"查询列表-审批模板组"
)
@ApiOperationSupport
(
order
=
8
)
public
Result
<
Object
>
ranksAt
(
@Validated
({
Ranks
.
class
})
@RequestBody
ValidList
<
SpmkApprovalTemplate
>
list
){
if
(
list
==
null
||
(
list
!=
null
&&
list
.
size
()
<=
0
))
{
return
ResultUtil
.
success
();
}
return
spmkApprovalTemplateMapper
.
updateListRandsById
(
list
)
?
ResultUtil
.
success
()
:
ResultUtil
.
error
();
}
//TODO 审批组
/**
* 新增或编辑-审批组
*/
@PostMapping
(
value
=
"/save_approval_g"
)
@ApiOperation
(
value
=
"9.新增或编辑-审批组"
,
httpMethod
=
"POST"
,
notes
=
"新增或编辑-审批组"
)
@ApiOperationSupport
(
order
=
9
)
public
Result
<
Object
>
saveAg
(
@CurrentUser
UserBean
userBean
,
@Validated
({
Insert
.
class
,
Update
.
class
})
@RequestBody
SpmkApprovalG
spmkApprovalG
){
if
(
spmkApprovalG
.
selectCount
(
new
QueryWrapper
<
SpmkApprovalG
>().
lambda
()
.
ne
(
spmkApprovalG
.
getId
()
!=
null
,
SpmkApprovalG:
:
getId
,
spmkApprovalG
.
getId
())
.
eq
(
SpmkApprovalG:
:
getName
,
spmkApprovalG
.
getName
())
.
eq
(
SpmkApprovalG:
:
getOrgCode
,
userBean
.
getOrgCode
()))
>
0
)
{
return
ResultUtil
.
error
(
"审批组名重复!"
);
}
spmkApprovalG
.
setOrgCode
(
userBean
.
getOrgCode
());
return
spmkApprovalG
.
insertOrUpdate
()
?
ResultUtil
.
data
(
spmkApprovalG
)
:
ResultUtil
.
error
();
}
/**
* 删除-审批组
*/
@DeleteMapping
(
value
=
"/delete_approval_g/{id}"
)
@ApiOperation
(
value
=
"10.删除-审批组"
,
httpMethod
=
"DELETE"
,
notes
=
"删除-审批组"
)
@ApiOperationSupport
(
order
=
10
)
public
Result
<
Object
>
deleteAgById
(
@PathVariable
int
id
){
// if (spmkCustomApprovalMapper.selectCount(new QueryWrapper<SpmkCustomApproval>().lambda().eq(SpmkCustomApproval::getApprovalGId, id)) > 0 )
// return ResultUtil.error("审批组存在 自定义审批,不可直接删除!");
SpmkCustomApproval
.
builder
().
build
().
delete
(
new
QueryWrapper
<
SpmkCustomApproval
>().
lambda
().
eq
(
SpmkCustomApproval:
:
getApprovalGId
,
id
));
return
SpmkApprovalG
.
builder
().
id
(
id
).
build
().
deleteById
()
?
ResultUtil
.
success
()
:
ResultUtil
.
error
(
"没有找到该对象"
);
}
/**
* 查询列表-审批组-审批管理
*/
@GetMapping
(
value
=
"/all_approval_g"
)
@ApiOperation
(
value
=
"11.查询列表-审批组-审批管理"
,
httpMethod
=
"GET"
,
notes
=
"查询列表-审批组-审批管理"
)
@ApiOperationSupport
(
order
=
11
)
public
Result
<
Object
>
selectListAgByAdmin
(
@CurrentUser
UserBean
userBean
){
List
<
Integer
>
depts
=
zzglBmgwMService
.
empNumupGetDepts
(
userBean
.
getOrgCode
(),
userBean
.
getEmpNum
());
return
ResultUtil
.
data
(
spmkApprovalGMapper
.
selectListAgInCaByAdmin
(
userBean
.
getOrgCode
(),
userBean
.
getEmpNum
(),
depts
));
}
/**
* 查询列表-审批组-个人审批
*/
@GetMapping
(
value
=
"/list_approval_g"
)
@ApiOperation
(
value
=
"11.查询列表-审批组-个人审批"
,
httpMethod
=
"GET"
,
notes
=
"查询列表-审批组-个人审批"
)
@ApiOperationSupport
(
order
=
11
)
public
Result
<
Object
>
selectListAg
(
@CurrentUser
UserBean
userBean
){
return
ResultUtil
.
data
(
spmkService
.
selectListAg
(
userBean
));
}
/**
* 排序-审批组
*/
@PutMapping
(
value
=
"/update_approval_g"
)
@ApiOperation
(
value
=
"12.排序-审批组"
,
httpMethod
=
"PUT"
,
notes
=
"排序-审批组"
)
@ApiOperationSupport
(
order
=
12
)
public
Result
<
Object
>
ranksAg
(
@Validated
({
Ranks
.
class
})
@RequestBody
ValidList
<
SpmkApprovalG
>
list
){
if
(
list
==
null
||
list
.
size
()
<=
0
)
{
return
ResultUtil
.
success
();
}
return
spmkApprovalGMapper
.
updateListRandsById
(
list
)
?
ResultUtil
.
success
()
:
ResultUtil
.
error
();
}
//TODO 自定义审批
/**
* 新增或编辑-自定义审批
*/
@PostMapping
(
value
=
"/save_custom_approval"
)
@ApiOperation
(
value
=
"13.新增或编辑-自定义审批"
,
httpMethod
=
"POST"
,
notes
=
"新增或编辑-自定义审批"
)
@ApiOperationSupport
(
order
=
13
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Result
<
Object
>
saveCa
(
@CurrentUser
UserBean
userBean
,
@Validated
@RequestBody
SpmkCustomApprovalDto
spmkCustomApprovalDto
)
throws
Exception
{
SpmkCustomApproval
ca
=
SpmkCustomApproval
.
builder
().
build
();
BeanUtil
.
copyProperties
(
spmkCustomApprovalDto
,
ca
,
"froms"
,
"router"
,
"initiatorConfigs"
);
if
(
ca
.
selectCount
(
new
QueryWrapper
<
SpmkCustomApproval
>().
lambda
()
.
ne
(
ca
.
getId
()
!=
null
,
SpmkCustomApproval:
:
getId
,
ca
.
getId
())
.
eq
(
SpmkCustomApproval:
:
getName
,
ca
.
getName
())
.
eq
(
SpmkCustomApproval:
:
getOrgCode
,
userBean
.
getOrgCode
()))
>
0
)
{
return
ResultUtil
.
error
(
"自定义审批名重复!"
);
}
ca
.
setOrgCode
(
userBean
.
getOrgCode
());
ca
.
setFroms
(
ObjectUtil
.
serialize
(
spmkCustomApprovalDto
.
getFroms
()));
ca
.
setRouter
(
ObjectUtil
.
serialize
(
spmkCustomApprovalDto
.
getRouter
()));
ca
.
setUpdateTime
(
new
Date
());
//1.新增 SpmkCustomApproval-自定义审批
if
(!
ca
.
insertOrUpdate
())
return
ResultUtil
.
error
(
"新增自定义审批 失败!"
);
Integer
id
=
ca
.
getId
();
// 2.删除 历史的 SpmkInitiatorConfig-审批发起人配置,
SpmkInitiatorConfig
.
builder
().
build
().
delete
(
new
QueryWrapper
<
SpmkInitiatorConfig
>().
lambda
().
eq
(
SpmkInitiatorConfig:
:
getCustomApprovalId
,
id
));
Console
.
log
(
"自定义审批id: "
+
id
);
List
<
SpmkInitiatorConfig
>
listIc
=
spmkCustomApprovalDto
.
getInitiatorConfigs
();
if
(
listIc
!=
null
&&
listIc
.
size
()
>
0
)
{
for
(
int
i
=
0
,
n
=
listIc
.
size
();
i
<
n
;
i
++)
{
listIc
.
get
(
i
).
setCustomApprovalId
(
id
);
}
// 3.新增 最新的 SpmkInitiatorConfig-审批发起人配置,
if
(!
spmkInitiatorConfigMapper
.
insertList
(
listIc
))
{
// 手动抛出异常,事务回滚
throw
new
Exception
();
}
}
//
/**
* 注意: 为保证该api的原子性 要加 事务处理 回滚(方法注解-@Transactional(rollbackFor = Exception.class))
* 1.新增 SpmkCustomApproval-自定义审批
* 2.删除 历史的 SpmkInitiatorConfig-审批发起人配置,
* 3.新增 最新的 SpmkInitiatorConfig-审批发起人配置,
*/
// 清空前端不需要的字段再返回,节省流量
ca
.
setFroms
(
null
);
ca
.
setRouter
(
null
);
return
ResultUtil
.
data
(
ca
);
}
/**
* 删除-自定义审批
* @throws Exception
*/
@DeleteMapping
(
value
=
"/delete_custom_approval/{id}"
)
@ApiOperation
(
value
=
"14.删除-自定义审批"
,
httpMethod
=
"DELETE"
,
notes
=
"删除-自定义审批"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ApiOperationSupport
(
order
=
14
)
public
Result
<
Object
>
deleteCaById
(
@PathVariable
int
id
)
throws
Exception
{
SpmkInitiatorConfig
.
builder
().
build
().
delete
(
new
QueryWrapper
<
SpmkInitiatorConfig
>().
lambda
().
eq
(
SpmkInitiatorConfig:
:
getCustomApprovalId
,
id
));
if
(!
SpmkCustomApproval
.
builder
().
id
(
id
).
build
().
deleteById
())
{
throw
new
Exception
();
}
return
ResultUtil
.
success
();
}
/**
* id查询-自定义审批
*/
@GetMapping
(
value
=
"/select_custom_approval/{id}"
)
@ApiOperation
(
value
=
"15.id查询-自定义审批"
,
httpMethod
=
"GET"
,
notes
=
"id查询-自定义审批"
)
@ApiOperationSupport
(
order
=
15
)
public
Result
<
Object
>
selectCaById
(
@PathVariable
int
id
){
SpmkCustomApproval
ca
=
SpmkCustomApproval
.
builder
().
id
(
id
).
build
().
selectById
();
List
<
SpmkInitiatorConfig
>
listIc
=
SpmkInitiatorConfig
.
builder
().
build
().
selectList
(
new
QueryWrapper
<
SpmkInitiatorConfig
>().
lambda
().
eq
(
SpmkInitiatorConfig:
:
getCustomApprovalId
,
id
));
SpmkCustomApprovalDto
caD
=
SpmkCustomApprovalDto
.
builder
()
.
froms
(
ObjectUtil
.
deserialize
(
ca
.
getFroms
()))
.
router
(
ObjectUtil
.
deserialize
(
ca
.
getRouter
()))
.
build
();
BeanUtil
.
copyProperties
(
ca
,
caD
,
"froms"
,
"router"
);
caD
.
setInitiatorConfigs
(
listIc
);
return
ResultUtil
.
data
(
caD
);
}
/**
* 排序-自定义审批
*/
@PutMapping
(
value
=
"/update_custom_approval"
)
@ApiOperation
(
value
=
"16.排序-自定义审批"
,
httpMethod
=
"PUT"
,
notes
=
"排序-自定义审批"
)
@ApiOperationSupport
(
order
=
16
)
public
Result
<
Object
>
ranksCa
(
@Validated
({
Ranks
.
class
})
@RequestBody
ValidList
<
SpmkCustomApproval
>
list
){
if
(
list
==
null
||
(
list
!=
null
&&
list
.
size
()
<=
0
))
{
return
ResultUtil
.
success
();
}
return
spmkCustomApprovalMapper
.
updateListRandsById
(
list
)
?
ResultUtil
.
success
()
:
ResultUtil
.
error
();
}
@Autowired
YgglService
ygglService
;
/**
* 排序-自定义审批
*/
@PutMapping
(
value
=
"/test_spmk"
)
@ApiOperation
(
value
=
"16.测试"
,
httpMethod
=
"PUT"
,
notes
=
"排序-自定义审批"
)
@ApiOperationSupport
(
order
=
16
)
public
Result
<
Object
>
test222
(
@Validated
({
Ranks
.
class
})
@RequestBody
ValidList
<
SpmkCustomApproval
>
list
){
Set
<
Integer
>
lanzi
=
new
HashSet
<
Integer
>();
//所有部门岗位
List
<
ZzglBmgwM
>
bmgws
=
ZzglBmgwM
.
builder
().
build
().
selectList
(
new
QueryWrapper
<
ZzglBmgwM
>().
lambda
().
eq
(
ZzglBmgwM:
:
getOrgCode
,
311
));
//个人岗位
YgglMainEmp
one
=
YgglMainEmp
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
YgglMainEmp
>().
lambda
()
.
select
(
YgglMainEmp:
:
getBmgwId
)
.
eq
(
YgglMainEmp:
:
getOrgCode
,
311
).
eq
(
YgglMainEmp:
:
getEmpNum
,
12512
));
Integer
getId
=
one
!=
null
?
one
.
getBmgwId
()
:
null
;
Set
<
Integer
>
all
=
getId
!=
null
?
empNumupdept2
(
lanzi
,
bmgws
,
getId
)
:
new
HashSet
<
Integer
>();
all
.
add
(
getId
);
return
spmkCustomApprovalMapper
.
updateListRandsById
(
list
)
?
ResultUtil
.
success
()
:
ResultUtil
.
error
();
}
//遍历
public
static
Set
<
Integer
>
empNumupdept2
(
Set
<
Integer
>
lanzi
,
List
<
ZzglBmgwM
>
bmgws
,
Integer
getId
)
{
for
(
ZzglBmgwM
z
:
bmgws
)
{
if
(
getId
.
equals
(
z
.
getId
()))
{
lanzi
.
add
(
getId
);
if
(
z
.
getUpId
()==
null
||
z
.
getUpId
()
==
0
)
{
return
lanzi
;
}
getId
=
z
.
getUpId
();
empNumupdept2
(
lanzi
,
bmgws
,
getId
);
}
}
return
lanzi
;
}
// TODO 审批汇总(发起审批)
/**
* 发起审批
* @throws Exception
*/
@PostMapping
(
value
=
"/start_approval"
)
@ApiOperation
(
value
=
"17.发起审批"
,
httpMethod
=
"POST"
,
notes
=
"发起审批"
)
@ApiOperationSupport
(
order
=
17
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Log
(
title
=
"审批-发起审批"
,
businessType
=
BusinessType
.
INSERT
)
public
Result
<
Object
>
saveA
(
@CurrentUser
UserBean
userBean
,
@Validated
@RequestBody
SpmkApproveSummaryDto
spmkApproveSummaryDto
)
throws
Exception
{
YgglMainEmp
ygglMainEmp
=
YgglMainEmp
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
YgglMainEmp
>()
.
lambda
()
.
select
(
YgglMainEmp:
:
getHeadUrl
,
YgglMainEmp:
:
getName
)
.
eq
(
YgglMainEmp:
:
getEmpNum
,
userBean
.
getEmpNum
())
.
eq
(
YgglMainEmp:
:
getOrgCode
,
userBean
.
getOrgCode
())
);
if
(
ygglMainEmp
==
null
)
return
ResultUtil
.
error
(
"发起人不存在!"
);
// List<SpmkApprovalG> saG = spmkService.selectListAg(userBean);
Router
router
=
spmkApproveSummaryDto
.
getRouter
();
List
<
Router
>
routers
=
router
.
getChildren
();
// routers = RouterUtils.clearRouters(routers);
if
(
routers
==
null
){
return
ResultUtil
.
error
(
"无法发起,请完善审批流程"
);
}
if
(
CollectionUtil
.
isNotEmpty
(
routers
))
{
// boolean hasAudit=false;
// if(routers.size()>0){
// for (Relation relation:routers.get(0).getRelation()) {
// if(relation.getUsers().size()>0){
// hasAudit=true;
// }
// }
// }
//// List<Relation> relations = routers.get(0).getRelation();
//// if (relations == null || relations.size() < 1) {
//// return ResultUtil.error("无法发起,请完善审批流程");
//// }
//// List<User> users = relations.get(0).getUsers();
//// if (CollectionUtil.isEmpty(users)) {
//// return ResultUtil.error("无法发起,请完善审批流程");
//// }
// if(!hasAudit){
// return ResultUtil.error("请选择审批人!");
// }
}
else
{
return
ResultUtil
.
error
(
"无法发起,请完善审批流程"
);
}
List
<
Router
>
listRouter
=
new
ArrayList
<
Router
>();
listRouter
.
add
(
router
);
JSONObject
jSONObject
=
spmkApproveSummaryDto
.
getRequestData
()
.
set
(
"orgCode"
,
userBean
.
getOrgCode
())
.
set
(
"initiator"
,
ygglMainEmp
.
getName
())
.
set
(
"headUrl"
,
ygglMainEmp
.
getHeadUrl
())
.
set
(
"id"
,
userBean
.
getEmpNum
());
RouterUtils
.
NextNode
(
listRouter
,
jSONObject
,
ISFIRST
);
List
<
FlowChildren
>
listFlowChildren
=
new
ArrayList
<
FlowChildren
>();
RouterUtils
.
getIsFlowChildren
(
listRouter
,
listFlowChildren
);
if
(
listFlowChildren
.
isEmpty
()){
return
ResultUtil
.
error
(
"无法发起,请完善审批流程"
);
}
List
<
FlowChildren
>
listFlowChildren1
=
(
ArrayList
<
FlowChildren
>)
SerializationUtils
.
clone
((
Serializable
)
listFlowChildren
);
List
<
String
>
uidlist
=
new
ArrayList
<>();
int
i
=
0
;
int
fsize
=
listFlowChildren
.
size
();
int
f
=
0
;
//listFlowChildren删除次数
for
(
FlowChildren
flowChildrenItem:
listFlowChildren
)
{
if
(
"audit"
.
equals
(
flowChildrenItem
.
getClassName
()))
{
boolean
hasAudit
=
false
;
for
(
Relation
relation
:
flowChildrenItem
.
getRelation
())
{
if
(
relation
.
getUsers
().
size
()
>
0
)
{
hasAudit
=
true
;
//审批人去重
if
(
relation
.
getUsers
().
size
()
>
1
){
int
j
=
0
;
int
usize
=
relation
.
getUsers
().
size
();
//
int
r
=
0
;
//user list删除次数
for
(
User
user:
relation
.
getUsers
()
)
{
if
(!
uidlist
.
contains
(
user
.
getId
()))
{
uidlist
.
add
(
user
.
getId
());
}
else
{
listFlowChildren1
.
get
(
i
).
getRelation
().
get
(
0
).
getUsers
().
remove
(
j
-
r
);
r
++;
}
j
++;
}
if
(
usize
==
r
){
listFlowChildren1
.
remove
(
i
-
f
);
f
++;
}
}
else
{
if
(!
uidlist
.
contains
(
relation
.
getUsers
().
get
(
0
).
getId
()))
{
uidlist
.
add
(
relation
.
getUsers
().
get
(
0
).
getId
());
}
else
{
listFlowChildren1
.
remove
(
i
-
f
);
f
++;
}
}
}
}
if
(!
hasAudit
)
{
return
ResultUtil
.
error
(
"审批流程设置审批人为空无法发起!"
);
}
}
i
++;
}
listFlowChildren
=
(
ArrayList
<
FlowChildren
>)
SerializationUtils
.
clone
((
Serializable
)
listFlowChildren1
);
/*for (FlowChildren flowChildrenItem: listFlowChildren) {
if("audit".equals(flowChildrenItem.getClassName())){
boolean hasAudit=false;
for (Relation relation:flowChildrenItem.getRelation()) {
if(relation.getUsers().size()>0){
hasAudit=true;
}
}
if(!hasAudit){
return ResultUtil.error("审批流程设置审批人为空无法发起!");
}
}
}*/
Logoutput
(
"listFlowChildren"
);
// 当前审批人
String
currentApprover
=
jSONObject
.
getStr
(
"current_approver"
);
// 封装 审批汇总
SpmkApproveSummary
as
=
SpmkApproveSummary
.
builder
()
.
orgCode
(
userBean
.
getOrgCode
())
.
empNum
(
userBean
.
getEmpNum
())
.
title
(
spmkApproveSummaryDto
.
getTitle
())
.
initiator
(
spmkApproveSummaryDto
.
getInitiator
())
.
approveName
(
spmkApproveSummaryDto
.
getApproveName
())
.
assoType
(
spmkApproveSummaryDto
.
getAssoType
())
.
sts
(
ApproveSummarySts
.
IN
.
ordinal
())
.
currentApprover
(
currentApprover
).
build
();
if
(!
as
.
insert
())
{
throw
new
CustomException
(
"审批汇总-新增异常"
);
}
// 插入记录- 审批执行记录 - 执行人记录
RouterUtils
.
insertogExecuteRecord
(
listFlowChildren
,
as
.
getId
());
// 封装 审批详情
SpmkApproveDetailSummary
adm
=
SpmkApproveDetailSummary
.
builder
().
build
();
adm
.
setApproveSummaryId
(
as
.
getId
());
adm
.
setName
(
spmkApproveSummaryDto
.
getTitle
());
adm
.
setRequestData
(
spmkApproveSummaryDto
.
getRequestData
().
toString
());
adm
.
setFroms
(
spmkApproveSummaryDto
.
getFroms
().
toString
());
adm
.
setRouter
(
listRouter
.
get
(
0
).
toJSONString
());
adm
.
setFlowChildren
(
JSONArray
.
fromObject
(
listFlowChildren
).
toString
());
try
{
spmkApproveDetailSummaryMapper
.
insert
(
adm
);
}
catch
(
Exception
e
){
throw
new
CustomException
(
"审批详情-新增异常"
);
}
return
ResultUtil
.
success
();
}
//TODO 审批汇总
/**
* 审批汇总
* @param summaryQueryDto
* @return
* @throws
*/
@PostMapping
(
value
=
"/select_approve_summary"
)
@ApiOperation
(
value
=
"18.审批汇总"
,
httpMethod
=
"POST"
,
notes
=
"审批汇总"
)
@ApiOperationSupport
(
order
=
18
)
@Log
(
title
=
"审批-审批汇总"
,
businessType
=
BusinessType
.
OTHER
)
public
Result
<
Object
>
selectAs
(
@CurrentUser
UserBean
userBean
,
@RequestBody
SummaryQueryDto
summaryQueryDto
)
{
IPage
<
SpmkApproveSummary
>
page
=
new
Page
<
SpmkApproveSummary
>(
summaryQueryDto
.
getCurrentPage
()
==
null
?
1
:
summaryQueryDto
.
getCurrentPage
(),
summaryQueryDto
.
getTotalPage
()
==
null
?
10
:
summaryQueryDto
.
getTotalPage
());
summaryQueryDto
.
setOrgCode
(
userBean
.
getOrgCode
());
Integer
deptId
=
summaryQueryDto
.
getDeptId
();
List
<
YgglMainEmp
>
listYgglMainEmp
=
zzglBmgwMService
.
selectOtherlistent
(
userBean
.
getOrgCode
(),
deptId
);
if
(
deptId
!=
null
&&
(
listYgglMainEmp
==
null
||
listYgglMainEmp
.
size
()
==
0
))
{
return
ResultUtil
.
data
(
new
ArrayList
<
SpmkApproveSummary
>());
}
List
<
Integer
>
empNums
=
new
ArrayList
<
Integer
>();
for
(
YgglMainEmp
ygglMainEmp
:
listYgglMainEmp
)
{
empNums
.
add
(
ygglMainEmp
.
getEmpNum
());
}
summaryQueryDto
.
setEmpNums
(
empNums
);
// 缺-部门id 搜索
IPage
<
SpmkApproveSummary
>
pageAs
=
spmkApproveSummaryMapper
.
selectPageByQuery
(
page
,
summaryQueryDto
);
List
<
SpmkApproveSummary
>
listAs
=
pageAs
.
getRecords
();
return
ResultUtil
.
data
(
pageAs
,
listAs
);
}
//TODO 审批详情
/**
* 审批详情
*/
@GetMapping
(
value
=
"/select_approve_detail/{id}"
)
@ApiOperation
(
value
=
"19.审批详情"
,
httpMethod
=
"GET"
,
notes
=
"审批详情"
)
@ApiOperationSupport
(
order
=
19
)
@Log
(
title
=
"审批-审批详情"
,
businessType
=
BusinessType
.
OTHER
)
public
Result
<
Object
>
selectAd
(
@PathVariable
(
required
=
true
)
Integer
id
)
{
SpmkApproveDetailDto
adD
=
spmkService
.
selectApproveDetailByAsId
(
id
);
System
.
out
.
println
(
ResultUtil
.
data
(
adD
));
return
ResultUtil
.
data
(
adD
);
}
//TODO 审批人审批
/**
* 审批人审批
*/
@PostMapping
(
value
=
"/approving"
)
@ApiOperation
(
value
=
"20.审批人审批"
,
httpMethod
=
"POST"
,
notes
=
"审批人审批"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ApiOperationSupport
(
order
=
20
)
@Log
(
title
=
"审批-审批流程"
,
businessType
=
BusinessType
.
UPDATE
)
// @BindingResultCtrol(title = "审批人审批")
public
Result
<
Object
>
approving
(
@CurrentUser
UserBean
userBean
,
@Validated
@RequestBody
ApprovingDto
approvingDto
)
throws
Exception
{
Integer
asId
=
approvingDto
.
getAsId
();
SpmkApproveDetailSummary
ad
=
SpmkApproveDetailSummary
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
SpmkApproveDetailSummary
>()
.
lambda
()
.
select
(
SpmkApproveDetailSummary:
:
getId
,
SpmkApproveDetailSummary:
:
getRequestData
,
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
()
>
SpmkEnumInterface
.
ApproveSummarySts
.
IN
.
ordinal
())
{
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
)
{
return
ResultUtil
.
error
(
"您已审批过!"
);
}
if
(
spmkExecutorMapper
.
selectCount
(
new
QueryWrapper
<
SpmkExecutor
>().
lambda
()
.
eq
(
SpmkExecutor:
:
getId
,
approvingDto
.
getExecutorId
())
.
eq
(
SpmkExecutor:
:
getEmpNum
,
userBean
.
getEmpNum
())
.
eq
(
SpmkExecutor:
:
getSts
,
SpmkEnumInterface
.
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
)
{
return
ResultUtil
.
error
(
"非当前审批人 或 管理员,无法操作!"
);
}
}
if
(
aSummary
.
getSts
()
==
0
)
{
List
<
FlowChildren
>
listFlowChildren
=
jsonObject
.
parseArray
(
ad
.
getFlowChildren
(),
FlowChildren
.
class
);
// 审批逻辑
RouterUtils
.
approving
(
listFlowChildren
,
asId
,
approvingDto
.
getExecuteRecordId
(),
approvingDto
.
getExecutorId
(),
approvingDto
.
getOpinion
(),
approvingDto
.
getSts
(),
approvingDto
.
getUser
()
);
// 更新 flowChildren
SpmkApproveDetailSummary
.
builder
().
id
(
ad
.
getId
()).
flowChildren
(
JSONArray
.
fromObject
(
listFlowChildren
).
toString
()).
build
().
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
()
!=
SpmkEnumInterface
.
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
)
Logoutput
(
"1----------"
+
sab
);
Logoutput
(
"2----------"
+
jSONObject
);
sab
.
handleApprove
(
jSONObject
);
}
}
}
else
{
return
ResultUtil
.
error
(
"该审批已结束!"
);
}
return
ResultUtil
.
success
();
}
@Autowired
private
PunchRecordMapper
punchrecordmapper
;
//TODO 我发起的/我审批的/抄送我的
/**
* 查询列表-我发起的/我审批的/抄送我的-分页
*/
@PostMapping
(
value
=
"/select_my_approve"
)
@ApiOperation
(
value
=
"21.查询列表-我发起的/我审批的/抄送我的-分页"
,
httpMethod
=
"POST"
,
notes
=
"查询列表-我审批的-关键字、审批状态、发起时间-分页"
)
@ApiOperationSupport
(
order
=
21
)
@Log
(
title
=
"审批-我发起的/我审批的/抄送我的"
,
businessType
=
BusinessType
.
OTHER
)
public
Result
<
Object
>
selectMyAs
(
@CurrentUser
UserBean
userBean
,
@Validated
@RequestBody
MySummaryQueryDto
mySummaryQueryDto
)
throws
MethodArgumentNotValidException
{
IPage
<
SpmkApproveSummary
>
page
=
new
Page
<
SpmkApproveSummary
>(
mySummaryQueryDto
.
getCurrentPage
()
==
null
?
1
:
mySummaryQueryDto
.
getCurrentPage
(),
mySummaryQueryDto
.
getTotalPage
()
==
null
?
10
:
mySummaryQueryDto
.
getTotalPage
());
mySummaryQueryDto
.
setOrgCode
(
userBean
.
getOrgCode
());
mySummaryQueryDto
.
setEmpNum
(
userBean
.
getEmpNum
());
if
(
mySummaryQueryDto
.
getSts
()
==
null
)
{
mySummaryQueryDto
.
setSts
(
0
);
}
//我发起的
if
(
mySummaryQueryDto
.
getType
()
==
0
)
{
// mySummaryQueryDto.setSts(null);
}
// 缺-部门id 搜索
IPage
<
SpmkApproveSummary
>
pageAs
=
spmkApproveSummaryMapper
.
selectPageByQueryForEmpNum
(
page
,
mySummaryQueryDto
);
List
<
SpmkApproveSummary
>
listAs
=
pageAs
.
getRecords
();
for
(
SpmkApproveSummary
sp
:
listAs
)
{
String
requerstr
=
""
;
try
{
SpmkApproveDetailSummary
ad
=
spmkApproveDetailSummaryMapper
.
selectOne
(
new
QueryWrapper
<
SpmkApproveDetailSummary
>().
lambda
().
eq
(
SpmkApproveDetailSummary:
:
getApproveSummaryId
,
sp
.
getId
()));
JSONObject
as
=
jsonObject
.
parseObject
(
ad
.
getRequestData
().
toString
(),
JSONObject
.
class
);
// Logoutput(as);
// Logoutput(sp.getId()+"==========================================="+sp.getAssoType());
requerstr
=
""
;
//assoType : 1转正 2离职 3调薪 4调岗 5加班 6请假 7出差 8外出 9补卡
switch
(
sp
.
getAssoType
())
{
case
1
:
requerstr
=
"转正时间:"
+
as
.
getJSONObject
(
"__newConfirmationTime"
).
getStr
(
"value"
);
break
;
case
2
:
requerstr
=
"离职时间:"
+
as
.
getJSONObject
(
"__terminationDate"
).
getStr
(
"value"
);
break
;
case
3
:
String
namepos
=
""
;
PunchRecord
pu
=
punchrecordmapper
.
organizationalStructure
(
Integer
.
valueOf
(
as
.
getJSONObject
(
"__TransferInDepartment"
).
getStr
(
"value"
)));
if
(
pu
!=
null
)
{
namepos
=
pu
.
getPost
();
}
requerstr
=
"调入岗位:"
+
namepos
;
break
;
case
5
:
requerstr
=
"加班时长:"
+
as
.
getJSONObject
(
"__timeLong"
).
getStr
(
"value"
)+
"(小时)"
;
break
;
case
6
:
String
name
=
""
;
KqglAssoLeaveRules
rul
=
KqglAssoLeaveRules
.
builder
().
build
().
selectById
(
as
.
getJSONObject
(
"__LeaveType"
).
getStr
(
"value"
));
if
(
rul
!=
null
)
{
name
=
rul
.
getName
();
}
requerstr
=
"请假类型:"
+
name
;
break
;
case
7
:
requerstr
=
"出差时长:"
+
as
.
getJSONObject
(
"__longTime"
).
getStr
(
"value"
)+
"(小时)"
;
break
;
case
8
:
requerstr
=
"外出时长:"
+
as
.
getJSONObject
(
"__longTime"
).
getStr
(
"value"
)+
"(小时)"
;
break
;
case
9
:
requerstr
=
"补卡时间:"
+
as
.
getJSONObject
(
"__PatchCardTime"
).
getStr
(
"value"
);
break
;
default
:
break
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
// Logoutput(requerstr);
sp
.
setDigest
(
requerstr
);
}
return
ResultUtil
.
data
(
pageAs
,
listAs
);
}
//TODO 撤销审批
/**
* 撤销审批
*/
@PutMapping
(
value
=
"/revoke_approval/{id}"
)
@ApiOperation
(
value
=
"22.撤销审批"
,
httpMethod
=
"PUT"
,
notes
=
"撤销审批"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ApiOperationSupport
(
order
=
22
)
@Log
(
title
=
"审批-撤销审批"
,
businessType
=
BusinessType
.
UPDATE
)
public
Result
<
Object
>
revokeApproval
(
@PathVariable
Integer
id
)
throws
Exception
{
SpmkApproveSummary
as
=
spmkApproveSummaryMapper
.
selectOne
(
new
QueryWrapper
<
SpmkApproveSummary
>()
.
lambda
()
.
select
(
SpmkApproveSummary:
:
getSts
)
.
eq
(
SpmkApproveSummary:
:
getId
,
id
));
return
as
!=
null
&&
as
.
getSts
()
!=
ApproveSummarySts
.
FINISH
.
ordinal
()
?
(
SpmkApproveSummary
.
builder
().
id
(
id
).
endTime
(
new
Date
()).
sts
(
ApproveSummarySts
.
UNDONE
.
ordinal
()).
build
().
updateById
()
?
ResultUtil
.
success
()
:
ResultUtil
.
error
(
"撤销异常"
))
:
ResultUtil
.
error
(
"审批已结束,无法撤销!"
);
}
/**
* 删除-审批(发起的审批)-根据审批汇总id
*/
@DeleteMapping
(
value
=
"/delete_approval/{id}"
)
@ApiOperation
(
value
=
"23.删除-审批(发起的审批)-根据审批汇总id"
,
httpMethod
=
"DELETE"
,
notes
=
"删除-审批(发起的审批)-根据审批汇总id"
)
@ApiOperationSupport
(
order
=
23
)
@Log
(
title
=
"审批-删除审批"
,
businessType
=
BusinessType
.
DELETE
)
public
Result
<
Object
>
deleteApprovalData
(
@PathVariable
Integer
id
){
List
<
SpmkApproveExecuteRecord
>
listAer
=
spmkApproveExecuteRecordMapper
.
selectList
(
new
QueryWrapper
<
SpmkApproveExecuteRecord
>()
.
lambda
()
.
select
(
SpmkApproveExecuteRecord:
:
getId
)
.
eq
(
SpmkApproveExecuteRecord:
:
getApproveSummaryId
,
id
));
if
(
listAer
!=
null
&&
listAer
.
size
()
>
0
)
{
for
(
SpmkApproveExecuteRecord
aer
:
listAer
)
{
spmkExecutorMapper
.
delete
(
new
QueryWrapper
<
SpmkExecutor
>().
lambda
().
eq
(
SpmkExecutor:
:
getApproveExecuteRecordId
,
aer
.
getId
()));
}
}
spmkApproveExecuteRecordMapper
.
delete
(
new
QueryWrapper
<
SpmkApproveExecuteRecord
>().
lambda
().
eq
(
SpmkApproveExecuteRecord:
:
getApproveSummaryId
,
id
));
//新审核表删除
spmkApproveDetailSummaryMapper
.
delete
(
new
QueryWrapper
<
SpmkApproveDetailSummary
>().
lambda
().
eq
(
SpmkApproveDetailSummary:
:
getApproveSummaryId
,
id
));
spmkApproveSummaryMapper
.
delete
(
new
QueryWrapper
<
SpmkApproveSummary
>().
lambda
().
eq
(
SpmkApproveSummary:
:
getId
,
id
));
return
ResultUtil
.
success
();
}
/**
* 删除-审批组、自定义审批、审批汇总、审批详情、审批执行记录、审批执行人记录 所有数据
*/
@DeleteMapping
(
value
=
"/delete_approval_data"
)
@ApiOperation
(
value
=
"90.(开发使用)删除-审批数据"
,
httpMethod
=
"DELETE"
,
notes
=
"审批组、自定义审批、审批汇总、审批详情、审批执行记录、审批执行人记录 所有数据"
)
@ApiOperationSupport
(
order
=
90
)
public
Result
<
Object
>
deleteApprovalData
(
@CurrentUser
UserBean
userBean
){
spmkApprovalGMapper
.
delete
(
null
);
spmkCustomApprovalMapper
.
delete
(
null
);
spmkApproveSummaryMapper
.
delete
(
null
);
spmkApproveDetailSummaryMapper
.
delete
(
null
);
spmkApproveExecuteRecordMapper
.
delete
(
null
);
spmkExecutorMapper
.
delete
(
null
);
Logoutput
(
"删除-审批组、自定义审批、审批汇总、审批详情、审批执行记录、审批执行人记录 所有数据 完成!"
);
return
ResultUtil
.
success
();
}
//TODO 审批图标列表
@GetMapping
(
value
=
"/icon"
)
@ApiOperation
(
value
=
"99.图标列表"
,
httpMethod
=
"GET"
,
notes
=
"接口发布说明"
)
@ApiOperationSupport
(
order
=
99
)
public
Result
<
List
<
SpmkIcon
>>
selectListIcon
(
@CurrentUser
UserBean
userBean
){
List
<
SpmkIcon
>
spmkIcons
=
SpmkIcon
.
builder
().
build
().
selectAll
();
return
ResultUtil
.
data
(
spmkIcons
,
"获取图标列表成功"
);
}
//TODO 测试-生成 审批组 和 自定义审批
@GetMapping
(
value
=
"/test"
)
@ApiOperation
(
value
=
"98.测试-生成 审批组 和 自定义审批"
,
httpMethod
=
"GET"
,
notes
=
"测试-生成 审批组 和 自定义审批"
)
@ApiOperationSupport
(
order
=
98
)
public
Result
<
List
<
SpmkIcon
>>
createCustomApproval
(
@RequestParam
Integer
orgCode
){
spmkService
.
createCustomApproval
(
orgCode
);
List
<
SpmkIcon
>
spmkIcons
=
SpmkIcon
.
builder
().
build
().
selectAll
();
return
ResultUtil
.
data
(
spmkIcons
,
"生成 审批组 和 自定义审批成功"
);
}
@GetMapping
(
value
=
"/verification_staff"
)
@ApiOperation
(
value
=
"校验员工是否是正式员工"
,
httpMethod
=
"GET"
,
notes
=
" 查询列表-假期规则"
)
public
Result
<
Object
>
verification_staff
(
@CurrentUser
UserBean
userBean
)
{
String
msg
=
""
;
YgglMainEmp
ygem
=
YgglMainEmp
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
YgglMainEmp
>().
lambda
().
eq
(
YgglMainEmp:
:
getOrgCode
,
userBean
.
getOrgCode
())
.
eq
(
YgglMainEmp:
:
getEmpNum
,
userBean
.
getEmpNum
()));
if
(
ygem
.
getJobStatus
()
==
1
)
{
msg
=
"正式员工不能发起转正审批"
;
}
return
ResultUtil
.
data
(
msg
);
}
@PostMapping
(
value
=
"/approved_quantity"
)
@ApiOperation
(
value
=
"APP-我发起的/我审批的/抄送我的-数量"
,
httpMethod
=
"POST"
,
notes
=
""
)
public
Result
<
Object
>
ApprovedQuantity
(
@CurrentUser
UserBean
userBean
,
@Validated
@RequestBody
MySummaryQueryDto
mysummaryquerydto
){
ApprovedQuantityDto
qna
=
ApprovedQuantityDto
.
builder
().
build
();
mysummaryquerydto
.
setEndTime
(
null
);
mysummaryquerydto
.
setStartTime
(
null
);
mysummaryquerydto
.
setOrgCode
(
userBean
.
getOrgCode
());
mysummaryquerydto
.
setEmpNum
(
userBean
.
getEmpNum
());
mysummaryquerydto
.
setSts
(
5
);
//状态 0审批中 1审批撤销 2审批通过/审批完成 3审批拒绝 4:(2/3) 5:全部
int
istartedit
=
0
,
ccme
=
0
,
iapprovedit
=
0
;
mysummaryquerydto
.
setType
(
0
);
//我发起的
List
<
SpmkApproveSummary
>
istartedit_
=
spmkApproveSummaryMapper
.
selectPageByQueryForEmpNum
(
mysummaryquerydto
);
if
(
istartedit_
.
size
()
>
0
)
{
istartedit
=
istartedit_
.
size
();
}
mysummaryquerydto
.
setType
(
1
);
//抄送我的
List
<
SpmkApproveSummary
>
ccme_
=
spmkApproveSummaryMapper
.
selectPageByQueryForEmpNum
(
mysummaryquerydto
);
if
(
ccme_
.
size
()
>
0
)
{
ccme
=
ccme_
.
size
();
}
mysummaryquerydto
.
setType
(
2
);
//我审批的
List
<
SpmkApproveSummary
>
iapprovedit_
=
spmkApproveSummaryMapper
.
selectPageByQueryForEmpNum
(
mysummaryquerydto
);
if
(
iapprovedit_
.
size
()
>
0
)
{
iapprovedit
=
iapprovedit_
.
size
();
}
qna
.
setIstartedit
(
istartedit
);
qna
.
setCcme
(
ccme
);
qna
.
setIapprovedit
(
iapprovedit
);
return
ResultUtil
.
data
(
qna
);
}
@Value
(
"${config-8timer.environmental-science}"
)
public
String
environmental_science
;
public
void
Logoutput
(
String
science
)
{
if
(!(
"pro"
).
equals
(
environmental_science
))
{
System
.
out
.
println
(
science
);
}
else
{
System
.
out
.
println
(
""
);
}
}
/**
* 审核详情数据转换
*/
@PostMapping
(
value
=
"/approved_addDetail"
)
@ApiOperation
(
value
=
"A审核详情数据转换"
,
httpMethod
=
"POST"
,
notes
=
""
)
public
String
addApproveDetail
(){
return
spmkService
.
addApproveDetail
();
}
}
package
cn
.
timer
.
api
.
controller
.
spmk
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
cn.timer.api.bean.spmk.*
;
import
cn.timer.api.dao.spmk.*
;
import
cn.timer.api.dto.spmk.*
;
import
cn.timer.api.utils.redis.RedisUtil
;
import
com.baomidou.mybatisplus.core.toolkit.SerializationUtils
;
import
net.sf.json.JSONArray
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.github.xiaoymin.knife4j.annotations.ApiOperationSupport
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.lang.Console
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.timer.api.aspect.lang.annotation.Log
;
import
cn.timer.api.aspect.lang.enums.BusinessType
;
import
cn.timer.api.bean.kqgl.PunchRecord
;
import
cn.timer.api.bean.kqmk.KqglAssoLeaveRules
;
import
cn.timer.api.bean.qyzx.QyzxEmpEntAsso
;
import
cn.timer.api.bean.yggl.YgglMainEmp
;
import
cn.timer.api.bean.zzgl.ZzglBmgwM
;
import
cn.timer.api.config.annotation.CurrentUser
;
import
cn.timer.api.config.annotation.UserBean
;
import
cn.timer.api.config.enuminterface.SpmkEnumInterface
;
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.config.exception.CustomException
;
import
cn.timer.api.config.validation.Insert
;
import
cn.timer.api.config.validation.Ranks
;
import
cn.timer.api.config.validation.Update
;
import
cn.timer.api.config.validation.ValidList
;
import
cn.timer.api.controller.spmk.service.SpmkService
;
import
cn.timer.api.controller.yggl.service.YgglService
;
import
cn.timer.api.controller.zzgl.service.ZzglBmgwMService
;
import
cn.timer.api.dao.kqgl.PunchRecordMapper
;
import
cn.timer.api.dao.qyzx.QyzxEmpEntAssoMapper
;
import
cn.timer.api.utils.Result
;
import
cn.timer.api.utils.ResultUtil
;
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
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
javax.annotation.Resource
;
@Api
(
tags
=
"3.0审批模块"
)
@RestController
@Transactional
@RequestMapping
(
value
=
"/spmk"
,
produces
=
{
"application/json"
,
"multipart/form-data"
})
public
class
SpmkController
{
@Autowired
private
SpmkService
spmkService
;
@Autowired
private
ZzglBmgwMService
zzglBmgwMService
;
@Autowired
private
QyzxEmpEntAssoMapper
qyzxEmpEntAssoMapper
;
@Autowired
private
SpmkApprovalTemplateGMapper
spmkApprovalTemplateGMapper
;
@Autowired
private
SpmkApprovalTemplateMapper
spmkApprovalTemplateMapper
;
@Autowired
private
SpmkApprovalGMapper
spmkApprovalGMapper
;
@Autowired
private
SpmkCustomApprovalMapper
spmkCustomApprovalMapper
;
@Autowired
private
SpmkApproveSummaryMapper
spmkApproveSummaryMapper
;
@Autowired
private
SpmkApproveExecuteRecordMapper
spmkApproveExecuteRecordMapper
;
@Autowired
private
SpmkExecutorMapper
spmkExecutorMapper
;
@Autowired
private
SpmkInitiatorConfigMapper
spmkInitiatorConfigMapper
;
@Autowired
private
SpmkApproveDetailSummaryMapper
spmkApproveDetailSummaryMapper
;
@Autowired
private
SpmkAssoBusinessFactory
spmkAssoBusinessFactory
;
private
static
com
.
alibaba
.
fastjson
.
JSONObject
jsonObject
=
new
com
.
alibaba
.
fastjson
.
JSONObject
();
private
boolean
ISFIRST
=
true
;
// 第一次启动审批流程
@Resource
private
RedisUtil
redisUtil
;
//TODO 审批模板组
/**
* 新增或编辑-审批模板组
*/
@PostMapping
(
value
=
"/save_approval_template_g"
)
@ApiOperation
(
value
=
"1.新增或编辑-审批模板组"
,
httpMethod
=
"POST"
,
notes
=
"新增或编辑-审批模板组"
)
@ApiOperationSupport
(
order
=
1
)
public
Result
<
Object
>
saveAtg
(
@Validated
({
Insert
.
class
,
Update
.
class
})
@RequestBody
SpmkApprovalTemplateG
spmkApprovalTemplateG
){
if
(
spmkApprovalTemplateG
.
selectCount
(
new
QueryWrapper
<
SpmkApprovalTemplateG
>().
lambda
()
.
ne
(
spmkApprovalTemplateG
.
getId
()
!=
null
,
SpmkApprovalTemplateG:
:
getId
,
spmkApprovalTemplateG
.
getId
())
.
eq
(
SpmkApprovalTemplateG:
:
getName
,
spmkApprovalTemplateG
.
getName
()))
>
0
)
{
return
ResultUtil
.
error
(
"审批模板组名重复!"
);
}
return
spmkApprovalTemplateG
.
insertOrUpdate
()
?
ResultUtil
.
data
(
spmkApprovalTemplateG
)
:
ResultUtil
.
error
();
}
/**
* 删除-审批模板组
*/
@DeleteMapping
(
value
=
"/delete_approval_template_g/{id}"
)
@ApiOperation
(
value
=
"2.删除-审批模板组"
,
httpMethod
=
"DELETE"
,
notes
=
"删除-审批模板组"
)
@ApiOperationSupport
(
order
=
2
)
public
Result
<
Object
>
deleteAtgById
(
@PathVariable
int
id
){
if
(
spmkApprovalTemplateMapper
.
selectCount
(
new
QueryWrapper
<
SpmkApprovalTemplate
>().
lambda
().
eq
(
SpmkApprovalTemplate:
:
getApprovalTemplateGId
,
id
))
>
0
)
return
ResultUtil
.
error
(
"审批模板组存在 模板,不可直接删除!"
);
return
SpmkApprovalTemplateG
.
builder
().
id
(
id
).
build
().
deleteById
()
?
ResultUtil
.
success
()
:
ResultUtil
.
error
(
"没有找到该对象"
);
}
/**
* 查询列表-审批模板组
*/
@GetMapping
(
value
=
"/list_approval_template_g"
)
@ApiOperation
(
value
=
"3.查询列表-审批模板组"
,
httpMethod
=
"GET"
,
notes
=
"查询列表-审批模板组"
)
@ApiOperationSupport
(
order
=
3
)
public
Result
<
Object
>
selectListAtg
(){
return
ResultUtil
.
data
(
spmkApprovalTemplateGMapper
.
selectListAtInAtg
());
}
/**
* 排序-审批模板组
*/
@PutMapping
(
value
=
"/update_approval_template_g"
)
@ApiOperation
(
value
=
"4.排序-审批模板组"
,
httpMethod
=
"PUT"
,
notes
=
"排序-审批模板组"
)
@ApiOperationSupport
(
order
=
4
)
public
Result
<
Object
>
ranksAtg
(
@Validated
(
Ranks
.
class
)
@RequestBody
ValidList
<
SpmkApprovalTemplateG
>
list
){
if
(
list
==
null
||
(
list
!=
null
&&
list
.
size
()
<=
0
))
{
return
ResultUtil
.
success
();
}
return
spmkApprovalTemplateGMapper
.
updateListRandsById
(
list
)
?
ResultUtil
.
success
()
:
ResultUtil
.
error
();
}
//TODO 审批模板
/**
* 新增或编辑-审批模板
*/
@PostMapping
(
value
=
"/save_approval_template"
)
@ApiOperation
(
value
=
"5.新增或编辑-审批模板"
,
httpMethod
=
"POST"
,
notes
=
"新增或编辑-审批模板"
)
@ApiOperationSupport
(
order
=
5
)
public
Result
<
Object
>
saveAt
(
@Validated
@RequestBody
SpmkApprovalTemplateDto
spmkApprovalTemplateDto
){
Integer
approvalTemplateGId
=
spmkApprovalTemplateDto
.
getApprovalTemplateGId
();
if
(
ObjectUtil
.
isNull
(
approvalTemplateGId
))
return
ResultUtil
.
error
(
"审批模板ID不为空"
);
SpmkApprovalTemplate
at
=
SpmkApprovalTemplate
.
builder
().
build
();
// 克隆 SpmkApprovalTemplateDto对象 到 SpmkApprovalTemplate对象,排除属性froms,router
BeanUtil
.
copyProperties
(
spmkApprovalTemplateDto
,
at
,
"froms"
,
"router"
);
// 序列化 后 写入 SpmkApprovalTemplate对象
at
.
setFroms
(
ObjectUtil
.
serialize
((
List
<
JSONObject
>)
spmkApprovalTemplateDto
.
getFroms
()));
at
.
setRouter
(
ObjectUtil
.
serialize
(
spmkApprovalTemplateDto
.
getRouter
()));
if
(
at
.
selectCount
(
new
QueryWrapper
<
SpmkApprovalTemplate
>().
lambda
()
.
ne
(
at
.
getId
()
!=
null
,
SpmkApprovalTemplate:
:
getId
,
at
.
getId
())
.
eq
(
SpmkApprovalTemplate:
:
getName
,
at
.
getName
()))
>
0
)
{
return
ResultUtil
.
error
(
"审批模板名重复!"
);
}
if
(!
at
.
insertOrUpdate
())
return
ResultUtil
.
error
(
"数据库操作失败"
);
// 清空前端不需要的字段再返回,节省流量
at
.
setFroms
(
null
);
at
.
setRouter
(
null
);
return
ResultUtil
.
data
(
at
);
}
/**
* 删除-审批模板
*/
@DeleteMapping
(
value
=
"/delete_approval_template/{id}"
)
@ApiOperation
(
value
=
"6.删除-审批模板"
,
httpMethod
=
"DELETE"
,
notes
=
"删除-审批模板"
)
@ApiOperationSupport
(
order
=
6
)
public
Result
<
Object
>
deleteAtById
(
@PathVariable
int
id
){
return
SpmkApprovalTemplate
.
builder
().
id
(
id
).
build
().
deleteById
()
?
ResultUtil
.
success
()
:
ResultUtil
.
error
(
"没有找到该对象"
);
}
/**
* id查询-审批模板
*/
@GetMapping
(
value
=
"/select_approval_template/{id}"
)
@ApiOperation
(
value
=
"7.id查询-审批模板"
,
httpMethod
=
"GET"
,
notes
=
"id查询-审批模板"
)
@ApiOperationSupport
(
order
=
7
)
public
Result
<
Object
>
selectAtById
(
@PathVariable
int
id
){
SpmkApprovalTemplate
at
=
SpmkApprovalTemplate
.
builder
().
id
(
id
).
build
().
selectById
();
SpmkApprovalTemplateDto
atd
=
SpmkApprovalTemplateDto
.
builder
().
build
();
BeanUtil
.
copyProperties
(
at
,
atd
,
"froms"
,
"router"
);
atd
.
setFroms
(
ObjectUtil
.
deserialize
(
at
.
getFroms
()));
atd
.
setRouter
(
ObjectUtil
.
deserialize
(
at
.
getRouter
()));
return
ResultUtil
.
data
(
atd
);
}
/**
* 排序-审批模板
*/
@PutMapping
(
value
=
"/update_approval_template"
)
@ApiOperation
(
value
=
"8.排序-审批模板"
,
httpMethod
=
"PUT"
,
notes
=
"查询列表-审批模板组"
)
@ApiOperationSupport
(
order
=
8
)
public
Result
<
Object
>
ranksAt
(
@Validated
({
Ranks
.
class
})
@RequestBody
ValidList
<
SpmkApprovalTemplate
>
list
){
if
(
list
==
null
||
(
list
!=
null
&&
list
.
size
()
<=
0
))
{
return
ResultUtil
.
success
();
}
return
spmkApprovalTemplateMapper
.
updateListRandsById
(
list
)
?
ResultUtil
.
success
()
:
ResultUtil
.
error
();
}
//TODO 审批组
/**
* 新增或编辑-审批组
*/
@PostMapping
(
value
=
"/save_approval_g"
)
@ApiOperation
(
value
=
"9.新增或编辑-审批组"
,
httpMethod
=
"POST"
,
notes
=
"新增或编辑-审批组"
)
@ApiOperationSupport
(
order
=
9
)
public
Result
<
Object
>
saveAg
(
@CurrentUser
UserBean
userBean
,
@Validated
({
Insert
.
class
,
Update
.
class
})
@RequestBody
SpmkApprovalG
spmkApprovalG
){
if
(
spmkApprovalG
.
selectCount
(
new
QueryWrapper
<
SpmkApprovalG
>().
lambda
()
.
ne
(
spmkApprovalG
.
getId
()
!=
null
,
SpmkApprovalG:
:
getId
,
spmkApprovalG
.
getId
())
.
eq
(
SpmkApprovalG:
:
getName
,
spmkApprovalG
.
getName
())
.
eq
(
SpmkApprovalG:
:
getOrgCode
,
userBean
.
getOrgCode
()))
>
0
)
{
return
ResultUtil
.
error
(
"审批组名重复!"
);
}
spmkApprovalG
.
setOrgCode
(
userBean
.
getOrgCode
());
return
spmkApprovalG
.
insertOrUpdate
()
?
ResultUtil
.
data
(
spmkApprovalG
)
:
ResultUtil
.
error
();
}
/**
* 删除-审批组
*/
@DeleteMapping
(
value
=
"/delete_approval_g/{id}"
)
@ApiOperation
(
value
=
"10.删除-审批组"
,
httpMethod
=
"DELETE"
,
notes
=
"删除-审批组"
)
@ApiOperationSupport
(
order
=
10
)
public
Result
<
Object
>
deleteAgById
(
@PathVariable
int
id
){
// if (spmkCustomApprovalMapper.selectCount(new QueryWrapper<SpmkCustomApproval>().lambda().eq(SpmkCustomApproval::getApprovalGId, id)) > 0 )
// return ResultUtil.error("审批组存在 自定义审批,不可直接删除!");
SpmkCustomApproval
.
builder
().
build
().
delete
(
new
QueryWrapper
<
SpmkCustomApproval
>().
lambda
().
eq
(
SpmkCustomApproval:
:
getApprovalGId
,
id
));
return
SpmkApprovalG
.
builder
().
id
(
id
).
build
().
deleteById
()
?
ResultUtil
.
success
()
:
ResultUtil
.
error
(
"没有找到该对象"
);
}
/**
* 查询列表-审批组-审批管理
*/
@GetMapping
(
value
=
"/all_approval_g"
)
@ApiOperation
(
value
=
"11.查询列表-审批组-审批管理"
,
httpMethod
=
"GET"
,
notes
=
"查询列表-审批组-审批管理"
)
@ApiOperationSupport
(
order
=
11
)
public
Result
<
Object
>
selectListAgByAdmin
(
@CurrentUser
UserBean
userBean
){
List
<
Integer
>
depts
=
zzglBmgwMService
.
empNumupGetDepts
(
userBean
.
getOrgCode
(),
userBean
.
getEmpNum
());
return
ResultUtil
.
data
(
spmkApprovalGMapper
.
selectListAgInCaByAdmin
(
userBean
.
getOrgCode
(),
userBean
.
getEmpNum
(),
depts
));
}
/**
* 查询列表-审批组-个人审批
*/
@GetMapping
(
value
=
"/list_approval_g"
)
@ApiOperation
(
value
=
"11.查询列表-审批组-个人审批"
,
httpMethod
=
"GET"
,
notes
=
"查询列表-审批组-个人审批"
)
@ApiOperationSupport
(
order
=
11
)
public
Result
<
Object
>
selectListAg
(
@CurrentUser
UserBean
userBean
){
return
ResultUtil
.
data
(
spmkService
.
selectListAg
(
userBean
));
}
/**
* 排序-审批组
*/
@PutMapping
(
value
=
"/update_approval_g"
)
@ApiOperation
(
value
=
"12.排序-审批组"
,
httpMethod
=
"PUT"
,
notes
=
"排序-审批组"
)
@ApiOperationSupport
(
order
=
12
)
public
Result
<
Object
>
ranksAg
(
@Validated
({
Ranks
.
class
})
@RequestBody
ValidList
<
SpmkApprovalG
>
list
){
if
(
list
==
null
||
list
.
size
()
<=
0
)
{
return
ResultUtil
.
success
();
}
return
spmkApprovalGMapper
.
updateListRandsById
(
list
)
?
ResultUtil
.
success
()
:
ResultUtil
.
error
();
}
//TODO 自定义审批
/**
* 新增或编辑-自定义审批
*/
@PostMapping
(
value
=
"/save_custom_approval"
)
@ApiOperation
(
value
=
"13.新增或编辑-自定义审批"
,
httpMethod
=
"POST"
,
notes
=
"新增或编辑-自定义审批"
)
@ApiOperationSupport
(
order
=
13
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Result
<
Object
>
saveCa
(
@CurrentUser
UserBean
userBean
,
@Validated
@RequestBody
SpmkCustomApprovalDto
spmkCustomApprovalDto
)
throws
Exception
{
SpmkCustomApproval
ca
=
SpmkCustomApproval
.
builder
().
build
();
BeanUtil
.
copyProperties
(
spmkCustomApprovalDto
,
ca
,
"froms"
,
"router"
,
"initiatorConfigs"
);
if
(
ca
.
selectCount
(
new
QueryWrapper
<
SpmkCustomApproval
>().
lambda
()
.
ne
(
ca
.
getId
()
!=
null
,
SpmkCustomApproval:
:
getId
,
ca
.
getId
())
.
eq
(
SpmkCustomApproval:
:
getName
,
ca
.
getName
())
.
eq
(
SpmkCustomApproval:
:
getOrgCode
,
userBean
.
getOrgCode
()))
>
0
)
{
return
ResultUtil
.
error
(
"自定义审批名重复!"
);
}
ca
.
setOrgCode
(
userBean
.
getOrgCode
());
ca
.
setFroms
(
ObjectUtil
.
serialize
(
spmkCustomApprovalDto
.
getFroms
()));
ca
.
setRouter
(
ObjectUtil
.
serialize
(
spmkCustomApprovalDto
.
getRouter
()));
ca
.
setUpdateTime
(
new
Date
());
//1.新增 SpmkCustomApproval-自定义审批
if
(!
ca
.
insertOrUpdate
())
return
ResultUtil
.
error
(
"新增自定义审批 失败!"
);
Integer
id
=
ca
.
getId
();
// 2.删除 历史的 SpmkInitiatorConfig-审批发起人配置,
SpmkInitiatorConfig
.
builder
().
build
().
delete
(
new
QueryWrapper
<
SpmkInitiatorConfig
>().
lambda
().
eq
(
SpmkInitiatorConfig:
:
getCustomApprovalId
,
id
));
Console
.
log
(
"自定义审批id: "
+
id
);
List
<
SpmkInitiatorConfig
>
listIc
=
spmkCustomApprovalDto
.
getInitiatorConfigs
();
if
(
listIc
!=
null
&&
listIc
.
size
()
>
0
)
{
for
(
int
i
=
0
,
n
=
listIc
.
size
();
i
<
n
;
i
++)
{
listIc
.
get
(
i
).
setCustomApprovalId
(
id
);
}
// 3.新增 最新的 SpmkInitiatorConfig-审批发起人配置,
if
(!
spmkInitiatorConfigMapper
.
insertList
(
listIc
))
{
// 手动抛出异常,事务回滚
throw
new
Exception
();
}
}
//
/**
* 注意: 为保证该api的原子性 要加 事务处理 回滚(方法注解-@Transactional(rollbackFor = Exception.class))
* 1.新增 SpmkCustomApproval-自定义审批
* 2.删除 历史的 SpmkInitiatorConfig-审批发起人配置,
* 3.新增 最新的 SpmkInitiatorConfig-审批发起人配置,
*/
// 清空前端不需要的字段再返回,节省流量
ca
.
setFroms
(
null
);
ca
.
setRouter
(
null
);
return
ResultUtil
.
data
(
ca
);
}
/**
* 删除-自定义审批
* @throws Exception
*/
@DeleteMapping
(
value
=
"/delete_custom_approval/{id}"
)
@ApiOperation
(
value
=
"14.删除-自定义审批"
,
httpMethod
=
"DELETE"
,
notes
=
"删除-自定义审批"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ApiOperationSupport
(
order
=
14
)
public
Result
<
Object
>
deleteCaById
(
@PathVariable
int
id
)
throws
Exception
{
SpmkInitiatorConfig
.
builder
().
build
().
delete
(
new
QueryWrapper
<
SpmkInitiatorConfig
>().
lambda
().
eq
(
SpmkInitiatorConfig:
:
getCustomApprovalId
,
id
));
if
(!
SpmkCustomApproval
.
builder
().
id
(
id
).
build
().
deleteById
())
{
throw
new
Exception
();
}
return
ResultUtil
.
success
();
}
/**
* id查询-自定义审批
*/
@GetMapping
(
value
=
"/select_custom_approval/{id}"
)
@ApiOperation
(
value
=
"15.id查询-自定义审批"
,
httpMethod
=
"GET"
,
notes
=
"id查询-自定义审批"
)
@ApiOperationSupport
(
order
=
15
)
public
Result
<
Object
>
selectCaById
(
@PathVariable
int
id
){
SpmkCustomApproval
ca
=
SpmkCustomApproval
.
builder
().
id
(
id
).
build
().
selectById
();
List
<
SpmkInitiatorConfig
>
listIc
=
SpmkInitiatorConfig
.
builder
().
build
().
selectList
(
new
QueryWrapper
<
SpmkInitiatorConfig
>().
lambda
().
eq
(
SpmkInitiatorConfig:
:
getCustomApprovalId
,
id
));
SpmkCustomApprovalDto
caD
=
SpmkCustomApprovalDto
.
builder
()
.
froms
(
ObjectUtil
.
deserialize
(
ca
.
getFroms
()))
.
router
(
ObjectUtil
.
deserialize
(
ca
.
getRouter
()))
.
build
();
BeanUtil
.
copyProperties
(
ca
,
caD
,
"froms"
,
"router"
);
caD
.
setInitiatorConfigs
(
listIc
);
return
ResultUtil
.
data
(
caD
);
}
/**
* 排序-自定义审批
*/
@PutMapping
(
value
=
"/update_custom_approval"
)
@ApiOperation
(
value
=
"16.排序-自定义审批"
,
httpMethod
=
"PUT"
,
notes
=
"排序-自定义审批"
)
@ApiOperationSupport
(
order
=
16
)
public
Result
<
Object
>
ranksCa
(
@Validated
({
Ranks
.
class
})
@RequestBody
ValidList
<
SpmkCustomApproval
>
list
){
if
(
list
==
null
||
(
list
!=
null
&&
list
.
size
()
<=
0
))
{
return
ResultUtil
.
success
();
}
return
spmkCustomApprovalMapper
.
updateListRandsById
(
list
)
?
ResultUtil
.
success
()
:
ResultUtil
.
error
();
}
@Autowired
YgglService
ygglService
;
/**
* 排序-自定义审批
*/
@PutMapping
(
value
=
"/test_spmk"
)
@ApiOperation
(
value
=
"16.测试"
,
httpMethod
=
"PUT"
,
notes
=
"排序-自定义审批"
)
@ApiOperationSupport
(
order
=
16
)
public
Result
<
Object
>
test222
(
@Validated
({
Ranks
.
class
})
@RequestBody
ValidList
<
SpmkCustomApproval
>
list
){
Set
<
Integer
>
lanzi
=
new
HashSet
<
Integer
>();
//所有部门岗位
List
<
ZzglBmgwM
>
bmgws
=
ZzglBmgwM
.
builder
().
build
().
selectList
(
new
QueryWrapper
<
ZzglBmgwM
>().
lambda
().
eq
(
ZzglBmgwM:
:
getOrgCode
,
311
));
//个人岗位
YgglMainEmp
one
=
YgglMainEmp
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
YgglMainEmp
>().
lambda
()
.
select
(
YgglMainEmp:
:
getBmgwId
)
.
eq
(
YgglMainEmp:
:
getOrgCode
,
311
).
eq
(
YgglMainEmp:
:
getEmpNum
,
12512
));
Integer
getId
=
one
!=
null
?
one
.
getBmgwId
()
:
null
;
Set
<
Integer
>
all
=
getId
!=
null
?
empNumupdept2
(
lanzi
,
bmgws
,
getId
)
:
new
HashSet
<
Integer
>();
all
.
add
(
getId
);
return
spmkCustomApprovalMapper
.
updateListRandsById
(
list
)
?
ResultUtil
.
success
()
:
ResultUtil
.
error
();
}
//遍历
public
static
Set
<
Integer
>
empNumupdept2
(
Set
<
Integer
>
lanzi
,
List
<
ZzglBmgwM
>
bmgws
,
Integer
getId
)
{
for
(
ZzglBmgwM
z
:
bmgws
)
{
if
(
getId
.
equals
(
z
.
getId
()))
{
lanzi
.
add
(
getId
);
if
(
z
.
getUpId
()==
null
||
z
.
getUpId
()
==
0
)
{
return
lanzi
;
}
getId
=
z
.
getUpId
();
empNumupdept2
(
lanzi
,
bmgws
,
getId
);
}
}
return
lanzi
;
}
// TODO 审批汇总(发起审批)
/**
* 发起审批
* @throws Exception
*/
@PostMapping
(
value
=
"/start_approval"
)
@ApiOperation
(
value
=
"17.发起审批"
,
httpMethod
=
"POST"
,
notes
=
"发起审批"
)
@ApiOperationSupport
(
order
=
17
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Log
(
title
=
"审批-发起审批"
,
businessType
=
BusinessType
.
INSERT
)
public
Result
<
Object
>
saveA
(
@CurrentUser
UserBean
userBean
,
@Validated
@RequestBody
SpmkApproveSummaryDto
spmkApproveSummaryDto
)
throws
Exception
{
YgglMainEmp
ygglMainEmp
=
YgglMainEmp
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
YgglMainEmp
>()
.
lambda
()
.
select
(
YgglMainEmp:
:
getHeadUrl
,
YgglMainEmp:
:
getName
)
.
eq
(
YgglMainEmp:
:
getEmpNum
,
userBean
.
getEmpNum
())
.
eq
(
YgglMainEmp:
:
getOrgCode
,
userBean
.
getOrgCode
())
);
if
(
ygglMainEmp
==
null
)
return
ResultUtil
.
error
(
"发起人不存在!"
);
// List<SpmkApprovalG> saG = spmkService.selectListAg(userBean);
Router
router
=
spmkApproveSummaryDto
.
getRouter
();
List
<
Router
>
routers
=
router
.
getChildren
();
// routers = RouterUtils.clearRouters(routers);
if
(
routers
==
null
){
return
ResultUtil
.
error
(
"无法发起,请完善审批流程"
);
}
if
(
CollectionUtil
.
isNotEmpty
(
routers
))
{
// boolean hasAudit=false;
// if(routers.size()>0){
// for (Relation relation:routers.get(0).getRelation()) {
// if(relation.getUsers().size()>0){
// hasAudit=true;
// }
// }
// }
//// List<Relation> relations = routers.get(0).getRelation();
//// if (relations == null || relations.size() < 1) {
//// return ResultUtil.error("无法发起,请完善审批流程");
//// }
//// List<User> users = relations.get(0).getUsers();
//// if (CollectionUtil.isEmpty(users)) {
//// return ResultUtil.error("无法发起,请完善审批流程");
//// }
// if(!hasAudit){
// return ResultUtil.error("请选择审批人!");
// }
}
else
{
return
ResultUtil
.
error
(
"无法发起,请完善审批流程"
);
}
List
<
Router
>
listRouter
=
new
ArrayList
<
Router
>();
listRouter
.
add
(
router
);
JSONObject
jSONObject
=
spmkApproveSummaryDto
.
getRequestData
()
.
set
(
"orgCode"
,
userBean
.
getOrgCode
())
.
set
(
"initiator"
,
ygglMainEmp
.
getName
())
.
set
(
"headUrl"
,
ygglMainEmp
.
getHeadUrl
())
.
set
(
"id"
,
userBean
.
getEmpNum
());
RouterUtils
.
NextNode
(
listRouter
,
jSONObject
,
ISFIRST
);
List
<
FlowChildren
>
listFlowChildren
=
new
ArrayList
<
FlowChildren
>();
RouterUtils
.
getIsFlowChildren
(
listRouter
,
listFlowChildren
);
if
(
listFlowChildren
.
isEmpty
()){
return
ResultUtil
.
error
(
"无法发起,请完善审批流程"
);
}
List
<
FlowChildren
>
listFlowChildren1
=
(
ArrayList
<
FlowChildren
>)
SerializationUtils
.
clone
((
Serializable
)
listFlowChildren
);
List
<
String
>
uidlist
=
new
ArrayList
<>();
int
i
=
0
;
int
fsize
=
listFlowChildren
.
size
();
int
f
=
0
;
//listFlowChildren删除次数
for
(
FlowChildren
flowChildrenItem:
listFlowChildren
)
{
if
(
"audit"
.
equals
(
flowChildrenItem
.
getClassName
()))
{
boolean
hasAudit
=
false
;
for
(
Relation
relation
:
flowChildrenItem
.
getRelation
())
{
if
(
relation
.
getUsers
().
size
()
>
0
)
{
hasAudit
=
true
;
//审批人去重
if
(
relation
.
getUsers
().
size
()
>
1
){
int
j
=
0
;
int
usize
=
relation
.
getUsers
().
size
();
//
int
r
=
0
;
//user list删除次数
for
(
User
user:
relation
.
getUsers
()
)
{
if
(!
uidlist
.
contains
(
user
.
getId
()))
{
uidlist
.
add
(
user
.
getId
());
}
else
{
listFlowChildren1
.
get
(
i
).
getRelation
().
get
(
0
).
getUsers
().
remove
(
j
-
r
);
r
++;
}
j
++;
}
if
(
usize
==
r
){
listFlowChildren1
.
remove
(
i
-
f
);
f
++;
}
}
else
{
if
(!
uidlist
.
contains
(
relation
.
getUsers
().
get
(
0
).
getId
()))
{
uidlist
.
add
(
relation
.
getUsers
().
get
(
0
).
getId
());
}
else
{
listFlowChildren1
.
remove
(
i
-
f
);
f
++;
}
}
}
}
if
(!
hasAudit
)
{
return
ResultUtil
.
error
(
"审批流程设置审批人为空无法发起!"
);
}
}
i
++;
}
listFlowChildren
=
(
ArrayList
<
FlowChildren
>)
SerializationUtils
.
clone
((
Serializable
)
listFlowChildren1
);
/*for (FlowChildren flowChildrenItem: listFlowChildren) {
if("audit".equals(flowChildrenItem.getClassName())){
boolean hasAudit=false;
for (Relation relation:flowChildrenItem.getRelation()) {
if(relation.getUsers().size()>0){
hasAudit=true;
}
}
if(!hasAudit){
return ResultUtil.error("审批流程设置审批人为空无法发起!");
}
}
}*/
Logoutput
(
"listFlowChildren"
);
// 当前审批人
String
currentApprover
=
jSONObject
.
getStr
(
"current_approver"
);
// 封装 审批汇总
SpmkApproveSummary
as
=
SpmkApproveSummary
.
builder
()
.
orgCode
(
userBean
.
getOrgCode
())
.
empNum
(
userBean
.
getEmpNum
())
.
title
(
spmkApproveSummaryDto
.
getTitle
())
.
initiator
(
spmkApproveSummaryDto
.
getInitiator
())
.
approveName
(
spmkApproveSummaryDto
.
getApproveName
())
.
assoType
(
spmkApproveSummaryDto
.
getAssoType
())
.
sts
(
ApproveSummarySts
.
IN
.
ordinal
())
.
currentApprover
(
currentApprover
).
build
();
if
(!
as
.
insert
())
{
throw
new
CustomException
(
"审批汇总-新增异常"
);
}
// 插入记录- 审批执行记录 - 执行人记录
RouterUtils
.
insertogExecuteRecord
(
listFlowChildren
,
as
.
getId
());
// 封装 审批详情
SpmkApproveDetailSummary
adm
=
SpmkApproveDetailSummary
.
builder
().
build
();
adm
.
setApproveSummaryId
(
as
.
getId
());
adm
.
setName
(
spmkApproveSummaryDto
.
getTitle
());
adm
.
setRequestData
(
spmkApproveSummaryDto
.
getRequestData
().
toString
());
adm
.
setFroms
(
spmkApproveSummaryDto
.
getFroms
().
toString
());
adm
.
setRouter
(
listRouter
.
get
(
0
).
toJSONString
());
adm
.
setFlowChildren
(
JSONArray
.
fromObject
(
listFlowChildren
).
toString
());
try
{
spmkApproveDetailSummaryMapper
.
insert
(
adm
);
}
catch
(
Exception
e
){
throw
new
CustomException
(
"审批详情-新增异常"
);
}
return
ResultUtil
.
success
();
}
//TODO 审批汇总
/**
* 审批汇总
* @param summaryQueryDto
* @return
* @throws
*/
@PostMapping
(
value
=
"/select_approve_summary"
)
@ApiOperation
(
value
=
"18.审批汇总"
,
httpMethod
=
"POST"
,
notes
=
"审批汇总"
)
@ApiOperationSupport
(
order
=
18
)
@Log
(
title
=
"审批-审批汇总"
,
businessType
=
BusinessType
.
OTHER
)
public
Result
<
Object
>
selectAs
(
@CurrentUser
UserBean
userBean
,
@RequestBody
SummaryQueryDto
summaryQueryDto
)
{
IPage
<
SpmkApproveSummary
>
page
=
new
Page
<
SpmkApproveSummary
>(
summaryQueryDto
.
getCurrentPage
()
==
null
?
1
:
summaryQueryDto
.
getCurrentPage
(),
summaryQueryDto
.
getTotalPage
()
==
null
?
10
:
summaryQueryDto
.
getTotalPage
());
summaryQueryDto
.
setOrgCode
(
userBean
.
getOrgCode
());
Integer
deptId
=
summaryQueryDto
.
getDeptId
();
List
<
YgglMainEmp
>
listYgglMainEmp
=
zzglBmgwMService
.
selectOtherlistent
(
userBean
.
getOrgCode
(),
deptId
);
if
(
deptId
!=
null
&&
(
listYgglMainEmp
==
null
||
listYgglMainEmp
.
size
()
==
0
))
{
return
ResultUtil
.
data
(
new
ArrayList
<
SpmkApproveSummary
>());
}
List
<
Integer
>
empNums
=
new
ArrayList
<
Integer
>();
for
(
YgglMainEmp
ygglMainEmp
:
listYgglMainEmp
)
{
empNums
.
add
(
ygglMainEmp
.
getEmpNum
());
}
summaryQueryDto
.
setEmpNums
(
empNums
);
// 缺-部门id 搜索
IPage
<
SpmkApproveSummary
>
pageAs
=
spmkApproveSummaryMapper
.
selectPageByQuery
(
page
,
summaryQueryDto
);
List
<
SpmkApproveSummary
>
listAs
=
pageAs
.
getRecords
();
return
ResultUtil
.
data
(
pageAs
,
listAs
);
}
//TODO 审批详情
/**
* 审批详情
*/
@GetMapping
(
value
=
"/select_approve_detail/{id}"
)
@ApiOperation
(
value
=
"19.审批详情"
,
httpMethod
=
"GET"
,
notes
=
"审批详情"
)
@ApiOperationSupport
(
order
=
19
)
@Log
(
title
=
"审批-审批详情"
,
businessType
=
BusinessType
.
OTHER
)
public
Result
<
Object
>
selectAd
(
@PathVariable
(
required
=
true
)
Integer
id
)
{
SpmkApproveDetailDto
adD
=
spmkService
.
selectApproveDetailByAsId
(
id
);
System
.
out
.
println
(
ResultUtil
.
data
(
adD
));
return
ResultUtil
.
data
(
adD
);
}
//TODO 审批人审批
/**
* 审批人审批
*/
@PostMapping
(
value
=
"/approving"
)
@ApiOperation
(
value
=
"20.审批人审批"
,
httpMethod
=
"POST"
,
notes
=
"审批人审批"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ApiOperationSupport
(
order
=
20
)
@Log
(
title
=
"审批-审批流程"
,
businessType
=
BusinessType
.
UPDATE
)
// @BindingResultCtrol(title = "审批人审批")
public
Result
<
Object
>
approving
(
@CurrentUser
UserBean
userBean
,
@Validated
@RequestBody
ApprovingDto
approvingDto
)
throws
Exception
{
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
,
5000
);
}
SpmkApproveDetailSummary
ad
=
SpmkApproveDetailSummary
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
SpmkApproveDetailSummary
>()
.
lambda
()
.
select
(
SpmkApproveDetailSummary:
:
getId
,
SpmkApproveDetailSummary:
:
getRequestData
,
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
(
"非当前审批人 或 管理员,无法操作!"
);
}
}
if
(
aSummary
.
getSts
()
==
0
)
{
List
<
FlowChildren
>
listFlowChildren
=
jsonObject
.
parseArray
(
ad
.
getFlowChildren
(),
FlowChildren
.
class
);
// 审批逻辑
RouterUtils
.
approving
(
listFlowChildren
,
asId
,
approvingDto
.
getExecuteRecordId
(),
approvingDto
.
getExecutorId
(),
approvingDto
.
getOpinion
(),
approvingDto
.
getSts
(),
approvingDto
.
getUser
()
);
// 更新 flowChildren
SpmkApproveDetailSummary
.
builder
().
id
(
ad
.
getId
()).
flowChildren
(
JSONArray
.
fromObject
(
listFlowChildren
).
toString
()).
build
().
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
)
Logoutput
(
"1----------"
+
sab
);
Logoutput
(
"2----------"
+
jSONObject
);
sab
.
handleApprove
(
jSONObject
);
}
}
}
else
{
redisUtil
.
set
(
asId
.
toString
(),
0
,
500
);
return
ResultUtil
.
error
(
"该审批已结束!"
);
}
redisUtil
.
set
(
asId
.
toString
(),
0
,
500
);
return
ResultUtil
.
success
();
}
@Autowired
private
PunchRecordMapper
punchrecordmapper
;
//TODO 我发起的/我审批的/抄送我的
/**
* 查询列表-我发起的/我审批的/抄送我的-分页
*/
@PostMapping
(
value
=
"/select_my_approve"
)
@ApiOperation
(
value
=
"21.查询列表-我发起的/我审批的/抄送我的-分页"
,
httpMethod
=
"POST"
,
notes
=
"查询列表-我审批的-关键字、审批状态、发起时间-分页"
)
@ApiOperationSupport
(
order
=
21
)
@Log
(
title
=
"审批-我发起的/我审批的/抄送我的"
,
businessType
=
BusinessType
.
OTHER
)
public
Result
<
Object
>
selectMyAs
(
@CurrentUser
UserBean
userBean
,
@Validated
@RequestBody
MySummaryQueryDto
mySummaryQueryDto
)
throws
MethodArgumentNotValidException
{
IPage
<
SpmkApproveSummary
>
page
=
new
Page
<
SpmkApproveSummary
>(
mySummaryQueryDto
.
getCurrentPage
()
==
null
?
1
:
mySummaryQueryDto
.
getCurrentPage
(),
mySummaryQueryDto
.
getTotalPage
()
==
null
?
10
:
mySummaryQueryDto
.
getTotalPage
());
mySummaryQueryDto
.
setOrgCode
(
userBean
.
getOrgCode
());
mySummaryQueryDto
.
setEmpNum
(
userBean
.
getEmpNum
());
if
(
mySummaryQueryDto
.
getSts
()
==
null
)
{
mySummaryQueryDto
.
setSts
(
0
);
}
//我发起的
if
(
mySummaryQueryDto
.
getType
()
==
0
)
{
// mySummaryQueryDto.setSts(null);
}
// 缺-部门id 搜索
IPage
<
SpmkApproveSummary
>
pageAs
=
spmkApproveSummaryMapper
.
selectPageByQueryForEmpNum
(
page
,
mySummaryQueryDto
);
List
<
SpmkApproveSummary
>
listAs
=
pageAs
.
getRecords
();
for
(
SpmkApproveSummary
sp
:
listAs
)
{
String
requerstr
=
""
;
try
{
SpmkApproveDetailSummary
ad
=
spmkApproveDetailSummaryMapper
.
selectOne
(
new
QueryWrapper
<
SpmkApproveDetailSummary
>().
lambda
().
eq
(
SpmkApproveDetailSummary:
:
getApproveSummaryId
,
sp
.
getId
()));
JSONObject
as
=
jsonObject
.
parseObject
(
ad
.
getRequestData
().
toString
(),
JSONObject
.
class
);
// Logoutput(as);
// Logoutput(sp.getId()+"==========================================="+sp.getAssoType());
requerstr
=
""
;
//assoType : 1转正 2离职 3调薪 4调岗 5加班 6请假 7出差 8外出 9补卡
switch
(
sp
.
getAssoType
())
{
case
1
:
requerstr
=
"转正时间:"
+
as
.
getJSONObject
(
"__newConfirmationTime"
).
getStr
(
"value"
);
break
;
case
2
:
requerstr
=
"离职时间:"
+
as
.
getJSONObject
(
"__terminationDate"
).
getStr
(
"value"
);
break
;
case
3
:
String
namepos
=
""
;
PunchRecord
pu
=
punchrecordmapper
.
organizationalStructure
(
Integer
.
valueOf
(
as
.
getJSONObject
(
"__TransferInDepartment"
).
getStr
(
"value"
)));
if
(
pu
!=
null
)
{
namepos
=
pu
.
getPost
();
}
requerstr
=
"调入岗位:"
+
namepos
;
break
;
case
5
:
requerstr
=
"加班时长:"
+
as
.
getJSONObject
(
"__timeLong"
).
getStr
(
"value"
)+
"(小时)"
;
break
;
case
6
:
String
name
=
""
;
KqglAssoLeaveRules
rul
=
KqglAssoLeaveRules
.
builder
().
build
().
selectById
(
as
.
getJSONObject
(
"__LeaveType"
).
getStr
(
"value"
));
if
(
rul
!=
null
)
{
name
=
rul
.
getName
();
}
requerstr
=
"请假类型:"
+
name
;
break
;
case
7
:
requerstr
=
"出差时长:"
+
as
.
getJSONObject
(
"__longTime"
).
getStr
(
"value"
)+
"(小时)"
;
break
;
case
8
:
requerstr
=
"外出时长:"
+
as
.
getJSONObject
(
"__longTime"
).
getStr
(
"value"
)+
"(小时)"
;
break
;
case
9
:
requerstr
=
"补卡时间:"
+
as
.
getJSONObject
(
"__PatchCardTime"
).
getStr
(
"value"
);
break
;
default
:
break
;
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
// Logoutput(requerstr);
sp
.
setDigest
(
requerstr
);
}
return
ResultUtil
.
data
(
pageAs
,
listAs
);
}
//TODO 撤销审批
/**
* 撤销审批
*/
@PutMapping
(
value
=
"/revoke_approval/{id}"
)
@ApiOperation
(
value
=
"22.撤销审批"
,
httpMethod
=
"PUT"
,
notes
=
"撤销审批"
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@ApiOperationSupport
(
order
=
22
)
@Log
(
title
=
"审批-撤销审批"
,
businessType
=
BusinessType
.
UPDATE
)
public
Result
<
Object
>
revokeApproval
(
@PathVariable
Integer
id
)
throws
Exception
{
SpmkApproveSummary
as
=
spmkApproveSummaryMapper
.
selectOne
(
new
QueryWrapper
<
SpmkApproveSummary
>()
.
lambda
()
.
select
(
SpmkApproveSummary:
:
getSts
)
.
eq
(
SpmkApproveSummary:
:
getId
,
id
));
return
as
!=
null
&&
as
.
getSts
()
!=
ApproveSummarySts
.
FINISH
.
ordinal
()
?
(
SpmkApproveSummary
.
builder
().
id
(
id
).
endTime
(
new
Date
()).
sts
(
ApproveSummarySts
.
UNDONE
.
ordinal
()).
build
().
updateById
()
?
ResultUtil
.
success
()
:
ResultUtil
.
error
(
"撤销异常"
))
:
ResultUtil
.
error
(
"审批已结束,无法撤销!"
);
}
/**
* 删除-审批(发起的审批)-根据审批汇总id
*/
@DeleteMapping
(
value
=
"/delete_approval/{id}"
)
@ApiOperation
(
value
=
"23.删除-审批(发起的审批)-根据审批汇总id"
,
httpMethod
=
"DELETE"
,
notes
=
"删除-审批(发起的审批)-根据审批汇总id"
)
@ApiOperationSupport
(
order
=
23
)
@Log
(
title
=
"审批-删除审批"
,
businessType
=
BusinessType
.
DELETE
)
public
Result
<
Object
>
deleteApprovalData
(
@PathVariable
Integer
id
){
List
<
SpmkApproveExecuteRecord
>
listAer
=
spmkApproveExecuteRecordMapper
.
selectList
(
new
QueryWrapper
<
SpmkApproveExecuteRecord
>()
.
lambda
()
.
select
(
SpmkApproveExecuteRecord:
:
getId
)
.
eq
(
SpmkApproveExecuteRecord:
:
getApproveSummaryId
,
id
));
if
(
listAer
!=
null
&&
listAer
.
size
()
>
0
)
{
for
(
SpmkApproveExecuteRecord
aer
:
listAer
)
{
spmkExecutorMapper
.
delete
(
new
QueryWrapper
<
SpmkExecutor
>().
lambda
().
eq
(
SpmkExecutor:
:
getApproveExecuteRecordId
,
aer
.
getId
()));
}
}
spmkApproveExecuteRecordMapper
.
delete
(
new
QueryWrapper
<
SpmkApproveExecuteRecord
>().
lambda
().
eq
(
SpmkApproveExecuteRecord:
:
getApproveSummaryId
,
id
));
//新审核表删除
spmkApproveDetailSummaryMapper
.
delete
(
new
QueryWrapper
<
SpmkApproveDetailSummary
>().
lambda
().
eq
(
SpmkApproveDetailSummary:
:
getApproveSummaryId
,
id
));
spmkApproveSummaryMapper
.
delete
(
new
QueryWrapper
<
SpmkApproveSummary
>().
lambda
().
eq
(
SpmkApproveSummary:
:
getId
,
id
));
return
ResultUtil
.
success
();
}
/**
* 删除-审批组、自定义审批、审批汇总、审批详情、审批执行记录、审批执行人记录 所有数据
*/
@DeleteMapping
(
value
=
"/delete_approval_data"
)
@ApiOperation
(
value
=
"90.(开发使用)删除-审批数据"
,
httpMethod
=
"DELETE"
,
notes
=
"审批组、自定义审批、审批汇总、审批详情、审批执行记录、审批执行人记录 所有数据"
)
@ApiOperationSupport
(
order
=
90
)
public
Result
<
Object
>
deleteApprovalData
(
@CurrentUser
UserBean
userBean
){
spmkApprovalGMapper
.
delete
(
null
);
spmkCustomApprovalMapper
.
delete
(
null
);
spmkApproveSummaryMapper
.
delete
(
null
);
spmkApproveDetailSummaryMapper
.
delete
(
null
);
spmkApproveExecuteRecordMapper
.
delete
(
null
);
spmkExecutorMapper
.
delete
(
null
);
Logoutput
(
"删除-审批组、自定义审批、审批汇总、审批详情、审批执行记录、审批执行人记录 所有数据 完成!"
);
return
ResultUtil
.
success
();
}
//TODO 审批图标列表
@GetMapping
(
value
=
"/icon"
)
@ApiOperation
(
value
=
"99.图标列表"
,
httpMethod
=
"GET"
,
notes
=
"接口发布说明"
)
@ApiOperationSupport
(
order
=
99
)
public
Result
<
List
<
SpmkIcon
>>
selectListIcon
(
@CurrentUser
UserBean
userBean
){
List
<
SpmkIcon
>
spmkIcons
=
SpmkIcon
.
builder
().
build
().
selectAll
();
return
ResultUtil
.
data
(
spmkIcons
,
"获取图标列表成功"
);
}
//TODO 测试-生成 审批组 和 自定义审批
@GetMapping
(
value
=
"/test"
)
@ApiOperation
(
value
=
"98.测试-生成 审批组 和 自定义审批"
,
httpMethod
=
"GET"
,
notes
=
"测试-生成 审批组 和 自定义审批"
)
@ApiOperationSupport
(
order
=
98
)
public
Result
<
List
<
SpmkIcon
>>
createCustomApproval
(
@RequestParam
Integer
orgCode
){
spmkService
.
createCustomApproval
(
orgCode
);
List
<
SpmkIcon
>
spmkIcons
=
SpmkIcon
.
builder
().
build
().
selectAll
();
return
ResultUtil
.
data
(
spmkIcons
,
"生成 审批组 和 自定义审批成功"
);
}
@GetMapping
(
value
=
"/verification_staff"
)
@ApiOperation
(
value
=
"校验员工是否是正式员工"
,
httpMethod
=
"GET"
,
notes
=
" 查询列表-假期规则"
)
public
Result
<
Object
>
verification_staff
(
@CurrentUser
UserBean
userBean
)
{
String
msg
=
""
;
YgglMainEmp
ygem
=
YgglMainEmp
.
builder
().
build
().
selectOne
(
new
QueryWrapper
<
YgglMainEmp
>().
lambda
().
eq
(
YgglMainEmp:
:
getOrgCode
,
userBean
.
getOrgCode
())
.
eq
(
YgglMainEmp:
:
getEmpNum
,
userBean
.
getEmpNum
()));
if
(
ygem
.
getJobStatus
()
==
1
)
{
msg
=
"正式员工不能发起转正审批"
;
}
return
ResultUtil
.
data
(
msg
);
}
@PostMapping
(
value
=
"/approved_quantity"
)
@ApiOperation
(
value
=
"APP-我发起的/我审批的/抄送我的-数量"
,
httpMethod
=
"POST"
,
notes
=
""
)
public
Result
<
Object
>
ApprovedQuantity
(
@CurrentUser
UserBean
userBean
,
@Validated
@RequestBody
MySummaryQueryDto
mysummaryquerydto
){
ApprovedQuantityDto
qna
=
ApprovedQuantityDto
.
builder
().
build
();
mysummaryquerydto
.
setEndTime
(
null
);
mysummaryquerydto
.
setStartTime
(
null
);
mysummaryquerydto
.
setOrgCode
(
userBean
.
getOrgCode
());
mysummaryquerydto
.
setEmpNum
(
userBean
.
getEmpNum
());
mysummaryquerydto
.
setSts
(
5
);
//状态 0审批中 1审批撤销 2审批通过/审批完成 3审批拒绝 4:(2/3) 5:全部
int
istartedit
=
0
,
ccme
=
0
,
iapprovedit
=
0
;
mysummaryquerydto
.
setType
(
0
);
//我发起的
List
<
SpmkApproveSummary
>
istartedit_
=
spmkApproveSummaryMapper
.
selectPageByQueryForEmpNum
(
mysummaryquerydto
);
if
(
istartedit_
.
size
()
>
0
)
{
istartedit
=
istartedit_
.
size
();
}
mysummaryquerydto
.
setType
(
1
);
//抄送我的
List
<
SpmkApproveSummary
>
ccme_
=
spmkApproveSummaryMapper
.
selectPageByQueryForEmpNum
(
mysummaryquerydto
);
if
(
ccme_
.
size
()
>
0
)
{
ccme
=
ccme_
.
size
();
}
mysummaryquerydto
.
setType
(
2
);
//我审批的
List
<
SpmkApproveSummary
>
iapprovedit_
=
spmkApproveSummaryMapper
.
selectPageByQueryForEmpNum
(
mysummaryquerydto
);
if
(
iapprovedit_
.
size
()
>
0
)
{
iapprovedit
=
iapprovedit_
.
size
();
}
qna
.
setIstartedit
(
istartedit
);
qna
.
setCcme
(
ccme
);
qna
.
setIapprovedit
(
iapprovedit
);
return
ResultUtil
.
data
(
qna
);
}
@Value
(
"${config-8timer.environmental-science}"
)
public
String
environmental_science
;
public
void
Logoutput
(
String
science
)
{
if
(!(
"pro"
).
equals
(
environmental_science
))
{
System
.
out
.
println
(
science
);
}
else
{
System
.
out
.
println
(
""
);
}
}
/**
* 审核详情数据转换
*/
@PostMapping
(
value
=
"/approved_addDetail"
)
@ApiOperation
(
value
=
"A审核详情数据转换"
,
httpMethod
=
"POST"
,
notes
=
""
)
public
String
addApproveDetail
(){
return
spmkService
.
addApproveDetail
();
}
}
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