feat(hrm): 报销申请支持前端指定流程模板

- 新增 tplId 字段用于前端明确选择流程模板
- 实现三步模板选择逻辑:优先使用前端指定模板、支持手动审批模式、兜底使用最新启用模板
- 优化流程启动逻辑,避免手动审批时意外触发模板规则
- 添加构建查询包装器方法的代码格式化调整
This commit is contained in:
2026-02-27 14:23:43 +08:00
parent ae3eb2688c
commit cb8d73917c
2 changed files with 22 additions and 3 deletions

View File

@@ -37,5 +37,7 @@ public class HrmReimburseReqBo extends BaseEntity {
private String accessoryReceiptIds;
private String remark;
private Long tplId;
}

View File

@@ -62,14 +62,30 @@ public class HrmReimburseReqServiceImpl implements IHrmReimburseReqService {
HrmReimburseReqVo bean = BeanUtil.toBean(add, HrmReimburseReqVo.class);
if (ok && "pending".equalsIgnoreCase(add.getStatus())) {
// 选择启用的最高版本模板(允许无模板:走自选审批人一次性审批)
HrmFlowTemplate tpl = flowTemplateMapper.selectOne(Wrappers.<HrmFlowTemplate>lambdaQuery()
Long startUserId = LoginHelper.getUserId();
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::getEnabled, 1)
.orderByDesc(HrmFlowTemplate::getVersion)
.last("limit 1"));
}
Long startUserId = LoginHelper.getUserId();
HrmFlowStartBo start = new HrmFlowStartBo();
if (tpl != null) {
start.setTplId(tpl.getTplId());
@@ -97,6 +113,7 @@ public class HrmReimburseReqServiceImpl implements IHrmReimburseReqService {
return baseMapper.deleteBatchIds(ids) > 0;
}
private LambdaQueryWrapper<HrmReimburseReq> buildQueryWrapper(HrmReimburseReqBo bo) {
LambdaQueryWrapper<HrmReimburseReq> lqw = Wrappers.lambdaQuery();
lqw.eq(bo.getBizId() != null, HrmReimburseReq::getBizId, bo.getBizId());