refactor(测试计划): 调整执行历史查询方式
This commit is contained in:
parent
870dbfa388
commit
b05031b548
|
@ -16,6 +16,7 @@ public class FunctionalCaseManageInterceptor {
|
|||
List<MybatisInterceptorConfig> configList = new ArrayList<>();
|
||||
|
||||
configList.add(new MybatisInterceptorConfig(FunctionalCaseMindDTO.class, "steps", CompressUtils.class, "zip", "unzip"));
|
||||
configList.add(new MybatisInterceptorConfig(FunctionalCaseMindDTO.class, "executeSteps", CompressUtils.class, "zip", "unzip"));
|
||||
configList.add(new MybatisInterceptorConfig(FunctionalCaseMindDTO.class, "textDescription", CompressUtils.class, "zip", "unzip"));
|
||||
configList.add(new MybatisInterceptorConfig(FunctionalCaseMindDTO.class, "expectedResult", CompressUtils.class, "zip", "unzip"));
|
||||
configList.add(new MybatisInterceptorConfig(FunctionalCaseMindDTO.class, "prerequisite", CompressUtils.class, "zip", "unzip"));
|
||||
|
|
|
@ -63,6 +63,9 @@ public class FunctionalCaseMindDTO {
|
|||
@Schema(description = "用例步骤(JSON),step_model 为 Step 时启用")
|
||||
private byte[] steps;
|
||||
|
||||
@Schema(description = "执行用例步骤(JSON),step_model 为 Step 时启用")
|
||||
private byte[] executeSteps;
|
||||
|
||||
@Schema(description = "步骤描述,step_model 为 Text 时启用")
|
||||
private byte[] textDescription;
|
||||
|
||||
|
|
|
@ -875,18 +875,22 @@
|
|||
<select id="getMinderTestPlanList" resultType="io.metersphere.functional.dto.FunctionalCaseMindDTO">
|
||||
SELECT
|
||||
tpfc.id as id,
|
||||
history.`status` as status,
|
||||
history.`status` as reviewStatus,
|
||||
fc.module_id as moduleId,
|
||||
fc.name as name,
|
||||
fc.id as caseId,
|
||||
fc.project_id, fc.template_id, fc.review_status, fc.pos, fc.case_edit_type,
|
||||
IFNULL(history.`steps`, fcb.steps) as steps, fcb.text_description, fcb.expected_result, fcb.prerequisite, fcb.description
|
||||
fc.project_id, fc.template_id, fc.pos, fc.case_edit_type,
|
||||
IFNULL(history.`steps`, fcb.steps) as steps, execute_history.`steps` as executeSteps, fcb.text_description, fcb.expected_result, fcb.prerequisite, fcb.description
|
||||
FROM
|
||||
test_plan_functional_case tpfc
|
||||
LEFT JOIN functional_case fc ON tpfc.functional_case_id = fc.id
|
||||
LEFT JOIN functional_case_blob fcb ON fcb.id = fc.id
|
||||
LEFT JOIN ( SELECT GROUP_CONCAT(DISTINCT tpceh.test_plan_case_id) AS test_plan_case_id, tpceh.`status`, tpceh.`steps` from test_plan_case_execute_history tpceh where tpceh.test_plan_id = #{request.planId}
|
||||
GROUP BY test_plan_case_id order by tpceh.create_time desc ) as history ON history.test_plan_case_id = tpfc.id
|
||||
LEFT JOIN (select * from (SELECT tpceh.test_plan_case_id, tpceh.`status`,tpceh.`steps`, ROW_NUMBER() OVER (PARTITION BY tpceh.test_plan_case_id ORDER BY tpceh.create_time DESC) as rn from test_plan_case_execute_history tpceh where tpceh.test_plan_id = #{request.planId} and tpceh.deleted = false
|
||||
|
||||
order by tpceh.create_time desc ) as history_filter WHERE rn = 1 ) as history ON history.test_plan_case_id = tpfc.id
|
||||
LEFT JOIN (select * from (SELECT tpceh.test_plan_case_id, tpceh.`status`,tpceh.`steps`, ROW_NUMBER() OVER (PARTITION BY tpceh.test_plan_case_id ORDER BY tpceh.create_time DESC) as rn from test_plan_case_execute_history tpceh where tpceh.test_plan_id = #{request.planId} and tpceh.deleted = false and tpceh.steps IS NOT NULL
|
||||
|
||||
order by tpceh.create_time desc ) as history_filter WHERE rn = 1 ) as execute_history ON execute_history.test_plan_case_id = tpfc.id
|
||||
WHERE
|
||||
tpfc.test_plan_id = #{request.planId}
|
||||
AND fc.deleted = #{deleted}
|
||||
|
|
|
@ -200,6 +200,9 @@ public class FunctionalCaseMinderService {
|
|||
String stepText = new String(functionalCaseMindDTO.getSteps(), StandardCharsets.UTF_8);
|
||||
if (StringUtils.isNotBlank(stepText)) {
|
||||
List<FunctionalCaseStepDTO> functionalCaseStepDTOS = JSON.parseArray(stepText, FunctionalCaseStepDTO.class);
|
||||
if (addActualResult) {
|
||||
compareStep(functionalCaseMindDTO.getExecuteSteps(), functionalCaseStepDTOS);
|
||||
}
|
||||
for (FunctionalCaseStepDTO functionalCaseStepDTO : functionalCaseStepDTOS) {
|
||||
i = i + 1;
|
||||
String desc = functionalCaseStepDTO.getDesc();
|
||||
|
@ -230,7 +233,7 @@ public class FunctionalCaseMinderService {
|
|||
if (StringUtils.isNotBlank(functionalCaseStepDTO.getExecuteResult())) {
|
||||
List<String> resource = stepFunctionalMinderTreeDTO.getData().getResource();
|
||||
List<String> list = new ArrayList<>(resource);
|
||||
list.add(statusMap.get(functionalCaseStepDTO.getExecuteResult()));
|
||||
list.add(0,statusMap.get(functionalCaseStepDTO.getExecuteResult()));
|
||||
stepFunctionalMinderTreeDTO.getData().setResource(list);
|
||||
}
|
||||
}
|
||||
|
@ -1276,4 +1279,26 @@ public class FunctionalCaseMinderService {
|
|||
return new BaseTreeNode(ModuleConstants.DEFAULT_NODE_ID, name, ModuleConstants.NODE_TYPE_DEFAULT, ModuleConstants.ROOT_NODE_PARENT_ID);
|
||||
}
|
||||
|
||||
private static void compareStep(byte[] steps, List<FunctionalCaseStepDTO> newCaseSteps) {
|
||||
if (steps != null) {
|
||||
String historyStepStr = new String(steps, StandardCharsets.UTF_8);
|
||||
if (StringUtils.isNotBlank(historyStepStr)) {
|
||||
List<FunctionalCaseStepDTO> historySteps = JSON.parseArray(historyStepStr, FunctionalCaseStepDTO.class);
|
||||
Map<String, FunctionalCaseStepDTO> historyStepMap = historySteps.stream().collect(Collectors.toMap(FunctionalCaseStepDTO::getId, t -> t));
|
||||
newCaseSteps.forEach(newCaseStep -> {
|
||||
setHistoryInfo(newCaseStep, historyStepMap);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setHistoryInfo(FunctionalCaseStepDTO newCaseStep, Map<String, FunctionalCaseStepDTO> historyStepMap) {
|
||||
FunctionalCaseStepDTO historyStep = historyStepMap.get(newCaseStep.getId());
|
||||
if (historyStep != null && StringUtils.equals(historyStep.getDesc(), newCaseStep.getDesc()) && StringUtils.equals(historyStep.getResult(), newCaseStep.getResult())) {
|
||||
newCaseStep.setExecuteResult(historyStep.getExecuteResult());
|
||||
newCaseStep.setActualResult(historyStep.getActualResult());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue