From 2ac649b06fd021d40eeca1bb95f1b54b61540a48 Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Thu, 15 Aug 2024 19:59:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B):=20?= =?UTF-8?q?=E6=8B=86=E5=88=86=E5=8D=95=E5=85=83=E6=A0=BC&=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E5=8D=95=E5=85=83=E6=A0=BC&=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=AD=97=E6=AE=B5=E8=A7=A3=E6=9E=90=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1045153 --user=王旭 【测试用例】ms系统语言为中文-用例导出为excel-默认格式/单元格拆分格式-导出数据模块、用例等级、步骤描述和预期结果为空 https://www.tapd.cn/55049933/s/1563756 --- .../CustomFieldMultipleTextValidator.java | 5 ++--- .../service/FunctionalCaseFileService.java | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldMultipleTextValidator.java b/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldMultipleTextValidator.java index 25335bf49b..4f6ea16ac4 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldMultipleTextValidator.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/excel/validate/CustomFieldMultipleTextValidator.java @@ -57,8 +57,7 @@ public class CustomFieldMultipleTextValidator extends AbstractCustomFieldValidat if (StringUtils.isBlank(keyOrValuesStr) || StringUtils.equals(keyOrValuesStr, "[]")) { return JSON.toJSONString(new ArrayList<>()); } - List keyOrValues = parse2Array(keyOrValuesStr); - - return JSON.toJSONString(keyOrValues); + String keyOrValues = String.join(",", JSON.parseArray(keyOrValuesStr)); + return keyOrValues; } } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseFileService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseFileService.java index 6bf3265832..24a18f42e7 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseFileService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseFileService.java @@ -606,10 +606,12 @@ public class FunctionalCaseFileService { //构建其他字段 buildExportOtherField(functionalCase, data, caseCommentMap, executeCommentMap, reviewCommentMap, request); validateExportTextField(data); - if (CollectionUtils.isNotEmpty(textDescriptionList) && !request.getIsMerge()) { + if (CollectionUtils.isNotEmpty(textDescriptionList) && request.getIsMerge()) { // 如果有多条步骤则添加多条数据,之后合并单元格 buildExportMergeData(rowMergeInfo, list, textDescriptionList, expectedResultList, data); } else { + data.setTextDescription(parseData(textDescriptionList)); + data.setExpectedResult(parseData(expectedResultList)); list.add(data); } }); @@ -617,6 +619,20 @@ public class FunctionalCaseFileService { return list; } + /** + * 处理单行格式 + * + * @param list + * @return + */ + private String parseData(List list) { + String result = ""; + for (int i = 0; i < list.size(); i++) { + result += "[" + (i + 1) + "]" + list.get(i) + "\n"; + } + return result; + } + /** * 构建基本参数 *