Commit 17c32534 by liyanlin

增加总经办审核

parent 7a7a55aa
......@@ -25,6 +25,9 @@ public class CostLogDomain {
public static final int HR_PASS = 8;
public static final int MANAGER_AUTO_PASS = 9;
public static final int MANAGER_MANUAL_PASS = 10;
@TableId(type = IdType.AUTO)
private Integer id; // 费用单日志
......
......@@ -63,6 +63,8 @@ public class CostController {
@Resource
private HrCheckState hrCheckState;
@Resource
private GeneralManagerCheckState generalManagerCheckState;
@Resource
CostListSearchService costListSearchService;
@Resource
CostDao costDao;
......@@ -280,6 +282,27 @@ public class CostController {
return CostResult.success();
}
@GetMapping("/check/managerCheck")
@ApiOperation("总经办审核通过")
public CostResult<Void> managerCheck(@RequestParam String costNo,
@RequestParam Integer userid) {
CostContext costContext = new CostContext(costNo, userid);
costContext.setCostState(generalManagerCheckState);
costContext.handle();
return CostResult.success();
}
@GetMapping("/check/managerRefuse")
@ApiOperation("总经办审核人驳回")
public CostResult<Void> managerRefuse(@RequestParam String costNo,
@RequestParam Integer userid,
@RequestParam String rejectReason) {
CostContext costContext = new CostContext(costNo, userid);
costContext.setCostState(generalManagerCheckState);
costContext.refuse(rejectReason);
return CostResult.success();
}
@GetMapping("/check/hrCheck")
@ApiOperation("行政审核通过")
public CostResult<Void> hrCheck(@RequestParam String costNo,
......
......@@ -48,13 +48,14 @@ public class CostDomain implements Serializable {
//借支/借还
public final static Integer COST_FROM_3 = 2;
// 0 待提交 1- 待财务审核 2待出纳付款 3被驳回 4已支付 5已作废 6-待部门审核 7-待财务审核 8-待最终审核人审核 9-人事审核
// 0 待提交 1- 待财务审核 2待出纳付款 3被驳回 4已支付 5已作废 6-待部门审核 7-待财务审核 8-待最终审核人审核 9-人事审核 10-总经办审核
public final static int STATUS_UN_SUBMIT = 0;
public final static int STATUS_DEPARTMENT_CHECK = 6;
public final static int STATUS_FINANCIAL_CHECK = 7;
public final static int STATUS_FINAL_CHECK = 8;
public final static int STATUS_HR_CHECK = 9;
public final static int STATUS_MANAGER_CHECK = 10;
public final static int STATUS_UN_PAY = 2;
public final static int STATUS_PAYED = 4;
......
......@@ -47,6 +47,8 @@ public class FinalCheckState extends CostState {
@Resource
UnPayState unPayState;
@Resource
GeneralManagerCheckState generalManagerCheckState;
@Resource
CostLogDao costLogDao;
@Resource
CostCurrentReviewerMapper costCurrentReviewerMapper;
......@@ -56,7 +58,7 @@ public class FinalCheckState extends CostState {
private void autoPass() {
CostDomain costDomain = costContext.costDomain;
costDomain.setCostStatus(CostDomain.STATUS_UN_PAY);
costDomain.setCostStatus(CostDomain.STATUS_MANAGER_CHECK);
costDomain.setLastModifyDate(LocalDateTime.now());
costDao.updateById(costDomain);
......@@ -64,9 +66,9 @@ public class FinalCheckState extends CostState {
costLogService.saveByManage(costDomain.getCostNo(), "最终审核自动通过,当前审核人:" + costCurrentReviewerList.stream().map(CostCurrentReviewer::getUsername)
.collect(Collectors.joining(",")), CostLogDomain.DEPARTMENT_AUTO_PASS);
//流转状态
nextState(unPayState);
nextState(generalManagerCheckState);
//通知财务系统
costContext.costService.toFinancial(costDomain);
//costContext.costService.toFinancial(costDomain);
}
@Resource
......@@ -143,7 +145,7 @@ public class FinalCheckState extends CostState {
.costNo(costDomain.getCostNo())
.isPassed(true)
.build();
costDomain.setCostStatus(CostDomain.STATUS_UN_PAY);
costDomain.setCostStatus(CostDomain.STATUS_MANAGER_CHECK);
costDomain.setLastModifyDate(LocalDateTime.now());
costDao.updateById(costDomain);
......@@ -154,7 +156,7 @@ public class FinalCheckState extends CostState {
sendWxMsg(costDomain, currentUserId);
//流转状态
nextState(unPayState);
nextState(generalManagerCheckState);
//通知财务系统
costContext.costService.toFinancial(costDomain);
}
......
package com.blt.other.module.cost.service.impl.costcheck;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.blt.other.common.exception.BizRuntimeException;
import com.blt.other.database.model.CostCompanyDomain;
import com.blt.other.database.model.CostLogDomain;
import com.blt.other.database.model.CostTypeDomain;
import com.blt.other.module.auth.model.OaUser;
import com.blt.other.module.cost.dao.CostCurrentReviewerMapper;
import com.blt.other.module.cost.dao.CostTypeDao;
import com.blt.other.module.cost.model.ApprovalHistoryDomain;
import com.blt.other.module.cost.model.CostCurrentReviewer;
import com.blt.other.module.cost.model.CostDomain;
import com.blt.other.module.cost.model.CostTemplate;
import com.blt.other.module.cost.service.ApprovalHistoryService;
import com.blt.other.module.sys.model.CostReviewer;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author: li.yanlin
* @Description: 增加总经办审核,目前限定铭哥审核,超过1w(含)的非工资/物流单,可能只是暂时性,所以先hard code,后续有需求再改
* @Date: Created in
* @Modified by:
*/
@Component
@Scope("prototype")
public class GeneralManagerCheckState extends CostState{
@Resource
UnPayState unPayState;
@Resource
CostCurrentReviewerMapper costCurrentReviewerMapper;
@Resource
ApprovalHistoryService approvalHistoryService;
@Resource
CostTypeDao costTypeDao;
@Override
public void handle() {
CostDomain costDomain = costContext.costDomain;
Integer currentUserId = costContext.currentUserId;
//CostTemplate costTemplate = costTemplateService.queryDetail(costDomain.getCostTemplateId());
//check status
if (!costDomain.getCostStatus().equals(CostDomain.STATUS_MANAGER_CHECK)) {
throw new BizRuntimeException("invalid status");
}
//小于1w的自动审核
if(this.autoPass(costDomain)){
//自动审核通过
if (this.autoCheck(costDomain)) {
costDomain.setCostStatus(CostDomain.STATUS_UN_PAY);
costDomain.setLastModifyDate(LocalDateTime.now());
costDao.updateById(costDomain);
List<CostCurrentReviewer> costCurrentReviewerList = costCurrentReviewerMapper.selectByCostNo(costDomain.getCostNo());
costLogService.saveByManage(costDomain.getCostNo(), "总经办自动审核通过,当前审核人:" + costCurrentReviewerList.stream().map(CostCurrentReviewer::getUsername)
.collect(Collectors.joining(",")), CostLogDomain.MANAGER_AUTO_PASS);
//流转状态
nextState(unPayState);
//发布到总线尝试下个环节的自动审核
costSubscribe.subscribe(costContext);
//通知财务系统
costContext.costService.toFinancial(costDomain);
return;
}
}
if(currentUserId != null) {
//目前限定铭哥能审核
if (currentUserId != 681) {
throw new BizRuntimeException("current user no authority");
}
//大于等于1w需要铭哥审批
if (costDomain.getAmountRmb().compareTo(new BigDecimal("10000")) >= 0) {
costDomain.setCostStatus(CostDomain.STATUS_UN_PAY);
costDomain.setLastModifyDate(LocalDateTime.now());
costDao.updateById(costDomain);
List<CostCurrentReviewer> costCurrentReviewerList = costCurrentReviewerMapper.selectByCostNo(costDomain.getCostNo());
costLogService.saveByManage(costDomain.getCostNo(), "总经办审核通过,当前审核人:" + costCurrentReviewerList.stream().map(CostCurrentReviewer::getUsername)
.collect(Collectors.joining(",")), CostLogDomain.MANAGER_MANUAL_PASS);
//流转状态
nextState(unPayState);
//发布到总线尝试下个环节的自动审核
costSubscribe.subscribe(costContext);
//通知财务系统
costContext.costService.toFinancial(costDomain);
return;
}
}
}
@Override
public void refuse(String rejectReason) {
CostDomain costDomain = costContext.costDomain;
Integer currentUserId = costContext.currentUserId;
CostCompanyDomain costCompany = costCompanyDao.selectByNo(costDomain.getCompanyNo());
//check status
if (!costDomain.getCostStatus().equals(CostDomain.STATUS_MANAGER_CHECK)) {
throw new BizRuntimeException("invalid status");
}
//人工审核通过
if (currentUserId != 681) {
throw new BizRuntimeException("current user no authority");
}
ApprovalHistoryDomain approvalHistoryDomain = ApprovalHistoryDomain.builder()
.approvalUserId(currentUserId)
.approvalTime(LocalDateTime.now())
.costStatus(costDomain.getCostStatus())
.costNo(costDomain.getCostNo())
.isPassed(false)
.build();
approvalHistoryService.save(approvalHistoryDomain);
costContext.costService.reject(costDomain.getCostNo());
costLogService.save(costDomain.getCostNo(), currentUserId, "总经办审核拒绝,理由:" + rejectReason, CostLogDomain.TYPE_UPDATE);
}
@Override
public void updateCurrentReviewer() {
CostDomain costDomain = costContext.costDomain;
//只查铭哥的ID
OaUser user = oaUserMapper.selectByOaUserId(681);
List<CostReviewer> costReviewerList = new ArrayList<>();
costReviewerList.add(CostReviewer.builder()
.reviewerUserId(user.getOaUserId())
.reviewerUserName(user.getUserName())
.build());
costCurrentReviewerService.updateByCostNoAndReviewer(costDomain.getCostNo(), costReviewerList);
// costLogService.save(costDomain.getCostNo(), costContext.currentUserId, "最终审核人:" + costReviewerList.stream().map(CostReviewer::getReviewerUserName).collect(Collectors.joining(",")));
}
private boolean autoPass(CostDomain costDomain){
if(costDomain.getAmountRmb().compareTo(new BigDecimal("10000")) < 0){
return true;
}
CostTypeDomain costTypeDomain = costTypeDao.selectByNo(costDomain.getTypeNo());
if(costTypeDomain.getTypeName().contains("工资") || costTypeDomain.getTypeName().contains("物流")){
return true;
}
return false;
}
}
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