feat(hrm): 报销申请支持前端指定流程模板
- 新增 tplId 字段用于前端明确选择流程模板 - 实现三步模板选择逻辑:优先使用前端指定模板、支持手动审批模式、兜底使用最新启用模板 - 优化流程启动逻辑,避免手动审批时意外触发模板规则 - 添加构建查询包装器方法的代码格式化调整
This commit is contained in:
@@ -37,5 +37,7 @@ public class HrmReimburseReqBo extends BaseEntity {
|
|||||||
private String accessoryReceiptIds;
|
private String accessoryReceiptIds;
|
||||||
|
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
private Long tplId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,14 +62,30 @@ public class HrmReimburseReqServiceImpl implements IHrmReimburseReqService {
|
|||||||
|
|
||||||
HrmReimburseReqVo bean = BeanUtil.toBean(add, HrmReimburseReqVo.class);
|
HrmReimburseReqVo bean = BeanUtil.toBean(add, HrmReimburseReqVo.class);
|
||||||
if (ok && "pending".equalsIgnoreCase(add.getStatus())) {
|
if (ok && "pending".equalsIgnoreCase(add.getStatus())) {
|
||||||
// 选择启用的最高版本模板(允许无模板:走自选审批人一次性审批)
|
Long startUserId = LoginHelper.getUserId();
|
||||||
HrmFlowTemplate tpl = flowTemplateMapper.selectOne(Wrappers.<HrmFlowTemplate>lambdaQuery()
|
|
||||||
|
HrmFlowTemplate tpl = null;
|
||||||
|
// 1) 优先:前端明确选择了模板(tplId 不为空)
|
||||||
|
if (bo.getTplId() != null) {
|
||||||
|
tpl = flowTemplateMapper.selectOne(Wrappers.<HrmFlowTemplate>lambdaQuery()
|
||||||
|
.eq(HrmFlowTemplate::getTplId, bo.getTplId())
|
||||||
|
.eq(HrmFlowTemplate::getBizType, "reimburse")
|
||||||
|
.eq(HrmFlowTemplate::getEnabled, 1)
|
||||||
|
.last("limit 1"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2) 手动审批:前端选择了手动审批人时,不允许兜底去找模板,否则会意外走到模板里的规则(例如 dept_leader)
|
||||||
|
boolean manualMode = bo.getTplId() == null && bo.getManualAssigneeUserId() != null;
|
||||||
|
|
||||||
|
// 3) 兜底:只有在既没有 tplId、也没有手动审批人的情况下,才自动选择最新启用模板
|
||||||
|
if (!manualMode && tpl == null) {
|
||||||
|
tpl = flowTemplateMapper.selectOne(Wrappers.<HrmFlowTemplate>lambdaQuery()
|
||||||
.eq(HrmFlowTemplate::getBizType, "reimburse")
|
.eq(HrmFlowTemplate::getBizType, "reimburse")
|
||||||
.eq(HrmFlowTemplate::getEnabled, 1)
|
.eq(HrmFlowTemplate::getEnabled, 1)
|
||||||
.orderByDesc(HrmFlowTemplate::getVersion)
|
.orderByDesc(HrmFlowTemplate::getVersion)
|
||||||
.last("limit 1"));
|
.last("limit 1"));
|
||||||
|
}
|
||||||
|
|
||||||
Long startUserId = LoginHelper.getUserId();
|
|
||||||
HrmFlowStartBo start = new HrmFlowStartBo();
|
HrmFlowStartBo start = new HrmFlowStartBo();
|
||||||
if (tpl != null) {
|
if (tpl != null) {
|
||||||
start.setTplId(tpl.getTplId());
|
start.setTplId(tpl.getTplId());
|
||||||
@@ -97,6 +113,7 @@ public class HrmReimburseReqServiceImpl implements IHrmReimburseReqService {
|
|||||||
return baseMapper.deleteBatchIds(ids) > 0;
|
return baseMapper.deleteBatchIds(ids) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private LambdaQueryWrapper<HrmReimburseReq> buildQueryWrapper(HrmReimburseReqBo bo) {
|
private LambdaQueryWrapper<HrmReimburseReq> buildQueryWrapper(HrmReimburseReqBo bo) {
|
||||||
LambdaQueryWrapper<HrmReimburseReq> lqw = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<HrmReimburseReq> lqw = Wrappers.lambdaQuery();
|
||||||
lqw.eq(bo.getBizId() != null, HrmReimburseReq::getBizId, bo.getBizId());
|
lqw.eq(bo.getBizId() != null, HrmReimburseReq::getBizId, bo.getBizId());
|
||||||
|
|||||||
Reference in New Issue
Block a user