From ff607a2d48f6dd4b1b47e245c95d86588be372b9 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Wed, 4 Aug 2021 17:34:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B):?= =?UTF-8?q?=20=E5=AF=BC=E5=85=A5=E6=A8=A1=E7=89=88=E4=BC=98=E5=8C=96#10022?= =?UTF-8?q?94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1002294 --user=lyh 11.测试跟踪导入模板优化 https://www.tapd.cn/55049933/s/1032253 --- .../excel/domain/TestCaseExcelDataCn.java | 6 ++++- .../excel/domain/TestCaseExcelDataTw.java | 6 ++++- .../excel/domain/TestCaseExcelDataUs.java | 6 ++++- .../FunctionCaseTemplateWriteHandler.java | 10 +++++-- .../TestCaseDataIgnoreErrorListener.java | 27 +++++++++---------- .../excel/listener/TestCaseDataListener.java | 15 +++++------ .../listener/TestCaseNoModelDataListener.java | 26 +++++++++--------- .../resources/i18n/messages_en_US.properties | 3 ++- .../resources/i18n/messages_zh_CN.properties | 3 ++- .../resources/i18n/messages_zh_TW.properties | 3 ++- 10 files changed, 62 insertions(+), 43 deletions(-) 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 5dad665fb8..41927fcc10 100644 --- a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataCn.java +++ b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataCn.java @@ -135,7 +135,11 @@ public class TestCaseExcelDataCn extends TestCaseExcelData { continue; } List list = new ArrayList<>(); - list.add(dto.getName()); + if (StringUtils.equals(dto.getName(), "责任人")) { + list.add("责任人(ID)"); + } else { + list.add(dto.getName()); + } returnList.add(list); } } 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 96f37c1115..e0232eaf23 100644 --- a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataTw.java +++ b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataTw.java @@ -135,7 +135,11 @@ public class TestCaseExcelDataTw extends TestCaseExcelData { continue; } List list = new ArrayList<>(); - list.add(dto.getName()); + if (StringUtils.equals(dto.getName(), "责任人")) { + list.add("維護人(ID)"); + } else { + list.add(dto.getName()); + } returnList.add(list); } } 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 3fe9160100..cecd8cf962 100644 --- a/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataUs.java +++ b/backend/src/main/java/io/metersphere/excel/domain/TestCaseExcelDataUs.java @@ -135,7 +135,11 @@ public class TestCaseExcelDataUs extends TestCaseExcelData { continue; } List list = new ArrayList<>(); - list.add(dto.getName()); + if (StringUtils.equals(dto.getName(), "责任人")) { + list.add("Maintainer(ID)"); + } else { + list.add(dto.getName()); + } returnList.add(list); } } diff --git a/backend/src/main/java/io/metersphere/excel/handler/FunctionCaseTemplateWriteHandler.java b/backend/src/main/java/io/metersphere/excel/handler/FunctionCaseTemplateWriteHandler.java index c3606135be..4ef5112631 100644 --- a/backend/src/main/java/io/metersphere/excel/handler/FunctionCaseTemplateWriteHandler.java +++ b/backend/src/main/java/io/metersphere/excel/handler/FunctionCaseTemplateWriteHandler.java @@ -43,7 +43,7 @@ public class FunctionCaseTemplateWriteHandler extends AbstractRowHeightStyleStra returnMap.put("ID",index); }else if(StringUtils.equalsAnyIgnoreCase(head,"所属模块","所屬模塊","Module")){ returnMap.put("Module",index); - }else if(StringUtils.equalsAnyIgnoreCase(head,"责任人","維護人","Maintainer")){ + }else if(StringUtils.equalsAnyIgnoreCase(head,"责任人(ID)","維護人(ID)","Maintainer(ID)")){ returnMap.put("Maintainer",index); }else if(StringUtils.equalsAnyIgnoreCase(head,"用例等级","用例等級","Priority")){ returnMap.put("Priority",index); @@ -51,6 +51,8 @@ public class FunctionCaseTemplateWriteHandler extends AbstractRowHeightStyleStra returnMap.put("Tag",index); }else if(StringUtils.equalsAnyIgnoreCase(head,"用例状态","用例狀態","Case status")){ returnMap.put("Status",index); + } else if (StringUtils.equalsAnyIgnoreCase(head, "编辑模式", "編輯模式", "Edit Model")) { + returnMap.put("StepModel",index); } index ++; } @@ -94,7 +96,7 @@ public class FunctionCaseTemplateWriteHandler extends AbstractRowHeightStyleStra sheet.getRow(0).getCell(1).setCellComment(comment); }else if(StringUtils.equalsAnyIgnoreCase(coloum,"Maintainer")){ Comment comment = drawingPatriarch.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, index, 0, (short) 3, 1)); - comment.setString(new XSSFRichTextString(Translator.get("please_input_workspace_member"))); + comment.setString(new XSSFRichTextString(Translator.get("please_input_project_member"))); sheet.getRow(0).getCell(1).setCellComment(comment); }else if(StringUtils.equalsAnyIgnoreCase(coloum,"Priority")){ Comment comment = drawingPatriarch.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, index, 0, (short) 3, 1)); @@ -122,6 +124,10 @@ public class FunctionCaseTemplateWriteHandler extends AbstractRowHeightStyleStra comment.setString(new XSSFRichTextString(Translator.get("options") + JSONArray.toJSONString(list))); sheet.getRow(0).getCell(1).setCellComment(comment); } + } else if (StringUtils.equalsAnyIgnoreCase(coloum, "StepModel")) { + Comment comment = drawingPatriarch.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, index, 0, (short) 3, 1)); + comment.setString(new XSSFRichTextString(Translator.get("step_model_tip"))); + sheet.getRow(0).getCell(1).setCellComment(comment); } } } 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 9123c0ec7e..311829222a 100644 --- a/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataIgnoreErrorListener.java +++ b/backend/src/main/java/io/metersphere/excel/listener/TestCaseDataIgnoreErrorListener.java @@ -6,10 +6,7 @@ import com.alibaba.fastjson.JSONObject; import io.metersphere.base.domain.TestCase; import io.metersphere.base.domain.TestCaseWithBLOBs; import io.metersphere.commons.constants.TestCaseConstants; -import io.metersphere.commons.utils.BeanUtils; -import io.metersphere.commons.utils.CommonBeanFactory; -import io.metersphere.commons.utils.ListUtils; -import io.metersphere.commons.utils.LogUtil; +import io.metersphere.commons.utils.*; import io.metersphere.excel.domain.ExcelErrData; import io.metersphere.excel.domain.TestCaseExcelData; import io.metersphere.excel.utils.ExcelValidateHelper; @@ -19,8 +16,6 @@ import io.metersphere.track.service.TestCaseService; import org.apache.commons.lang3.StringUtils; import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -132,8 +127,12 @@ public class TestCaseDataIgnoreErrorListener extends EasyExcelListener { //校验维护人 - if (!userIds.contains(data.getMaintainer())) { - stringBuilder.append(Translator.get("user_not_exists") + ":" + data.getMaintainer() + "; "); + if (StringUtils.isBlank(data.getMaintainer())) { + data.setMaintainer(SessionUtils.getUserId()); + } else { + if (!userIds.contains(data.getMaintainer())) { + stringBuilder.append(Translator.get("user_not_exists") + ":" + data.getMaintainer() + "; "); + } } /* diff --git a/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java b/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java index 38e89cdc10..504eaa80ac 100644 --- a/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java +++ b/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java @@ -3,17 +3,13 @@ package io.metersphere.excel.listener; import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; -import com.alibaba.excel.exception.ExcelAnalysisException; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import io.metersphere.base.domain.TestCase; import io.metersphere.base.domain.TestCaseWithBLOBs; import io.metersphere.commons.constants.TestCaseConstants; import io.metersphere.commons.exception.MSException; -import io.metersphere.commons.utils.BeanUtils; -import io.metersphere.commons.utils.CommonBeanFactory; -import io.metersphere.commons.utils.ListUtils; -import io.metersphere.commons.utils.LogUtil; +import io.metersphere.commons.utils.*; import io.metersphere.dto.CustomFieldDao; import io.metersphere.excel.annotation.NotRequired; import io.metersphere.excel.domain.ExcelErrData; @@ -231,8 +227,12 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener