From c31b5a6ff0fa5ad0716c78ea569feabb82bacba5 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Thu, 6 Jun 2024 20:09:40 +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=8E=A5=E5=8F=A3=E6=8A=A5=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/api/domain/ApiReport.java | 17 ++- .../api/domain/ApiReportExample.java | 116 +++++++++++++----- .../api/domain/ApiScenarioReport.java | 17 ++- .../api/domain/ApiScenarioReportExample.java | 116 +++++++++++++----- .../api/mapper/ApiReportMapper.xml | 69 +++++++---- .../api/mapper/ApiScenarioReportMapper.xml | 82 ++++++++----- .../migration/3.0.0/ddl/V3.0.0_13__ga_ddl.sql | 16 ++- .../metersphere/api/dto/report/ReportDTO.java | 4 + .../api/mapper/ExtApiReportMapper.xml | 19 +-- .../api/mapper/ExtApiScenarioMapper.xml | 2 +- .../api/mapper/ExtApiScenarioReportMapper.xml | 17 +-- .../api/mapper/ExtApiTestCaseMapper.xml | 2 +- .../api/service/ApiTaskCenterService.java | 17 ++- .../resources/dml/init_api_definition.sql | 80 ++++++------ .../system/mapper/ExtRealMapper.xml | 38 +++--- .../system/mapper/ExtScheduleMapper.xml | 1 - .../system/service/TaskCenterService.java | 12 +- 17 files changed, 410 insertions(+), 215 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 8b712585e9..307e2fe352 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 @@ -20,10 +20,10 @@ public class ApiReport implements Serializable { @Size(min = 1, max = 300, message = "{api_report.name.length_range}", groups = {Created.class, Updated.class}) private String name; - @Schema(description = "测试计划id", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{api_report.test_plan_id.not_blank}", groups = {Created.class}) - @Size(min = 1, max = 50, message = "{api_report.test_plan_id.length_range}", groups = {Created.class, Updated.class}) - private String testPlanId; + @Schema(description = "测试计划关联用例表ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{api_report.test_plan_case_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{api_report.test_plan_case_id.length_range}", groups = {Created.class, Updated.class}) + private String testPlanCaseId; @Schema(description = "创建人") private String createUser; @@ -144,12 +144,16 @@ public class ApiReport implements Serializable { @Size(min = 1, max = 20, message = "{api_report.exec_status.length_range}", groups = {Created.class, Updated.class}) private String execStatus; + @Schema(description = "是否是测试计划整体执行", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "{api_report.plan.not_blank}", groups = {Created.class}) + private Boolean plan; + private static final long serialVersionUID = 1L; public enum Column { id("id", "id", "VARCHAR", false), name("name", "name", "VARCHAR", true), - testPlanId("test_plan_id", "testPlanId", "VARCHAR", false), + testPlanCaseId("test_plan_case_id", "testPlanCaseId", "VARCHAR", false), createUser("create_user", "createUser", "VARCHAR", false), deleteTime("delete_time", "deleteTime", "BIGINT", false), deleteUser("delete_user", "deleteUser", "VARCHAR", false), @@ -178,7 +182,8 @@ public class ApiReport implements Serializable { requestPassRate("request_pass_rate", "requestPassRate", "VARCHAR", false), assertionPassRate("assertion_pass_rate", "assertionPassRate", "VARCHAR", false), scriptIdentifier("script_identifier", "scriptIdentifier", "VARCHAR", false), - execStatus("exec_status", "execStatus", "VARCHAR", false); + execStatus("exec_status", "execStatus", "VARCHAR", false), + plan("plan", "plan", "BIT", true); 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 cb31934d1b..8aadf7e809 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 @@ -244,73 +244,73 @@ public class ApiReportExample { return (Criteria) this; } - public Criteria andTestPlanIdIsNull() { - addCriterion("test_plan_id is null"); + public Criteria andTestPlanCaseIdIsNull() { + addCriterion("test_plan_case_id is null"); return (Criteria) this; } - public Criteria andTestPlanIdIsNotNull() { - addCriterion("test_plan_id is not null"); + public Criteria andTestPlanCaseIdIsNotNull() { + addCriterion("test_plan_case_id is not null"); return (Criteria) this; } - public Criteria andTestPlanIdEqualTo(String value) { - addCriterion("test_plan_id =", value, "testPlanId"); + public Criteria andTestPlanCaseIdEqualTo(String value) { + addCriterion("test_plan_case_id =", value, "testPlanCaseId"); return (Criteria) this; } - public Criteria andTestPlanIdNotEqualTo(String value) { - addCriterion("test_plan_id <>", value, "testPlanId"); + public Criteria andTestPlanCaseIdNotEqualTo(String value) { + addCriterion("test_plan_case_id <>", value, "testPlanCaseId"); return (Criteria) this; } - public Criteria andTestPlanIdGreaterThan(String value) { - addCriterion("test_plan_id >", value, "testPlanId"); + public Criteria andTestPlanCaseIdGreaterThan(String value) { + addCriterion("test_plan_case_id >", value, "testPlanCaseId"); return (Criteria) this; } - public Criteria andTestPlanIdGreaterThanOrEqualTo(String value) { - addCriterion("test_plan_id >=", value, "testPlanId"); + public Criteria andTestPlanCaseIdGreaterThanOrEqualTo(String value) { + addCriterion("test_plan_case_id >=", value, "testPlanCaseId"); return (Criteria) this; } - public Criteria andTestPlanIdLessThan(String value) { - addCriterion("test_plan_id <", value, "testPlanId"); + public Criteria andTestPlanCaseIdLessThan(String value) { + addCriterion("test_plan_case_id <", value, "testPlanCaseId"); return (Criteria) this; } - public Criteria andTestPlanIdLessThanOrEqualTo(String value) { - addCriterion("test_plan_id <=", value, "testPlanId"); + public Criteria andTestPlanCaseIdLessThanOrEqualTo(String value) { + addCriterion("test_plan_case_id <=", value, "testPlanCaseId"); return (Criteria) this; } - public Criteria andTestPlanIdLike(String value) { - addCriterion("test_plan_id like", value, "testPlanId"); + public Criteria andTestPlanCaseIdLike(String value) { + addCriterion("test_plan_case_id like", value, "testPlanCaseId"); return (Criteria) this; } - public Criteria andTestPlanIdNotLike(String value) { - addCriterion("test_plan_id not like", value, "testPlanId"); + public Criteria andTestPlanCaseIdNotLike(String value) { + addCriterion("test_plan_case_id not like", value, "testPlanCaseId"); return (Criteria) this; } - public Criteria andTestPlanIdIn(List values) { - addCriterion("test_plan_id in", values, "testPlanId"); + public Criteria andTestPlanCaseIdIn(List values) { + addCriterion("test_plan_case_id in", values, "testPlanCaseId"); return (Criteria) this; } - public Criteria andTestPlanIdNotIn(List values) { - addCriterion("test_plan_id not in", values, "testPlanId"); + public Criteria andTestPlanCaseIdNotIn(List values) { + addCriterion("test_plan_case_id not in", values, "testPlanCaseId"); return (Criteria) this; } - public Criteria andTestPlanIdBetween(String value1, String value2) { - addCriterion("test_plan_id between", value1, value2, "testPlanId"); + public Criteria andTestPlanCaseIdBetween(String value1, String value2) { + addCriterion("test_plan_case_id between", value1, value2, "testPlanCaseId"); return (Criteria) this; } - public Criteria andTestPlanIdNotBetween(String value1, String value2) { - addCriterion("test_plan_id not between", value1, value2, "testPlanId"); + public Criteria andTestPlanCaseIdNotBetween(String value1, String value2) { + addCriterion("test_plan_case_id not between", value1, value2, "testPlanCaseId"); return (Criteria) this; } @@ -2213,6 +2213,66 @@ public class ApiReportExample { addCriterion("exec_status not between", value1, value2, "execStatus"); return (Criteria) this; } + + public Criteria andPlanIsNull() { + addCriterion("`plan` is null"); + return (Criteria) this; + } + + public Criteria andPlanIsNotNull() { + addCriterion("`plan` is not null"); + return (Criteria) this; + } + + public Criteria andPlanEqualTo(Boolean value) { + addCriterion("`plan` =", value, "plan"); + return (Criteria) this; + } + + public Criteria andPlanNotEqualTo(Boolean value) { + addCriterion("`plan` <>", value, "plan"); + return (Criteria) this; + } + + public Criteria andPlanGreaterThan(Boolean value) { + addCriterion("`plan` >", value, "plan"); + return (Criteria) this; + } + + public Criteria andPlanGreaterThanOrEqualTo(Boolean value) { + addCriterion("`plan` >=", value, "plan"); + return (Criteria) this; + } + + public Criteria andPlanLessThan(Boolean value) { + addCriterion("`plan` <", value, "plan"); + return (Criteria) this; + } + + public Criteria andPlanLessThanOrEqualTo(Boolean value) { + addCriterion("`plan` <=", value, "plan"); + return (Criteria) this; + } + + public Criteria andPlanIn(List values) { + addCriterion("`plan` in", values, "plan"); + return (Criteria) this; + } + + public Criteria andPlanNotIn(List values) { + addCriterion("`plan` not in", values, "plan"); + return (Criteria) this; + } + + public Criteria andPlanBetween(Boolean value1, Boolean value2) { + addCriterion("`plan` between", value1, value2, "plan"); + return (Criteria) this; + } + + public Criteria andPlanNotBetween(Boolean value1, Boolean value2) { + addCriterion("`plan` not between", value1, value2, "plan"); + 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 543fbdc4d2..00b6de4557 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 @@ -20,10 +20,10 @@ public class ApiScenarioReport implements Serializable { @Size(min = 1, max = 300, message = "{api_scenario_report.name.length_range}", groups = {Created.class, Updated.class}) private String name; - @Schema(description = "测试计划id", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{api_scenario_report.test_plan_id.not_blank}", groups = {Created.class}) - @Size(min = 1, max = 50, message = "{api_scenario_report.test_plan_id.length_range}", groups = {Created.class, Updated.class}) - private String testPlanId; + @Schema(description = "测试计划关联场景表ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{api_scenario_report.test_plan_scenario_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{api_scenario_report.test_plan_scenario_id.length_range}", groups = {Created.class, Updated.class}) + private String testPlanScenarioId; @Schema(description = "创建人") private String createUser; @@ -147,12 +147,16 @@ public class ApiScenarioReport implements Serializable { @Size(min = 1, max = 20, message = "{api_scenario_report.exec_status.length_range}", groups = {Created.class, Updated.class}) private String execStatus; + @Schema(description = "是否是测试计划整体执行", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "{api_scenario_report.plan.not_blank}", groups = {Created.class}) + private Boolean plan; + private static final long serialVersionUID = 1L; public enum Column { id("id", "id", "VARCHAR", false), name("name", "name", "VARCHAR", true), - testPlanId("test_plan_id", "testPlanId", "VARCHAR", false), + testPlanScenarioId("test_plan_scenario_id", "testPlanScenarioId", "VARCHAR", false), createUser("create_user", "createUser", "VARCHAR", false), deleteTime("delete_time", "deleteTime", "BIGINT", false), deleteUser("delete_user", "deleteUser", "VARCHAR", false), @@ -182,7 +186,8 @@ public class ApiScenarioReport implements Serializable { assertionPassRate("assertion_pass_rate", "assertionPassRate", "VARCHAR", false), scriptIdentifier("script_identifier", "scriptIdentifier", "VARCHAR", false), waitingTime("waiting_time", "waitingTime", "BIGINT", false), - execStatus("exec_status", "execStatus", "VARCHAR", false); + execStatus("exec_status", "execStatus", "VARCHAR", false), + plan("plan", "plan", "BIT", true); 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 e4ccdbdb5c..bb035ff763 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 @@ -244,73 +244,73 @@ public class ApiScenarioReportExample { return (Criteria) this; } - public Criteria andTestPlanIdIsNull() { - addCriterion("test_plan_id is null"); + public Criteria andTestPlanScenarioIdIsNull() { + addCriterion("test_plan_scenario_id is null"); return (Criteria) this; } - public Criteria andTestPlanIdIsNotNull() { - addCriterion("test_plan_id is not null"); + public Criteria andTestPlanScenarioIdIsNotNull() { + addCriterion("test_plan_scenario_id is not null"); return (Criteria) this; } - public Criteria andTestPlanIdEqualTo(String value) { - addCriterion("test_plan_id =", value, "testPlanId"); + public Criteria andTestPlanScenarioIdEqualTo(String value) { + addCriterion("test_plan_scenario_id =", value, "testPlanScenarioId"); return (Criteria) this; } - public Criteria andTestPlanIdNotEqualTo(String value) { - addCriterion("test_plan_id <>", value, "testPlanId"); + public Criteria andTestPlanScenarioIdNotEqualTo(String value) { + addCriterion("test_plan_scenario_id <>", value, "testPlanScenarioId"); return (Criteria) this; } - public Criteria andTestPlanIdGreaterThan(String value) { - addCriterion("test_plan_id >", value, "testPlanId"); + public Criteria andTestPlanScenarioIdGreaterThan(String value) { + addCriterion("test_plan_scenario_id >", value, "testPlanScenarioId"); return (Criteria) this; } - public Criteria andTestPlanIdGreaterThanOrEqualTo(String value) { - addCriterion("test_plan_id >=", value, "testPlanId"); + public Criteria andTestPlanScenarioIdGreaterThanOrEqualTo(String value) { + addCriterion("test_plan_scenario_id >=", value, "testPlanScenarioId"); return (Criteria) this; } - public Criteria andTestPlanIdLessThan(String value) { - addCriterion("test_plan_id <", value, "testPlanId"); + public Criteria andTestPlanScenarioIdLessThan(String value) { + addCriterion("test_plan_scenario_id <", value, "testPlanScenarioId"); return (Criteria) this; } - public Criteria andTestPlanIdLessThanOrEqualTo(String value) { - addCriterion("test_plan_id <=", value, "testPlanId"); + public Criteria andTestPlanScenarioIdLessThanOrEqualTo(String value) { + addCriterion("test_plan_scenario_id <=", value, "testPlanScenarioId"); return (Criteria) this; } - public Criteria andTestPlanIdLike(String value) { - addCriterion("test_plan_id like", value, "testPlanId"); + public Criteria andTestPlanScenarioIdLike(String value) { + addCriterion("test_plan_scenario_id like", value, "testPlanScenarioId"); return (Criteria) this; } - public Criteria andTestPlanIdNotLike(String value) { - addCriterion("test_plan_id not like", value, "testPlanId"); + public Criteria andTestPlanScenarioIdNotLike(String value) { + addCriterion("test_plan_scenario_id not like", value, "testPlanScenarioId"); return (Criteria) this; } - public Criteria andTestPlanIdIn(List values) { - addCriterion("test_plan_id in", values, "testPlanId"); + public Criteria andTestPlanScenarioIdIn(List values) { + addCriterion("test_plan_scenario_id in", values, "testPlanScenarioId"); return (Criteria) this; } - public Criteria andTestPlanIdNotIn(List values) { - addCriterion("test_plan_id not in", values, "testPlanId"); + public Criteria andTestPlanScenarioIdNotIn(List values) { + addCriterion("test_plan_scenario_id not in", values, "testPlanScenarioId"); return (Criteria) this; } - public Criteria andTestPlanIdBetween(String value1, String value2) { - addCriterion("test_plan_id between", value1, value2, "testPlanId"); + public Criteria andTestPlanScenarioIdBetween(String value1, String value2) { + addCriterion("test_plan_scenario_id between", value1, value2, "testPlanScenarioId"); return (Criteria) this; } - public Criteria andTestPlanIdNotBetween(String value1, String value2) { - addCriterion("test_plan_id not between", value1, value2, "testPlanId"); + public Criteria andTestPlanScenarioIdNotBetween(String value1, String value2) { + addCriterion("test_plan_scenario_id not between", value1, value2, "testPlanScenarioId"); return (Criteria) this; } @@ -2273,6 +2273,66 @@ public class ApiScenarioReportExample { addCriterion("exec_status not between", value1, value2, "execStatus"); return (Criteria) this; } + + public Criteria andPlanIsNull() { + addCriterion("`plan` is null"); + return (Criteria) this; + } + + public Criteria andPlanIsNotNull() { + addCriterion("`plan` is not null"); + return (Criteria) this; + } + + public Criteria andPlanEqualTo(Boolean value) { + addCriterion("`plan` =", value, "plan"); + return (Criteria) this; + } + + public Criteria andPlanNotEqualTo(Boolean value) { + addCriterion("`plan` <>", value, "plan"); + return (Criteria) this; + } + + public Criteria andPlanGreaterThan(Boolean value) { + addCriterion("`plan` >", value, "plan"); + return (Criteria) this; + } + + public Criteria andPlanGreaterThanOrEqualTo(Boolean value) { + addCriterion("`plan` >=", value, "plan"); + return (Criteria) this; + } + + public Criteria andPlanLessThan(Boolean value) { + addCriterion("`plan` <", value, "plan"); + return (Criteria) this; + } + + public Criteria andPlanLessThanOrEqualTo(Boolean value) { + addCriterion("`plan` <=", value, "plan"); + return (Criteria) this; + } + + public Criteria andPlanIn(List values) { + addCriterion("`plan` in", values, "plan"); + return (Criteria) this; + } + + public Criteria andPlanNotIn(List values) { + addCriterion("`plan` not in", values, "plan"); + return (Criteria) this; + } + + public Criteria andPlanBetween(Boolean value1, Boolean value2) { + addCriterion("`plan` between", value1, value2, "plan"); + return (Criteria) this; + } + + public Criteria andPlanNotBetween(Boolean value1, Boolean value2) { + addCriterion("`plan` not between", value1, value2, "plan"); + 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 9b494d6c57..9878b86225 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 @@ -4,7 +4,7 @@ - + @@ -34,6 +34,7 @@ + @@ -94,12 +95,12 @@ - id, `name`, test_plan_id, create_user, delete_time, delete_user, deleted, update_user, + id, `name`, test_plan_case_id, create_user, delete_time, delete_user, deleted, update_user, update_time, start_time, end_time, request_duration, `status`, trigger_mode, 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, - exec_status + exec_status, `plan` @@ -371,8 +378,8 @@ `name` = #{record.name,jdbcType=VARCHAR}, - - test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, + + test_plan_case_id = #{record.testPlanCaseId,jdbcType=VARCHAR}, create_user = #{record.createUser,jdbcType=VARCHAR}, @@ -461,6 +468,9 @@ exec_status = #{record.execStatus,jdbcType=VARCHAR}, + + `plan` = #{record.plan,jdbcType=BIT}, + @@ -470,7 +480,7 @@ update api_report set id = #{record.id,jdbcType=VARCHAR}, `name` = #{record.name,jdbcType=VARCHAR}, - test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, + test_plan_case_id = #{record.testPlanCaseId,jdbcType=VARCHAR}, create_user = #{record.createUser,jdbcType=VARCHAR}, delete_time = #{record.deleteTime,jdbcType=BIGINT}, delete_user = #{record.deleteUser,jdbcType=VARCHAR}, @@ -499,7 +509,8 @@ request_pass_rate = #{record.requestPassRate,jdbcType=VARCHAR}, assertion_pass_rate = #{record.assertionPassRate,jdbcType=VARCHAR}, script_identifier = #{record.scriptIdentifier,jdbcType=VARCHAR}, - exec_status = #{record.execStatus,jdbcType=VARCHAR} + exec_status = #{record.execStatus,jdbcType=VARCHAR}, + `plan` = #{record.plan,jdbcType=BIT} @@ -510,8 +521,8 @@ `name` = #{name,jdbcType=VARCHAR}, - - test_plan_id = #{testPlanId,jdbcType=VARCHAR}, + + test_plan_case_id = #{testPlanCaseId,jdbcType=VARCHAR}, create_user = #{createUser,jdbcType=VARCHAR}, @@ -600,13 +611,16 @@ exec_status = #{execStatus,jdbcType=VARCHAR}, + + `plan` = #{plan,jdbcType=BIT}, + where id = #{id,jdbcType=VARCHAR} update api_report set `name` = #{name,jdbcType=VARCHAR}, - test_plan_id = #{testPlanId,jdbcType=VARCHAR}, + test_plan_case_id = #{testPlanCaseId,jdbcType=VARCHAR}, create_user = #{createUser,jdbcType=VARCHAR}, delete_time = #{deleteTime,jdbcType=BIGINT}, delete_user = #{deleteUser,jdbcType=VARCHAR}, @@ -635,20 +649,21 @@ request_pass_rate = #{requestPassRate,jdbcType=VARCHAR}, assertion_pass_rate = #{assertionPassRate,jdbcType=VARCHAR}, script_identifier = #{scriptIdentifier,jdbcType=VARCHAR}, - exec_status = #{execStatus,jdbcType=VARCHAR} + exec_status = #{execStatus,jdbcType=VARCHAR}, + `plan` = #{plan,jdbcType=BIT} where id = #{id,jdbcType=VARCHAR} insert into api_report - (id, `name`, test_plan_id, create_user, delete_time, delete_user, deleted, update_user, + (id, `name`, test_plan_case_id, create_user, delete_time, delete_user, deleted, update_user, update_time, start_time, end_time, request_duration, `status`, trigger_mode, 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, exec_status) + script_identifier, exec_status, `plan`) values - (#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.testPlanId,jdbcType=VARCHAR}, + (#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.testPlanCaseId,jdbcType=VARCHAR}, #{item.createUser,jdbcType=VARCHAR}, #{item.deleteTime,jdbcType=BIGINT}, #{item.deleteUser,jdbcType=VARCHAR}, #{item.deleted,jdbcType=BIT}, #{item.updateUser,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=BIGINT}, #{item.startTime,jdbcType=BIGINT}, #{item.endTime,jdbcType=BIGINT}, #{item.requestDuration,jdbcType=BIGINT}, @@ -659,7 +674,8 @@ #{item.assertionSuccessCount,jdbcType=BIGINT}, #{item.requestErrorRate,jdbcType=VARCHAR}, #{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.scriptIdentifier,jdbcType=VARCHAR}, #{item.execStatus,jdbcType=VARCHAR}, + #{item.plan,jdbcType=BIT}) @@ -678,8 +694,8 @@ #{item.name,jdbcType=VARCHAR} - - #{item.testPlanId,jdbcType=VARCHAR} + + #{item.testPlanCaseId,jdbcType=VARCHAR} #{item.createUser,jdbcType=VARCHAR} @@ -768,6 +784,9 @@ #{item.execStatus,jdbcType=VARCHAR} + + #{item.plan,jdbcType=BIT} + ) 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 3523566b19..26e3deca91 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 @@ -4,7 +4,7 @@ - + @@ -35,6 +35,7 @@ + @@ -95,12 +96,12 @@ - id, `name`, test_plan_id, create_user, delete_time, delete_user, deleted, update_user, - update_time, start_time, end_time, request_duration, `status`, trigger_mode, 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 + id, `name`, test_plan_scenario_id, create_user, delete_time, delete_user, deleted, + update_user, update_time, start_time, end_time, request_duration, `status`, trigger_mode, + 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` @@ -378,8 +387,8 @@ `name` = #{record.name,jdbcType=VARCHAR}, - - test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, + + test_plan_scenario_id = #{record.testPlanScenarioId,jdbcType=VARCHAR}, create_user = #{record.createUser,jdbcType=VARCHAR}, @@ -471,6 +480,9 @@ exec_status = #{record.execStatus,jdbcType=VARCHAR}, + + `plan` = #{record.plan,jdbcType=BIT}, + @@ -480,7 +492,7 @@ update api_scenario_report set id = #{record.id,jdbcType=VARCHAR}, `name` = #{record.name,jdbcType=VARCHAR}, - test_plan_id = #{record.testPlanId,jdbcType=VARCHAR}, + test_plan_scenario_id = #{record.testPlanScenarioId,jdbcType=VARCHAR}, create_user = #{record.createUser,jdbcType=VARCHAR}, delete_time = #{record.deleteTime,jdbcType=BIGINT}, delete_user = #{record.deleteUser,jdbcType=VARCHAR}, @@ -510,7 +522,8 @@ assertion_pass_rate = #{record.assertionPassRate,jdbcType=VARCHAR}, script_identifier = #{record.scriptIdentifier,jdbcType=VARCHAR}, waiting_time = #{record.waitingTime,jdbcType=BIGINT}, - exec_status = #{record.execStatus,jdbcType=VARCHAR} + exec_status = #{record.execStatus,jdbcType=VARCHAR}, + `plan` = #{record.plan,jdbcType=BIT} @@ -521,8 +534,8 @@ `name` = #{name,jdbcType=VARCHAR}, - - test_plan_id = #{testPlanId,jdbcType=VARCHAR}, + + test_plan_scenario_id = #{testPlanScenarioId,jdbcType=VARCHAR}, create_user = #{createUser,jdbcType=VARCHAR}, @@ -614,13 +627,16 @@ exec_status = #{execStatus,jdbcType=VARCHAR}, + + `plan` = #{plan,jdbcType=BIT}, + where id = #{id,jdbcType=VARCHAR} update api_scenario_report set `name` = #{name,jdbcType=VARCHAR}, - test_plan_id = #{testPlanId,jdbcType=VARCHAR}, + test_plan_scenario_id = #{testPlanScenarioId,jdbcType=VARCHAR}, create_user = #{createUser,jdbcType=VARCHAR}, delete_time = #{deleteTime,jdbcType=BIGINT}, delete_user = #{deleteUser,jdbcType=VARCHAR}, @@ -650,20 +666,21 @@ assertion_pass_rate = #{assertionPassRate,jdbcType=VARCHAR}, script_identifier = #{scriptIdentifier,jdbcType=VARCHAR}, waiting_time = #{waitingTime,jdbcType=BIGINT}, - exec_status = #{execStatus,jdbcType=VARCHAR} + exec_status = #{execStatus,jdbcType=VARCHAR}, + `plan` = #{plan,jdbcType=BIT} where id = #{id,jdbcType=VARCHAR} insert into api_scenario_report - (id, `name`, test_plan_id, create_user, delete_time, delete_user, deleted, update_user, - update_time, start_time, end_time, request_duration, `status`, trigger_mode, run_mode, - pool_id, integrated, project_id, environment_id, error_count, fake_error_count, + (id, `name`, test_plan_scenario_id, create_user, delete_time, delete_user, deleted, + update_user, update_time, start_time, end_time, request_duration, `status`, trigger_mode, + 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) + script_identifier, waiting_time, exec_status, `plan`) values - (#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.testPlanId,jdbcType=VARCHAR}, + (#{item.id,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, #{item.testPlanScenarioId,jdbcType=VARCHAR}, #{item.createUser,jdbcType=VARCHAR}, #{item.deleteTime,jdbcType=BIGINT}, #{item.deleteUser,jdbcType=VARCHAR}, #{item.deleted,jdbcType=BIT}, #{item.updateUser,jdbcType=VARCHAR}, #{item.updateTime,jdbcType=BIGINT}, #{item.startTime,jdbcType=BIGINT}, #{item.endTime,jdbcType=BIGINT}, #{item.requestDuration,jdbcType=BIGINT}, @@ -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.waitingTime,jdbcType=BIGINT}, - #{item.execStatus,jdbcType=VARCHAR}) + #{item.execStatus,jdbcType=VARCHAR}, #{item.plan,jdbcType=BIT}) @@ -694,8 +711,8 @@ #{item.name,jdbcType=VARCHAR} - - #{item.testPlanId,jdbcType=VARCHAR} + + #{item.testPlanScenarioId,jdbcType=VARCHAR} #{item.createUser,jdbcType=VARCHAR} @@ -787,6 +804,9 @@ #{item.execStatus,jdbcType=VARCHAR} + + #{item.plan,jdbcType=BIT} + ) diff --git a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_13__ga_ddl.sql b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_13__ga_ddl.sql index db5ce22ccb..02c19da8ea 100644 --- a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_13__ga_ddl.sql +++ b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_13__ga_ddl.sql @@ -133,9 +133,6 @@ ALTER TABLE api_scenario_report ADD COLUMN exec_status VARCHAR(20) NOT NULL DEF ALTER TABLE api_scenario_report ALTER COLUMN status set DEFAULT '-'; CREATE INDEX idx_exec_status ON api_scenario_report(exec_status); --- set innodb lock wait timeout to default -SET SESSION innodb_lock_wait_timeout = DEFAULT; - -- 测试计划队列表 CREATE TABLE IF NOT EXISTS test_plan_execution_queue ( @@ -152,5 +149,18 @@ CREATE TABLE IF NOT EXISTS test_plan_execution_queue DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '测试计划执行队列'; +ALTER TABLE api_report CHANGE COLUMN `test_plan_id` `test_plan_case_id` VARCHAR(50) NOT NULL DEFAULT 'NONE' COMMENT '测试计划关联用例表ID'; +ALTER TABLE api_report DROP INDEX idx_test_plan_id; +CREATE INDEX idx_test_plan_case_id ON api_report(test_plan_case_id); +ALTER TABLE api_report ADD COLUMN `plan` BIT(1) NOT NULL DEFAULT 0 COMMENT '是否是测试计划整体执行'; +CREATE INDEX idx_plan ON api_report(`plan`); +ALTER TABLE api_scenario_report CHANGE COLUMN `test_plan_id` `test_plan_scenario_id` VARCHAR(50) NOT NULL DEFAULT 'NONE' COMMENT '测试计划关联场景表ID'; +ALTER TABLE api_scenario_report DROP INDEX idx_test_plan_id; +CREATE INDEX idx_test_plan_scenario_id ON api_scenario_report(test_plan_scenario_id); +ALTER TABLE api_scenario_report ADD COLUMN `plan` BIT(1) NOT NULL DEFAULT 0 COMMENT '是否是测试计划整体执行'; +CREATE INDEX idx_plan ON api_scenario_report(`plan`); +-- set innodb lock wait timeout to default +SET SESSION innodb_lock_wait_timeout = DEFAULT; + diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/report/ReportDTO.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/report/ReportDTO.java index 8306ef6c34..90822ca3b3 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/report/ReportDTO.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/report/ReportDTO.java @@ -23,6 +23,10 @@ public class ReportDTO implements Serializable { private String organizationId; @Schema(description = "是否是集成报告") private Boolean integrated; + @Schema(description = "资源id") + private String resourceId; + @Schema(description = "测试计划id") + private String testPlanId; } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiReportMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiReportMapper.xml index 5881701020..c2d5d62ddd 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiReportMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiReportMapper.xml @@ -28,7 +28,7 @@ select ar.* from api_report ar where ar.deleted = false - and ar.test_plan_id = 'NONE' + and ar.test_plan_case_id = 'NONE' and ( ar.name like concat('%', #{request.keyword},'%') @@ -45,7 +45,7 @@ select ar.id from api_report ar where ar.deleted = false - and ar.test_plan_id = 'NONE' + and ar.test_plan_case_id = 'NONE' and ( ar.name like concat('%', #{request.condition.keyword},'%') @@ -62,7 +62,7 @@ select api_report.id, api_report.name - from api_report where api_report.test_plan_id = 'NONE' + from api_report where api_report.test_plan_case_id = 'NONE' and api_report.id in #{id} @@ -97,7 +97,7 @@ count(api_report.id) from api_report inner join api_report_step on api_report_step.report_id = api_report.id - where api_report.test_plan_id = 'NONE' + where api_report.test_plan_case_id = 'NONE' and api_report.start_time <= #{time} and api_report.project_id = #{projectId} @@ -106,7 +106,7 @@ api_report.id from api_report inner join api_report_step on api_report_step.report_id = api_report.id - where api_report.test_plan_id = 'NONE' + where api_report.test_plan_case_id = 'NONE' and api_report.start_time <= #{time} and api_report.project_id = #{projectId} limit 500; @@ -177,6 +177,7 @@ ar.create_user AS operationName, ar.trigger_mode, ar.start_time, + ar.plan, project.organization_id, if(ar.integrated, ar.id, c.num) AS resourceNum, @@ -192,7 +193,7 @@ left join project on ar.project_id = project.id where ar.start_time BETWEEN #{startTime} AND #{endTime} - + and ar.plan = 0 and ar.project_id IN @@ -211,12 +212,12 @@ @@ -99,18 +99,19 @@ api_scenario_report.id from api_scenario_report inner join api_scenario_report_step on api_scenario_report.id = api_scenario_report_step.report_id - where api_scenario_report.test_plan_id = 'NONE' + where api_scenario_report.test_plan_scenario_id = 'NONE' and api_scenario_report.start_time <= #{time} and api_scenario_report.project_id = #{projectId} limit 500 \ No newline at end of file diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtScheduleMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtScheduleMapper.xml index 2a8f5a4aac..6000d9078a 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtScheduleMapper.xml +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtScheduleMapper.xml @@ -237,7 +237,6 @@ #{id} - and project_id in diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/TaskCenterService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/TaskCenterService.java index 61aa402a35..9e0dbaf634 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/TaskCenterService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/TaskCenterService.java @@ -355,9 +355,7 @@ public class TaskCenterService { } public int getSystemScheduleTotal() { - List projectList = getSystemProjectList(); - List projectIds = projectList.stream().map(OptionDTO::getId).toList(); - return extScheduleMapper.countByProjectIds(projectIds); + return extScheduleMapper.countByProjectIds(new ArrayList<>()); } public int getOrgScheduleTotal(String currentOrganizationId) { @@ -374,11 +372,9 @@ public class TaskCenterService { } public int getSystemRealTotal() { - List projectList = getSystemProjectList(); - List projectIds = projectList.stream().map(OptionDTO::getId).toList(); - int apiTestCaseTotal = extRealMapper.caseReportCountByProjectIds(projectIds, DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime()); - int apiScenarioTotal = extRealMapper.scenarioReportCountByProjectIds(projectIds, DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime()); - int testPlanTotal = extRealMapper.testPlanReportCountByProjectIds(projectIds, DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime()); + int apiTestCaseTotal = extRealMapper.caseReportCountByProjectIds(new ArrayList<>(), DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime()); + int apiScenarioTotal = extRealMapper.scenarioReportCountByProjectIds(new ArrayList<>(), DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime()); + int testPlanTotal = extRealMapper.testPlanReportCountByProjectIds(new ArrayList<>(), DateUtils.getDailyStartTime(), DateUtils.getDailyEndTime()); return apiTestCaseTotal + apiScenarioTotal + testPlanTotal; }