fix(测试计划): #1006817 【测试跟踪】导入xmind格式,导入更新,没有修改用例等级

【【测试跟踪】导入xmind格式,导入更新,没有修改用例等级】https://www.tapd.cn/55049933/bugtrace/bugs/view?bug_id=1155049933001006817
This commit is contained in:
song-tianyang 2021-09-22 17:27:50 +08:00 committed by song-tianyang
parent 3f2ef4100c
commit 1b193a3589
1 changed files with 21 additions and 0 deletions

View File

@ -633,6 +633,8 @@ public class TestCaseService {
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());
@ -640,12 +642,31 @@ public class TestCaseService {
testcase.setNum(num.decrementAndGet());
}
testcase.setReviewStatus(TestCaseReviewStatus.Prepare.name());
testcase.setCustomFields(customFieldStr);
mapper.updateByPrimaryKeySelective(testcase);
});
}
sqlSession.flushStatements();
}
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的数据更新到数据库
* feat(测试跟踪):通过Excel导入导出时有ID字段可通过Excel导入来更新用例 (#1727)