Browse Source

excel模板导出和数据导出是post请求

大数据与最优化研究所 1 week ago
parent
commit
4f090036b3

+ 13 - 5
src/main/java/com/xjrsoft/module/form/controller/FormExecuteController.java

@@ -467,8 +467,12 @@ public class FormExecuteController {
         FormReleaseConfig formReleaseConfig = JSONUtil.toBean(formRelease.getConfigJson(), FormReleaseConfig.class);
         // 配置excel第一行字段名
         List<List<String>> head = new ArrayList<>();
-        List<ColumnConfig> columnConfigs = formReleaseConfig.getListConfig().getColumnConfigs();
-        for (ColumnConfig config : columnConfigs) {
+//        List<ColumnConfig> columnConfigs = formReleaseConfig.getListConfig().getColumnConfigs();
+        List<ImportConfig> importConfigs = formReleaseConfig.getListConfig().getImportConfigs();
+//        for (ColumnConfig config : columnConfigs) {
+//            head.add(Collections.singletonList(config.getLabel()));
+//        }
+        for (ImportConfig config : importConfigs) {
             head.add(Collections.singletonList(config.getLabel()));
         }
         List<Map<Integer, Object>> dataList = EasyExcel.read(file.getInputStream()).head(head).sheet().doReadSync();
@@ -476,9 +480,13 @@ public class FormExecuteController {
         List<Map<String, Object>> savedDataList = new ArrayList<>(dataList.size());
         for (Map<Integer, Object> data : dataList) {
             Map<String, Object> saveData = new HashMap<>(data.size());
-            for (int i = 0; i < columnConfigs.size(); i++) {
-                ColumnConfig columnConfig = columnConfigs.get(i);
-                saveData.put(columnConfig.getColumnName(), data.get(i));
+//            for (int i = 0; i < columnConfigs.size(); i++) {
+//                ColumnConfig columnConfig = columnConfigs.get(i);
+//                saveData.put(columnConfig.getColumnName(), data.get(i));
+//            }
+            for (int i = 0; i < importConfigs.size(); i++) {
+                ImportConfig importConfig = importConfigs.get(i);
+                saveData.put(importConfig.getFieldName(), data.get(i));
             }
             savedDataList.add(saveData);
         }