feat(测试计划): 报告功能用例明细支持执行历史
This commit is contained in:
parent
ab4113c975
commit
1f64a7e300
|
@ -69,6 +69,9 @@ public class TestPlanReportFunctionCase implements Serializable {
|
|||
@NotNull(message = "{test_plan_report_function_case.pos.not_blank}", groups = {Created.class})
|
||||
private Long pos;
|
||||
|
||||
@Schema(description = "执行报告ID")
|
||||
private String functionCaseExecuteReportId;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public enum Column {
|
||||
|
@ -84,7 +87,8 @@ public class TestPlanReportFunctionCase implements Serializable {
|
|||
functionCaseBugCount("function_case_bug_count", "functionCaseBugCount", "BIGINT", false),
|
||||
functionCaseExecuteResult("function_case_execute_result", "functionCaseExecuteResult", "VARCHAR", false),
|
||||
testPlanCollectionId("test_plan_collection_id", "testPlanCollectionId", "VARCHAR", false),
|
||||
pos("pos", "pos", "BIGINT", false);
|
||||
pos("pos", "pos", "BIGINT", false),
|
||||
functionCaseExecuteReportId("function_case_execute_report_id", "functionCaseExecuteReportId", "VARCHAR", false);
|
||||
|
||||
private static final String BEGINNING_DELIMITER = "`";
|
||||
|
||||
|
|
|
@ -983,6 +983,76 @@ public class TestPlanReportFunctionCaseExample {
|
|||
addCriterion("pos not between", value1, value2, "pos");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFunctionCaseExecuteReportIdIsNull() {
|
||||
addCriterion("function_case_execute_report_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFunctionCaseExecuteReportIdIsNotNull() {
|
||||
addCriterion("function_case_execute_report_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFunctionCaseExecuteReportIdEqualTo(String value) {
|
||||
addCriterion("function_case_execute_report_id =", value, "functionCaseExecuteReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFunctionCaseExecuteReportIdNotEqualTo(String value) {
|
||||
addCriterion("function_case_execute_report_id <>", value, "functionCaseExecuteReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFunctionCaseExecuteReportIdGreaterThan(String value) {
|
||||
addCriterion("function_case_execute_report_id >", value, "functionCaseExecuteReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFunctionCaseExecuteReportIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("function_case_execute_report_id >=", value, "functionCaseExecuteReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFunctionCaseExecuteReportIdLessThan(String value) {
|
||||
addCriterion("function_case_execute_report_id <", value, "functionCaseExecuteReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFunctionCaseExecuteReportIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("function_case_execute_report_id <=", value, "functionCaseExecuteReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFunctionCaseExecuteReportIdLike(String value) {
|
||||
addCriterion("function_case_execute_report_id like", value, "functionCaseExecuteReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFunctionCaseExecuteReportIdNotLike(String value) {
|
||||
addCriterion("function_case_execute_report_id not like", value, "functionCaseExecuteReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFunctionCaseExecuteReportIdIn(List<String> values) {
|
||||
addCriterion("function_case_execute_report_id in", values, "functionCaseExecuteReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFunctionCaseExecuteReportIdNotIn(List<String> values) {
|
||||
addCriterion("function_case_execute_report_id not in", values, "functionCaseExecuteReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFunctionCaseExecuteReportIdBetween(String value1, String value2) {
|
||||
addCriterion("function_case_execute_report_id between", value1, value2, "functionCaseExecuteReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFunctionCaseExecuteReportIdNotBetween(String value1, String value2) {
|
||||
addCriterion("function_case_execute_report_id not between", value1, value2, "functionCaseExecuteReportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<result column="function_case_execute_result" jdbcType="VARCHAR" property="functionCaseExecuteResult" />
|
||||
<result column="test_plan_collection_id" jdbcType="VARCHAR" property="testPlanCollectionId" />
|
||||
<result column="pos" jdbcType="BIGINT" property="pos" />
|
||||
<result column="function_case_execute_report_id" jdbcType="VARCHAR" property="functionCaseExecuteReportId" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
|
@ -77,7 +78,8 @@
|
|||
<sql id="Base_Column_List">
|
||||
id, test_plan_report_id, test_plan_function_case_id, function_case_id, function_case_num,
|
||||
function_case_name, function_case_module, function_case_priority, function_case_execute_user,
|
||||
function_case_bug_count, function_case_execute_result, test_plan_collection_id, pos
|
||||
function_case_bug_count, function_case_execute_result, test_plan_collection_id, pos,
|
||||
function_case_execute_report_id
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.metersphere.plan.domain.TestPlanReportFunctionCaseExample" resultMap="BaseResultMap">
|
||||
select
|
||||
|
@ -115,13 +117,13 @@
|
|||
function_case_module, function_case_priority,
|
||||
function_case_execute_user, function_case_bug_count,
|
||||
function_case_execute_result, test_plan_collection_id,
|
||||
pos)
|
||||
pos, function_case_execute_report_id)
|
||||
values (#{id,jdbcType=VARCHAR}, #{testPlanReportId,jdbcType=VARCHAR}, #{testPlanFunctionCaseId,jdbcType=VARCHAR},
|
||||
#{functionCaseId,jdbcType=VARCHAR}, #{functionCaseNum,jdbcType=BIGINT}, #{functionCaseName,jdbcType=VARCHAR},
|
||||
#{functionCaseModule,jdbcType=VARCHAR}, #{functionCasePriority,jdbcType=VARCHAR},
|
||||
#{functionCaseExecuteUser,jdbcType=VARCHAR}, #{functionCaseBugCount,jdbcType=BIGINT},
|
||||
#{functionCaseExecuteResult,jdbcType=VARCHAR}, #{testPlanCollectionId,jdbcType=VARCHAR},
|
||||
#{pos,jdbcType=BIGINT})
|
||||
#{pos,jdbcType=BIGINT}, #{functionCaseExecuteReportId,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.plan.domain.TestPlanReportFunctionCase">
|
||||
insert into test_plan_report_function_case
|
||||
|
@ -165,6 +167,9 @@
|
|||
<if test="pos != null">
|
||||
pos,
|
||||
</if>
|
||||
<if test="functionCaseExecuteReportId != null">
|
||||
function_case_execute_report_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
|
@ -206,6 +211,9 @@
|
|||
<if test="pos != null">
|
||||
#{pos,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="functionCaseExecuteReportId != null">
|
||||
#{functionCaseExecuteReportId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.metersphere.plan.domain.TestPlanReportFunctionCaseExample" resultType="java.lang.Long">
|
||||
|
@ -256,6 +264,9 @@
|
|||
<if test="record.pos != null">
|
||||
pos = #{record.pos,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.functionCaseExecuteReportId != null">
|
||||
function_case_execute_report_id = #{record.functionCaseExecuteReportId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
|
@ -275,7 +286,8 @@
|
|||
function_case_bug_count = #{record.functionCaseBugCount,jdbcType=BIGINT},
|
||||
function_case_execute_result = #{record.functionCaseExecuteResult,jdbcType=VARCHAR},
|
||||
test_plan_collection_id = #{record.testPlanCollectionId,jdbcType=VARCHAR},
|
||||
pos = #{record.pos,jdbcType=BIGINT}
|
||||
pos = #{record.pos,jdbcType=BIGINT},
|
||||
function_case_execute_report_id = #{record.functionCaseExecuteReportId,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
|
@ -319,6 +331,9 @@
|
|||
<if test="pos != null">
|
||||
pos = #{pos,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="functionCaseExecuteReportId != null">
|
||||
function_case_execute_report_id = #{functionCaseExecuteReportId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
|
@ -335,7 +350,8 @@
|
|||
function_case_bug_count = #{functionCaseBugCount,jdbcType=BIGINT},
|
||||
function_case_execute_result = #{functionCaseExecuteResult,jdbcType=VARCHAR},
|
||||
test_plan_collection_id = #{testPlanCollectionId,jdbcType=VARCHAR},
|
||||
pos = #{pos,jdbcType=BIGINT}
|
||||
pos = #{pos,jdbcType=BIGINT},
|
||||
function_case_execute_report_id = #{functionCaseExecuteReportId,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<insert id="batchInsert" parameterType="map">
|
||||
|
@ -343,7 +359,7 @@
|
|||
(id, test_plan_report_id, test_plan_function_case_id, function_case_id, function_case_num,
|
||||
function_case_name, function_case_module, function_case_priority, function_case_execute_user,
|
||||
function_case_bug_count, function_case_execute_result, test_plan_collection_id,
|
||||
pos)
|
||||
pos, function_case_execute_report_id)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.id,jdbcType=VARCHAR}, #{item.testPlanReportId,jdbcType=VARCHAR}, #{item.testPlanFunctionCaseId,jdbcType=VARCHAR},
|
||||
|
@ -351,7 +367,8 @@
|
|||
#{item.functionCaseName,jdbcType=VARCHAR}, #{item.functionCaseModule,jdbcType=VARCHAR},
|
||||
#{item.functionCasePriority,jdbcType=VARCHAR}, #{item.functionCaseExecuteUser,jdbcType=VARCHAR},
|
||||
#{item.functionCaseBugCount,jdbcType=BIGINT}, #{item.functionCaseExecuteResult,jdbcType=VARCHAR},
|
||||
#{item.testPlanCollectionId,jdbcType=VARCHAR}, #{item.pos,jdbcType=BIGINT})
|
||||
#{item.testPlanCollectionId,jdbcType=VARCHAR}, #{item.pos,jdbcType=BIGINT}, #{item.functionCaseExecuteReportId,jdbcType=VARCHAR}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
<insert id="batchInsertSelective" parameterType="map">
|
||||
|
@ -403,6 +420,9 @@
|
|||
<if test="'pos'.toString() == column.value">
|
||||
#{item.pos,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test="'function_case_execute_report_id'.toString() == column.value">
|
||||
#{item.functionCaseExecuteReportId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
</foreach>
|
||||
)
|
||||
</foreach>
|
||||
|
|
|
@ -227,6 +227,7 @@ ALTER TABLE test_plan_report DROP `execute_time`;
|
|||
-- 计划报告功能用例明细表
|
||||
ALTER TABLE test_plan_report_function_case ADD `test_plan_collection_id` VARCHAR(50) NOT NULL COMMENT '测试集ID';
|
||||
ALTER TABLE test_plan_report_function_case ADD `pos` BIGINT NOT NULL COMMENT '自定义排序';
|
||||
ALTER TABLE test_plan_report_function_case ADD `function_case_execute_report_id` VARCHAR(50) COMMENT '执行报告ID';
|
||||
CREATE INDEX idx_test_plan_collection_id ON test_plan_report_function_case(test_plan_collection_id);
|
||||
CREATE INDEX idx_pos ON test_plan_report_function_case(pos);
|
||||
|
||||
|
|
|
@ -40,10 +40,7 @@ import org.apache.ibatis.session.SqlSessionFactory;
|
|||
import org.mybatis.spring.SqlSessionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
|
@ -70,6 +67,8 @@ public class TestPlanReportService {
|
|||
@Resource
|
||||
private ExtTestPlanReportFunctionalCaseMapper extTestPlanReportFunctionalCaseMapper;
|
||||
@Resource
|
||||
private TestPlanCaseExecuteHistoryMapper testPlanCaseExecuteHistoryMapper;
|
||||
@Resource
|
||||
private ExtTestPlanReportApiCaseMapper extTestPlanReportApiCaseMapper;
|
||||
@Resource
|
||||
private ExtTestPlanReportApiScenarioMapper extTestPlanReportApiScenarioMapper;
|
||||
|
@ -339,12 +338,27 @@ public class TestPlanReportService {
|
|||
List<String> ids = reportFunctionCases.stream().map(TestPlanReportFunctionCase::getFunctionCaseId).distinct().toList();
|
||||
List<SelectOption> options = extTestPlanReportFunctionalCaseMapper.getCasePriorityByIds(ids);
|
||||
Map<String, String> casePriorityMap = options.stream().collect(Collectors.toMap(SelectOption::getValue, SelectOption::getText));
|
||||
// 关联的功能用例最新一次执行历史
|
||||
List<String> relateIds = reportFunctionCases.stream().map(TestPlanReportFunctionCase::getTestPlanFunctionCaseId).toList();
|
||||
TestPlanCaseExecuteHistoryExample example = new TestPlanCaseExecuteHistoryExample();
|
||||
example.createCriteria().andTestPlanCaseIdIn(relateIds);
|
||||
List<TestPlanCaseExecuteHistory> functionalExecHisList = testPlanCaseExecuteHistoryMapper.selectByExample(example);
|
||||
Map<String, List<TestPlanCaseExecuteHistory>> functionalExecMap = functionalExecHisList.stream().collect(Collectors.groupingBy(TestPlanCaseExecuteHistory::getTestPlanCaseId));
|
||||
|
||||
|
||||
reportFunctionCases.forEach(reportFunctionalCase -> {
|
||||
reportFunctionalCase.setId(IDGenerator.nextStr());
|
||||
reportFunctionalCase.setTestPlanReportId(report.getId());
|
||||
reportFunctionalCase.setFunctionCaseModule(moduleParam.getFunctionalModuleMap().getOrDefault(reportFunctionalCase.getFunctionCaseModule(),
|
||||
ModuleTreeUtils.MODULE_PATH_PREFIX + reportFunctionalCase.getFunctionCaseModule()));
|
||||
reportFunctionalCase.setFunctionCasePriority(casePriorityMap.get(reportFunctionalCase.getFunctionCaseId()));
|
||||
List<TestPlanCaseExecuteHistory> hisList = functionalExecMap.get(reportFunctionalCase.getTestPlanFunctionCaseId());
|
||||
if (CollectionUtils.isNotEmpty(hisList)) {
|
||||
Optional<String> lastExecuteHisOpt = hisList.stream().sorted(Comparator.comparing(TestPlanCaseExecuteHistory::getCreateTime).reversed()).map(TestPlanCaseExecuteHistory::getId).findFirst();
|
||||
reportFunctionalCase.setFunctionCaseExecuteReportId(lastExecuteHisOpt.get());
|
||||
} else {
|
||||
reportFunctionalCase.setFunctionCaseExecuteReportId(null);
|
||||
}
|
||||
});
|
||||
// 插入计划功能用例关联数据 -> 报告内容
|
||||
TestPlanReportFunctionCaseMapper batchMapper = sqlSession.getMapper(TestPlanReportFunctionCaseMapper.class);
|
||||
|
|
Loading…
Reference in New Issue