xiangpei
2025-01-09 72a7deb95e2e48dade03e54b90a7498f226af1fc
flowable/src/main/java/com/ycl/service/impl/FlowTaskServiceImpl.java
@@ -28,6 +28,7 @@
import com.ycl.flow.FindNextNodeUtil;
import com.ycl.flow.FlowableUtils;
import com.ycl.mapper.ProcessCodingMapper;
import com.ycl.service.FlowLogService;
import com.ycl.service.IFlowTaskService;
import com.ycl.service.ISysDeployFormService;
import com.ycl.service.ISysFormService;
@@ -93,6 +94,7 @@
    private final ISysFormService sysFormService;
    private final TaskCommonService taskCommonService;
    private final ProcessCodingMapper processCodingMapper;
    private final FlowLogService flowLogService;
    /**
     * 完成审核任务
@@ -136,17 +138,18 @@
        if (!org.springframework.util.CollectionUtils.isEmpty(variables)) {
            for (String key : variables.keySet()) {
                newV.put(task.getTaskDefinitionKey() + "&" + key, variables.get(key));
//                if (ProcessConstants.TASK_FORM_KEY.equals(key)) {
//                    newV.put(task.getTaskDefinitionKey() + "_" + ProcessConstants.TASK_FORM_KEY, variables.get(key));
//                } else if (ProcessConstants.WIDGET_LIST.equals(key)){
//                    newV.put(task.getTaskDefinitionKey() + "_" + ProcessConstants.WIDGET_LIST, variables.get(key));
//                }
            }
        }
        taskService.addComment(taskId, task.getProcessInstanceId(), FlowComment.SUBMIT.getType(), "完成提交");
        // 判断当前任务是不是转办过的
        Boolean delegation = flowLogService.taskDelegation(task.getProcessInstanceId(), task.getId());
        if (delegation) {
            taskService.resolveTask(taskId, newV);
        }
        // 先让当前用户认领这个任务
        taskService.claim(taskId, SecurityUtils.getUserId() + "");
        taskService.addComment(taskId, task.getProcessInstanceId(), FlowComment.SUBMIT.getType(), "完成提交");
        taskService.complete(taskId, newV);
        return AjaxResult.success("提交成功");
    }
@@ -1239,21 +1242,22 @@
     */
    private List<FormDetailVO> getBeforeNodeForm(Map<String, Object> parameters, String formKey, String taskName, String processDefId, String processDefKey, Boolean currentNeedData) {
        if (!parameters.keySet().stream().anyMatch(key -> key.contains(ProcessConstants.TASK_FORM_KEY))) {
            FormDetailVO formDetailVO = new FormDetailVO();
            formDetailVO.setBeforeNodeName(taskName);
            formDetailVO.setCurrent(Boolean.TRUE);
            // 如果是空的,使用formId去查
            if (StringUtils.isNotBlank(formKey)) {
                SysForm sysForm = sysFormService.selectSysFormById(Long.parseLong(formKey));
                if (Objects.isNull(sysForm)) {
                    throw new RuntimeException("该流程绑定的表单不存在或已被删除");
                }
                FormDetailVO formDetailVO = new FormDetailVO();
                Map<String, Object> data = new HashMap<>(1);
                data.put(ProcessConstants.TASK_FORM_KEY, JSONObject.parseObject(sysForm.getFormContent()));
                formDetailVO.setFormJsonObj(data);
                formDetailVO.setBeforeNodeName(taskName);
                formDetailVO.setCurrent(Boolean.TRUE);
                return Arrays.asList(formDetailVO);
            } else {
                return new ArrayList<>(1);
                return Arrays.asList(formDetailVO);
            }
        }
        // 这里只需要查自身以及上一个节点(如果并行的有多个)的表单数据