From 23eda6b1a90e7688bc804953103b4e2020ec5198 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 16 Jan 2022 13:47:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20bpm=20=E5=9F=BA=E4=BA=8E?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E5=AE=9E=E4=BE=8B=E6=9F=A5=E8=AF=A2=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bpm/convert/task/BpmTaskConvert.java | 66 +++++++++---------- .../service/task/impl/BpmTaskServiceImpl.java | 5 +- 2 files changed, 31 insertions(+), 40 deletions(-) diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmTaskConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmTaskConvert.java index db91d544f..d3c77f59a 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmTaskConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmTaskConvert.java @@ -29,27 +29,21 @@ public interface BpmTaskConvert { BpmTaskConvert INSTANCE = Mappers.getMapper(BpmTaskConvert.class); - default List convertList(List tasks, Map processInstanceMap, - Map userMap) { + default List convertList1(List tasks, Map processInstanceMap, + Map userMap) { return CollectionUtils.convertList(tasks, task -> { + BpmTaskTodoPageItemRespVO respVO = convert1(task); ProcessInstance processInstance = processInstanceMap.get(task.getProcessInstanceId()); - return convert(task, processInstance, userMap.get(Long.valueOf(processInstance.getStartUserId()))); + if (processInstance != null) { + SysUserDO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId())); + respVO.setProcessInstance(convert(processInstance, startUser)); + } + return respVO; }); } - @Mappings({ - @Mapping(source = "task.id", target = "id"), - @Mapping(source = "task.name", target = "name"), - @Mapping(source = "task.claimTime", target = "claimTime"), - @Mapping(source = "task.createTime", target = "createTime"), - @Mapping(source = "task.suspended", target = "suspensionState", qualifiedByName = "convertSuspendedToSuspensionState"), - @Mapping(source = "processInstance.id", target = "processInstance.id"), - @Mapping(source = "processInstance.name", target = "processInstance.name"), - @Mapping(source = "processInstance.startUserId", target = "processInstance.startUserId"), - @Mapping(source = "processInstance.processDefinitionId", target = "processInstance.processDefinitionId"), - @Mapping(source = "user.nickname", target = "processInstance.startUserNickname") - }) - BpmTaskTodoPageItemRespVO convert(Task task, ProcessInstance processInstance, SysUserDO user); + @Mapping(source = "suspended", target = "suspensionState", qualifiedByName = "convertSuspendedToSuspensionState") + BpmTaskTodoPageItemRespVO convert1(Task bean); @Named("convertSuspendedToSuspensionState") default Integer convertSuspendedToSuspensionState(boolean suspended) { @@ -61,29 +55,19 @@ public interface BpmTaskConvert { Map historicProcessInstanceMap, Map userMap) { return CollectionUtils.convertList(tasks, task -> { + BpmTaskDonePageItemRespVO respVO = convert2(task); BpmTaskExtDO taskExtDO = bpmTaskExtDOMap.get(task.getId()); + copyTo(taskExtDO, respVO); HistoricProcessInstance processInstance = historicProcessInstanceMap.get(task.getProcessInstanceId()); - SysUserDO userDO = userMap.get(Long.valueOf(processInstance.getStartUserId())); - return convert(task, taskExtDO, processInstance, userDO); + if (processInstance != null) { + SysUserDO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId())); + respVO.setProcessInstance(convert(processInstance, startUser)); + } + return respVO; }); } - @Mappings({ - @Mapping(source = "task.id", target = "id"), - @Mapping(source = "task.name", target = "name"), - @Mapping(source = "task.claimTime", target = "claimTime"), - @Mapping(source = "task.createTime", target = "createTime"), - @Mapping(source = "task.endTime", target = "endTime"), - @Mapping(source = "task.durationInMillis", target = "durationInMillis"), - @Mapping(source = "taskExtDO.result", target = "result"), - @Mapping(source = "taskExtDO.comment", target = "comment"), - @Mapping(source = "processInstance.id", target = "processInstance.id"), - @Mapping(source = "processInstance.name", target = "processInstance.name"), - @Mapping(source = "processInstance.startUserId", target = "processInstance.startUserId"), - @Mapping(source = "processInstance.processDefinitionId", target = "processInstance.processDefinitionId"), - @Mapping(source = "startUser.nickname", target = "processInstance.startUserNickname") - }) - BpmTaskDonePageItemRespVO convert(HistoricTaskInstance task, BpmTaskExtDO taskExtDO, HistoricProcessInstance processInstance, SysUserDO startUser); + BpmTaskDonePageItemRespVO convert2(HistoricTaskInstance bean); @Mappings({ @Mapping(source = "id", target = "taskId"), @@ -98,7 +82,7 @@ public interface BpmTaskConvert { return CollectionUtils.convertList(tasks, task -> { BpmTaskRespVO respVO = convert3(task); BpmTaskExtDO taskExtDO = bpmTaskExtDOMap.get(task.getId()); - copyTo3(taskExtDO, respVO); + copyTo(taskExtDO, respVO); if (processInstance != null) { SysUserDO startUser = userMap.get(NumberUtils.parseLong(processInstance.getStartUserId())); respVO.setProcessInstance(convert(processInstance, startUser)); @@ -117,7 +101,17 @@ public interface BpmTaskConvert { BpmTaskRespVO convert3(HistoricTaskInstance bean); BpmTaskRespVO.User convert3(SysUserDO bean); - void copyTo3(BpmTaskExtDO from, @MappingTarget BpmTaskRespVO to); + + void copyTo(BpmTaskExtDO from, @MappingTarget BpmTaskDonePageItemRespVO to); + + @Mappings({ + @Mapping(source = "processInstance.id", target = "id"), + @Mapping(source = "processInstance.name", target = "name"), + @Mapping(source = "processInstance.startUserId", target = "startUserId"), + @Mapping(source = "processInstance.processDefinitionId", target = "processDefinitionId"), + @Mapping(source = "startUser.nickname", target = "startUserNickname") + }) + BpmTaskTodoPageItemRespVO.ProcessInstance convert(ProcessInstance processInstance, SysUserDO startUser); @Mappings({ @Mapping(source = "processInstance.id", target = "id"), diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java index d059834b2..b15ef39ce 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java @@ -2,7 +2,6 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.task.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.IoUtil; -import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.*; import cn.iocoder.yudao.adminserver.modules.bpm.convert.task.BpmTaskConvert; @@ -34,7 +33,6 @@ import org.activiti.engine.history.HistoricTaskInstance; import org.activiti.engine.history.HistoricTaskInstanceQuery; import org.activiti.engine.repository.ProcessDefinition; import org.activiti.engine.runtime.ProcessInstance; -import org.activiti.engine.task.Comment; import org.activiti.engine.task.Task; import org.activiti.engine.task.TaskQuery; import org.activiti.image.ProcessDiagramGenerator; @@ -48,7 +46,6 @@ import javax.validation.Valid; import java.io.IOException; import java.io.InputStream; import java.util.*; -import java.util.function.Function; import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.*; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -155,7 +152,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { Map userMap = userService.getUserMap( convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId()))); // 拼接结果 - return new PageResult<>(BpmTaskConvert.INSTANCE.convertList(tasks, processInstanceMap, userMap), + return new PageResult<>(BpmTaskConvert.INSTANCE.convertList1(tasks, processInstanceMap, userMap), taskQuery.count()); }