From 75ff358d6d41bbc31061abc51b9ebc5ead99c8ad Mon Sep 17 00:00:00 2001 From: dimengzhe Date: Tue, 11 Feb 2025 10:32:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B5=81=E7=A8=8B=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flowable/biz/flowtask/FlowTaskService.java | 17 ++++++++++------- .../yxt/anrui/portal/biz/flow/FlowableRest.java | 5 +++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowtask/FlowTaskService.java b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowtask/FlowTaskService.java index cf22c64048..bd7b1cee9e 100644 --- a/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowtask/FlowTaskService.java +++ b/anrui-flowable/anrui-flowable-biz/src/main/java/com/yxt/anrui/flowable/biz/flowtask/FlowTaskService.java @@ -330,10 +330,12 @@ public class FlowTaskService extends MybatisBaseService 转换为以逗号分隔的字符串 String assigneeIdsStr = String.join(",", assigneeIds); - - // 远程调用批量查询用户信息 - Map userMap = sysUserFeign.fetchBySids(assigneeIdsStr).getData().stream() - .collect(Collectors.toMap(SysUserVo::getSid, user -> user)); + Map userMap = new HashMap<>(); + if(StringUtils.isNotBlank(assigneeIdsStr)){ + // 远程调用批量查询用户信息 + userMap = sysUserFeign.fetchBySids(assigneeIdsStr).getData().stream() + .collect(Collectors.toMap(SysUserVo::getSid, user -> user)); + } // 直接查询所有流程实例评论 List commentList = taskService.getProcessInstanceComments(procInsId); @@ -345,6 +347,7 @@ public class FlowTaskService extends MybatisBaseService finalHisFlowList = Collections.synchronizedList(hisFlowList); // 使用 parallelStream 前先进行 null 检查和过滤 + Map finalUserMap = userMap; hisFlowList = list.parallelStream() .filter(histIns -> histIns != null && histIns.getTaskId() != null) // 过滤掉 histIns 或 histIns.getTaskId() 为 null 的元素 .map(histIns -> { @@ -366,8 +369,8 @@ public class FlowTaskService extends MybatisBaseService> flowRecordAndComment(String procInsId, String deployId) { + long startTimes = System.currentTimeMillis(); // 记录开始时间 // 并行调用外部服务 CompletableFuture> flowRecordFuture = CompletableFuture.supplyAsync(() -> flowableService.flowRecord(procInsId, deployId)); @@ -266,6 +269,8 @@ public class FlowableRest implements FlowableFeign { // 返回结果 ResultBean> resultBean = new ResultBean>().success(); resultBean.setData(flowList); + long endTime = System.currentTimeMillis(); + log.info("流程记录接口耗时 {} ms", endTime - startTimes); return resultBean; }