From a5b8b9b67e9853e1ddf30e51b450029d19b4256b Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 9 Jan 2022 09:46:34 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E5=A4=8D=E5=B7=B2=E5=8A=9E?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=9A=84=20API=20=E6=8E=A5=E5=8F=A3=E7=9A=84?= =?UTF-8?q?=20NPE=202.=20=E5=AE=9E=E7=8E=B0=E5=B7=B2=E5=8A=9E=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=9A=84=20UI=20=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bpm/convert/task/BpmTaskConvert.java | 7 +- .../task/BpmProcessInstanceService.java | 27 +++++ .../impl/BpmProcessInstanceServiceImpl.java | 8 +- .../service/task/impl/BpmTaskServiceImpl.java | 6 +- yudao-admin-ui/src/api/bpm/task.js | 8 ++ yudao-admin-ui/src/views/bpm/task/done.vue | 105 ++++++++++++++++++ yudao-admin-ui/src/views/bpm/task/todo.vue | 24 +--- .../activiti/core/util/ActivitiUtils.java | 5 + 8 files changed, 160 insertions(+), 30 deletions(-) create mode 100644 yudao-admin-ui/src/views/bpm/task/done.vue 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 101dc1e48..96f273bf6 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 @@ -6,6 +6,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.TaskStep import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import org.activiti.engine.history.HistoricActivityInstance; +import org.activiti.engine.history.HistoricProcessInstance; import org.activiti.engine.history.HistoricTaskInstance; import org.activiti.engine.impl.persistence.entity.SuspensionState; import org.activiti.engine.runtime.ProcessInstance; @@ -64,10 +65,10 @@ public interface BpmTaskConvert { } default List convertList2(List tasks, - Map processInstanceMap, + Map historicProcessInstanceMap, Map userMap) { return CollectionUtils.convertList(tasks, task -> { - ProcessInstance processInstance = processInstanceMap.get(task.getProcessInstanceId()); + HistoricProcessInstance processInstance = historicProcessInstanceMap.get(task.getProcessInstanceId()); return convert(task, processInstance, userMap.get(Long.valueOf(processInstance.getStartUserId()))); }); } @@ -85,6 +86,6 @@ public interface BpmTaskConvert { @Mapping(source = "processInstance.processDefinitionId", target = "processInstance.processDefinitionId"), @Mapping(source = "user.nickname", target = "processInstance.startUserNickname") }) - BpmTaskDonePageItemRespVO convert(HistoricTaskInstance task, ProcessInstance processInstance, SysUserDO user); + BpmTaskDonePageItemRespVO convert(HistoricTaskInstance task, HistoricProcessInstance processInstance, SysUserDO user); } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmProcessInstanceService.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmProcessInstanceService.java index 96d751a01..255b8f5ae 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmProcessInstanceService.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/BpmProcessInstanceService.java @@ -8,6 +8,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceDel import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import org.activiti.engine.history.HistoricProcessInstance; import org.activiti.engine.runtime.ProcessInstance; import javax.validation.Valid; @@ -91,4 +92,30 @@ public interface BpmProcessInstanceService { return CollectionUtils.convertMap(getProcessInstances(ids), ProcessInstance::getProcessInstanceId); } + /** + * 获得历史的流程实例 + * + * @param id 流程实例的编号 + * @return 历史的流程实例 + */ + HistoricProcessInstance getHistoricProcessInstance(String id); + + /** + * 获得历史的流程实例列表 + * + * @param ids 流程实例的编号集合 + * @return 历史的流程实例列表 + */ + List getHistoricProcessInstances(Set ids); + + /** + * 获得历史的流程实例 Map + * + * @param ids 流程实例的编号集合 + * @return 历史的流程实例列表 Map + */ + default Map getHistoricProcessInstanceMap(Set ids) { + return CollectionUtils.convertMap(getHistoricProcessInstances(ids), HistoricProcessInstance::getId); + } + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java index 7082924a2..66770cb07 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmProcessInstanceServiceImpl.java @@ -186,8 +186,14 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService * @param id 流程实例的编号 * @return 历史的流程实例 */ - private HistoricProcessInstance getHistoricProcessInstance(String id) { + @Override + public HistoricProcessInstance getHistoricProcessInstance(String id) { return historyService.createHistoricProcessInstanceQuery().processInstanceId(id).singleResult(); } + @Override + public List getHistoricProcessInstances(Set ids) { + return historyService.createHistoricProcessInstanceQuery().processInstanceIds(ids).list(); + } + } 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 e155349fa..baca9f41f 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 @@ -144,13 +144,13 @@ public class BpmTaskServiceImpl implements BpmTaskService { } // 获得 ProcessInstance Map - Map processInstanceMap = processInstanceService.getProcessInstanceMap( + Map historicProcessInstanceMap = processInstanceService.getHistoricProcessInstanceMap( convertSet(tasks, HistoricTaskInstance::getProcessInstanceId)); // 获得 User Map Map userMap = userService.getUserMap( - convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId()))); + convertSet(historicProcessInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId()))); // 拼接结果 - return new PageResult<>(BpmTaskConvert.INSTANCE.convertList2(tasks, processInstanceMap, userMap), + return new PageResult<>(BpmTaskConvert.INSTANCE.convertList2(tasks, historicProcessInstanceMap, userMap), taskQuery.count()); } diff --git a/yudao-admin-ui/src/api/bpm/task.js b/yudao-admin-ui/src/api/bpm/task.js index 623291575..3b4dc305f 100644 --- a/yudao-admin-ui/src/api/bpm/task.js +++ b/yudao-admin-ui/src/api/bpm/task.js @@ -8,6 +8,14 @@ export function getTodoTaskPage(query) { }) } +export function getDoneTaskPage(query) { + return request({ + url: '/bpm/task/done-page', + method: 'get', + params: query + }) +} + export function completeTask(data) { return request({ url: '/bpm/task/complete', diff --git a/yudao-admin-ui/src/views/bpm/task/done.vue b/yudao-admin-ui/src/views/bpm/task/done.vue new file mode 100644 index 000000000..8def1171e --- /dev/null +++ b/yudao-admin-ui/src/views/bpm/task/done.vue @@ -0,0 +1,105 @@ + + + diff --git a/yudao-admin-ui/src/views/bpm/task/todo.vue b/yudao-admin-ui/src/views/bpm/task/todo.vue index ac39f7a21..53063e0f1 100644 --- a/yudao-admin-ui/src/views/bpm/task/todo.vue +++ b/yudao-admin-ui/src/views/bpm/task/todo.vue @@ -52,7 +52,7 @@