Merge branch 'master' of github.com:metersphere/metersphere

This commit is contained in:
chenjianxing 2021-03-24 19:57:18 +08:00
commit 0fa16caf5a
6 changed files with 32 additions and 16 deletions

View File

@ -5,6 +5,7 @@ import io.metersphere.api.service.*;
import io.metersphere.base.domain.ApiDefinitionExecResult; import io.metersphere.base.domain.ApiDefinitionExecResult;
import io.metersphere.base.domain.ApiScenarioReport; import io.metersphere.base.domain.ApiScenarioReport;
import io.metersphere.base.domain.ApiTestReport; import io.metersphere.base.domain.ApiTestReport;
import io.metersphere.base.domain.TestPlanReport;
import io.metersphere.commons.constants.*; import io.metersphere.commons.constants.*;
import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
@ -14,6 +15,7 @@ import io.metersphere.notice.sender.NoticeModel;
import io.metersphere.notice.service.NoticeSendService; import io.metersphere.notice.service.NoticeSendService;
import io.metersphere.service.SystemParameterService; import io.metersphere.service.SystemParameterService;
import io.metersphere.track.service.TestPlanReportService; import io.metersphere.track.service.TestPlanReportService;
import io.metersphere.track.service.TestPlanService;
import io.metersphere.track.service.TestPlanTestCaseService; import io.metersphere.track.service.TestPlanTestCaseService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;

View File

@ -403,17 +403,24 @@ public class ApiDefinitionService {
private void importMsCase(ApiDefinitionImport apiImport, SqlSession sqlSession, ApiTestCaseMapper apiTestCaseMapper) { private void importMsCase(ApiDefinitionImport apiImport, SqlSession sqlSession, ApiTestCaseMapper apiTestCaseMapper) {
List<ApiTestCaseWithBLOBs> cases = apiImport.getCases(); List<ApiTestCaseWithBLOBs> cases = apiImport.getCases();
List<String> caseNames = apiTestCaseService.listPorjectAllCaseName(SessionUtils.getCurrentProjectId());
Set<String> existCaseName = new HashSet<>();
caseNames.forEach(item -> {
existCaseName.add(item);
});
if (CollectionUtils.isNotEmpty(cases)) { if (CollectionUtils.isNotEmpty(cases)) {
int batchCount = 0; int batchCount = 0;
cases.forEach(item -> { cases.forEach(item -> {
item.setId(UUID.randomUUID().toString()); if(!existCaseName.contains(item.getName())) {
item.setCreateTime(System.currentTimeMillis()); item.setId(UUID.randomUUID().toString());
item.setUpdateTime(System.currentTimeMillis()); item.setCreateTime(System.currentTimeMillis());
item.setCreateUserId(SessionUtils.getUserId()); item.setUpdateTime(System.currentTimeMillis());
item.setUpdateUserId(SessionUtils.getUserId()); item.setCreateUserId(SessionUtils.getUserId());
item.setProjectId(SessionUtils.getCurrentProjectId()); item.setUpdateUserId(SessionUtils.getUserId());
item.setNum(getNextNum(item.getApiDefinitionId())); item.setProjectId(SessionUtils.getCurrentProjectId());
apiTestCaseMapper.insert(item); item.setNum(getNextNum(item.getApiDefinitionId()));
apiTestCaseMapper.insert(item);
}
}); });
if (batchCount % 300 == 0) { if (batchCount % 300 == 0) {
sqlSession.flushStatements(); sqlSession.flushStatements();
@ -628,12 +635,7 @@ public class ApiDefinitionService {
} }
if (!CollectionUtils.isEmpty(apiImport.getCases())) { if (!CollectionUtils.isEmpty(apiImport.getCases())) {
for (int i = 0; i < apiImport.getCases().size(); i++) { importMsCase(apiImport, sqlSession, apiTestCaseMapper);
importMsCase(apiImport, sqlSession, apiTestCaseMapper);
if (i % 300 == 0) {
sqlSession.flushStatements();
}
}
} }
sqlSession.flushStatements(); sqlSession.flushStatements();
} }

View File

@ -80,6 +80,10 @@ public class ApiTestCaseService {
private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR; private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR;
public List<String> listPorjectAllCaseName(String projectId) {
return extApiTestCaseMapper.listPorjectAllCaseName(projectId);
}
public List<ApiTestCaseResult> list(ApiTestCaseRequest request) { public List<ApiTestCaseResult> list(ApiTestCaseRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
List<ApiTestCaseResult> returnList = extApiTestCaseMapper.list(request); List<ApiTestCaseResult> returnList = extApiTestCaseMapper.list(request);

View File

@ -12,6 +12,8 @@ import java.util.List;
public interface ExtApiTestCaseMapper { public interface ExtApiTestCaseMapper {
List<String> listPorjectAllCaseName(@Param("projectId") String projectId);
List<ApiTestCaseResult> list(@Param("request") ApiTestCaseRequest request); List<ApiTestCaseResult> list(@Param("request") ApiTestCaseRequest request);
List<ApiTestCaseDTO> listSimple(@Param("request") ApiTestCaseRequest request); List<ApiTestCaseDTO> listSimple(@Param("request") ApiTestCaseRequest request);

View File

@ -391,6 +391,8 @@
<select id="getNextNum" resultType="io.metersphere.base.domain.ApiTestCase"> <select id="getNextNum" resultType="io.metersphere.base.domain.ApiTestCase">
SELECT * FROM api_test_case WHERE api_test_case.api_definition_id = #{definitionId} ORDER BY num DESC LIMIT 1; SELECT * FROM api_test_case WHERE api_test_case.api_definition_id = #{definitionId} ORDER BY num DESC LIMIT 1;
</select> </select>
<select id="listPorjectAllCaseName" resultType="java.lang.String">
select name from api_test_case where project_id = #{projectId}
</select>
</mapper> </mapper>

View File

@ -86,7 +86,7 @@
show-overflow-tooltip show-overflow-tooltip
:key="index"> :key="index">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-progress :percentage="scope.row.passRate.substring(0, scope.row.passRate.length-1)"></el-progress> <el-progress :percentage="calPassRate(scope)"></el-progress>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -293,6 +293,10 @@ export default {
this.initTableData(); this.initTableData();
}, },
methods: { methods: {
calPassRate(scope) {
let passRate = scope.row.passRate.substring(0, scope.row.passRate.length-1);
return Number.parseInt(passRate, 10);
},
customHeader() { customHeader() {
this.$refs.headerCustom.open(this.tableLabel) this.$refs.headerCustom.open(this.tableLabel)
}, },