|
|
|
@ -21,14 +21,12 @@ import com.keyware.shandan.system.service.SysFileService; |
|
|
|
|
import com.keyware.shandan.system.utils.SysSettingUtil; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayOutputStream; |
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.InputStream; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
public class ExportComponent { |
|
|
|
|
private final String exportId; |
|
|
|
@ -107,9 +105,8 @@ public class ExportComponent { |
|
|
|
|
JSONObject col = (JSONObject) json; |
|
|
|
|
String comment = col.getString("comment"); |
|
|
|
|
String colName = col.getString("columnName"); |
|
|
|
|
String name = StringUtils.hasTextByDefault(comment, colName); |
|
|
|
|
colNameList.add(colName); |
|
|
|
|
return name; |
|
|
|
|
return colName + (StringUtils.hasText(comment) ? "[" + comment + "]" : ""); |
|
|
|
|
}).toList(); |
|
|
|
|
|
|
|
|
|
// 添加第一行
|
|
|
|
@ -118,7 +115,13 @@ public class ExportComponent { |
|
|
|
|
// 遍历数据
|
|
|
|
|
datas.forEach(data -> { |
|
|
|
|
// 遍历字段列名,获取对应数据并拼接成列的集合
|
|
|
|
|
List<String> cells = StreamUtil.as(colNameList).map(col -> data.get(col).toString()).toList(); |
|
|
|
|
List<String> cells = colNameList.stream().map(col -> { |
|
|
|
|
Object value = data.get(col); |
|
|
|
|
if (value == null) { |
|
|
|
|
return ""; |
|
|
|
|
} |
|
|
|
|
return String.valueOf(value); |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
rowList.add(cells); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|