修改流程任务节点可以修改业务表单中数据
Some checks are pending
Java CI with Maven / build (11) (push) Waiting to run
Java CI with Maven / build (17) (push) Waiting to run
Java CI with Maven / build (8) (push) Waiting to run
yudao-ui-admin CI / build (14.x) (push) Waiting to run
yudao-ui-admin CI / build (16.x) (push) Waiting to run
Some checks are pending
Java CI with Maven / build (11) (push) Waiting to run
Java CI with Maven / build (17) (push) Waiting to run
Java CI with Maven / build (8) (push) Waiting to run
yudao-ui-admin CI / build (14.x) (push) Waiting to run
yudao-ui-admin CI / build (16.x) (push) Waiting to run
This commit is contained in:
parent
b582c9020f
commit
5675cec761
@ -182,6 +182,23 @@ public class BpmTaskController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/getTaskAssignee")
|
||||
public CommonResult<String> getTaskAssignee(@RequestParam("taskId") String taskId) {
|
||||
String assignee = taskService.getTaskAssignee( taskId );
|
||||
return success(assignee);
|
||||
}
|
||||
|
||||
@GetMapping("/getTaskConfigFromBpmn")
|
||||
public CommonResult<String> getTaskConfigFromBpmn(@RequestParam("taskId") String taskId,@RequestParam("itemStr") String itemStr) {
|
||||
String value = taskService.getTaskConfigFromBpmn( taskId,itemStr );
|
||||
return success(value);
|
||||
}
|
||||
|
||||
@GetMapping("/getTaskIdsForProcessInstance")
|
||||
public CommonResult<List<String>> getTaskIdsForProcessInstance(@RequestParam("processinstanceId") String processinstanceId) {
|
||||
List<String> taskids = taskService.getTaskIdsForProcessInstance( processinstanceId );
|
||||
return success(taskids);
|
||||
}
|
||||
@PutMapping("/delegate")
|
||||
@Operation(summary = "委派任务", description = "用于【流程详情】的【委派】按钮")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:task:update')")
|
||||
|
@ -94,7 +94,7 @@ public class BpmTaskCandidateInvoker {
|
||||
Set<Long> userIds = null;
|
||||
Integer strategy = BpmnModelUtils.parseCandidateStrategy(execution.getCurrentFlowElement());
|
||||
String range = BpmnModelUtils.parseCandidateRange(execution.getCurrentFlowElement());
|
||||
String itemType = BpmnModelUtils.parseItemType(execution.getCurrentFlowElement());
|
||||
// String itemType = BpmnModelUtils.parseItemType(execution.getCurrentFlowElement());
|
||||
String param = BpmnModelUtils.parseCandidateParam(execution.getCurrentFlowElement());
|
||||
// 1.1 计算任务的候选人 审批人范围为:本部门或本公司
|
||||
if ((range != null) && (range.equals("1") || range.equals("2")) ){
|
||||
|
@ -182,5 +182,25 @@ public interface BpmTaskService {
|
||||
* @return 任务 ID 与名字的 Map
|
||||
*/
|
||||
Map<String, String> getTaskNameByTaskIds(Collection<String> taskIds);
|
||||
|
||||
/**
|
||||
* 获取当前任务的 Assignee(处理人)
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
* @return 当前任务的 Assignee(处理人)
|
||||
*/
|
||||
public String getTaskAssignee(String taskId);
|
||||
/**
|
||||
* 根据流程实例 ID 来查询流程实例中的所有待处理任务
|
||||
*
|
||||
* @param processInstanceId 流程实例ID
|
||||
* @return 待处理任务ids
|
||||
*/
|
||||
public List<String> getTaskIdsForProcessInstance(String processInstanceId);
|
||||
/**
|
||||
* 根据流程实例 ID 来查询流程实例中的所有待处理任务
|
||||
*
|
||||
* @param taskId 任务ID itemStr任务中设置参数
|
||||
* @return 返回任务参数值
|
||||
*/
|
||||
public String getTaskConfigFromBpmn(String taskId,String itemStr);
|
||||
}
|
||||
|
@ -27,10 +27,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.bpmn.model.FlowElement;
|
||||
import org.flowable.bpmn.model.UserTask;
|
||||
import org.flowable.engine.HistoryService;
|
||||
import org.flowable.engine.ManagementService;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.flowable.engine.*;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.flowable.task.api.DelegationState;
|
||||
import org.flowable.task.api.Task;
|
||||
@ -48,6 +45,7 @@ import org.springframework.util.Assert;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -85,6 +83,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Resource
|
||||
private RepositoryService repositoryService;
|
||||
|
||||
@Override
|
||||
public PageResult<Task> getTaskTodoPage(Long userId, BpmTaskPageReqVO pageVO) {
|
||||
TaskQuery taskQuery = taskService.createTaskQuery()
|
||||
@ -819,4 +820,99 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
return convertMap(tasks, Task::getId, Task::getName);
|
||||
}
|
||||
|
||||
|
||||
// 获取当前任务的 Assignee(处理人)
|
||||
public String getTaskAssignee(String taskId) {
|
||||
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
if (task != null) {
|
||||
return task.getAssignee(); // 返回处理人的ID
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//根据流程实例 ID 来查询流程实例中的所有待处理任务
|
||||
public List<String> getTaskIdsForProcessInstance(String processInstanceId) {
|
||||
List<Task> tasks = taskService.createTaskQuery()
|
||||
.processInstanceId(processInstanceId) // 根据流程实例查询
|
||||
.list(); // 获取所有待处理任务
|
||||
List<String> taskIds = new ArrayList<>();
|
||||
for (Task task : tasks) {
|
||||
taskIds.add(task.getId()); // 获取任务ID并添加到列表
|
||||
}
|
||||
return taskIds;
|
||||
}
|
||||
//根据流程流程任务节点id,和参数值,获取流程中设置的值
|
||||
public String getTaskConfigFromBpmn(String taskId,String itemStr) {
|
||||
// 获取任务对象
|
||||
AtomicReference<String> valueStrRef = new AtomicReference<>("");
|
||||
Task task = taskService.createTaskQuery()
|
||||
.taskId(taskId)
|
||||
.singleResult();
|
||||
|
||||
if (task != null) {
|
||||
String processDefinitionId = task.getProcessDefinitionId();
|
||||
String taskDefinitionKey = task.getTaskDefinitionKey();
|
||||
|
||||
// 获取流程定义的 BPMN 模型
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
|
||||
|
||||
// 根据任务定义 Key 获取任务节点
|
||||
FlowElement flowElement = bpmnModel.getFlowElement(taskDefinitionKey);
|
||||
|
||||
if (flowElement instanceof UserTask) {
|
||||
UserTask userTask = (UserTask) flowElement;
|
||||
//System.out.println();
|
||||
|
||||
userTask.getAttributes().forEach((key, valueList) -> {
|
||||
//System.out.println("Extension Key: " + key);
|
||||
valueList.forEach(attribute -> {
|
||||
if (attribute.getName().equals( itemStr )) { // 检查属性名称是否为 itemType
|
||||
//System.out.println("itemType 的值: " + attribute.getValue()); // 获取并打印属性值
|
||||
valueStrRef.set(attribute.getValue());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
String valueStr = valueStrRef.get();
|
||||
//System.out.println("valueStr:"+valueStr);
|
||||
return valueStr;
|
||||
}
|
||||
|
||||
public void getTaskCompleteConfig2(String taskId) {
|
||||
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
|
||||
if (task != null) {
|
||||
// 基本信息
|
||||
System.out.println("Task ID: " + task.getId());
|
||||
System.out.println("Task Name: " + task.getName());
|
||||
System.out.println("Task Definition Key: " + task.getTaskDefinitionKey());
|
||||
System.out.println("Assignee: " + task.getAssignee());
|
||||
|
||||
// 获取流程定义信息
|
||||
String processDefinitionId = task.getProcessDefinitionId();
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
|
||||
FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey());
|
||||
|
||||
if (flowElement instanceof UserTask) {
|
||||
UserTask userTask = (UserTask) flowElement;
|
||||
|
||||
// 扩展属性
|
||||
userTask.getExtensionElements().forEach((key, value) -> {
|
||||
System.out.println("Extension Key: " + key);
|
||||
value.forEach(extensionElement -> {
|
||||
System.out.println("Extension Value: " + extensionElement.getElementText());
|
||||
});
|
||||
});
|
||||
|
||||
// 表单信息
|
||||
// String formKey = formService.getTaskFormKey(taskId);
|
||||
// System.out.println("Form Key: " + formKey);
|
||||
}
|
||||
} else {
|
||||
System.out.println("Task not found for ID: " + taskId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.home.service.qjgl.listener;
|
||||
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.flowable.engine.delegate.ExecutionListener;
|
||||
|
||||
public class ProcessEndListener implements ExecutionListener {
|
||||
@Override
|
||||
public void notify(DelegateExecution execution) {
|
||||
System.out.println("task name:"+execution.getEventName() );
|
||||
// if (execution.getEventName().equals("end")) {
|
||||
// // 流程结束时触发
|
||||
// System.out.println("Process instance " + execution.getProcessInstanceId() + " has ended.");
|
||||
// }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user