Commit 236ab785 by 陶湘宇

防止重复提交审批

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