|
|
@@ -47,10 +47,12 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.sql.Date;
|
|
|
import java.sql.SQLException;
|
|
|
import java.sql.Time;
|
|
|
import java.sql.Timestamp;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
|
import java.time.ZoneId;
|
|
|
@@ -77,6 +79,8 @@ import java.util.stream.Collectors;
|
|
|
@AllArgsConstructor
|
|
|
public class FormExecuteController {
|
|
|
|
|
|
+ private static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
private final IFormExecuteService formExecuteService;
|
|
|
|
|
|
private final IFormReleaseService formReleaseService;
|
|
|
@@ -260,7 +264,7 @@ public class FormExecuteController {
|
|
|
// 设置第每列的列宽度
|
|
|
for (ImportConfig importConfig : importConfigs) {
|
|
|
if(importConfig.getWidth() == 0){
|
|
|
- sheet.setColumnWidth(importConfig.getSortCode(), importConfig.getLabel().length() * 4 * 256);
|
|
|
+ sheet.setColumnWidth(importConfig.getSortCode(), importConfig.getLabel().length() * 3 * 256);
|
|
|
// sheet.autoSizeColumn(importConfig.getSortCode());
|
|
|
}else {
|
|
|
sheet.setColumnWidth(importConfig.getSortCode(), importConfig.getWidth() * 256);
|
|
|
@@ -314,6 +318,23 @@ public class FormExecuteController {
|
|
|
value = LocalDateTimeUtil.format(time);
|
|
|
}
|
|
|
|
|
|
+ // 检查类层次结构
|
|
|
+ if (value == null) {
|
|
|
+ value = "";
|
|
|
+ } else if (value instanceof Integer) {
|
|
|
+ value = Integer.toString((Integer) value);
|
|
|
+ } else if (value instanceof Double) {
|
|
|
+ value = Double.toString((Double) value);
|
|
|
+ } else if (value instanceof Long) {
|
|
|
+ value = Long.toString((Long) value);
|
|
|
+ } else if (value instanceof BigDecimal) {
|
|
|
+ value = ((BigDecimal) value).toPlainString();
|
|
|
+ } else if (value instanceof Date) {
|
|
|
+ value = DATE_FORMATTER.format((Date) value);
|
|
|
+ } else {
|
|
|
+ value = value.toString(); // 默认处理其他类型的对象
|
|
|
+ }
|
|
|
+
|
|
|
Cell cell = dataRow.createCell(i);
|
|
|
cell.setCellValue((String)value);
|
|
|
cell.setCellStyle(cellStyle);
|
|
|
@@ -463,16 +484,15 @@ public class FormExecuteController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
FormRelease formRelease = formReleaseService.getById(releaseId);
|
|
|
FormReleaseConfig formReleaseConfig = JSONUtil.toBean(formRelease.getConfigJson(), FormReleaseConfig.class);
|
|
|
// 配置excel第一行字段名
|
|
|
List<List<String>> head = new ArrayList<>();
|
|
|
// List<ColumnConfig> columnConfigs = formReleaseConfig.getListConfig().getColumnConfigs();
|
|
|
- List<ImportConfig> importConfigs = formReleaseConfig.getListConfig().getImportConfigs();
|
|
|
// for (ColumnConfig config : columnConfigs) {
|
|
|
// head.add(Collections.singletonList(config.getLabel()));
|
|
|
// }
|
|
|
+ List<ImportConfig> importConfigs = formReleaseConfig.getListConfig().getImportConfigs();
|
|
|
for (ImportConfig config : importConfigs) {
|
|
|
head.add(Collections.singletonList(config.getLabel()));
|
|
|
}
|