From fe5faf362c6061962b3c4b7691705266ffb44179 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Sat, 11 Mar 2023 11:43:20 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E6=B6=88=E8=B4=B9=E9=98=BB=E5=A1=9E=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ApiExecutionQueueService.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/service/ApiExecutionQueueService.java b/api-test/backend/src/main/java/io/metersphere/service/ApiExecutionQueueService.java index c52bfeb067..dedb73104c 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/ApiExecutionQueueService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/ApiExecutionQueueService.java @@ -272,8 +272,23 @@ public class ApiExecutionQueueService { } public void testPlanReportTestEnded(String testPlanReportId) { - // 检查测试计划中其他队列是否结束 - kafkaTemplate.send(KafkaTopicConstants.TEST_PLAN_REPORT_TOPIC, testPlanReportId); + ApiExecutionQueueExample executionQueueExample = new ApiExecutionQueueExample(); + executionQueueExample.createCriteria().andReportIdEqualTo(testPlanReportId); + List queues = queueMapper.selectByExample(executionQueueExample); + if (org.springframework.util.CollectionUtils.isEmpty(queues)) { + LoggerUtil.info("测试计划执行结束开始发送通知:" + testPlanReportId); + kafkaTemplate.send(KafkaTopicConstants.TEST_PLAN_REPORT_TOPIC, testPlanReportId); + } else { + List ids = queues.stream().map(ApiExecutionQueue::getId).collect(Collectors.toList()); + ApiExecutionQueueDetailExample detailExample = new ApiExecutionQueueDetailExample(); + detailExample.createCriteria().andQueueIdIn(ids); + long count = executionQueueDetailMapper.countByExample(detailExample); + if (count == 0) { + LoggerUtil.info("测试计划执行结束开始发送通知:" + testPlanReportId); + // 检查测试计划中其他队列是否结束 + kafkaTemplate.send(KafkaTopicConstants.TEST_PLAN_REPORT_TOPIC, testPlanReportId); + } + } } public void queueNext(ResultDTO dto) {