fix (接口自动化): K8s串行集成报告顺序问题修复 #1006159

--bug=1006159 --user=赵勇 【接口测试】使用k8s资... https://www.tapd.cn/55049933/s/1039129
This commit is contained in:
fit2-zhao 2021-08-25 11:02:12 +08:00 committed by fit2-zhao
parent 56d1dc8a35
commit a4089c2270
3 changed files with 27 additions and 3 deletions

View File

@ -23,6 +23,7 @@ import io.metersphere.base.mapper.ApiScenarioMapper;
import io.metersphere.base.mapper.ApiScenarioReportDetailMapper;
import io.metersphere.base.mapper.ApiScenarioReportMapper;
import io.metersphere.base.mapper.TestPlanApiScenarioMapper;
import io.metersphere.base.mapper.ext.ExtApiScenarioReportDetailMapper;
import io.metersphere.base.mapper.ext.ExtApiScenarioReportMapper;
import io.metersphere.commons.constants.*;
import io.metersphere.commons.exception.MSException;
@ -63,6 +64,9 @@ public class ApiScenarioReportService {
private ApiScenarioReportMapper apiScenarioReportMapper;
@Resource
private ApiScenarioReportDetailMapper apiScenarioReportDetailMapper;
@Resource
private ExtApiScenarioReportDetailMapper extApiScenarioReportDetailMapper;
@Resource
private ApiScenarioMapper apiScenarioMapper;
@Resource
@ -443,9 +447,12 @@ public class ApiScenarioReportService {
if (CollectionUtils.isNotEmpty(reportIds)) {
TestResult testResult = new TestResult();
testResult.setTestId(UUID.randomUUID().toString());
ApiScenarioReportDetailExample example = new ApiScenarioReportDetailExample();
example.createCriteria().andReportIdIn(reportIds);
List<ApiScenarioReportDetail> details = apiScenarioReportDetailMapper.selectByExampleWithBLOBs(example);
StringBuilder idStr = new StringBuilder();
reportIds.forEach(item -> {
idStr.append("\"").append(item).append("\"").append(",");
});
List<ApiScenarioReportDetail> details = extApiScenarioReportDetailMapper.selectByIds(idStr.toString().substring(0, idStr.toString().length() - 1), "\"" + StringUtils.join(reportIds, ",") + "\"");
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// 记录单场景通过率

View File

@ -0,0 +1,10 @@
package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.ApiScenarioReportDetail;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ExtApiScenarioReportDetailMapper {
List<ApiScenarioReportDetail> selectByIds(@Param("ids") String ids, @Param("oderId") String oderId);
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.base.mapper.ext.ExtApiScenarioReportDetailMapper">
<select id="selectByIds" resultType="io.metersphere.base.domain.ApiScenarioReportDetail">
select t.* from api_scenario_report_detail t where t.report_id in (${ids}) ORDER BY FIND_IN_SET(t.report_id,${oderId})
</select>
</mapper>