From 7832a10c02887d5b3a7843662e6e1c6703f4a2ea Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Tue, 15 Oct 2024 14:24:06 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E4=BB=BB=E5=8A=A1=E4=B8=AD=E5=BF=83):?= =?UTF-8?q?=20=E4=BB=BB=E5=8A=A1=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=80=BC=E5=A4=84=E7=90=86&domain=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/domain/ApiReport.java | 6 +- .../api/domain/ApiReportExample.java | 70 +++++++++++++++++++ .../api/domain/ApiScenarioReport.java | 6 +- .../api/domain/ApiScenarioReportExample.java | 70 +++++++++++++++++++ .../api/mapper/ApiReportMapper.xml | 34 +++++++-- .../api/mapper/ApiScenarioReportMapper.xml | 37 +++++++--- .../metersphere/system/domain/ExecTask.java | 8 ++- .../system/domain/ExecTaskExample.java | 60 ++++++++++++++++ .../system/mapper/ExecTaskMapper.xml | 39 ++++++++--- .../system/service/BaseTaskHubService.java | 42 +++++++++-- 10 files changed, 338 insertions(+), 34 deletions(-) diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiReport.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiReport.java index 307e2fe352..866a9ff0bd 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiReport.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiReport.java @@ -148,6 +148,9 @@ public class ApiReport implements Serializable { @NotNull(message = "{api_report.plan.not_blank}", groups = {Created.class}) private Boolean plan; + @Schema(description = "关联任务id(集合报告)/任务项id") + private String associatedTaskId; + private static final long serialVersionUID = 1L; public enum Column { @@ -183,7 +186,8 @@ public class ApiReport implements Serializable { assertionPassRate("assertion_pass_rate", "assertionPassRate", "VARCHAR", false), scriptIdentifier("script_identifier", "scriptIdentifier", "VARCHAR", false), execStatus("exec_status", "execStatus", "VARCHAR", false), - plan("plan", "plan", "BIT", true); + plan("plan", "plan", "BIT", true), + associatedTaskId("associated_task_id", "associatedTaskId", "VARCHAR", false); private static final String BEGINNING_DELIMITER = "`"; diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiReportExample.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiReportExample.java index 8aadf7e809..8ba1150c1a 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiReportExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiReportExample.java @@ -2273,6 +2273,76 @@ public class ApiReportExample { addCriterion("`plan` not between", value1, value2, "plan"); return (Criteria) this; } + + public Criteria andAssociatedTaskIdIsNull() { + addCriterion("associated_task_id is null"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdIsNotNull() { + addCriterion("associated_task_id is not null"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdEqualTo(String value) { + addCriterion("associated_task_id =", value, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdNotEqualTo(String value) { + addCriterion("associated_task_id <>", value, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdGreaterThan(String value) { + addCriterion("associated_task_id >", value, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdGreaterThanOrEqualTo(String value) { + addCriterion("associated_task_id >=", value, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdLessThan(String value) { + addCriterion("associated_task_id <", value, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdLessThanOrEqualTo(String value) { + addCriterion("associated_task_id <=", value, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdLike(String value) { + addCriterion("associated_task_id like", value, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdNotLike(String value) { + addCriterion("associated_task_id not like", value, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdIn(List values) { + addCriterion("associated_task_id in", values, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdNotIn(List values) { + addCriterion("associated_task_id not in", values, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdBetween(String value1, String value2) { + addCriterion("associated_task_id between", value1, value2, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdNotBetween(String value1, String value2) { + addCriterion("associated_task_id not between", value1, value2, "associatedTaskId"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioReport.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioReport.java index 00b6de4557..fc1d5772ea 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioReport.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioReport.java @@ -151,6 +151,9 @@ public class ApiScenarioReport implements Serializable { @NotNull(message = "{api_scenario_report.plan.not_blank}", groups = {Created.class}) private Boolean plan; + @Schema(description = "关联任务id(集合报告)/任务项id") + private String associatedTaskId; + private static final long serialVersionUID = 1L; public enum Column { @@ -187,7 +190,8 @@ public class ApiScenarioReport implements Serializable { scriptIdentifier("script_identifier", "scriptIdentifier", "VARCHAR", false), waitingTime("waiting_time", "waitingTime", "BIGINT", false), execStatus("exec_status", "execStatus", "VARCHAR", false), - plan("plan", "plan", "BIT", true); + plan("plan", "plan", "BIT", true), + associatedTaskId("associated_task_id", "associatedTaskId", "VARCHAR", false); private static final String BEGINNING_DELIMITER = "`"; diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioReportExample.java b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioReportExample.java index bb035ff763..58746eadcb 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioReportExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/api/domain/ApiScenarioReportExample.java @@ -2333,6 +2333,76 @@ public class ApiScenarioReportExample { addCriterion("`plan` not between", value1, value2, "plan"); return (Criteria) this; } + + public Criteria andAssociatedTaskIdIsNull() { + addCriterion("associated_task_id is null"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdIsNotNull() { + addCriterion("associated_task_id is not null"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdEqualTo(String value) { + addCriterion("associated_task_id =", value, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdNotEqualTo(String value) { + addCriterion("associated_task_id <>", value, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdGreaterThan(String value) { + addCriterion("associated_task_id >", value, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdGreaterThanOrEqualTo(String value) { + addCriterion("associated_task_id >=", value, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdLessThan(String value) { + addCriterion("associated_task_id <", value, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdLessThanOrEqualTo(String value) { + addCriterion("associated_task_id <=", value, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdLike(String value) { + addCriterion("associated_task_id like", value, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdNotLike(String value) { + addCriterion("associated_task_id not like", value, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdIn(List values) { + addCriterion("associated_task_id in", values, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdNotIn(List values) { + addCriterion("associated_task_id not in", values, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdBetween(String value1, String value2) { + addCriterion("associated_task_id between", value1, value2, "associatedTaskId"); + return (Criteria) this; + } + + public Criteria andAssociatedTaskIdNotBetween(String value1, String value2) { + addCriterion("associated_task_id not between", value1, value2, "associatedTaskId"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiReportMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiReportMapper.xml index 9878b86225..54f561690d 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiReportMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiReportMapper.xml @@ -35,6 +35,7 @@ + @@ -100,7 +101,7 @@ pool_id, integrated, project_id, environment_id, error_count, fake_error_count, pending_count, success_count, assertion_count, assertion_success_count, request_error_rate, request_pending_rate, request_fake_error_rate, request_pass_rate, assertion_pass_rate, script_identifier, - exec_status, `plan` + exec_status, `plan`, associated_task_id @@ -471,6 +480,9 @@ `plan` = #{record.plan,jdbcType=BIT}, + + associated_task_id = #{record.associatedTaskId,jdbcType=VARCHAR}, + @@ -510,7 +522,8 @@ assertion_pass_rate = #{record.assertionPassRate,jdbcType=VARCHAR}, script_identifier = #{record.scriptIdentifier,jdbcType=VARCHAR}, exec_status = #{record.execStatus,jdbcType=VARCHAR}, - `plan` = #{record.plan,jdbcType=BIT} + `plan` = #{record.plan,jdbcType=BIT}, + associated_task_id = #{record.associatedTaskId,jdbcType=VARCHAR} @@ -614,6 +627,9 @@ `plan` = #{plan,jdbcType=BIT}, + + associated_task_id = #{associatedTaskId,jdbcType=VARCHAR}, + where id = #{id,jdbcType=VARCHAR} @@ -650,7 +666,8 @@ assertion_pass_rate = #{assertionPassRate,jdbcType=VARCHAR}, script_identifier = #{scriptIdentifier,jdbcType=VARCHAR}, exec_status = #{execStatus,jdbcType=VARCHAR}, - `plan` = #{plan,jdbcType=BIT} + `plan` = #{plan,jdbcType=BIT}, + associated_task_id = #{associatedTaskId,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} @@ -660,7 +677,7 @@ pool_id, integrated, project_id, environment_id, error_count, fake_error_count, pending_count, success_count, assertion_count, assertion_success_count, request_error_rate, request_pending_rate, request_fake_error_rate, request_pass_rate, assertion_pass_rate, - script_identifier, exec_status, `plan`) + script_identifier, exec_status, `plan`, associated_task_id) values (#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.testPlanCaseId,jdbcType=VARCHAR}, @@ -675,7 +692,7 @@ #{item.requestPendingRate,jdbcType=VARCHAR}, #{item.requestFakeErrorRate,jdbcType=VARCHAR}, #{item.requestPassRate,jdbcType=VARCHAR}, #{item.assertionPassRate,jdbcType=VARCHAR}, #{item.scriptIdentifier,jdbcType=VARCHAR}, #{item.execStatus,jdbcType=VARCHAR}, - #{item.plan,jdbcType=BIT}) + #{item.plan,jdbcType=BIT}, #{item.associatedTaskId,jdbcType=VARCHAR}) @@ -787,6 +804,9 @@ #{item.plan,jdbcType=BIT} + + #{item.associatedTaskId,jdbcType=VARCHAR} + ) diff --git a/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiScenarioReportMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiScenarioReportMapper.xml index 26e3deca91..ff4443eed7 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiScenarioReportMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/api/mapper/ApiScenarioReportMapper.xml @@ -36,6 +36,7 @@ + @@ -101,7 +102,7 @@ run_mode, pool_id, integrated, project_id, environment_id, error_count, fake_error_count, pending_count, success_count, assertion_count, assertion_success_count, request_error_rate, request_pending_rate, request_fake_error_rate, request_pass_rate, assertion_pass_rate, - script_identifier, waiting_time, exec_status, `plan` + script_identifier, waiting_time, exec_status, `plan`, associated_task_id @@ -483,6 +490,9 @@ `plan` = #{record.plan,jdbcType=BIT}, + + associated_task_id = #{record.associatedTaskId,jdbcType=VARCHAR}, + @@ -523,7 +533,8 @@ script_identifier = #{record.scriptIdentifier,jdbcType=VARCHAR}, waiting_time = #{record.waitingTime,jdbcType=BIGINT}, exec_status = #{record.execStatus,jdbcType=VARCHAR}, - `plan` = #{record.plan,jdbcType=BIT} + `plan` = #{record.plan,jdbcType=BIT}, + associated_task_id = #{record.associatedTaskId,jdbcType=VARCHAR} @@ -630,6 +641,9 @@ `plan` = #{plan,jdbcType=BIT}, + + associated_task_id = #{associatedTaskId,jdbcType=VARCHAR}, + where id = #{id,jdbcType=VARCHAR} @@ -667,7 +681,8 @@ script_identifier = #{scriptIdentifier,jdbcType=VARCHAR}, waiting_time = #{waitingTime,jdbcType=BIGINT}, exec_status = #{execStatus,jdbcType=VARCHAR}, - `plan` = #{plan,jdbcType=BIT} + `plan` = #{plan,jdbcType=BIT}, + associated_task_id = #{associatedTaskId,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} @@ -677,7 +692,7 @@ run_mode, pool_id, integrated, project_id, environment_id, error_count, fake_error_count, pending_count, success_count, assertion_count, assertion_success_count, request_error_rate, request_pending_rate, request_fake_error_rate, request_pass_rate, assertion_pass_rate, - script_identifier, waiting_time, exec_status, `plan`) + script_identifier, waiting_time, exec_status, `plan`, associated_task_id) values (#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.testPlanScenarioId,jdbcType=VARCHAR}, @@ -692,7 +707,8 @@ #{item.requestPendingRate,jdbcType=VARCHAR}, #{item.requestFakeErrorRate,jdbcType=VARCHAR}, #{item.requestPassRate,jdbcType=VARCHAR}, #{item.assertionPassRate,jdbcType=VARCHAR}, #{item.scriptIdentifier,jdbcType=VARCHAR}, #{item.waitingTime,jdbcType=BIGINT}, - #{item.execStatus,jdbcType=VARCHAR}, #{item.plan,jdbcType=BIT}) + #{item.execStatus,jdbcType=VARCHAR}, #{item.plan,jdbcType=BIT}, #{item.associatedTaskId,jdbcType=VARCHAR} + ) @@ -807,6 +823,9 @@ #{item.plan,jdbcType=BIT} + + #{item.associatedTaskId,jdbcType=VARCHAR} + ) diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/ExecTask.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/ExecTask.java index b15d28d6a9..a52bcc4bf2 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/system/domain/ExecTask.java +++ b/backend/framework/domain/src/main/java/io/metersphere/system/domain/ExecTask.java @@ -4,6 +4,7 @@ import io.metersphere.validation.groups.Created; import io.metersphere.validation.groups.Updated; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; import java.io.Serializable; import java.util.ArrayList; @@ -71,6 +72,10 @@ public class ExecTask implements Serializable { @Schema(description = "结束时间") private Long endTime; + @Schema(description = "是否是集成报告", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "{exec_task.integrated.not_blank}", groups = {Created.class}) + private Boolean integrated; + private static final long serialVersionUID = 1L; public enum Column { @@ -88,7 +93,8 @@ public class ExecTask implements Serializable { createTime("create_time", "createTime", "BIGINT", false), createUser("create_user", "createUser", "VARCHAR", false), startTime("start_time", "startTime", "BIGINT", false), - endTime("end_time", "endTime", "BIGINT", false); + endTime("end_time", "endTime", "BIGINT", false), + integrated("integrated", "integrated", "BIT", false); private static final String BEGINNING_DELIMITER = "`"; diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/ExecTaskExample.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/ExecTaskExample.java index 0199169e0f..22cbfef906 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/system/domain/ExecTaskExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/system/domain/ExecTaskExample.java @@ -1103,6 +1103,66 @@ public class ExecTaskExample { addCriterion("end_time not between", value1, value2, "endTime"); return (Criteria) this; } + + public Criteria andIntegratedIsNull() { + addCriterion("integrated is null"); + return (Criteria) this; + } + + public Criteria andIntegratedIsNotNull() { + addCriterion("integrated is not null"); + return (Criteria) this; + } + + public Criteria andIntegratedEqualTo(Boolean value) { + addCriterion("integrated =", value, "integrated"); + return (Criteria) this; + } + + public Criteria andIntegratedNotEqualTo(Boolean value) { + addCriterion("integrated <>", value, "integrated"); + return (Criteria) this; + } + + public Criteria andIntegratedGreaterThan(Boolean value) { + addCriterion("integrated >", value, "integrated"); + return (Criteria) this; + } + + public Criteria andIntegratedGreaterThanOrEqualTo(Boolean value) { + addCriterion("integrated >=", value, "integrated"); + return (Criteria) this; + } + + public Criteria andIntegratedLessThan(Boolean value) { + addCriterion("integrated <", value, "integrated"); + return (Criteria) this; + } + + public Criteria andIntegratedLessThanOrEqualTo(Boolean value) { + addCriterion("integrated <=", value, "integrated"); + return (Criteria) this; + } + + public Criteria andIntegratedIn(List values) { + addCriterion("integrated in", values, "integrated"); + return (Criteria) this; + } + + public Criteria andIntegratedNotIn(List values) { + addCriterion("integrated not in", values, "integrated"); + return (Criteria) this; + } + + public Criteria andIntegratedBetween(Boolean value1, Boolean value2) { + addCriterion("integrated between", value1, value2, "integrated"); + return (Criteria) this; + } + + public Criteria andIntegratedNotBetween(Boolean value1, Boolean value2) { + addCriterion("integrated not between", value1, value2, "integrated"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/ExecTaskMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/ExecTaskMapper.xml index 48f2c3df97..d38f02201a 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/ExecTaskMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/ExecTaskMapper.xml @@ -17,6 +17,7 @@ + @@ -78,7 +79,7 @@ id, num, task_name, `status`, case_count, `result`, task_type, resource_id, trigger_mode, - project_id, organization_id, create_time, create_user, start_time, end_time + project_id, organization_id, create_time, create_user, start_time, end_time, integrated @@ -275,6 +282,9 @@ end_time = #{record.endTime,jdbcType=BIGINT}, + + integrated = #{record.integrated,jdbcType=BIT}, + @@ -296,7 +306,8 @@ create_time = #{record.createTime,jdbcType=BIGINT}, create_user = #{record.createUser,jdbcType=VARCHAR}, start_time = #{record.startTime,jdbcType=BIGINT}, - end_time = #{record.endTime,jdbcType=BIGINT} + end_time = #{record.endTime,jdbcType=BIGINT}, + integrated = #{record.integrated,jdbcType=BIT} @@ -346,6 +357,9 @@ end_time = #{endTime,jdbcType=BIGINT}, + + integrated = #{integrated,jdbcType=BIT}, + where id = #{id,jdbcType=VARCHAR} @@ -364,21 +378,23 @@ create_time = #{createTime,jdbcType=BIGINT}, create_user = #{createUser,jdbcType=VARCHAR}, start_time = #{startTime,jdbcType=BIGINT}, - end_time = #{endTime,jdbcType=BIGINT} + end_time = #{endTime,jdbcType=BIGINT}, + integrated = #{integrated,jdbcType=BIT} where id = #{id,jdbcType=VARCHAR} insert into exec_task (id, num, task_name, `status`, case_count, `result`, task_type, resource_id, trigger_mode, - project_id, organization_id, create_time, create_user, start_time, end_time) + project_id, organization_id, create_time, create_user, start_time, end_time, integrated + ) values (#{item.id,jdbcType=VARCHAR}, #{item.num,jdbcType=BIGINT}, #{item.taskName,jdbcType=VARCHAR}, #{item.status,jdbcType=VARCHAR}, #{item.caseCount,jdbcType=BIGINT}, #{item.result,jdbcType=VARCHAR}, #{item.taskType,jdbcType=VARCHAR}, #{item.resourceId,jdbcType=VARCHAR}, #{item.triggerMode,jdbcType=VARCHAR}, #{item.projectId,jdbcType=VARCHAR}, #{item.organizationId,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, - #{item.createUser,jdbcType=VARCHAR}, #{item.startTime,jdbcType=BIGINT}, #{item.endTime,jdbcType=BIGINT} - ) + #{item.createUser,jdbcType=VARCHAR}, #{item.startTime,jdbcType=BIGINT}, #{item.endTime,jdbcType=BIGINT}, + #{item.integrated,jdbcType=BIT}) @@ -436,6 +452,9 @@ #{item.endTime,jdbcType=BIGINT} + + #{item.integrated,jdbcType=BIT} + ) diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseTaskHubService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseTaskHubService.java index 1ef8b8c3a6..a4f7aeb6a0 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseTaskHubService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/BaseTaskHubService.java @@ -2,8 +2,11 @@ package io.metersphere.system.service; import com.github.pagehelper.Page; import com.github.pagehelper.page.PageMethod; +import io.metersphere.project.domain.Project; +import io.metersphere.project.domain.ProjectExample; import io.metersphere.project.domain.ProjectTestResourcePool; import io.metersphere.project.domain.ProjectTestResourcePoolExample; +import io.metersphere.project.mapper.ProjectMapper; import io.metersphere.project.mapper.ProjectTestResourcePoolMapper; import io.metersphere.sdk.constants.ExecStatus; import io.metersphere.sdk.constants.ResultStatus; @@ -73,6 +76,10 @@ public class BaseTaskHubService { private ExecTaskMapper execTaskMapper; @Resource private ExecTaskItemMapper execTaskItemMapper; + @Resource + private ProjectMapper projectMapper; + @Resource + private OrganizationMapper organizationMapper; /** * 系统-获取执行任务列表 @@ -89,7 +96,32 @@ public class BaseTaskHubService { } private List getPage(BasePageRequest request, String orgId, String projectId) { - return extExecTaskMapper.selectList(request, orgId, projectId); + List list = extExecTaskMapper.selectList(request, orgId, projectId); + handleList(list); + return list; + } + + private void handleList(List list) { + if(CollectionUtils.isEmpty(list)){ + return; + } + List projectIds = list.stream().map(TaskHubDTO::getProjectId).distinct().toList(); + List organizationIds = list.stream().map(TaskHubDTO::getProjectId).distinct().toList(); + ProjectExample projectExample = new ProjectExample(); + projectExample.createCriteria().andIdIn(projectIds); + List projectList = projectMapper.selectByExample(projectExample); + Map projectMaps = projectList.stream().collect(Collectors.toMap(Project::getId, Project::getName)); + + OrganizationExample organizationExample = new OrganizationExample(); + organizationExample.createCriteria().andIdIn(organizationIds); + List organizationList = organizationMapper.selectByExample(organizationExample); + Map organizationMaps = organizationList.stream().collect(Collectors.toMap(Organization::getId, Organization::getName)); + + list.forEach(item -> { + item.setProjectName(projectMaps.getOrDefault(item.getProjectId(), StringUtils.EMPTY)); + item.setOrganizationName(organizationMaps.getOrDefault(item.getOrganizationId(), StringUtils.EMPTY)); + }); + } @@ -236,13 +268,13 @@ public class BaseTaskHubService { Map> taskItems = taskItemList.stream().collect(Collectors.groupingBy(ExecTaskItem::getTaskId)); taskItems.forEach((taskId, items) -> { //成功数量 - long successCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ResultStatus.SUCCESS.name(), item.getStatus())).count(); + long successCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ResultStatus.SUCCESS.name(), item.getResult())).count(); //失败数量 - long errorCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ResultStatus.ERROR.name(), item.getStatus())).count(); + long errorCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ResultStatus.ERROR.name(), item.getResult())).count(); //误报数量 - long fakeErrorCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ResultStatus.FAKE_ERROR.name(), item.getStatus())).count(); + long fakeErrorCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ResultStatus.FAKE_ERROR.name(), item.getResult())).count(); //未执行数量 - long pendingCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ExecStatus.PENDING.name(), item.getStatus())).count(); + long pendingCount = items.stream().filter(item -> StringUtils.endsWithIgnoreCase(ExecStatus.PENDING.name(), item.getResult())).count(); TaskStatisticsResponse response = new TaskStatisticsResponse(); response.setId(taskId);