From f87d8f01def236b7bf4b6b9d67de0699c9950fe6 Mon Sep 17 00:00:00 2001 From: bob Date: Tue, 14 Mar 2023 14:13:47 +0800 Subject: [PATCH 1/2] fix(flow) update VariablesSubmitDate --- .../controller/FlowTaskController.java | 2 +- .../vo/UpdateVariablesSubmitDateVo.java | 2 ++ .../flowable/service/IFlowTaskService.java | 2 +- .../service/impl/FlowTaskServiceImpl.java | 32 +++++++++++++------ 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowTaskController.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowTaskController.java index 4e19cff..c3441d8 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowTaskController.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/controller/FlowTaskController.java @@ -95,7 +95,7 @@ public class FlowTaskController { @ApiOperation(value = "修改任务完成时间", response = FlowTaskDto.class) @PostMapping(value = "/updateTaskFinishDate") public AjaxResult updateTaskFinishDate(@RequestBody UpdateVariablesSubmitDateVo vo) { - return flowTaskService.updateVariablesSubmitDate(vo); + return flowTaskService.updateTaskFinishDate(vo); } @ApiOperation(value = "审批任务") diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/vo/UpdateVariablesSubmitDateVo.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/vo/UpdateVariablesSubmitDateVo.java index d42bd89..a353b2d 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/vo/UpdateVariablesSubmitDateVo.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/vo/UpdateVariablesSubmitDateVo.java @@ -12,6 +12,8 @@ public class UpdateVariablesSubmitDateVo { @ApiModelProperty("任务id") private String taskId; + @ApiModelProperty("任务顺序编号") + private String taskIndex; @ApiModelProperty("提交时间") private String finishDate; diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowTaskService.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowTaskService.java index 5e69bbb..45a51cb 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowTaskService.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/IFlowTaskService.java @@ -167,7 +167,7 @@ public interface IFlowTaskService { AjaxResult processVariables(String taskId); AjaxResult updateVariablesSubmitDate(String processInstanceId,String submitDate); - AjaxResult updateVariablesSubmitDate(UpdateVariablesSubmitDateVo vo); + AjaxResult updateTaskFinishDate(UpdateVariablesSubmitDateVo vo); /** * 获取下一节点 diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java index 858d6e1..2ffd986 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/service/impl/FlowTaskServiceImpl.java @@ -2,8 +2,10 @@ package com.ruoyi.flowable.service.impl; import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; @@ -237,11 +239,9 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask } catch (FlowableException e) { throw new CustomException("无法取消或开始活动"); } - runtimeService.updateBusinessStatus(flowTaskVo.getInstanceId(), FlowStatus.REJECT.getValue()); } - /** * 退回任务 * @@ -998,23 +998,37 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask return AjaxResult.success(); } @Override - public AjaxResult updateVariablesSubmitDate(UpdateVariablesSubmitDateVo vo) { + public AjaxResult updateTaskFinishDate(UpdateVariablesSubmitDateVo vo) { if (StringUtils.isBlank(vo.getProcessInstanceId()) || StringUtils.isBlank(vo.getFinishDate())) { return AjaxResult.error("更新提交时间失败,参数无效"); } - Execution execution = runtimeService.createExecutionQuery().processInstanceId(vo.getProcessInstanceId()).variableExists("submitDate").singleResult(); - ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(vo.getProcessInstanceId()).includeProcessVariables().singleResult(); - if (Objects.isNull(execution)) { + HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().processInstanceId(vo.getProcessInstanceId()).taskId(vo.getTaskId()).singleResult(); + if (Objects.isNull(historicTaskInstance)) { + return AjaxResult.error("更新提交时间失败,此任务不存在"); + } + String executionId = historicTaskInstance.getExecutionId(); + if (Objects.isNull(executionId)) { return AjaxResult.error("更新提交时间失败,查询错误"); } + ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(vo.getProcessInstanceId()).includeProcessVariables().singleResult(); + Map variables = processInstance.getProcessVariables(); Map map = (Map)MapUtils.getMap(variables, USER_MODIFY_TASK_FINISH_TIME_VARIABLE_KEY,new HashMap<>()); - map.put(vo.getTaskId(), DateUtil.parse(vo.getFinishDate(), DatePattern.NORM_DATETIME_FORMATTER)); - runtimeService.setVariable(execution.getId(),USER_MODIFY_TASK_FINISH_TIME_VARIABLE_KEY,map); - + DateTime submitDate = DateUtil.parse(vo.getFinishDate(), DatePattern.NORM_DATETIME_FORMATTER); + map.put(vo.getTaskId(),submitDate); + runtimeService.setVariable(vo.getProcessInstanceId(), USER_MODIFY_TASK_FINISH_TIME_VARIABLE_KEY,map); + updateSubmitDate(vo.getProcessInstanceId(), historicTaskInstance.getName(), submitDate); return AjaxResult.success(); } + public void updateSubmitDate( String processInstanceId,String taskName, DateTime submitDate) { + if (ObjectUtil.notEqual("提交汇报",taskName)) { + return; + } + runtimeService.setVariable(processInstanceId,"submitDate",submitDate); + } + + /** * 获取下一节点 * From e830cc9c794b394ebdb2c5e611ef84d8ff952101 Mon Sep 17 00:00:00 2001 From: bob Date: Tue, 14 Mar 2023 14:19:12 +0800 Subject: [PATCH 2/2] fix(flow) update VariablesSubmitDate,delete invalid button --- .../views/flowable/task/allprocess/index.vue | 56 +++++++++---------- .../src/views/flowable/task/record/admin.vue | 7 ++- .../src/views/flowable/task/record/index.vue | 17 +----- .../src/views/flowable/task/todo/index.vue | 30 +++++----- 4 files changed, 46 insertions(+), 64 deletions(-) diff --git a/ruoyi-ui/src/views/flowable/task/allprocess/index.vue b/ruoyi-ui/src/views/flowable/task/allprocess/index.vue index 42d3ed2..3894630 100644 --- a/ruoyi-ui/src/views/flowable/task/allprocess/index.vue +++ b/ruoyi-ui/src/views/flowable/task/allprocess/index.vue @@ -24,17 +24,17 @@ - - - 新增流程 - + + + + + + + + + + + @@ -46,29 +46,23 @@ - - 导出 - - - + + + + + + + + + + + + - - - - - - + +