fix: 带文件导出-文件字段路径错误Bug

This commit is contained in:
2023-09-27 09:48:36 +08:00
parent e2f5934b64
commit a6caecb9af
2 changed files with 14 additions and 7 deletions
@@ -204,7 +204,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
IPage<Map<String, Object>> infoPage = lawsCommonMapper.getCommonPage(page, tableName, selectField, selectCondition);
// 对返回的数据做处理
// 做字段翻译和拼接
infoPage.setRecords(processResultMapPageList(infoPage.getRecords(), fieldListSelect));
infoPage.setRecords(processResultMapPageList(infoPage.getRecords(), fieldList));
// 待处理
return infoPage;
}
@@ -1039,7 +1039,10 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
for (int j = 0; j < headers.size(); j++) {
Cell dataCell = dataRow.createCell(j);
Object value = dataRowMap.get(headers.get(j).getDbFieldName());
LawsTag lawsTag = headers.get(j);
// 如果有翻译字典的就用翻译字典
Object dictValue = dataRowMap.get(lawsTag.getDbFieldName() + FieldCommon._DICT_TEXT);
Object value = dictValue == null ? dataRowMap.get(lawsTag.getDbFieldName()) : dictValue;
if (value != null) {
dataCell.setCellValue(value.toString());
}
@@ -1099,7 +1102,10 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
for (int j = 0; j < headers.size(); j++) {
Cell dataCell = dataRow.createCell(j);
Object value = dataRowMap.get(headers.get(j).getDbFieldName());
LawsTag lawsTag = headers.get(j);
// 如果有翻译字典的就用翻译字典
Object dictValue = dataRowMap.get(lawsTag.getDbFieldName() + FieldCommon._DICT_TEXT);
Object value = dictValue == null ? dataRowMap.get(lawsTag.getDbFieldName()) : dictValue;
if (value != null) {
dataCell.setCellValue(value.toString());
}
@@ -3,6 +3,7 @@ package com.jero.modules.laws.standard.service.impl;
import cn.hutool.core.io.FileUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.common.exception.JeroBootException;
import com.jero.modules.laws.common.constant.FieldCommon;
import com.jero.modules.laws.standard.service.ILawsStandardFileService;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
@@ -53,7 +54,7 @@ public class LawsStandardFileServiceImpl implements ILawsStandardFileService {
// 遍历每个记录
for (Map<String, Object> record : records) {
String standardNo = (String) record.get("standard_number");
String standardNo = (String) record.get(FieldCommon.STANDARD_NUMBER);
for (LawsTag tag : fileHeaders) {
String fileName = tag.getDbFieldTxt();
String key = standardNo + "-" + tag.getDbFieldName();
@@ -65,17 +66,17 @@ public class LawsStandardFileServiceImpl implements ILawsStandardFileService {
// 遍历找到的结果
if (lawsStandardFiles.size() == 1) {
String fileExtension = "." + FileUtil.extName(lawsStandardFiles.get(0).getFileName());
allFileName = new StringBuilder(standardNo + "/" + fileName + fileExtension);
allFileName = new StringBuilder(standardNo.replace("/", "") + "/" + fileName + fileExtension);
} else {
for (int i = 1; i <= lawsStandardFiles.size(); i++) {
String fileExtension = "." + FileUtil.extName(lawsStandardFiles.get(0).getFileName());
allFileName.append(standardNo).append("/").append(fileName).append(i).append(fileExtension).append(",");
allFileName.append(standardNo.replace("/", "")).append("/").append(fileName).append(i).append(fileExtension).append(",");
}
// 去除最后一个,
allFileName = new StringBuilder(allFileName.substring(0, allFileName.length() - 1));
}
// 最终设置
record.put(tag.getDbFieldName(), allFileName.toString());
record.put(tag.getDbFieldName() + FieldCommon._DICT_TEXT, allFileName.toString());
}
}
}