Commit 1586e07d by liyanlin

增加审批历史

parent d0665a59
package com.blt.other.module.cost.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.blt.other.module.cost.model.ApprovalHistoryDomain;
/**
* @Author: li.yanlin
* @Description:
* @Date: Created in
* @Modified by:
*/
public interface ApprovalHistoryMapper extends BaseMapper<ApprovalHistoryDomain> {
}
package com.blt.other.module.cost.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @Author: li.yanlin
* @Description:
* @Date: Created in
* @Modified by:
*/
@Data
@Builder
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "审批历史", description = "")
public class ApprovalHistoryDomain implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "费用单号")
private String costNo;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@ApiModelProperty(value = "审批时间")
private LocalDateTime approvalTime;
@ApiModelProperty(value = "审批前费用状态")
private Integer costStatus;
@ApiModelProperty(value = "是否通过")
private boolean isPassed;
@ApiModelProperty(value = "审批人")
private Integer approvalUserId;
}
package com.blt.other.module.cost.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.blt.other.module.cost.dao.ApprovalHistoryMapper;
import com.blt.other.module.cost.model.ApprovalHistoryDomain;
/**
* @Author: li.yanlin
* @Description:
* @Date: Created in
* @Modified by:
*/
public interface ApprovalHistoryService extends IService<ApprovalHistoryDomain> {
}
package com.blt.other.module.cost.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blt.other.module.cost.dao.ApprovalHistoryMapper;
import com.blt.other.module.cost.model.ApprovalHistoryDomain;
import com.blt.other.module.cost.service.ApprovalHistoryService;
import org.springframework.stereotype.Service;
/**
* @Author: li.yanlin
* @Description:
* @Date: Created in
* @Modified by:
*/
@Service
public class ApprovalHistoryServiceImpl extends ServiceImpl<ApprovalHistoryMapper, ApprovalHistoryDomain> implements ApprovalHistoryService {
}
......@@ -9,9 +9,11 @@ import com.blt.other.module.auth.model.OaDepartment;
import com.blt.other.module.auth.model.OaUser;
import com.blt.other.module.cost.dao.CostCurrentReviewerMapper;
import com.blt.other.module.cost.dao.SpecDepartmentCheckConfigMapper;
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.dao.DepartmentReviewerMapper;
import com.blt.other.module.sys.model.CostReviewer;
import com.blt.other.module.sys.model.DepartmentReviewer;
......@@ -51,6 +53,9 @@ public class DepartmentCheckState extends CostState {
@Resource
CostCurrentReviewerMapper costCurrentReviewerMapper;
@Resource
ApprovalHistoryService approvalHistoryService;
@Transactional(rollbackFor = Exception.class)
@Override
public void handle() {
......@@ -121,11 +126,19 @@ public class DepartmentCheckState extends CostState {
if (costContext.currentUserId != null) {
//人工审核通过
if (costCurrentReviewerService.canAudit(currentUserId, costDomain.getCostNo())) {
ApprovalHistoryDomain approvalHistoryDomain = ApprovalHistoryDomain.builder()
.approvalUserId(currentUserId)
.approvalTime(LocalDateTime.now())
.costStatus(costDomain.getCostStatus())
.costNo(costDomain.getCostNo())
.isPassed(true)
.build();
costDomain.setCostStatus(CostDomain.STATUS_HR_CHECK);
costDomain.setLastModifyDate(LocalDateTime.now());
costDao.updateById(costDomain);
costLogService.save(costDomain.getCostNo(), currentUserId, "部门审核通过", CostLogDomain.DEPARTMENT_MANUAL_PASS);
//审批历史
approvalHistoryService.save(approvalHistoryDomain);
nextState(hrCheckState);
//发布到总线尝试下个环节的自动审核
costSubscribe.subscribe(costContext);
......@@ -155,6 +168,14 @@ public class DepartmentCheckState extends CostState {
}
costLogService.save(costDomain.getCostNo(), currentUserId, "部门审核拒绝,理由:" + rejectReason, CostLogDomain.TYPE_UPDATE);
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());
}
......
......@@ -6,9 +6,11 @@ import com.blt.other.database.model.CostCompanyDomain;
import com.blt.other.database.model.CostLogDomain;
import com.blt.other.module.cost.dao.CostCurrentReviewerMapper;
import com.blt.other.module.cost.dao.CostLogDao;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Scope;
......@@ -41,6 +43,8 @@ public class FinalCheckState extends CostState {
CostLogDao costLogDao;
@Resource
CostCurrentReviewerMapper costCurrentReviewerMapper;
@Resource
ApprovalHistoryService approvalHistoryService;
private void autoPass() {
CostDomain costDomain = costContext.costDomain;
......@@ -100,6 +104,13 @@ public class FinalCheckState extends CostState {
if (costContext.currentUserId != null) {
//人工审核通过
if (costCurrentReviewerService.canAudit(currentUserId, costDomain.getCostNo())) {
ApprovalHistoryDomain approvalHistoryDomain = ApprovalHistoryDomain.builder()
.approvalUserId(currentUserId)
.approvalTime(LocalDateTime.now())
.costStatus(costDomain.getCostStatus())
.costNo(costDomain.getCostNo())
.isPassed(true)
.build();
costDomain.setCostStatus(CostDomain.STATUS_UN_PAY);
costDomain.setLastModifyDate(LocalDateTime.now());
costDao.updateById(costDomain);
......@@ -107,6 +118,7 @@ public class FinalCheckState extends CostState {
log.info("费用单:{}最终审核人工审核通过", costDomain.getCostNo());
costLogService.save(costDomain.getCostNo(), currentUserId, "最终审核通过", CostLogDomain.FINAL_MANUAL_PASS);
approvalHistoryService.save(approvalHistoryDomain);
//流转状态
nextState(unPayState);
//通知财务系统
......@@ -136,7 +148,14 @@ public class FinalCheckState extends CostState {
}
costContext.costService.reject(costDomain.getCostNo());
ApprovalHistoryDomain approvalHistoryDomain = ApprovalHistoryDomain.builder()
.approvalUserId(currentUserId)
.approvalTime(LocalDateTime.now())
.costStatus(costDomain.getCostStatus())
.costNo(costDomain.getCostNo())
.isPassed(false)
.build();
approvalHistoryService.save(approvalHistoryDomain);
log.info("费用单:{}最终审核拒绝,理由:{}", costDomain.getCostNo(), rejectReason);
costLogService.save(costDomain.getCostNo(), currentUserId, "最终审核拒绝,理由:" + rejectReason, CostLogDomain.TYPE_UPDATE);
......
......@@ -6,9 +6,11 @@ import com.blt.other.database.model.CostCompanyDomain;
import com.blt.other.database.model.CostLogDomain;
import com.blt.other.module.cost.dao.CostCompanyDao;
import com.blt.other.module.cost.dao.CostCurrentReviewerMapper;
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;
......@@ -38,6 +40,8 @@ public class FinancialCheckState extends CostState {
CostCompanyDao costCompanyDao;
@Resource
CostCurrentReviewerMapper costCurrentReviewerMapper;
@Resource
ApprovalHistoryService approvalHistoryService;
@Override
void nextState(CostState costState) {
......@@ -79,12 +83,20 @@ public class FinancialCheckState extends CostState {
if (costContext.currentUserId != null) {
//人工审核通过
if (costCurrentReviewerService.canAudit(currentUserId, costDomain.getCostNo())) {
ApprovalHistoryDomain approvalHistoryDomain = ApprovalHistoryDomain.builder()
.approvalUserId(currentUserId)
.approvalTime(LocalDateTime.now())
.costStatus(costDomain.getCostStatus())
.costNo(costDomain.getCostNo())
.isPassed(true)
.build();
costDomain.setCostStatus(CostDomain.STATUS_FINAL_CHECK);
costDomain.setLastModifyDate(LocalDateTime.now());
costDao.updateById(costDomain);
costLogService.save(costDomain.getCostNo(), currentUserId, "财务审核通过", CostLogDomain.FINANCIAL_MANUAL_PASS);
approvalHistoryService.save(approvalHistoryDomain);
//流转状态
nextState(finalCheckState);
//发布到总线尝试下个环节的自动审核
......@@ -113,7 +125,14 @@ public class FinancialCheckState extends CostState {
if (!costCurrentReviewerService.canAudit(currentUserId, costDomain.getCostNo())) {
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);
......
......@@ -8,8 +8,10 @@ import com.blt.other.module.auth.dao.OaDepartmentMapper;
import com.blt.other.module.auth.dao.OaUserMapper;
import com.blt.other.module.auth.model.OaUser;
import com.blt.other.module.cost.dao.CostCompanyDao;
import com.blt.other.module.cost.model.ApprovalHistoryDomain;
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.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
......@@ -39,6 +41,8 @@ public class HrCheckState extends CostState {
OaUserMapper oaUserMapper;
@Resource
CostCompanyDao costCompanyDao;
@Resource
ApprovalHistoryService approvalHistoryService;
@Override
public void handle() {
......@@ -69,11 +73,19 @@ public class HrCheckState extends CostState {
if (costContext.currentUserId != null) {
//人工审核通过
if (costCurrentReviewerService.canAudit(currentUserId, costDomain.getCostNo())) {
ApprovalHistoryDomain approvalHistoryDomain = ApprovalHistoryDomain.builder()
.approvalUserId(currentUserId)
.approvalTime(LocalDateTime.now())
.costStatus(costDomain.getCostStatus())
.costNo(costDomain.getCostNo())
.isPassed(true)
.build();
costDomain.setCostStatus(CostDomain.STATUS_FINANCIAL_CHECK);
costDomain.setLastModifyDate(LocalDateTime.now());
costDao.updateById(costDomain);
costLogService.save(costDomain.getCostNo(), currentUserId, "行政审核通过", CostLogDomain.HR_PASS);
approvalHistoryService.save(approvalHistoryDomain);
nextState(financialCheckState);
//发布到总线尝试下个环节的自动审核
costSubscribe.subscribe(costContext);
......@@ -108,7 +120,14 @@ public class HrCheckState extends CostState {
//sd
costContext.costService.reject(costDomain.getCostNo());
ApprovalHistoryDomain approvalHistoryDomain = ApprovalHistoryDomain.builder()
.approvalUserId(currentUserId)
.approvalTime(LocalDateTime.now())
.costStatus(costDomain.getCostStatus())
.costNo(costDomain.getCostNo())
.isPassed(false)
.build();
approvalHistoryService.save(approvalHistoryDomain);
}
@Override
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.blt.other.module.cost.dao.ApprovalHistoryMapper">
<!--<select id="select" resultType="com.blt.other.module.cost.model.ApprovalHistoryDomain">
SELECT
*
FROM
approval_history
</select>-->
</mapper>
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