diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index e4afaf8998..8e60778994 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -143,7 +143,7 @@ public class ApiScenarioReportService { if (report != null) { report.setId(report.getId()); report.setName(report.getScenarioName() + "-" + DateUtils.getTimeStr(System.currentTimeMillis())); - report.setCreateTime(startTime); + report.setEndTime(System.currentTimeMillis()); report.setUpdateTime(startTime); String status = test.getError() == 0 ? "Success" : "Error"; report.setStatus(status); @@ -165,7 +165,7 @@ public class ApiScenarioReportService { report.setScenarioId(test.getScenarioId()); report.setTriggerMode(test.getTriggerMode()); report.setDescription(test.getDescription()); - report.setCreateTime(System.currentTimeMillis()); + report.setEndTime(System.currentTimeMillis()); report.setUpdateTime(System.currentTimeMillis()); report.setStatus(test.getStatus()); report.setUserId(test.getUserId()); @@ -235,6 +235,7 @@ public class ApiScenarioReportService { if (StringUtils.isNotEmpty(report.getTriggerMode()) && report.getTriggerMode().equals("CASE")) { report.setTriggerMode(TriggerMode.MANUAL.name()); } + report.setEndTime(System.currentTimeMillis()); apiScenarioReportMapper.updateByPrimaryKeySelective(report); if (scenarioResult.getError() > 0) { testPlanApiScenario.setLastResult(ScenarioStatus.Fail.name()); @@ -244,8 +245,9 @@ public class ApiScenarioReportService { String passRate = new DecimalFormat("0%").format((float) scenarioResult.getSuccess() / (scenarioResult.getSuccess() + scenarioResult.getError())); testPlanApiScenario.setPassRate(passRate); testPlanApiScenario.setReportId(report.getId()); - testPlanApiScenario.setUpdateTime(report.getCreateTime()); report.setTestPlanScenarioId(testPlanApiScenario.getId()); + report.setEndTime(System.currentTimeMillis()); + testPlanApiScenario.setUpdateTime(report.getCreateTime()); testPlanApiScenarioMapper.updateByPrimaryKeySelective(testPlanApiScenario); // 更新场景状态 @@ -259,10 +261,10 @@ public class ApiScenarioReportService { scenario.setPassRate(passRate); scenario.setReportId(report.getId()); int executeTimes = 0; - if(scenario.getExecuteTimes() != null){ + if (scenario.getExecuteTimes() != null) { executeTimes = scenario.getExecuteTimes().intValue(); } - scenario.setExecuteTimes(executeTimes+1); + scenario.setExecuteTimes(executeTimes + 1); apiScenarioMapper.updateByPrimaryKey(scenario); } @@ -319,6 +321,7 @@ public class ApiScenarioReportService { TestPlanApiScenario testPlanApiScenario = testPlanApiScenarioMapper.selectByPrimaryKey(planScenarioId); report.setScenarioId(testPlanApiScenario.getApiScenarioId()); report.setTestPlanScenarioId(planScenarioId); + report.setEndTime(System.currentTimeMillis()); apiScenarioReportMapper.updateByPrimaryKeySelective(report); @@ -343,6 +346,7 @@ public class ApiScenarioReportService { apiScenarioReportDetailMapper.insert(detail); testPlanApiScenario.setReportId(report.getId()); + report.setEndTime(System.currentTimeMillis()); testPlanApiScenario.setUpdateTime(System.currentTimeMillis()); testPlanApiScenarioMapper.updateByPrimaryKeySelective(testPlanApiScenario); scenarioIdList.add(testPlanApiScenario.getApiScenarioId()); @@ -359,10 +363,10 @@ public class ApiScenarioReportService { scenario.setPassRate(passRate); scenario.setReportId(report.getId()); int executeTimes = 0; - if(scenario.getExecuteTimes() != null){ + if (scenario.getExecuteTimes() != null) { executeTimes = scenario.getExecuteTimes().intValue(); } - scenario.setExecuteTimes(executeTimes+1); + scenario.setExecuteTimes(executeTimes + 1); apiScenarioMapper.updateByPrimaryKey(scenario); } @@ -403,6 +407,7 @@ public class ApiScenarioReportService { if (CollectionUtils.isNotEmpty(reportList)) { reportList.forEach(report -> { report.setUpdateTime(System.currentTimeMillis()); + report.setEndTime(System.currentTimeMillis()); String status = "Error"; report.setStatus(status); scenarioReportMapper.updateByPrimaryKeySelective(report); @@ -464,6 +469,7 @@ public class ApiScenarioReportService { if (StringUtils.isNotEmpty(report.getTriggerMode()) && report.getTriggerMode().equals("CASE")) { report.setTriggerMode(TriggerMode.MANUAL.name()); } + report.setEndTime(System.currentTimeMillis()); apiScenarioReportMapper.updateByPrimaryKey(report); ApiScenarioReportDetail detail = new ApiScenarioReportDetail(); @@ -557,10 +563,10 @@ public class ApiScenarioReportService { scenario.setPassRate(passRate); scenario.setReportId(report.getId()); int executeTimes = 0; - if(scenario.getExecuteTimes() != null){ + if (scenario.getExecuteTimes() != null) { executeTimes = scenario.getExecuteTimes().intValue(); } - scenario.setExecuteTimes(executeTimes+1); + scenario.setExecuteTimes(executeTimes + 1); apiScenarioMapper.updateByPrimaryKey(scenario); } diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReport.java b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReport.java index 38a957c6c7..2119c627b7 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReport.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReport.java @@ -1,8 +1,9 @@ package io.metersphere.base.domain; -import java.io.Serializable; import lombok.Data; +import java.io.Serializable; + @Data public class ApiScenarioReport implements Serializable { private String id; @@ -35,5 +36,7 @@ public class ApiScenarioReport implements Serializable { private String testPlanScenarioId; + private Long endTime; + private static final long serialVersionUID = 1L; } diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportExample.java b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportExample.java index 8ad0c2f032..c2c3a59059 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioReportExample.java @@ -993,6 +993,66 @@ public class ApiScenarioReportExample { addCriterion("actuator not between", value1, value2, "actuator"); return (Criteria) this; } + + public Criteria andEndTimeIsNull() { + addCriterion("end_time is null"); + return (Criteria) this; + } + + public Criteria andEndTimeIsNotNull() { + addCriterion("end_time is not null"); + return (Criteria) this; + } + + public Criteria andEndTimeEqualTo(Long value) { + addCriterion("end_time =", value, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeNotEqualTo(Long value) { + addCriterion("end_time <>", value, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeGreaterThan(Long value) { + addCriterion("end_time >", value, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeGreaterThanOrEqualTo(Long value) { + addCriterion("end_time >=", value, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeLessThan(Long value) { + addCriterion("end_time <", value, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeLessThanOrEqualTo(Long value) { + addCriterion("end_time <=", value, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeIn(List values) { + addCriterion("end_time in", values, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeNotIn(List values) { + addCriterion("end_time not in", values, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeBetween(Long value1, Long value2) { + addCriterion("end_time between", value1, value2, "endTime"); + return (Criteria) this; + } + + public Criteria andEndTimeNotBetween(Long value1, Long value2) { + addCriterion("end_time not between", value1, value2, "endTime"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportMapper.xml index 251545c65c..502ff02d99 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioReportMapper.xml @@ -15,6 +15,7 @@ + @@ -79,7 +80,7 @@ id, project_id, `name`, create_time, update_time, `status`, user_id, trigger_mode, - execute_type, scenario_name, scenario_id, create_user, actuator + execute_type, scenario_name, scenario_id, create_user, actuator, end_time description @@ -137,12 +138,14 @@ create_time, update_time, `status`, user_id, trigger_mode, execute_type, scenario_name, scenario_id, create_user, - actuator, description) + actuator, end_time, description + ) values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{triggerMode,jdbcType=VARCHAR}, #{executeType,jdbcType=VARCHAR}, #{scenarioName,jdbcType=VARCHAR}, #{scenarioId,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, - #{actuator,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR}) + #{actuator,jdbcType=VARCHAR}, #{endTime,jdbcType=BIGINT}, #{description,jdbcType=LONGVARCHAR} + ) insert into api_scenario_report @@ -186,6 +189,9 @@ actuator, + + end_time, + description, @@ -230,6 +236,9 @@ #{actuator,jdbcType=VARCHAR}, + + #{endTime,jdbcType=BIGINT}, + #{description,jdbcType=LONGVARCHAR}, @@ -283,6 +292,9 @@ actuator = #{record.actuator,jdbcType=VARCHAR}, + + end_time = #{record.endTime,jdbcType=BIGINT}, + description = #{record.description,jdbcType=LONGVARCHAR}, @@ -306,6 +318,7 @@ scenario_id = #{record.scenarioId,jdbcType=VARCHAR}, create_user = #{record.createUser,jdbcType=VARCHAR}, actuator = #{record.actuator,jdbcType=VARCHAR}, + end_time = #{record.endTime,jdbcType=BIGINT}, description = #{record.description,jdbcType=LONGVARCHAR} @@ -325,7 +338,8 @@ scenario_name = #{record.scenarioName,jdbcType=VARCHAR}, scenario_id = #{record.scenarioId,jdbcType=VARCHAR}, create_user = #{record.createUser,jdbcType=VARCHAR}, - actuator = #{record.actuator,jdbcType=VARCHAR} + actuator = #{record.actuator,jdbcType=VARCHAR}, + end_time = #{record.endTime,jdbcType=BIGINT} @@ -369,6 +383,9 @@ actuator = #{actuator,jdbcType=VARCHAR}, + + end_time = #{endTime,jdbcType=BIGINT}, + description = #{description,jdbcType=LONGVARCHAR}, @@ -389,6 +406,7 @@ scenario_id = #{scenarioId,jdbcType=VARCHAR}, create_user = #{createUser,jdbcType=VARCHAR}, actuator = #{actuator,jdbcType=VARCHAR}, + end_time = #{endTime,jdbcType=BIGINT}, description = #{description,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=VARCHAR} @@ -405,7 +423,8 @@ scenario_name = #{scenarioName,jdbcType=VARCHAR}, scenario_id = #{scenarioId,jdbcType=VARCHAR}, create_user = #{createUser,jdbcType=VARCHAR}, - actuator = #{actuator,jdbcType=VARCHAR} + actuator = #{actuator,jdbcType=VARCHAR}, + end_time = #{endTime,jdbcType=BIGINT} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml index ebda27fe1f..ca1e3360dc 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioReportMapper.xml @@ -99,7 +99,7 @@