diff --git a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelData.java b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelData.java index bbbe5f60e1..590dfe893f 100644 --- a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelData.java +++ b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelData.java @@ -37,6 +37,14 @@ public class TestCaseExcelData { @ExcelIgnore private String stepModel; + /** + * 责任人 + * 用例状态 + * 用例等级 + */ + @ExcelIgnore + private String status; + public Set getExcludeColumnFiledNames(boolean needNum){ Set excludeColumnFiledNames = new HashSet<>(); if(!needNum){ diff --git a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataCn.java b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataCn.java index 9934b40137..a7ddf657d7 100644 --- a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataCn.java +++ b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataCn.java @@ -70,6 +70,11 @@ public class TestCaseExcelDataCn extends TestCaseExcelData { @ExcelProperty("预期结果") private String stepResult; + @ColumnWidth(50) + @ExcelProperty("用例状态") + private String status; + + @ColumnWidth(50) @ExcelProperty("编辑模式") @NotRequired diff --git a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataTw.java b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataTw.java index c8e8479877..28fd263840 100644 --- a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataTw.java +++ b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataTw.java @@ -70,6 +70,10 @@ public class TestCaseExcelDataTw extends TestCaseExcelData { @ExcelProperty("預期結果") private String stepResult; + @ColumnWidth(50) + @ExcelProperty("用例狀態") + private String status; + @ColumnWidth(50) @ExcelProperty("編輯模式") @NotRequired diff --git a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataUs.java b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataUs.java index b63d626c22..8185de5261 100644 --- a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataUs.java +++ b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataUs.java @@ -71,6 +71,10 @@ public class TestCaseExcelDataUs extends TestCaseExcelData { @ExcelProperty("Step result") private String stepResult; + @ColumnWidth(50) + @ExcelProperty("Case status") + private String status; + @ColumnWidth(50) @ExcelProperty("Edit Model") @NotRequired diff --git a/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataIgnoreErrorListener.java b/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataIgnoreErrorListener.java index a1597d474a..9123c0ec7e 100644 --- a/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataIgnoreErrorListener.java +++ b/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataIgnoreErrorListener.java @@ -257,6 +257,37 @@ public class TestCaseDataIgnoreErrorListener extends EasyExcelListener0){ + testCase.setCustomFields(customArr.toString()); + } + //将标签设置为前端可解析的格式 String modifiedTags = modifyTagPattern(data); testCase.setTags(modifiedTags); @@ -297,6 +328,37 @@ public class TestCaseDataIgnoreErrorListener extends EasyExcelListener0){ + testCase.setCustomFields(customArr.toString()); + } + //将标签设置为前端可解析的格式 String modifiedTags = modifyTagPattern(data); testCase.setTags(modifiedTags); diff --git a/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataListener.java b/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataListener.java index 0716710255..4ea8b6b606 100644 --- a/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataListener.java +++ b/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataListener.java @@ -272,6 +272,37 @@ public class TestCaseDataListener extends EasyExcelListener { testCase.setTags(modifiedTags); testCase.setType("functional"); + JSONArray customArr = new JSONArray(); + String caseStatusValue = ""; + if(StringUtils.equalsAny(data.getStatus(),"Underway","进行中","進行中")){ + caseStatusValue = "Underway"; + }else if(StringUtils.equalsAny(data.getStatus(),"Prepare","未开始","未開始")){ + caseStatusValue = "Prepare"; + }else if(StringUtils.equalsAny(data.getStatus(),"Completed","已完成","已完成")){ + caseStatusValue = "Completed"; + } + if(StringUtils.isNotEmpty(caseStatusValue)){ + JSONObject statusObj = new JSONObject(); + statusObj.put("id",UUID.randomUUID().toString()); + statusObj.put("name","用例状态"); + statusObj.put("value",caseStatusValue); + statusObj.put("customData",null); + customArr.add(statusObj); + } + + if(StringUtils.isNotEmpty(data.getMaintainer())){ + JSONObject obj = new JSONObject(); + obj.put("id",UUID.randomUUID().toString()); + obj.put("name","责任人"); + obj.put("value",data.getMaintainer()); + obj.put("customData",null); + customArr.add(obj); + } + + if(customArr.size()>0){ + testCase.setCustomFields(customArr.toString()); + } + if (StringUtils.isNotBlank(data.getStepModel()) && StringUtils.equals(data.getStepModel(), TestCaseConstants.StepModel.TEXT.name())) { testCase.setStepDescription(data.getStepDesc()); @@ -308,6 +339,37 @@ public class TestCaseDataListener extends EasyExcelListener { String steps = getSteps(data); testCase.setSteps(steps); + JSONArray customArr = new JSONArray(); + String caseStatusValue = ""; + if(StringUtils.equalsAny(data.getStatus(),"Underway","进行中","進行中")){ + caseStatusValue = "Underway"; + }else if(StringUtils.equalsAny(data.getStatus(),"Prepare","未开始","未開始")){ + caseStatusValue = "Prepare"; + }else if(StringUtils.equalsAny(data.getStatus(),"Completed","已完成","已完成")){ + caseStatusValue = "Completed"; + } + if(StringUtils.isNotEmpty(caseStatusValue)){ + JSONObject statusObj = new JSONObject(); + statusObj.put("id",UUID.randomUUID().toString()); + statusObj.put("name","用例状态"); + statusObj.put("value",caseStatusValue); + statusObj.put("customData",null); + customArr.add(statusObj); + } + + if(StringUtils.isNotEmpty(data.getMaintainer())){ + JSONObject obj = new JSONObject(); + obj.put("id",UUID.randomUUID().toString()); + obj.put("name","责任人"); + obj.put("value",data.getMaintainer()); + obj.put("customData",null); + customArr.add(obj); + } + + if(customArr.size()>0){ + testCase.setCustomFields(customArr.toString()); + } + //将标签设置为前端可解析的格式 String modifiedTags = modifyTagPattern(data); testCase.setTags(modifiedTags); diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index ec16fdbcd9..733cad5ef3 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -242,13 +242,13 @@ public class TestCaseService { // 如果上边字段全部相同,去检查 remark 和 steps if (!CollectionUtils.isEmpty(caseList)) { - String caseRemark = testCase.getRemark(); - String caseSteps = testCase.getSteps(); - String casePrerequisite = testCase.getPrerequisite(); + String caseRemark = testCase.getRemark() == null? "" : testCase.getRemark(); + String caseSteps = testCase.getSteps() == null? "" : testCase.getSteps(); + String casePrerequisite = testCase.getPrerequisite() == null? "" : testCase.getPrerequisite(); for (TestCaseWithBLOBs tc : caseList) { - String steps = tc.getSteps(); - String remark = tc.getRemark(); - String prerequisite = tc.getPrerequisite(); + String steps = tc.getSteps() == null?"" : tc.getSteps(); + String remark = tc.getRemark() == null?"" : tc.getRemark(); + String prerequisite = tc.getPrerequisite() == null?"" : tc.getPrerequisite(); if (StringUtils.equals(steps, caseSteps) && StringUtils.equals(remark, caseRemark) && StringUtils.equals(prerequisite, casePrerequisite)) { //MSException.throwException(Translator.get("test_case_already_exists")); return tc; @@ -872,6 +872,7 @@ public class TestCaseService { } } data.setMaintainer(t.getMaintainer()); + data.setStatus(t.getStatus()); list.add(data); }); return list;