Commit 667b9522 by 翁国栋

管理员审批重复扣除假期余额bug

parent 78b4ac17
...@@ -51,72 +51,73 @@ import java.util.*; ...@@ -51,72 +51,73 @@ import java.util.*;
@Api(tags = "3.0Admin审批模块") @Api(tags = "3.0Admin审批模块")
@RestController @RestController
@Transactional @Transactional
@RequestMapping(value = "/admin/spmk", produces = { "application/json","multipart/form-data" }) @RequestMapping(value = "/admin/spmk", produces = {"application/json", "multipart/form-data"})
public class AdminSpmkController { public class AdminSpmkController {
@Autowired @Autowired
private QyzxEmpEntAssoMapper qyzxEmpEntAssoMapper; private QyzxEmpEntAssoMapper qyzxEmpEntAssoMapper;
@Autowired @Autowired
private SpmkApproveSummaryMapper spmkApproveSummaryMapper; private SpmkApproveSummaryMapper spmkApproveSummaryMapper;
@Autowired @Autowired
private SpmkExecutorMapper spmkExecutorMapper; private SpmkExecutorMapper spmkExecutorMapper;
@Autowired @Autowired
private SpmkAssoBusinessFactory spmkAssoBusinessFactory; private SpmkAssoBusinessFactory spmkAssoBusinessFactory;
@Autowired @Autowired
private SpmkApproveExecuteRecordMapper spmkApproveExecuteRecordMapper; private SpmkApproveExecuteRecordMapper spmkApproveExecuteRecordMapper;
private static com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject(); private static com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
@Resource @Resource
private RedisUtil redisUtil; private RedisUtil redisUtil;
//TODO 管理员审批 //TODO 管理员审批
/**
* 管理员审批 /**
*/ * 管理员审批
@PostMapping(value = "/approving") */
@ApiOperation(value = "1.审批人审批", httpMethod = "POST", notes = "审批人审批") @PostMapping(value = "/approving")
@Transactional(rollbackFor = Exception.class) @ApiOperation(value = "1.审批人审批", httpMethod = "POST", notes = "审批人审批")
@ApiOperationSupport(order = 20) @Transactional(rollbackFor = Exception.class)
@Log(title = "审批-审批流程", businessType = BusinessType.UPDATE) @ApiOperationSupport(order = 20)
public Result<Object> approving(@CurrentUser UserBean userBean,@Validated @RequestBody AdminApprovingDto approvingDto) throws Exception { @Log(title = "审批-审批流程", businessType = BusinessType.UPDATE)
/*判断是否有权限转派*/ public Result<Object> approving(@CurrentUser UserBean userBean, @Validated @RequestBody AdminApprovingDto approvingDto) throws Exception {
//if(approvingDto.getSts()==4){ /*判断是否有权限转派*/
QyzxEmpEntAsso ent = QyzxEmpEntAsso.builder().build().selectOne(new QueryWrapper<QyzxEmpEntAsso>().lambda().eq(QyzxEmpEntAsso::getOrgCode, userBean.getOrgCode()).eq(QyzxEmpEntAsso::getEmpNum, userBean.getEmpNum())); //if(approvingDto.getSts()==4){
if(ent != null) { QyzxEmpEntAsso ent = QyzxEmpEntAsso.builder().build().selectOne(new QueryWrapper<QyzxEmpEntAsso>().lambda().eq(QyzxEmpEntAsso::getOrgCode, userBean.getOrgCode()).eq(QyzxEmpEntAsso::getEmpNum, userBean.getEmpNum()));
/*超管和管理员不受权限控制*/ if (ent != null) {
if(ent.getUserType() == 2) { /*超管和管理员不受权限控制*/
ZzglAuth zzglAuth = ZzglAuth.builder().build().selectOne(new QueryWrapper<ZzglAuth>().lambda().eq(ZzglAuth::getBmgwId, userBean.getUserInfo().getBmgwId()) if (ent.getUserType() == 2) {
.eq(ZzglAuth::getMenuId, "/Approvalspbutonspbuton020102")); ZzglAuth zzglAuth = ZzglAuth.builder().build().selectOne(new QueryWrapper<ZzglAuth>().lambda().eq(ZzglAuth::getBmgwId, userBean.getUserInfo().getBmgwId())
if (zzglAuth == null) { .eq(ZzglAuth::getMenuId, "/Approvalspbutonspbuton020102"));
return ResultUtil.error("您没有权限"); if (zzglAuth == null) {
} return ResultUtil.error("您没有权限");
} }
} }
//} }
Integer asId = approvingDto.getAsId(); //}
//查询redis中当前有没有在被审批执行中,0是没有在执行,1是在执行 Integer asId = approvingDto.getAsId();
Integer approStatus=Integer.parseInt(redisUtil.get(asId.toString())==null?"0":redisUtil.get(asId.toString()).toString()); //查询redis中当前有没有在被审批执行中,0是没有在执行,1是在执行
if(approStatus==1){ Integer approStatus = Integer.parseInt(redisUtil.get(asId.toString()) == null ? "0" : redisUtil.get(asId.toString()).toString());
return ResultUtil.error("该审批已在审批中!"); if (approStatus == 1) {
}else{ return ResultUtil.error("该审批已在审批中!");
redisUtil.set(asId.toString(),1,2); } else {
} redisUtil.set(asId.toString(), 1, 2);
SpmkApproveDetailSummary ad = SpmkApproveDetailSummary.builder().build().selectOne(new QueryWrapper<SpmkApproveDetailSummary>() }
.lambda() SpmkApproveDetailSummary ad = SpmkApproveDetailSummary.builder().build().selectOne(new QueryWrapper<SpmkApproveDetailSummary>()
.select(SpmkApproveDetailSummary::getId, .lambda()
SpmkApproveDetailSummary::getRequestData, .select(SpmkApproveDetailSummary::getId,
SpmkApproveDetailSummary::getFroms, SpmkApproveDetailSummary::getRequestData,
SpmkApproveDetailSummary::getFlowChildren) SpmkApproveDetailSummary::getFroms,
.eq(SpmkApproveDetailSummary::getApproveSummaryId, asId)); SpmkApproveDetailSummary::getFlowChildren)
.eq(SpmkApproveDetailSummary::getApproveSummaryId, asId));
// 查询 SpmkApproveSummary 状态,
SpmkApproveSummary aSummary = spmkApproveSummaryMapper.selectOne(new QueryWrapper<SpmkApproveSummary>().lambda() // 查询 SpmkApproveSummary 状态,
.select(SpmkApproveSummary::getSts,SpmkApproveSummary::getAssoType,SpmkApproveSummary::getEmpNum,SpmkApproveSummary::getOrgCode) SpmkApproveSummary aSummary = spmkApproveSummaryMapper.selectOne(new QueryWrapper<SpmkApproveSummary>().lambda()
.eq(SpmkApproveSummary::getId, asId)); .select(SpmkApproveSummary::getSts, SpmkApproveSummary::getAssoType, SpmkApproveSummary::getEmpNum, SpmkApproveSummary::getOrgCode)
.eq(SpmkApproveSummary::getId, asId));
// if (aSummary.getSts() > ApproveSummarySts.IN.ordinal()) { // if (aSummary.getSts() > ApproveSummarySts.IN.ordinal()) {
// redisUtil.set(asId.toString(),0,500); // redisUtil.set(asId.toString(),0,500);
...@@ -132,146 +133,151 @@ public class AdminSpmkController { ...@@ -132,146 +133,151 @@ public class AdminSpmkController {
// redisUtil.set(asId.toString(),0,500); // redisUtil.set(asId.toString(),0,500);
// return ResultUtil.error("您已审批过!"); // return ResultUtil.error("您已审批过!");
// } // }
//判断是否是请假审批 //判断是否是请假审批
if(aSummary.getAssoType()==ApproveEnum.LEAVE.getType()){ if (aSummary.getAssoType() == ApproveEnum.LEAVE.getType()) {
if(approvingDto.getSts()==2) { if (approvingDto.getSts() == 2) {
JSONObject jSONObject = jsonObject.parseObject(ad.getRequestData(), JSONObject.class); JSONObject jSONObject = jsonObject.parseObject(ad.getRequestData(), JSONObject.class);
// 请假类型 - 前端传中文 // 请假类型 - 前端传中文
String LeaveType = ObjectUtil.isNull(jSONObject.get("__LeaveType", FromData.class)) ? null : jSONObject.get("__LeaveType", FromData.class).getValue(); String LeaveType = ObjectUtil.isNull(jSONObject.get("__LeaveType", FromData.class)) ? null : jSONObject.get("__LeaveType", FromData.class).getValue();
// 时长 // 时长
String longTime = ObjectUtil.isNull(jSONObject.get("__longTime", FromData.class)) ? null : jSONObject.get("__longTime", FromData.class).getValue(); String longTime = ObjectUtil.isNull(jSONObject.get("__longTime", FromData.class)) ? null : jSONObject.get("__longTime", FromData.class).getValue();
//判断这个人假期是否足够 //判断这个人假期是否足够
KqglAssoLeaveEmployeeBalance emba = KqglAssoLeaveEmployeeBalance.builder().build().selectOne(new QueryWrapper<KqglAssoLeaveEmployeeBalance>().lambda().eq(KqglAssoLeaveEmployeeBalance::getLeaveRulesId, Convert.toInt(LeaveType)) KqglAssoLeaveEmployeeBalance emba = KqglAssoLeaveEmployeeBalance.builder().build().selectOne(new QueryWrapper<KqglAssoLeaveEmployeeBalance>().lambda().eq(KqglAssoLeaveEmployeeBalance::getLeaveRulesId, Convert.toInt(LeaveType))
.eq(KqglAssoLeaveEmployeeBalance::getUserid, aSummary.getEmpNum()).eq(KqglAssoLeaveEmployeeBalance::getOrgCode, aSummary.getOrgCode())); .eq(KqglAssoLeaveEmployeeBalance::getUserid, aSummary.getEmpNum()).eq(KqglAssoLeaveEmployeeBalance::getOrgCode, aSummary.getOrgCode()));
if (emba != null) { if (emba != null) {
if (emba.getBalanceDays()!=-1&&emba.getBalanceDays() < Convert.toInt(longTime)) { if (emba.getBalanceDays() != -1 && emba.getBalanceDays() < Convert.toInt(longTime)) {
return ResultUtil.error("当前发起人假期余额不足"); return ResultUtil.error("当前发起人假期余额不足");
} }
} }
} }
} }
if ( spmkExecutorMapper.selectCount(new QueryWrapper<SpmkExecutor>().lambda() if (spmkExecutorMapper.selectCount(new QueryWrapper<SpmkExecutor>().lambda()
.eq(SpmkExecutor::getId, approvingDto.getExecutorId()) .eq(SpmkExecutor::getId, approvingDto.getExecutorId())
.eq(SpmkExecutor::getEmpNum, userBean.getEmpNum()) .eq(SpmkExecutor::getEmpNum, userBean.getEmpNum())
.eq(SpmkExecutor::getSts, ExecutorSts.IN_EXECUTION.ordinal())) == 0) { .eq(SpmkExecutor::getSts, ExecutorSts.IN_EXECUTION.ordinal())) == 0) {
Integer adminNum = new LambdaQueryChainWrapper<QyzxEmpEntAsso>(qyzxEmpEntAssoMapper) Integer adminNum = new LambdaQueryChainWrapper<QyzxEmpEntAsso>(qyzxEmpEntAssoMapper)
.eq(QyzxEmpEntAsso::getEmpNum, userBean.getEmpNum()) .eq(QyzxEmpEntAsso::getEmpNum, userBean.getEmpNum())
.eq(QyzxEmpEntAsso::getOrgCode, userBean.getOrgCode()) .eq(QyzxEmpEntAsso::getOrgCode, userBean.getOrgCode())
.in(QyzxEmpEntAsso::getUserType, SysRoleType.U_TYPE_ADMIN,SysRoleType.U_TYPE_C_ADMIN) .in(QyzxEmpEntAsso::getUserType, SysRoleType.U_TYPE_ADMIN, SysRoleType.U_TYPE_C_ADMIN)
.count(); .count();
if (adminNum <= 0) { if (adminNum <= 0) {
redisUtil.set(asId.toString(),0,500); redisUtil.set(asId.toString(), 0, 500);
return ResultUtil.error("非当前审批人 或 管理员,无法操作!"); return ResultUtil.error("非当前审批人 或 管理员,无法操作!");
} }
} }
//如果是再次审批 //如果是再次审批
SpmkApproveExecuteRecord spmkApproveExecuteRecord = SpmkApproveExecuteRecord.builder().id(approvingDto.getExecuteRecordId()).build().selectById(); SpmkApproveExecuteRecord spmkApproveExecuteRecord = SpmkApproveExecuteRecord.builder().id(approvingDto.getExecuteRecordId()).build().selectById();
if(spmkApproveExecuteRecord.getSts()>1){ if (spmkApproveExecuteRecord.getSts() > 1) {
spmkApproveExecuteRecordMapper.delExecuteRecord(approvingDto.getExecuteRecordId(), asId); spmkApproveExecuteRecordMapper.delExecuteRecord(approvingDto.getExecuteRecordId(), asId);
} }
List<FlowChildren> listFlowChildren = jsonObject.parseArray(ad.getFlowChildren(),FlowChildren.class); List<FlowChildren> listFlowChildren = jsonObject.parseArray(ad.getFlowChildren(), FlowChildren.class);
RouterUtils.updateRefuseToAgree( RouterUtils.updateRefuseToAgree(
listFlowChildren, listFlowChildren,
asId, asId,
approvingDto.getExecuteRecordId(), approvingDto.getExecuteRecordId(),
approvingDto.getExecutorId(), approvingDto.getExecutorId(),
approvingDto.getOpinion(), approvingDto.getOpinion(),
approvingDto.getSts(), approvingDto.getSts(),
aSummary.getSts(), aSummary.getSts(),
approvingDto.getUser(), approvingDto.getUser(),
approvingDto.getSignatureImg(), approvingDto.getSignatureImg(),
userBean.getEmpNum(), userBean.getEmpNum(),
approvingDto.getUserList(), approvingDto.getUserList(),
approvingDto.getTypeIndex(), approvingDto.getTypeIndex(),
approvingDto.getUserIndex() approvingDto.getUserIndex()
); );
listFlowChildren.forEach(l->{ listFlowChildren.forEach(l -> {
//如果大节点已经完成 //如果大节点已经完成
if(l.getClassName().equals("audit")){ if (l.getClassName().equals("audit")) {
if(l.getExecute().equals("2")){ if (l.getExecute().equals("2")) {
l.getRelation().get(0).getUsers().forEach(v->{ l.getRelation().get(0).getUsers().forEach(v -> {
if(!v.getExecute().equals("2")){ if (!v.getExecute().equals("2")) {
v.setExecute("2"); v.setExecute("2");
} }
}); });
}else if(l.getExecute().equals("1")){ } else if (l.getExecute().equals("1")) {
//大节点未执行完 //大节点未执行完
} }
} }
}); });
// 更新 flowChildren // 更新 flowChildren
SpmkApproveDetailSummary sadsUpdate = SpmkApproveDetailSummary.builder().id(ad.getId()).flowChildren(JSONArray.fromObject(listFlowChildren).toString()).build(); SpmkApproveDetailSummary sadsUpdate = SpmkApproveDetailSummary.builder().id(ad.getId()).flowChildren(JSONArray.fromObject(listFlowChildren).toString()).build();
/*// 审批详情 审批时添加 附件 /*// 审批详情 审批时添加 附件
if(RequestDataUtils.addFileList(ad,approvingDto.getFileList())){ if(RequestDataUtils.addFileList(ad,approvingDto.getFileList())){
sadsUpdate.setRequestData(ad.getRequestData()); sadsUpdate.setRequestData(ad.getRequestData());
}*/ }*/
sadsUpdate.updateById(); sadsUpdate.updateById();
//最后一条数据 //最后一条数据
FlowChildren fc = CollUtil.getLast(listFlowChildren); FlowChildren fc = CollUtil.getLast(listFlowChildren);
/** TODO:每次审批都校验一次json是否正确 /** TODO:每次审批都校验一次json是否正确
* 1.验证当前流程是否已完成,如果已完成验证是否有子节点出现未完成的状态 * 1.验证当前流程是否已完成,如果已完成验证是否有子节点出现未完成的状态
* 2.验证当前节点上面的节点是否已完成,未完成的都改为已完成 * 2.验证当前节点上面的节点是否已完成,未完成的都改为已完成
* 3.验证当前流程是否全部完成,如果已经完成,修改所有的节点为已完成 * 3.验证当前流程是否全部完成,如果已经完成,修改所有的节点为已完成
* 4.验证当前节点 * 4.验证当前节点
*/ */
if (fc.getExecute() == "2") { if (fc.getExecute() == "2") {
//未更新sts前
// 查询 SpmkApproveSummary 状态 int lastSts = aSummary.getSts();
aSummary = spmkApproveSummaryMapper.selectOne(new QueryWrapper<SpmkApproveSummary>().lambda() // 查询 SpmkApproveSummary 状态
.select(SpmkApproveSummary::getSts,SpmkApproveSummary::getAssoType) aSummary = spmkApproveSummaryMapper.selectOne(new QueryWrapper<SpmkApproveSummary>().lambda()
.eq(SpmkApproveSummary::getId, asId)); .select(SpmkApproveSummary::getSts, SpmkApproveSummary::getAssoType, SpmkApproveSummary::getEmpNum, SpmkApproveSummary::getOrgCode)
.eq(SpmkApproveSummary::getId, asId));
// if (aSummary.getSts() != ApproveSummarySts.REFUSE.ordinal()) { // if (aSummary.getSts() != ApproveSummarySts.REFUSE.ordinal()) {
SpmkApproveSummary.builder().id(asId).currentApprover(CommonEnum.NULL_STR.getDesc()).endTime(new Date()).sts(ApproveSummarySts.FINISH.ordinal()).build().updateById(); 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 jSONObject = jsonObject.parseObject(ad.getRequestData(), JSONObject.class);
jSONObject.set("approveId", FromData.builder().value(String.valueOf(asId)).build()); jSONObject.set("approveId", FromData.builder().value(String.valueOf(asId)).build());
jSONObject.set("orgCode", userBean.getOrgCode()); jSONObject.set("orgCode", userBean.getOrgCode());
//如果请假审批,并且上一次是同意这次重复同意不会扣除假期余额
//审批完成后 业务 if (aSummary.getAssoType() == ApproveEnum.LEAVE.getType() && Integer.parseInt(fc.getExecute()) == lastSts) {
SpmkAssoBusiness sab = spmkAssoBusinessFactory.createSpmkService(ApproveEnum.getEnums(aSummary.getAssoType()));
if (sab != null){ } else {
//审批完成后 业务
log.info("1----------{}",sab); SpmkAssoBusiness sab = spmkAssoBusinessFactory.createSpmkService(ApproveEnum.getEnums(aSummary.getAssoType()));
}
log.info("2----------{}", jSONObject); if (sab != null) {
sab.handleApprove(jSONObject);
} log.info("1----------{}", sab);
}
log.info("2----------{}", jSONObject);
sab.handleApprove(jSONObject);
}
}
// } // }
// }else { // }else {
// redisUtil.set(asId.toString(),0,500); // redisUtil.set(asId.toString(),0,500);
// return ResultUtil.error("该审批已结束!"); // return ResultUtil.error("该审批已结束!");
// } // }
redisUtil.set(asId.toString(),0,500); redisUtil.set(asId.toString(), 0, 500);
return ResultUtil.success(); return ResultUtil.success();
} }
/** /**
* 删除-考核模板 * 删除-考核模板
@DeleteMapping(value = "/del_appraisal_t/{id}") @DeleteMapping(value = "/del_appraisal_t/{id}")
@ApiOperation(value = "2.移除-审批人", httpMethod = "DELETE", notes = "移除-审批人") @ApiOperation(value = "2.移除-审批人", httpMethod = "DELETE", notes = "移除-审批人")
@ApiOperationSupport(order = 6) @ApiOperationSupport(order = 6)
@Role @Role public Result<Object> delAT(@CurrentUser UserBean userBean,@Validated @RequestBody AdminApprovingDto approvingDto) throws Exception {
public Result<Object> delAT(@CurrentUser UserBean userBean,@Validated @RequestBody AdminApprovingDto approvingDto) throws Exception {
jxglAppraisalTMapper.delete(new QueryWrapper<JxglAppraisalT>().lambda().eq(JxglAppraisalT::getId, id) jxglAppraisalTMapper.delete(new QueryWrapper<JxglAppraisalT>().lambda().eq(JxglAppraisalT::getId, id)
.eq(JxglAppraisalT::getOrgCode, userBean.getOrgCode())); .eq(JxglAppraisalT::getOrgCode, userBean.getOrgCode()));
return ResultUtil.success(); return ResultUtil.success();
}*/ }*/
} }
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