fix: 测试计划进度显示错误

--bug=1009891 --user=陈建星 [测试计划]github#9762测试计划执行完所有用例后,测试进度错误,未显示100% #9762 https://www.tapd.cn/55049933/s/1096837
This commit is contained in:
chenjianxing 2022-01-24 11:26:26 +08:00 committed by fit2-zhao
parent cd892ee675
commit 64f1ef7eea
2 changed files with 5 additions and 49 deletions

View File

@ -210,7 +210,7 @@
from
test_plan_api_scenario
where test_plan_id = #{planId}
AND api_scenario_id in (SELECT id FROM api_test_case WHERE (`status` is null or `status` != 'Trash'))
AND api_scenario_id in (SELECT id FROM api_scenario WHERE (`status` is null or `status` != 'Trash'))
</select>
<select id="getIdsByPlanId" resultType="java.lang.String">
select id

View File

@ -303,7 +303,7 @@ public class TestCaseService {
testCase.setCreateUser(SessionUtils.getUserId());
testCase.setOrder(oldTestCase.getOrder());
testCase.setRefId(oldTestCase.getRefId());
testCase.setLatest(null);
testCase.setLatest(false);
DealWithOtherInfo(testCase, oldTestCase.getId());
testCaseMapper.insertSelective(testCase);
}
@ -932,53 +932,6 @@ public class TestCaseService {
}
}
// public void updateImportData(List<TestCaseWithBLOBs> testCases, TestCaseImportRequest request) {
// String projectId = request.getProjectId();
// Map<String, String> nodePathMap = testCaseNodeService.createNodeByTestCases(testCases, projectId);
// SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
// TestCaseMapper mapper = sqlSession.getMapper(TestCaseMapper.class);
// try {
// if (!testCases.isEmpty()) {
// AtomicInteger sort = new AtomicInteger();
// AtomicInteger num = new AtomicInteger();
// num.set(getNextNum(projectId) + testCases.size());
// testCases.forEach(testcase -> {
// TestCaseWithBLOBs oldCase = testCaseMapper.selectByPrimaryKey(testcase.getId());
// String customFieldStr = this.updateCustomField(oldCase.getCustomFields(), testcase.getPriority());
// testcase.setUpdateTime(System.currentTimeMillis());
// testcase.setNodeId(nodePathMap.get(testcase.getNodePath()));
// testcase.setSort(sort.getAndIncrement());
// if (testcase.getNum() == null) {
// testcase.setNum(num.decrementAndGet());
// }
// testcase.setReviewStatus(TestCaseReviewStatus.Prepare.name());
// testcase.setCustomFields(customFieldStr);
// mapper.updateByPrimaryKeySelective(testcase);
// });
// sqlSession.flushStatements();
// }
// } finally {
// SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
// }
// }
private String updateCustomField(String customFields, String priority) {
try {
JSONArray newArr = new JSONArray();
JSONArray customArr = JSONArray.parseArray(customFields);
for (int i = 0; i < customArr.size(); i++) {
JSONObject obj = customArr.getJSONObject(i);
if (obj.containsKey("name") && StringUtils.equalsIgnoreCase(obj.getString("name"), "用例等级")) {
obj.put("value", priority);
}
newArr.add(obj);
}
customFields = newArr.toJSONString();
} catch (Exception e) {
}
return customFields;
}
/**
* 把Excel中带ID的数据更新到数据库
@ -1058,6 +1011,7 @@ public class TestCaseService {
testcase.setCreateUser(SessionUtils.getUserId());
testcase.setCustomNum(dbCase.getCustomNum());
testcase.setNum(dbCase.getNum());
testcase.setLatest(false);
testcase.setType(dbCase.getType());
if (StringUtils.isBlank(testcase.getStatus())) {
testcase.setStatus(TestCaseReviewStatus.Prepare.name());
@ -1812,6 +1766,8 @@ public class TestCaseService {
}
this.setNode(request);
request.setStatus(null); // 不更新状态
request.setRefId(testCaseWithBLOBs.getRefId());
request.setVersionId(testCaseWithBLOBs.getVersionId());
editTestCase(request);
return request.getId();
}