Commit 2db85eb6 by wilse

新增工厂流程

parent 4eb9f0a4
......@@ -59,7 +59,7 @@ public class CostDto {
@ApiModelProperty("关联父单")
private String supCostNo;
@ApiModelProperty("费用单状态 0 待提交 1- 待财务审核 2待出纳付款 3被驳回 4已支付 5已作废 6-待部门审核 7-待财务审核 8-待最终审核人审核")
@ApiModelProperty("费用单状态 0 待提交 1- 待财务审核 2待出纳付款 3被驳回 4已支付 5已作废 6-待部门审核 7-待财务审核 8-待最终审核人审核 9-人事审核 10-总经办审核 11-工厂流程审核")
private Integer costStatus;
@ApiModelProperty("文件地址")
......
......@@ -28,6 +28,9 @@ public class CostLogDomain {
public static final int MANAGER_AUTO_PASS = 9;
public static final int MANAGER_MANUAL_PASS = 10;
public static final int FACTORY_AUTO_PASS = 10;
public static final int FACTORY_MANUAL_PASS = 10;
@TableId(type = IdType.AUTO)
private Integer id; // 费用单日志
......
......@@ -67,6 +67,8 @@ public class CostController {
@Resource
private GeneralManagerCheckState generalManagerCheckState;
@Resource
private FactoryCheckState factoryCheckState;
@Resource
CostListSearchService costListSearchService;
@Resource
CostDao costDao;
......@@ -229,7 +231,9 @@ public class CostController {
Long count2 = costService.checkCostList(req).getTotal();
req.setType(3);
Long count3 = costService.checkCostList(req).getTotal();
return CostResult.success(count + count1 + count2 + count3);
req.setType(5);
Long count4 = costService.checkCostList(req).getTotal();
return CostResult.success(count + count1 + count2 + count3 + count4);
}
@ApiOperation("部门审核通过")
......@@ -317,6 +321,27 @@ public class CostController {
return CostResult.success();
}
@GetMapping("/check/factoryCheck")
@ApiOperation("工厂流程审核通过")
public CostResult<Void> factoryCheck(@RequestParam String costNo,
@RequestParam Integer userid) {
CostContext costContext = new CostContext(costNo, userid);
costContext.setCostState(factoryCheckState);
costContext.handle();
return CostResult.success();
}
@GetMapping("/check/factoryRefuse")
@ApiOperation("工厂流程审核人驳回")
public CostResult<Void> factoryRefuse(@RequestParam String costNo,
@RequestParam Integer userid,
@RequestParam String rejectReason) {
CostContext costContext = new CostContext(costNo, userid);
costContext.setCostState(factoryCheckState);
costContext.refuse(rejectReason);
return CostResult.success();
}
@GetMapping("/check/hrCheck")
@ApiOperation("行政审核通过")
public CostResult<Void> hrCheck(@RequestParam String costNo,
......
......@@ -63,6 +63,10 @@ public interface CostDao extends BaseMapper<CostDomain> {
IPage<CostDomain> generalManagerCheckCostList(@Param("page") IPage<CostDomain> page,
@Param("req") CheckCostListReq req);
//管理后台 需要我工厂流程审核费用列表查询
IPage<CostDomain> factoryCheckCostList(@Param("page") IPage<CostDomain> page,
@Param("req") CheckCostListReq req);
//管理后台 所有需要我审核的费用单列表
IPage<CostDomain> allCheckCostList(@Param("page") IPage<CostDomain> page,
@Param("req") AllCheckCostListReq req);
......
......@@ -23,7 +23,7 @@ public class CheckCostListReq {
Integer pageNum;
Integer pageSize;
@ApiModelProperty("1-财务+最终审核 2-部门审核 3-人事审核")
@ApiModelProperty("1-财务+最终审核 2-部门审核 3-人事审核 4-总经办 5-工厂流程")
Integer type;
@ApiModelProperty("1- 全部 2-待审核 3-已手动审核 4-已自动审核")
Integer status;
......
......@@ -48,7 +48,7 @@ public class CostDomain implements Serializable {
//借支/借还
public final static Integer COST_FROM_3 = 2;
// 0 待提交 1- 待财务审核 2待出纳付款 3被驳回 4已支付 5已作废 6-待部门审核 7-待财务审核 8-待最终审核人审核 9-人事审核 10-总经办审核
// 0 待提交 1- 待财务审核 2待出纳付款 3被驳回 4已支付 5已作废 6-待部门审核 7-待财务审核 8-待最终审核人审核 9-人事审核 10-总经办审核 11-工厂流程审核
public final static int STATUS_UN_SUBMIT = 0;
public final static int STATUS_DEPARTMENT_CHECK = 6;
......@@ -56,6 +56,7 @@ public class CostDomain implements Serializable {
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_FACTORY_CHECK = 11;
public final static int STATUS_UN_PAY = 2;
public final static int STATUS_PAYED = 4;
......
......@@ -99,6 +99,11 @@ public class AppCostServiceImpl implements AppCostService {
costContext = new CostContext(costNo, oaUserId);
costContext.setCostState(costState);
return costContext;
case CostDomain.STATUS_FACTORY_CHECK:
costState = SpringContextUtil.getBean(FactoryCheckState.class);
costContext = new CostContext(costNo, oaUserId);
costContext.setCostState(costState);
return costContext;
default:
throw new BizRuntimeException("invalid cost status");
}
......
......@@ -313,6 +313,10 @@ public abstract class AbstractCostService implements CostService {
if (req.getType().equals(4)) {
return costDao.generalManagerCheckCostList(page, req).convert(CostDomain::castToDto);
}
//需要工厂流程审核
if (req.getType().equals(5)) {
return costDao.factoryCheckCostList(page, req).convert(CostDomain::castToDto);
}
throw new BizRuntimeException("invalid param");
}
......
......@@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
......@@ -91,4 +92,13 @@ public abstract class CostState {
public void updateCurrentReviewer() {
}
/**
* 是否为工厂主体
* @param companyNo
* @return
*/
protected Boolean isFactory(String companyNo){
return Arrays.asList("COM1806191800036","COM1807101556392","COM1807091522544","COM1905141105045").contains(companyNo);
}
}
package com.blt.other.module.cost.service.impl.costcheck;
import com.blt.other.common.exception.BizRuntimeException;
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.CostLogDao;
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.service.ApprovalHistoryService;
import com.blt.other.module.sys.model.CostReviewer;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.WeekFields;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/**
* @Author: li.yanlin
* @Description: 增加工厂流程审核,目前限定赵鹏审核,1w(含)以上全部审核,3k(含)-1w(不含)每周随机最多3单,可能只是暂时性,所以先hard code,后续有需求再改
* @Date: Created in
* @Modified by:
*/
@Component
@Scope("prototype")
public class FactoryCheckState extends CostState {
//@Resource
//UnPayState unPayState;
@Resource
FinalCheckState finalCheckState;
@Resource
CostCurrentReviewerMapper costCurrentReviewerMapper;
@Resource
ApprovalHistoryService approvalHistoryService;
@Resource
CostTypeDao costTypeDao;
@Resource
CostLogDao costLogDao;
//审批次数 周 -> 次数
static Map<Integer, Integer> APPROVE_TIMES = new ConcurrentHashMap<>();
@Override
@Transactional(rollbackFor = Exception.class)
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_FACTORY_CHECK)) {
throw new BizRuntimeException("invalid status");
}
//自动审核流转
if (this.autoPass(costDomain)) {
costDomain.setCostStatus(CostDomain.STATUS_FINAL_CHECK);
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.FACTORY_AUTO_PASS);
//流转状态
nextState(finalCheckState);
//发布到总线尝试下个环节的自动审核
costSubscribe.subscribe(costContext);
//通知财务系统
//costContext.costService.toFinancial(costDomain);
return;
}
if (currentUserId != null) {
//目前限定赵鹏能审核
if (currentUserId == 720 || currentUserId == 3075) {
//大于等于3k需要赵鹏审批
if (costDomain.getAmountRmb().compareTo(new BigDecimal("3000")) >= 0) {
costDomain.setCostStatus(CostDomain.STATUS_FINAL_CHECK);
costDomain.setLastModifyDate(LocalDateTime.now());
costDao.updateById(costDomain);
List<CostCurrentReviewer> costCurrentReviewerList = costCurrentReviewerMapper.selectByCostNo(costDomain.getCostNo());
costLogService.save(costDomain.getCostNo(), currentUserId, "工厂审核通过,当前审核人:" + costCurrentReviewerList.stream().map(CostCurrentReviewer::getUsername)
.collect(Collectors.joining(",")), CostLogDomain.FACTORY_MANUAL_PASS);
//流转状态
nextState(finalCheckState);
//发布到总线尝试下个环节的自动审核
costSubscribe.subscribe(costContext);
return;
}
} else {
throw new BizRuntimeException("current user no authority");
}
}
}
@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_FACTORY_CHECK)) {
throw new BizRuntimeException("invalid status");
}
//人工审核拒绝
if (currentUserId == 720 || currentUserId == 3075) {
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);
} else {
throw new BizRuntimeException("current user no authority");
}
}
@Override
public void updateCurrentReviewer() {
CostDomain costDomain = costContext.costDomain;
//只查赵鹏的ID
OaUser user = oaUserMapper.selectByOaUserId(720);
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(costContext.currentUserId != null)
return false;
CostLogDomain costLogDomain = costLogDao.selectDepartmentCheckLog(costDomain.getCostNo());
List<CostCurrentReviewer> costCurrentReviewerList = costCurrentReviewerMapper.selectByCostNo(costDomain.getCostNo());
if (costLogDomain != null
&& costCurrentReviewerList
.stream()
.map(CostCurrentReviewer::getOaUserId)
.collect(Collectors.toList())
.contains(costLogDomain.getUpdateUserid())) {
//部门审核人和工厂审核人是同一个人,工厂审核人自动通过。
return true;
}
//小于3k不需要审核
if(costDomain.getAmountRmb().compareTo(BigDecimal.valueOf(3000)) < 0) {
return true;
}
//3k-1w需要随机审核,每周三单;
if (costDomain.getAmountRmb().compareTo(BigDecimal.valueOf(3000)) >= 0 && costDomain.getAmountRmb().compareTo(BigDecimal.valueOf(10000)) < 0) {
LocalDate nowDay = LocalDate.now();
WeekFields weekFields = WeekFields.ISO;
Integer weekCounter = nowDay.get(weekFields.weekOfWeekBasedYear());
Integer times = APPROVE_TIMES.get(weekCounter);
if (times == null) {
APPROVE_TIMES = new ConcurrentHashMap<>();
times = 0;
}
if (times < 3 && LocalDateTime.now().getSecond() % 3 == 0) {
APPROVE_TIMES.put(weekCounter, ++times);
} else if(times.equals(0) && APPROVE_TIMES.isEmpty() && nowDay.getDayOfWeek().equals(DayOfWeek.WEDNESDAY)){
//周四还没随机到先搞一单进去
APPROVE_TIMES.put(weekCounter, 1);
}
else
return false;
return true;
}
return false;
}
}
......@@ -105,8 +105,6 @@ public class FinalCheckState extends CostState {
CostDomain costDomain = costContext.costDomain;
Integer currentUserId = costContext.currentUserId;
CostTemplate costTemplate = costTemplateService.queryDetail(costDomain.getCostTemplateId());
//check status
if (!costDomain.getCostStatus().equals(CostDomain.STATUS_FINAL_CHECK)) {
throw new BizRuntimeException("invalid status");
......
......@@ -44,6 +44,8 @@ public class FinancialCheckState extends CostState {
@Resource
FinalCheckState finalCheckState;
@Resource
FactoryCheckState factoryCheckState;
@Resource
CostCompanyDao costCompanyDao;
@Resource
CostCurrentReviewerMapper costCurrentReviewerMapper;
......@@ -95,7 +97,7 @@ public class FinancialCheckState extends CostState {
if (costTemplate.shouldFinancialAutoCheck(costDomain)) {
//自动审核通过
if (this.autoCheck(costDomain)) {
costDomain.setCostStatus(CostDomain.STATUS_FINAL_CHECK);
costDomain.setCostStatus(super.isFactory(costDomain.getCompanyNo()) ? CostDomain.STATUS_FACTORY_CHECK : CostDomain.STATUS_FINAL_CHECK);
costDomain.setLastModifyDate(LocalDateTime.now());
costDao.updateById(costDomain);
......@@ -103,7 +105,7 @@ public class FinancialCheckState extends CostState {
costLogService.saveByManage(costDomain.getCostNo(), "财务自动审核通过,当前审核人:" + costCurrentReviewerList.stream().map(CostCurrentReviewer::getUsername)
.collect(Collectors.joining(",")), CostLogDomain.DEPARTMENT_AUTO_PASS);
//流转状态
nextState(finalCheckState);
nextState(super.isFactory(costDomain.getCompanyNo()) ? factoryCheckState : finalCheckState);
//发布到总线尝试下个环节的自动审核
costSubscribe.subscribe(costContext);
return;
......@@ -121,7 +123,7 @@ public class FinancialCheckState extends CostState {
.costNo(costDomain.getCostNo())
.isPassed(true)
.build();
costDomain.setCostStatus(CostDomain.STATUS_FINAL_CHECK);
costDomain.setCostStatus(super.isFactory(costDomain.getCompanyNo()) ? CostDomain.STATUS_FACTORY_CHECK : CostDomain.STATUS_FINAL_CHECK);
costDomain.setLastModifyDate(LocalDateTime.now());
costDao.updateById(costDomain);
......@@ -129,7 +131,7 @@ public class FinancialCheckState extends CostState {
sendWxMsg(costDomain, currentUserId);
approvalHistoryService.save(approvalHistoryDomain);
//流转状态
nextState(finalCheckState);
nextState(super.isFactory(costDomain.getCompanyNo()) ? factoryCheckState : finalCheckState);
//发布到总线尝试下个环节的自动审核
costSubscribe.subscribe(costContext);
}
......
......@@ -279,6 +279,16 @@
<include refid="checkCostListSearch"/>
</select>
<!--需要我总审核的-->
<select id="factoryCheckCostList" resultType="com.blt.other.module.cost.model.CostDomain">
select t1.*
from cost t1
left join cost_current_reviewer t3 on t1.cost_no = t3.cost_no and t3.oa_user_id = #{req.userid}
where t1.cost_status = 11
and t3.id is not null
<include refid="checkCostListSearch"/>
</select>
<select id="allCheckCostList" resultType="com.blt.other.module.cost.model.CostDomain">
select c.* from cost c
left join cost_current_reviewer ccr on ccr.cost_no = c.cost_no
......
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