From a6c00523808fb5e7f0728e93eed75d05704fde1c Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Wed, 14 Dec 2022 14:26:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E8=BF=87=E6=85=A2=E7=9A=84=E7=BC=BA=E9=99=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1020646 --user=王孝刚 【任务中心】github #20425,任务中心接口请求时间长,导致任务中心访问时空白页经常出现,接口返回数据后,再次访问任务中心,非空白页 https://www.tapd.cn/55049933/s/1315602 --- .../base/mapper/ext/ExtTaskMapper.java | 8 +- .../base/mapper/ext/ExtTaskMapper.xml | 204 +++++++++------ .../commons/constants/TaskCenterType.java | 5 + .../task/controller/TaskController.java | 9 +- .../task/dto/TaskCenterRequest.java | 3 + .../task/dto/TaskStatisticsDTO.java | 16 ++ .../metersphere/task/service/TaskService.java | 39 ++- .../websocket/TaskCenterWebSocket.java | 32 ++- .../business/components/task/TaskCenter.vue | 173 ++++++++----- .../components/task/TaskCenterItem.vue | 241 ++++++++++++++++++ .../components/task/TaskReportStatus.vue | 48 ++++ frontend/src/i18n/en-US.js | 6 + frontend/src/i18n/zh-CN.js | 5 + frontend/src/i18n/zh-TW.js | 6 + 14 files changed, 620 insertions(+), 175 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/commons/constants/TaskCenterType.java create mode 100644 backend/src/main/java/io/metersphere/task/dto/TaskStatisticsDTO.java create mode 100644 frontend/src/business/components/task/TaskCenterItem.vue create mode 100644 frontend/src/business/components/task/TaskReportStatus.vue diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTaskMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTaskMapper.java index 6439e67643..a45283c97c 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTaskMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTaskMapper.java @@ -2,15 +2,17 @@ package io.metersphere.base.mapper.ext; import io.metersphere.task.dto.TaskCenterDTO; import io.metersphere.task.dto.TaskCenterRequest; +import io.metersphere.task.dto.TaskStatisticsDTO; import org.apache.ibatis.annotations.Param; import java.util.List; public interface ExtTaskMapper { - List getTasks(@Param("request") TaskCenterRequest request); - - int getRunningTasks(@Param("request") TaskCenterRequest request); + List getApiTasks(@Param("request") TaskCenterRequest request); + List getScenarioTasks(@Param("request") TaskCenterRequest request); + List getPerfTasks(@Param("request") TaskCenterRequest request); + TaskStatisticsDTO getRunningTasks(@Param("request") TaskCenterRequest request); List getCases(@Param("id") String id); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTaskMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTaskMapper.xml index 27809b69a3..4e137327fd 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTaskMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTaskMapper.xml @@ -1,74 +1,88 @@ - + SELECT t.id,t.name,'API' AS executionModule, t.report_type, ifnull(t2.name,'LOCAL') AS actuator, t1.`name` AS + executor,t.create_time AS executionTime, ifnull(t.trigger_mode,'MANUAL') AS triggerMode + ,ifnull(t.status,'Saved') AS executionStatus + FROM api_definition_exec_result t INNER JOIN `user` t1 ON t.user_id = t1.id LEFT JOIN test_resource_pool t2 ON t.actuator = t2.id - where to_days(FROM_UNIXTIME(t.create_time/1000))= to_days(now()) and t.execute_type !='Debug' and t.execute_type - !='Marge' and t.project_id in - - #{id} - - - and t.trigger_mode = #{request.triggerMode} - - - and t.status = #{request.executionStatus} - - - and t.user_id = #{request.executor} - - ) - UNION ALL - (select t.id,t.name,'API' as executionModule, t.report_type, ifnull(t2.name,'LOCAL') as actuator, t1.`name` as - executor,t.create_time as executionTime, ifnull(t.trigger_mode,'MANUAL') as triggerMode - ,ifnull(t.status,'Saved') as executionStatus - from api_definition_exec_result t inner join `user` t1 ON t.user_id = t1.id left join test_resource_pool t2 on - t.actuator = t2.id - where to_days(FROM_UNIXTIME(t.create_time/1000))= to_days(now()) and t.project_id in + WHERE to_days(FROM_UNIXTIME(t.create_time/1000))= to_days(now()) AND t.project_id IN #{id} - and t.trigger_mode = #{request.triggerMode} + + + AND t.trigger_mode in ('JENKINS_API_PLAN', 'JENKINS_SCENARIO_PLAN', 'JENKINS_PERFORMANCE_TEST', 'JENKINS') + + - and t.status = #{request.executionStatus} + AND t.status = #{request.executionStatus} - and t.user_id = #{request.executor} + AND t.user_id = #{request.executor} - and (t.integrated_report_id is null or t.integrated_report_id = 'null') - ) - UNION ALL - (select t.id,t.name,'PERFORMANCE' as executionModule,'PERFORMANCE' as report_type, ifnull(t2.name,'LOCAL') as - actuator, t1.`name` as executor,t.create_time as executionTime, t.trigger_mode as triggerMode ,t.`status` as - executionStatus - from load_test_report t inner join `user` t1 ON t.user_id = t1.id left join test_resource_pool t2 on - t.test_resource_pool_id = t2.id - where to_days(FROM_UNIXTIME(t.create_time/1000))= to_days(now()) and t.project_id in + AND (t.integrated_report_id IS NULL OR t.integrated_report_id = 'null') + ORDER BY t.create_time DESC + + + + + + - + SELECT ( + SELECT + count( t.id ) + FROM + api_scenario_report t + LEFT JOIN `user` t1 ON t.user_id = t1.id + LEFT JOIN test_resource_pool t2 ON t.actuator = t2.id + WHERE + to_days(FROM_UNIXTIME( t.create_time / 1000 ))= to_days(now()) + AND t.execute_type != 'Debug' + AND t.execute_type != 'Marge' + AND t.project_id IN #{id} - and t.trigger_mode = #{request.triggerMode} + + + AND t.trigger_mode in ('JENKINS_API_PLAN', 'JENKINS_SCENARIO_PLAN', 'JENKINS_PERFORMANCE_TEST', 'JENKINS') + + - and t.status = #{request.executionStatus} + AND t.status = #{request.executionStatus} - and t.user_id = #{request.executor} + AND t.user_id = #{request.executor} - and t.status in ("running","starting","waiting") - ) - UNION ALL - (select t.id,'API' as executionModule, t.report_type, ifnull(t2.name,'LOCAL') as actuator, t1.`name` as - executor,t.create_time as executionTime, ifnull(t.trigger_mode,'MANUAL') as triggerMode - ,ifnull(t.status,'Saved') as executionStatus - from api_definition_exec_result t left join `user` t1 ON t.user_id = t1.id left join test_resource_pool t2 on - t.actuator = t2.id - where to_days(FROM_UNIXTIME(t.create_time/1000))= to_days(now()) and t.project_id in + AND t.status IN ("running","starting","waiting") + ) as scenarioTotal , + (SELECT + count( t.id ) + FROM + api_definition_exec_result t + LEFT JOIN `user` t1 ON t.user_id = t1.id + LEFT JOIN test_resource_pool t2 ON t.actuator = t2.id + WHERE + to_days( FROM_UNIXTIME( t.create_time / 1000 ))= to_days(now()) + AND t.project_id IN #{id} - and t.trigger_mode = #{request.triggerMode} + + + AND t.trigger_mode in ('JENKINS_API_PLAN', 'JENKINS_SCENARIO_PLAN', 'JENKINS_PERFORMANCE_TEST', 'JENKINS') + + - and t.status = #{request.executionStatus} + AND t.status = #{request.executionStatus} - and t.user_id = #{request.executor} + AND t.user_id = #{request.executor} - and (t.integrated_report_id is null or t.integrated_report_id = 'null') - and t.status in ("running","starting","waiting") - ) - UNION ALL - (select t.id,'PERFORMANCE' as executionModule,'PERFORMANCE' as report_type, ifnull(t2.name,'LOCAL') as actuator, - t1.`name` as executor,t.create_time as executionTime, t.trigger_mode as triggerMode ,t.`status` as - executionStatus - from load_test_report t left join `user` t1 ON t.user_id = t1.id left join test_resource_pool t2 on - t.test_resource_pool_id = t2.id - where to_days(FROM_UNIXTIME(t.create_time/1000))= to_days(now()) and t.project_id in + AND (t.integrated_report_id IS NULL OR t.integrated_report_id = 'null') + AND t.status IN ("running","starting","waiting") + ) as apiTotal , + (SELECT + count( t.id ) + FROM + load_test_report t + LEFT JOIN `user` t1 ON t.user_id = t1.id + LEFT JOIN test_resource_pool t2 ON t.test_resource_pool_id = t2.id + WHERE + to_days(FROM_UNIXTIME( t.create_time / 1000 ))= to_days(now()) + AND t.project_id IN #{id} - and t.trigger_mode = #{request.triggerMode} + + + AND t.trigger_mode in ('JENKINS_API_PLAN', 'JENKINS_SCENARIO_PLAN', 'JENKINS_PERFORMANCE_TEST', 'JENKINS') + + - and t.status = #{request.executionStatus} + AND t.status = #{request.executionStatus} - and t.user_id = #{request.executor} + AND t.user_id = #{request.executor} - and t.status in ("running","starting","waiting") - ) - )tt; + AND t.status IN ("running","starting","waiting") + ) as perfTotal