1. 新增业务流程任务表单可配置自定义路由表单选项
fix:
1. 修复 mysql 脚本部分字段未同步脚本的错误
2. 角色为空无法登录系统
3. 主子表缩写命名下代码生成器错误
(cherry picked from commit 3812611b04)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.task;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.business.core.util.DeptUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
@@ -142,7 +143,18 @@ public class BpmTaskController {
|
||||
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), DeptUtil::getDeptId));
|
||||
// 获得 Form Map
|
||||
Map<Long, BpmFormDO> formMap = formService.getFormMap(
|
||||
convertSet(taskList, task -> NumberUtils.parseLong(task.getFormKey())));
|
||||
convertSet(taskList, task -> {
|
||||
String formKey = task.getFormKey();
|
||||
if (StrUtil.isBlank(formKey)) {
|
||||
return 0L;
|
||||
}
|
||||
try {
|
||||
return Long.parseLong(formKey);
|
||||
} catch (NumberFormatException e) {
|
||||
// 如果 formKey 不是数字(比如是URL),返回0L
|
||||
return 0L;
|
||||
}
|
||||
}));
|
||||
return success(BpmTaskConvert.INSTANCE.buildTaskListByProcessInstanceId(taskList,
|
||||
formMap, userMap, deptMap));
|
||||
}
|
||||
|
||||
@@ -27,4 +27,7 @@ public class BpmTaskApproveReqVO {
|
||||
@Schema(description = "下一个节点审批人", example = "{nodeId:[1, 2]}")
|
||||
private Map<String, List<Long>> nextAssignees; // 为什么是 Map,而不是 List 呢?因为下一个节点可能是多个,例如说并行网关的情况
|
||||
|
||||
// 新增任务变量实例,业务表单
|
||||
@Schema(description = "任务变量实例,业务表单", example = "{'formField1': 'value1', 'formField2': 'value2'}")
|
||||
private Map<String, String> taskVariables;
|
||||
}
|
||||
|
||||
@@ -68,6 +68,8 @@ public class BpmTaskRespVO {
|
||||
|
||||
@Schema(description = "表单编号", example = "1024")
|
||||
private Long formId;
|
||||
@Schema(description = "表单路由", example = "1024")
|
||||
private String formPath;
|
||||
@Schema(description = "表单名字", example = "请假表单")
|
||||
private String formName;
|
||||
@Schema(description = "表单的配置,JSON 字符串")
|
||||
|
||||
@@ -103,7 +103,15 @@ public interface BpmTaskConvert {
|
||||
}
|
||||
taskVO.setStatus(taskStatus).setReason(FlowableUtils.getTaskReason(task));
|
||||
// 表单信息
|
||||
BpmFormDO form = MapUtil.get(formMap, NumberUtils.parseLong(task.getFormKey()), BpmFormDO.class);
|
||||
BpmFormDO form = null;
|
||||
try {
|
||||
Long formId = NumberUtils.parseLong(task.getFormKey());
|
||||
form = MapUtil.get(formMap, formId, BpmFormDO.class);
|
||||
} catch (NumberFormatException e) {
|
||||
// 如果 formKey 不是数字(比如是URL),设置 formPath
|
||||
taskVO.setFormPath(task.getFormKey());
|
||||
taskVO.setFormVariables(FlowableUtils.getTaskFormVariable(task));
|
||||
}
|
||||
if (form != null) {
|
||||
taskVO.setFormId(form.getId()).setFormName(form.getName()).setFormConf(form.getConf())
|
||||
.setFormFields(form.getFields()).setFormVariables(FlowableUtils.getTaskFormVariable(task));
|
||||
@@ -146,6 +154,9 @@ public interface BpmTaskConvert {
|
||||
if (form != null) {
|
||||
bpmTaskRespVO.setFormId(form.getId()).setFormName(form.getName())
|
||||
.setFormConf(form.getConf()).setFormFields(form.getFields());
|
||||
}else{
|
||||
// 任务级别的业务表单
|
||||
bpmTaskRespVO.setFormPath(todoTask.getFormKey());
|
||||
}
|
||||
return bpmTaskRespVO;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.*;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
@@ -165,7 +166,13 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
// 4. 任务表单
|
||||
BpmFormDO taskForm = null;
|
||||
if (StrUtil.isNotBlank(todoTask.getFormKey())) {
|
||||
taskForm = formService.getForm(NumberUtils.parseLong(todoTask.getFormKey()));
|
||||
try {
|
||||
Long formId = Long.parseLong(todoTask.getFormKey());
|
||||
taskForm = formService.getForm(formId);
|
||||
} catch (NumberFormatException e) {
|
||||
// 如果 formKey 不是数字(比如是URL),则不处理表单
|
||||
taskForm = null;
|
||||
}
|
||||
}
|
||||
|
||||
return BpmTaskConvert.INSTANCE.buildTodoTask(todoTask, childrenTasks, buttonsSetting, taskForm)
|
||||
@@ -573,6 +580,13 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
processVariables.putAll(reqVO.getVariables());
|
||||
}
|
||||
|
||||
// 如果任务变量不为空,设置任务级别的变量实例信息
|
||||
if (CollUtil.isNotEmpty(reqVO.getTaskVariables())) {
|
||||
Map<String, String> taskVariables = new HashMap<>();
|
||||
taskVariables.put("taskVariables", JSONUtil.toJsonStr(reqVO.getTaskVariables()));
|
||||
taskService.setVariablesLocal(task.getId(), taskVariables);
|
||||
}
|
||||
|
||||
// 4. 校验并处理 APPROVE_USER_SELECT 当前审批人,选择下一节点审批人的逻辑
|
||||
Map<String, Object> variables = validateAndSetNextAssignees(task.getTaskDefinitionKey(), processVariables,
|
||||
bpmnModel, reqVO.getNextAssignees(), instance);
|
||||
|
||||
Reference in New Issue
Block a user