Browse Source

历史数据导出

wangyangyang 3 years ago
parent
commit
9cc4af3ced

+ 1 - 1
sms_water/src/main/java/com/huaxu/controller/DayMonthYearReportController.java

@@ -292,7 +292,7 @@ public class DayMonthYearReportController {
         if (CollectionUtil.isEmpty(list)) {
             return new AjaxMessage<>(ResultStatus.OK);
         }
-        List<List<String>> reportTitle = ReportExcelUtil.toExcelTitleList(list.get(0).getReportTitle(), queryDto.getSceneType(),1);
+        List<List<String>> reportTitle = ReportExcelUtil.toHistoryDataExcelTitleList(list.get(0).getReportTitle(), queryDto.getSceneType(),1);
         String filePath = ExcelUtil.writeSimpleExcelWithHeader(baseDir, SceneEnum.getMsg(queryDto.getSceneType()) + "报表", reportTitle, ReportExcelUtil.toHisoryDataReportExcelDto(list, queryDto.getSceneType()));
         return new AjaxMessage<>(ResultStatus.OK, filePath);
     }

+ 30 - 0
sms_water/src/main/java/com/huaxu/util/ReportExcelUtil.java

@@ -148,6 +148,36 @@ public class ReportExcelUtil {
         return result;
     }
 
+    /**
+     * @Author lihui
+     * @Description 按顺序组装导出的标题
+     * @Date 17:11 2021/5/17
+     * @Param [titleDtos, titleType]
+     * @return java.util.List<java.util.List<java.lang.String>>
+     **/
+    public static List<List<String>> toHistoryDataExcelTitleList(List<ReportTitleDto> titleDtos, int titleType,int reportType){
+        List<List<String>> titleList = toTitleList(titleDtos,reportType);
+        String[] shuZu  = TITLE_MAP.get(4);
+        if (shuZu == null) {
+            return titleList;
+        }
+        boolean isEmpty = CollectionUtil.isEmpty(titleList);
+        List<List<String>> result = new ArrayList<>();
+        for (String string : shuZu) {
+            List<String> listString = new ArrayList<>();
+            listString.add(string);
+            if (!isEmpty){
+                listString.add(string);
+                listString.add(string);
+            }
+            result.add(listString);
+        }
+        if (!isEmpty) {
+            result.addAll(titleList);
+        }
+        return result;
+    }
+
     private static List<List<String>> toTitleList(List<ReportTitleDto> list,int reportType) {
         if (CollectionUtil.isEmpty(list)) {
             return null;