mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 12:39:05 +08:00
🐛 协同办公我的已办回显有问题
This commit is contained in:
1 parent
444efe2dd6
commit
547de0f2d2
1 file changed
+100
-89
+100
-89
@@ -16,6 +16,7 @@ import org.flowable.task.api.DelegationState;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.flowable.task.api.TaskQuery;
|
||||
import org.flowable.task.api.history.HistoricTaskInstance;
|
||||
import org.flowable.variable.api.history.HistoricVariableInstance;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -32,115 +33,125 @@ import java.util.Optional;
|
||||
@RequestMapping("/task")
|
||||
public class EngineTaskController {
|
||||
|
||||
private final TaskService taskService;
|
||||
private final TaskService taskService;
|
||||
|
||||
private final HistoryService historyService;
|
||||
private final HistoryService historyService;
|
||||
|
||||
private final RuntimeService runtimeService;
|
||||
private final RuntimeService runtimeService;
|
||||
|
||||
/**
|
||||
* 查询任务变量
|
||||
* @param paramDto 参数DTO
|
||||
* @return 变量Map
|
||||
*/
|
||||
@PostMapping("queryTaskVariables")
|
||||
public R queryTaskVariables(@RequestBody VariableQueryParamDto paramDto) {
|
||||
/**
|
||||
* 查询任务变量
|
||||
*
|
||||
* @param paramDto 参数DTO
|
||||
* @return 变量Map
|
||||
*/
|
||||
@PostMapping("queryTaskVariables")
|
||||
public R queryTaskVariables(@RequestBody VariableQueryParamDto paramDto) {
|
||||
|
||||
List<String> keyList = paramDto.getKeyList();
|
||||
if (CollUtil.isEmpty(keyList)) {
|
||||
TaskQuery taskQuery = taskService.createTaskQuery();
|
||||
List<String> keyList = paramDto.getKeyList();
|
||||
if (CollUtil.isEmpty(keyList)) {
|
||||
TaskQuery taskQuery = taskService.createTaskQuery();
|
||||
|
||||
Task task = taskQuery.taskId(paramDto.getTaskId()).singleResult();
|
||||
if (task == null) {
|
||||
return R.failed("任务不存在");
|
||||
}
|
||||
Task task = taskQuery.taskId(paramDto.getTaskId()).singleResult();
|
||||
if (task == null) {
|
||||
return R.failed("任务不存在");
|
||||
}
|
||||
|
||||
Map<String, Object> variables = runtimeService.getVariables(task.getExecutionId());
|
||||
Map<String, Object> variables = runtimeService.getVariables(task.getExecutionId());
|
||||
|
||||
return R.ok(variables);
|
||||
}
|
||||
return R.ok(variables);
|
||||
}
|
||||
|
||||
Map<String, Object> variables = taskService.getVariables(paramDto.getTaskId(), keyList);
|
||||
return R.ok(variables);
|
||||
Map<String, Object> variables = taskService.getVariables(paramDto.getTaskId(), keyList);
|
||||
return R.ok(variables);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询任务详情
|
||||
* @param taskId 任务ID
|
||||
* @param userId 用户ID
|
||||
* @return 任务结果DTO
|
||||
*/
|
||||
@GetMapping("/engine/queryTask")
|
||||
public R queryTask(String taskId, String userId) {
|
||||
Optional<Task> task = Optional
|
||||
.ofNullable(taskService.createTaskQuery().taskId(taskId).taskAssignee(userId).singleResult());
|
||||
/**
|
||||
* 查询任务详情
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
* @param userId 用户ID
|
||||
* @return 任务结果DTO
|
||||
*/
|
||||
@GetMapping("/engine/queryTask")
|
||||
public R queryTask(String taskId, String userId) {
|
||||
Optional<Task> task = Optional
|
||||
.ofNullable(taskService.createTaskQuery().taskId(taskId).taskAssignee(userId).singleResult());
|
||||
|
||||
if (task.isPresent()) {
|
||||
String processDefinitionId = task.get().getProcessDefinitionId();
|
||||
String taskDefinitionKey = task.get().getTaskDefinitionKey();
|
||||
DelegationState delegationState = task.get().getDelegationState();
|
||||
String processInstanceId = task.get().getProcessInstanceId();
|
||||
Object delegateVariable = taskService.getVariableLocal(taskId, "delegate");
|
||||
if (task.isPresent()) {
|
||||
String processDefinitionId = task.get().getProcessDefinitionId();
|
||||
String taskDefinitionKey = task.get().getTaskDefinitionKey();
|
||||
DelegationState delegationState = task.get().getDelegationState();
|
||||
String processInstanceId = task.get().getProcessInstanceId();
|
||||
Object delegateVariable = taskService.getVariableLocal(taskId, "delegate");
|
||||
|
||||
String flowId = NodeUtil.getFlowId(processDefinitionId);
|
||||
Map<String, Object> variables = taskService.getVariables(taskId);
|
||||
Map<String, Object> variableAll = new HashMap<>(variables);
|
||||
String flowId = NodeUtil.getFlowId(processDefinitionId);
|
||||
Map<String, Object> variables = taskService.getVariables(taskId);
|
||||
Map<String, Object> variableAll = new HashMap<>(variables);
|
||||
|
||||
TaskResultDto taskResultDto = new TaskResultDto();
|
||||
taskResultDto.setFlowId(flowId);
|
||||
taskResultDto.setProcessInstanceId(processDefinitionId);
|
||||
taskResultDto.setNodeId(taskDefinitionKey);
|
||||
taskResultDto.setCurrentTask(true);
|
||||
taskResultDto.setDelegate(Convert.toBool(delegateVariable, false));
|
||||
taskResultDto.setVariableAll(variableAll);
|
||||
taskResultDto.setProcessInstanceId(processInstanceId);
|
||||
taskResultDto.setDelegationState(delegationState == null ? null : delegationState.toString());
|
||||
TaskResultDto taskResultDto = new TaskResultDto();
|
||||
taskResultDto.setFlowId(flowId);
|
||||
taskResultDto.setProcessInstanceId(processDefinitionId);
|
||||
taskResultDto.setNodeId(taskDefinitionKey);
|
||||
taskResultDto.setCurrentTask(true);
|
||||
taskResultDto.setDelegate(Convert.toBool(delegateVariable, false));
|
||||
taskResultDto.setVariableAll(variableAll);
|
||||
taskResultDto.setProcessInstanceId(processInstanceId);
|
||||
taskResultDto.setDelegationState(delegationState == null ? null : delegationState.toString());
|
||||
|
||||
return R.ok(taskResultDto);
|
||||
}
|
||||
else {
|
||||
Optional<HistoricTaskInstance> historicTaskInstance = Optional.ofNullable(historyService
|
||||
.createHistoricTaskInstanceQuery().taskId(taskId).taskAssignee(userId).singleResult());
|
||||
return R.ok(taskResultDto);
|
||||
} else {
|
||||
Optional<HistoricTaskInstance> historicTaskInstance = Optional
|
||||
.ofNullable(historyService.createHistoricTaskInstanceQuery()
|
||||
.taskId(taskId)
|
||||
.taskAssignee(userId)
|
||||
.singleResult());
|
||||
|
||||
if (historicTaskInstance.isPresent()) {
|
||||
String processDefinitionId = historicTaskInstance.get().getProcessDefinitionId();
|
||||
String taskDefinitionKey = historicTaskInstance.get().getTaskDefinitionKey();
|
||||
String processInstanceId = historicTaskInstance.get().getProcessInstanceId();
|
||||
if (historicTaskInstance.isPresent()) {
|
||||
String processDefinitionId = historicTaskInstance.get().getProcessDefinitionId();
|
||||
String taskDefinitionKey = historicTaskInstance.get().getTaskDefinitionKey();
|
||||
String processInstanceId = historicTaskInstance.get().getProcessInstanceId();
|
||||
|
||||
String flowId = NodeUtil.getFlowId(processDefinitionId);
|
||||
Map<String, Object> variableAll = new HashMap<>();
|
||||
String flowId = NodeUtil.getFlowId(processDefinitionId);
|
||||
|
||||
TaskResultDto taskResultDto = new TaskResultDto();
|
||||
taskResultDto.setFlowId(flowId);
|
||||
taskResultDto.setNodeId(taskDefinitionKey);
|
||||
taskResultDto.setCurrentTask(false);
|
||||
taskResultDto.setVariableAll(variableAll);
|
||||
taskResultDto.setProcessInstanceId(processInstanceId);
|
||||
List<HistoricVariableInstance> variableInstanceList = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstanceId).list();
|
||||
Map<String, Object> variableAll = new HashMap<>();
|
||||
|
||||
return R.ok(taskResultDto);
|
||||
}
|
||||
else {
|
||||
return R.failed("任务不存在");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(variableInstanceList)) {
|
||||
variableInstanceList.forEach(historicVariableInstance -> variableAll.put(historicVariableInstance.getVariableName(), historicVariableInstance.getValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成任务
|
||||
* @param taskParamDto 任务参数DTO
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PostMapping("/complete")
|
||||
public R complete(@RequestBody TaskParamDto taskParamDto) {
|
||||
Map<String, Object> taskLocalParamMap = taskParamDto.getTaskLocalParamMap();
|
||||
if (CollUtil.isNotEmpty(taskLocalParamMap)) {
|
||||
taskService.setVariablesLocal(taskParamDto.getTaskId(), taskLocalParamMap);
|
||||
}
|
||||
TaskResultDto taskResultDto = new TaskResultDto();
|
||||
taskResultDto.setFlowId(flowId);
|
||||
taskResultDto.setNodeId(taskDefinitionKey);
|
||||
taskResultDto.setCurrentTask(false);
|
||||
taskResultDto.setVariableAll(variableAll);
|
||||
taskResultDto.setProcessInstanceId(processInstanceId);
|
||||
|
||||
taskService.complete(taskParamDto.getTaskId(), taskParamDto.getParamMap());
|
||||
return R.ok(taskResultDto);
|
||||
} else {
|
||||
return R.failed("任务不存在");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
/**
|
||||
* 完成任务
|
||||
*
|
||||
* @param taskParamDto 任务参数DTO
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PostMapping("/complete")
|
||||
public R complete(@RequestBody TaskParamDto taskParamDto) {
|
||||
Map<String, Object> taskLocalParamMap = taskParamDto.getTaskLocalParamMap();
|
||||
if (CollUtil.isNotEmpty(taskLocalParamMap)) {
|
||||
taskService.setVariablesLocal(taskParamDto.getTaskId(), taskLocalParamMap);
|
||||
}
|
||||
|
||||
taskService.complete(taskParamDto.getTaskId(), taskParamDto.getParamMap());
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user