feat(travel): 添加差旅申请模板选择功能
- 在 HrmTravelReqBo 中新增 tplId 字段用于指定流程模板 - 实现前端选择模板的优先级逻辑:优先使用指定模板,其次自动选择最新启用模板 - 添加手动审批模式判断,避免手动审批人情况下意外触发模板规则 - 重构流程模板选择逻辑,支持明确的模板ID查询和版本排序
This commit is contained in:
@@ -42,4 +42,6 @@ public class HrmTravelReqBo extends BaseEntity {
|
||||
private String bankName;
|
||||
private String bankAccount;
|
||||
private String remark;
|
||||
|
||||
private String tplId;
|
||||
}
|
||||
|
||||
@@ -63,14 +63,28 @@ public class HrmTravelReqServiceImpl implements IHrmTravelReqService {
|
||||
HrmTravelReqVo bean = BeanUtil.toBean(add, HrmTravelReqVo.class);
|
||||
// 业务表状态规范:pending/approved/rejected
|
||||
// 当提交为 pending 时,自动启动流程实例(hrm_flow_instance/hrm_flow_task)
|
||||
// 1) 优先:前端明确选择了模板(tplId 不为空)
|
||||
HrmFlowTemplate tpl = null;
|
||||
if (ok && "pending".equalsIgnoreCase(add.getStatus())) {
|
||||
// 选择启用的最高版本模板(允许无模板:走自选审批人一次性审批)
|
||||
HrmFlowTemplate tpl = flowTemplateMapper.selectOne(Wrappers.<HrmFlowTemplate>lambdaQuery()
|
||||
.eq(HrmFlowTemplate::getBizType, "travel")
|
||||
.eq(HrmFlowTemplate::getEnabled, 1)
|
||||
.orderByDesc(HrmFlowTemplate::getVersion)
|
||||
.last("limit 1"));
|
||||
if(bo.getTplId() != null){
|
||||
// 选择启用的最高版本模板(允许无模板:走自选审批人一次性审批)
|
||||
tpl = flowTemplateMapper.selectOne(Wrappers.<HrmFlowTemplate>lambdaQuery()
|
||||
.eq(HrmFlowTemplate::getTplId, bo.getTplId())
|
||||
.eq(HrmFlowTemplate::getBizType, "travel")
|
||||
.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, "travel")
|
||||
.eq(HrmFlowTemplate::getEnabled, 1)
|
||||
.orderByDesc(HrmFlowTemplate::getVersion)
|
||||
.last("limit 1"));
|
||||
}
|
||||
Long startUserId = LoginHelper.getUserId();
|
||||
|
||||
HrmFlowStartBo start = new HrmFlowStartBo();
|
||||
|
||||
Reference in New Issue
Block a user