From fcca534f2bc2fcc0834d03ae5a6c827500cb959e Mon Sep 17 00:00:00 2001 From: bob Date: Tue, 14 Feb 2023 14:03:41 +0800 Subject: [PATCH] fix(changeTaskTime) --- .../common/constant/ProcessConstants.java | 4 + .../flowable/common/enums/FlowStatus.java | 11 +- .../controller/FlowTaskController.java | 7 +- .../flowable/domain/dto/FlowTaskDto.java | 2 + .../vo/UpdateVariablesSubmitDateVo.java | 4 +- .../flowable/service/IFlowTaskService.java | 2 + .../service/impl/FlowTaskServiceImpl.java | 43 +- ruoyi-ui/src/api/flowable/definition.js | 7 + ruoyi-ui/src/router/index.js | 12 + .../views/flowable/task/allprocess/index.vue | 27 +- .../src/views/flowable/task/process/index.vue | 11 +- .../src/views/flowable/task/record/admin.vue | 813 ++++++++++++++++++ 12 files changed, 904 insertions(+), 39 deletions(-) create mode 100644 ruoyi-ui/src/views/flowable/task/record/admin.vue diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/common/constant/ProcessConstants.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/common/constant/ProcessConstants.java index dc55dfa..ca064a0 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/common/constant/ProcessConstants.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/common/constant/ProcessConstants.java @@ -75,6 +75,10 @@ public class ProcessConstants { * 流程跳过 */ public static final String FLOWABLE_SKIP_EXPRESSION_ENABLED = "_FLOWABLE_SKIP_EXPRESSION_ENABLED"; + /** + * 用户修改的任务完成时间字段key + */ + public static final String USER_MODIFY_TASK_FINISH_TIME_VARIABLE_KEY = "userModifyTaskFinishTime"; } diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/common/enums/FlowStatus.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/common/enums/FlowStatus.java index 43179f3..f29e1df 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/common/enums/FlowStatus.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/common/enums/FlowStatus.java @@ -11,11 +11,12 @@ public enum FlowStatus { /** * 说明 */ - REBACK("reback", "退回意见"), - REJECT("reject", "驳回意见"), - DELEGATE("delegate", "委派意见"), - ASSIGN("assign", "转办意见"), - STOP("stop", "终止流程"); + APPROVING("approving", "审批中"), + REBACK("reback", "退回"), + REJECT("reject", "驳回"), + DELEGATE("delegate", "委派"), + ASSIGN("assign", "转办"), + STOP("stop", "终止"); /** * 类型 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 5c275ef..4e19cff 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 @@ -90,7 +90,12 @@ public class FlowTaskController { @ApiOperation(value = "更新流程变量提交时间", response = FlowTaskDto.class) @PostMapping(value = "/updateVariablesSubmitDate") public AjaxResult updateVariablesSubmitDate(@RequestBody UpdateVariablesSubmitDateVo vo) { - return flowTaskService.updateVariablesSubmitDate(vo.getProcessInstanceId(), vo.getSubmitDate()); + return flowTaskService.updateVariablesSubmitDate(vo.getProcessInstanceId(), vo.getFinishDate()); + } + @ApiOperation(value = "修改任务完成时间", response = FlowTaskDto.class) + @PostMapping(value = "/updateTaskFinishDate") + public AjaxResult updateTaskFinishDate(@RequestBody UpdateVariablesSubmitDateVo vo) { + return flowTaskService.updateVariablesSubmitDate(vo); } @ApiOperation(value = "审批任务") diff --git a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/dto/FlowTaskDto.java b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/dto/FlowTaskDto.java index 4985379..ed491a4 100644 --- a/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/dto/FlowTaskDto.java +++ b/ruoyi-flowable/src/main/java/com/ruoyi/flowable/domain/dto/FlowTaskDto.java @@ -99,5 +99,7 @@ public class FlowTaskDto implements Serializable { @ApiModelProperty("任务完成时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date finishTime; + @ApiModelProperty("任务状态") + private String status; } 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 2434916..d42bd89 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 @@ -10,7 +10,9 @@ public class UpdateVariablesSubmitDateVo { @ApiModelProperty("流程实例id") private String processInstanceId; + @ApiModelProperty("任务id") + private String taskId; @ApiModelProperty("提交时间") - private String submitDate; + 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 a3de2a9..5e69bbb 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 @@ -2,6 +2,7 @@ package com.ruoyi.flowable.service; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.flowable.domain.vo.FlowTaskVo; +import com.ruoyi.flowable.domain.vo.UpdateVariablesSubmitDateVo; import org.flowable.task.api.Task; import java.io.InputStream; @@ -166,6 +167,7 @@ public interface IFlowTaskService { AjaxResult processVariables(String taskId); AjaxResult updateVariablesSubmitDate(String processInstanceId,String submitDate); + AjaxResult updateVariablesSubmitDate(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 546daae..69ae164 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 @@ -1,7 +1,9 @@ package com.ruoyi.flowable.service.impl; +import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.map.MapUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; import com.ruoyi.common.core.domain.AjaxResult; @@ -17,6 +19,7 @@ import com.ruoyi.flowable.domain.dto.FlowNextDto; import com.ruoyi.flowable.domain.dto.FlowTaskDto; import com.ruoyi.flowable.domain.dto.FlowViewerDto; import com.ruoyi.flowable.domain.vo.FlowTaskVo; +import com.ruoyi.flowable.domain.vo.UpdateVariablesSubmitDateVo; import com.ruoyi.flowable.factory.FlowServiceFactory; import com.ruoyi.flowable.flow.CustomProcessDiagramGenerator; import com.ruoyi.flowable.flow.FindNextNodeUtil; @@ -60,6 +63,8 @@ import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; +import static com.ruoyi.flowable.common.constant.ProcessConstants.USER_MODIFY_TASK_FINISH_TIME_VARIABLE_KEY; + /** * @author XuanXuan * @date 2021-04-03 @@ -100,6 +105,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask taskService.setAssignee(taskVo.getTaskId(), userId.toString()); taskService.complete(taskVo.getTaskId(), taskVo.getValues()); } + runtimeService.updateBusinessStatus(taskVo.getInstanceId(), FlowStatus.APPROVING.getValue()); return AjaxResult.success(); } @@ -468,6 +474,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask flowTask.setProcDefVersion(pd.getVersion()); flowTask.setCategory(pd.getCategory()); flowTask.setProcDefVersion(pd.getVersion()); + flowTask.setStatus(hisIns.getBusinessStatus()); if (MapUtils.isNotEmpty(hisIns.getProcessVariables()) && hisIns.getProcessVariables().containsKey("submitDate") && StringUtils.isNotBlank(MapUtils.getString(hisIns.getProcessVariables(), "submitDate"))) { @@ -722,6 +729,8 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask .processInstanceId(procInsId) .orderByHistoricActivityInstanceStartTime() .desc().list(); + ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().includeProcessVariables().processInstanceId(procInsId).singleResult(); + Map userModifyTaskFinishTime = Optional.ofNullable(processInstance).map(e -> ( Map)MapUtils.getMap(e.getProcessVariables(), USER_MODIFY_TASK_FINISH_TIME_VARIABLE_KEY)).orElse(new HashMap<>()); List hisFlowList = new ArrayList<>(); for (HistoricActivityInstance histIns : list) { if (StringUtils.isNotBlank(histIns.getTaskId())) { @@ -729,7 +738,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask flowTask.setTaskId(histIns.getTaskId()); flowTask.setTaskName(histIns.getActivityName()); flowTask.setCreateTime(histIns.getStartTime()); - flowTask.setFinishTime(histIns.getEndTime()); + flowTask.setFinishTime(parseFinishTime(userModifyTaskFinishTime, histIns.getTaskId(), histIns.getEndTime())); if (StringUtils.isNotBlank(histIns.getAssignee())) { SysUser sysUser = sysUserService.selectUserById(Long.parseLong(histIns.getAssignee())); flowTask.setAssigneeId(sysUser.getUserId()); @@ -776,10 +785,10 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask map.put("finished", false); } - ProcessInstance processInstance = runtimeService.createProcessInstanceQuery() - .processInstanceId(procInsId) - .includeProcessVariables() - .singleResult(); +// ProcessInstance processInstance = runtimeService.createProcessInstanceQuery() +// .processInstanceId(procInsId) +// .includeProcessVariables() +// .singleResult(); if (Objects.nonNull(processInstance)) { map.put("form", processInstance.getProcessVariables()); } else { @@ -796,6 +805,13 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask return AjaxResult.success(map); } + public static Date parseFinishTime(Map userModifyTaskFinishTime ,String taskId, Date taskEndTime) { + if (MapUtils.isEmpty(userModifyTaskFinishTime)) { + return taskEndTime; + } + return userModifyTaskFinishTime.containsKey(taskId) ? MapUtil.getDate(userModifyTaskFinishTime, taskId) : taskEndTime; + } + /** * 根据任务ID查询挂载的表单信息 * @@ -930,6 +946,23 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask runtimeService.setVariable(execution.getId(),"submitDate",submitDate); return AjaxResult.success(); } + @Override + public AjaxResult updateVariablesSubmitDate(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)) { + return AjaxResult.error("更新提交时间失败,查询错误"); + } + 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); + + return AjaxResult.success(); + } /** * 获取下一节点 diff --git a/ruoyi-ui/src/api/flowable/definition.js b/ruoyi-ui/src/api/flowable/definition.js index 7cd49ca..9080d20 100644 --- a/ruoyi-ui/src/api/flowable/definition.js +++ b/ruoyi-ui/src/api/flowable/definition.js @@ -32,6 +32,13 @@ export function updateVariablesSubmitDate(data) { method: 'post', data: data }) +}// 更新流程变量提交时间 +export function updateTaskFinishDate(data) { + return request({ + url: '/flowable/task/updateTaskFinishDate', + method: 'post', + data: data + }) } // 激活/挂起流程 diff --git a/ruoyi-ui/src/router/index.js b/ruoyi-ui/src/router/index.js index b307974..481cc45 100644 --- a/ruoyi-ui/src/router/index.js +++ b/ruoyi-ui/src/router/index.js @@ -133,6 +133,18 @@ export const constantRoutes = [ meta: { title: '流程处理', icon: '' } } ] + }, { + path: '/flowable', + component: Layout, + hidden: true, + children: [ + { + path: 'task/record/admin', + component: (resolve) => require(['@/views/flowable/task/record/admin'], resolve), + name: 'Record', + meta: { title: '流程管理', icon: '' } + } + ] }, { path: '/tool', diff --git a/ruoyi-ui/src/views/flowable/task/allprocess/index.vue b/ruoyi-ui/src/views/flowable/task/allprocess/index.vue index 5f40874..42d3ed2 100644 --- a/ruoyi-ui/src/views/flowable/task/allprocess/index.vue +++ b/ruoyi-ui/src/views/flowable/task/allprocess/index.vue @@ -94,9 +94,9 @@ 详情 - - 更新提交时间 - + + + 下载附件 @@ -114,25 +114,7 @@ @pagination="getList" /> - - - - - - - - - 确认 - - -
-
@@ -320,9 +302,10 @@ export default { this.openUpdateSubmitDate = true this.processInstanceId = row.procInsId }, + // 详情按钮 /** 流程流转记录 */ handleFlowRecord(row){ - this.$router.push({ path: '/flowable/task/record/index', + this.$router.push({ path: '/flowable/task/record/admin', query: { procInsId: row.procInsId, deployId: row.deployId, diff --git a/ruoyi-ui/src/views/flowable/task/process/index.vue b/ruoyi-ui/src/views/flowable/task/process/index.vue index 59e2387..bd5fbc5 100644 --- a/ruoyi-ui/src/views/flowable/task/process/index.vue +++ b/ruoyi-ui/src/views/flowable/task/process/index.vue @@ -72,8 +72,9 @@ @@ -94,9 +95,9 @@ 详情 - - - + + 重新发起 + diff --git a/ruoyi-ui/src/views/flowable/task/record/admin.vue b/ruoyi-ui/src/views/flowable/task/record/admin.vue new file mode 100644 index 0000000..e8ace84 --- /dev/null +++ b/ruoyi-ui/src/views/flowable/task/record/admin.vue @@ -0,0 +1,813 @@ + + + +