Commit 597c3f71 by huluobin

hr check

parent c61c6e9c
......@@ -2,11 +2,12 @@ package com.blt.other.module.auth.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import java.io.Serializable;
/**
* <p>
*
......@@ -20,22 +21,23 @@ import lombok.*;
@NoArgsConstructor
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="CostReviewer对象", description="")
@ApiModel(value = "CostReviewer对象", description = "")
public class CostReviewer implements Serializable {
private static final long serialVersionUID = 1L;
public static final Integer departmentReviewer=1;
public static final Integer financialReviewer =2;
public static final Integer finalReviewer =3;
public static final Integer departmentReviewer = 1;
public static final Integer financialReviewer = 2;
public static final Integer finalReviewer = 3;
public static final Integer hrReviewer = 4;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "type=1:部门id ; type in (2,3):财务主体id;")
@ApiModelProperty(value = "type=1:部门id ; type in (2,3,4):财务主体id;")
private Integer referId;
@ApiModelProperty(value = "1-部门审核人 2-财务审核人 3-最终审核人")
@ApiModelProperty(value = "1-部门审核人 2-财务审核人 3-最终审核人 4-行政审核人")
private Integer type;
@ApiModelProperty(value = "审核人")
......
......@@ -173,6 +173,8 @@ public class CostController {
RefuseState refuseState;
@Autowired
UnPayState unPayState;
@Autowired
HrCheckState hrCheckState;
@ApiOperation("提交费用单")
@PostMapping("submitAudit")
......@@ -298,6 +300,27 @@ public class CostController {
return CostResult.success();
}
@GetMapping("/check/hrCheck")
@ApiOperation("行政审核通过")
public CostResult<Void> hrCheck(@RequestParam String costNo,
@RequestParam Integer userid) {
CostContext costContext = new CostContext(costNo, userid);
costContext.setCostState(hrCheckState);
costContext.handle();
return CostResult.success();
}
@GetMapping("/check/hrCheckRefuse")
@ApiOperation("最终审核人驳回")
public CostResult<Void> hrCheckRefuse(@RequestParam String costNo,
@RequestParam Integer userid,
@RequestParam String rejectReason) {
CostContext costContext = new CostContext(costNo, userid);
costContext.setCostState(hrCheckState);
costContext.refuse(rejectReason);
return CostResult.success();
}
@ApiOperation("删除费用单")
@PostMapping("/deleted")
public CostResult<Void> deleted(@RequestParam String costNo) {
......
......@@ -60,7 +60,7 @@ public class CostApiDto {
Integer userid;
Integer pageNum;
Integer pageSize;
@ApiModelProperty("1-财务+最终审核 2-部门审核")
@ApiModelProperty("1-财务+最终审核 2-部门审核 3-人事审核")
Integer type;
@ApiModelProperty("1- 全部 2-待审核 3-已手动审核 4-已自动审核")
Integer status;
......
......@@ -35,12 +35,13 @@ public class CostDomain implements Serializable {
//借支/借还
public final static Integer COST_FROM_3 = 2;
// 0 待提交 1- 待财务审核 2待出纳付款 3被驳回 4已支付 5已作废 6-待部门审核 7-待财务审核 8-待最终审核人审核
// 0 待提交 1- 待财务审核 2待出纳付款 3被驳回 4已支付 5已作废 6-待部门审核 7-待财务审核 8-待最终审核人审核 9-人事审核
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_UN_PAY = 2;
public final static int STATUS_PAYED = 4;
......@@ -84,7 +85,7 @@ public class CostDomain implements Serializable {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
// @ApiModelProperty("关联子单")
// @ApiModelProperty("关联子单")
// @Deprecated
// private String sonCostNo;
@ApiModelProperty("关联父单")
......@@ -118,7 +119,6 @@ public class CostDomain implements Serializable {
private String bankCompany;
@ApiModelProperty("1 付款费用 2 收款费用 3 借支/借还")
private Integer costForm;
@ApiModelProperty("1 借支 2 借还")
......
......@@ -113,4 +113,8 @@ public class CostTemplate implements Serializable {
amount.compareTo(departmentMinimumReviewAmount) <= 0 &&
!cost.getCompanyName().contains("工会"));
}
public boolean shouldHrCheck(CostDomain costDomain) {
return costDomain.getCompanyName().contains("工会");
}
}
......@@ -26,7 +26,7 @@ import javax.annotation.Resource;
public class DepartmentCheckState extends CostState {
@Autowired
FinancialCheckState financialCheckState;
HrCheckState hrCheckState;
@Resource
OaDepartmentMapper oaDepartmentMapper;
@Resource
......@@ -48,12 +48,12 @@ public class DepartmentCheckState extends CostState {
OaDepartment oaDepartment = oaDepartmentMapper.selectByDepartmentId(oaUser.getPrimaryDepartmentId());
if (!costTemplate.shouldDepartmentCheck(costDomain, oaDepartment.getDepartmentMinimumReviewAmount())) {
costDomain.setCostStatus(CostDomain.STATUS_FINANCIAL_CHECK);
costDomain.setCostStatus(CostDomain.STATUS_HR_CHECK);
costDao.updateById(costDomain);
//流转状态
nextState(financialCheckState);
nextState(hrCheckState);
costSubscribe.subscribe(costContext);
costLogService.saveByManage(costDomain.getCostNo(), "部门审核自动通过", CostLogDomain.DEPARTMENT_AUTO_PASS);
......@@ -65,12 +65,12 @@ public class DepartmentCheckState extends CostState {
if (costTemplate.shouldDepartmentAutoCheck(costDomain)) {
//自动审核通过
if (this.autoCheck(costDomain)) {
costDomain.setCostStatus(CostDomain.STATUS_FINANCIAL_CHECK);
costDomain.setCostStatus(CostDomain.STATUS_HR_CHECK);
costDao.updateById(costDomain);
costLogService.saveByManage(costDomain.getCostNo(), "部门自动审核通过", CostLogDomain.DEPARTMENT_AUTO_PASS);
//流转状态
nextState(financialCheckState);
nextState(hrCheckState);
costSubscribe.subscribe(costContext);
return;
}
......@@ -81,11 +81,11 @@ public class DepartmentCheckState extends CostState {
if (costContext.currentUserId != null) {
//人工审核通过
if (costReviewerMapper.queryOne(costUser.getPrimaryDepartmentId(), CostReviewer.departmentReviewer, currentUserId) != null) {
costDomain.setCostStatus(CostDomain.STATUS_FINANCIAL_CHECK);
costDomain.setCostStatus(CostDomain.STATUS_HR_CHECK);
costDao.updateById(costDomain);
costLogService.save(costDomain.getCostNo(), currentUserId, "部门审核通过", CostLogDomain.DEPARTMENT_AUTO_PASS);
costLogService.save(costDomain.getCostNo(), currentUserId, "部门审核通过", CostLogDomain.DEPARTMENT_MANUAL_PASS);
nextState(financialCheckState);
nextState(hrCheckState);
//发布到总线尝试下个环节的自动审核
costSubscribe.subscribe(costContext);
}
......
package com.blt.other.module.cost.service.impl.costcheck;
import com.blt.other.common.exception.BizRuntimeException;
import com.blt.other.module.auth.dao.OaDepartmentMapper;
import com.blt.other.module.auth.dao.OaUserMapper;
import com.blt.other.module.auth.model.CostReviewer;
import com.blt.other.module.auth.model.OaUser;
import com.blt.other.module.cost.dao.CostCompanyDao;
import com.blt.other.module.cost.model.CostDomain;
import com.blt.other.module.cost.model.CostTemplate;
import com.blt.other.module.database.model.CostCompanyDomain;
import com.blt.other.module.database.model.CostLogDomain;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/10/30 2:57 下午
*/
@Component
public class HrCheckState extends CostState {
@Autowired
FinancialCheckState financialCheckState;
@Resource
OaDepartmentMapper oaDepartmentMapper;
@Resource
OaUserMapper oaUserMapper;
@Resource
CostCompanyDao costCompanyDao;
@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_HR_CHECK)) {
throw new BizRuntimeException("invalid status");
}
//如果不需要审核 直接通过
if (!costTemplate.shouldHrCheck(costDomain) {
costDomain.setCostStatus(CostDomain.STATUS_FINANCIAL_CHECK);
costDao.updateById(costDomain);
//流转状态
nextState(financialCheckState);
costSubscribe.subscribe(costContext);
// costLogService.saveByManage(costDomain.getCostNo(), "行政审核自动通过", CostLogDomain.DEPARTMENT_AUTO_PASS);
return;
}
//人工审核
CostCompanyDomain costCompany = costCompanyDao.selectByNo(costDomain.getCompanyNo());
if (costContext.currentUserId != null) {
//人工审核通过
if (costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.hrReviewer, currentUserId) != null) {
costDomain.setCostStatus(CostDomain.STATUS_FINANCIAL_CHECK);
costDao.updateById(costDomain);
costLogService.save(costDomain.getCostNo(), currentUserId, "行政审核通过", CostLogDomain.HR_PASS);
nextState(financialCheckState);
//发布到总线尝试下个环节的自动审核
costSubscribe.subscribe(costContext);
}
//人工审核没权限
else {
throw new BizRuntimeException("current user no authority");
}
}
}
@Override
public void refuse(String rejectReason) {
CostDomain costDomain = costContext.costDomain;
Integer currentUserId = costContext.currentUserId;
OaUser costUser = oaUserMapper.selectByOaUserId(costDomain.getCreateUserid());
//check status
if (!costDomain.getCostStatus().equals(CostDomain.STATUS_HR_CHECK)) {
throw new BizRuntimeException("invalid status");
}
//人工审核没权限
CostCompanyDomain costCompany = costCompanyDao.selectByNo(costDomain.getCompanyNo());
if (costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.hrReviewer, currentUserId) == null) {
throw new BizRuntimeException("current user no authority");
}
costLogService.save(costDomain.getCostNo(), currentUserId, "行政审核拒绝,理由:" + rejectReason, CostLogDomain.TYPE_UPDATE);
//sd
costContext.costService.reject(costDomain.getCostNo());
}
}
......@@ -9,13 +9,18 @@ import java.util.Date;
public class CostLogDomain {
//更新
public static final int TYPE_UPDATE = 1;
public static final int DEPARTMENT_AUTO_PASS = 2;
public static final int DEPARTMENT_MANUAL_PASS = 3;
public static final int FINANCIAL_AUTO_PASS = 4;
public static final int FINANCIAL_MANUAL_PASS = 5;
public static final int FINAL_AUTO_PASS = 6;
public static final int FINAL_MANUAL_PASS = 7;
public static final int HR_PASS = 8;
private Integer id; // 费用单日志
private String costNo; // 费用单号
private String updateUsercode; // 更新人编号
......
......@@ -429,9 +429,25 @@
and (t1.cost_status = 7 or t1.cost_status = 8)
and (t4.reviewer_user_id = #{req.userid} or t5.reviewer_user_id = #{req.userid})
</if>
/*部门审核*/
/*行政审核*/
<if test="req.type == 3">
/* 全部 */
<if test=" req.status == 1 ">
and t1.company_name like concat('%','工会','%')
</if>
/*待行政审核*/
<if test=" req.status == 2 ">
and t1.cost_status = 9
</if>
/*行政已手动审核*/
<if test=" req.status == 3 ">
and t2.type = 8
</if>
</if>
/* 部门审核 */
<if test="req.type == 2">
/*全部 0 待提交 1- 待财务审核 2待出纳付款 3被驳回 4已支付 5已作废 6-待部门审核 7-待财务审核 8-待最终审核人审核*/
/*0 待提交 1- 待财务审核 2待出纳付款 3被驳回 4已支付 5已作废 6-待部门审核 7-待财务审核 8-待最终审核人审核*/
/*全部 */
<if test=" req.status == 1 ">
and t1.cost_status not in (0,5,3)
</if>
......@@ -439,11 +455,11 @@
<if test=" req.status == 2 ">
and t1.cost_status = 6
</if>
/*已手动审核*/
/*已手动审核 日志类型区分*/
<if test=" req.status == 3 ">
and t2.type = 5
</if>
/*已自动审核*/
/*已自动审核 日志类型区分*/
<if test=" req.status == 4 ">
and t2.type = 4
</if>
......
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