From 7b2cce1b88761c23da4dc8b5343dd9700c36a6fd Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期二, 27 二月 2024 10:32:46 +0800 Subject: [PATCH] 修改导出报告功能 --- src/main/java/com/lf/server/service/sys/ReportService.java | 206 +++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 166 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/lf/server/service/sys/ReportService.java b/src/main/java/com/lf/server/service/sys/ReportService.java index ab0863b..e01b58e 100644 --- a/src/main/java/com/lf/server/service/sys/ReportService.java +++ b/src/main/java/com/lf/server/service/sys/ReportService.java @@ -167,6 +167,12 @@ case "countExplorationPoints": createCountExplorationPointsWord(source, target); break; + case "countSizesByType": + createCountSizesByTypeWord(source, target); + break; + case "countSizesByPrj": + createCountSizesByPrjWord(source, target); + break; default: break; } @@ -183,6 +189,12 @@ break; case "countExplorationPoints": createCountExplorationPointsExcel(source, target); + break; + case "countSizesByType": + createCountSizesByTypeExcel(source, target); + break; + case "countSizesByPrj": + createCountSizesByPrjExcel(source, target); break; default: break; @@ -214,29 +226,6 @@ } /** - * 鍒涘缓 鏈嶅姟璋冪敤閲忕粺璁� Word - */ - public void createCountServicesWord(String source, String target) { - List<CountEntity> list = countServices(); - if (null == list || list.isEmpty()) { - return; - } - - int rows = 1, allCount = 0; - ArrayList<String[]> addList = new ArrayList<>(); - for (CountEntity ce : list) { - allCount += ce.getCount(); - String[] strs = new String[]{"" + rows++, ce.getM1(), ce.getCount().toString()}; - addList.add(strs); - } - if (addList.size() > 0) { - addList.add(new String[]{"" + rows, "鎬昏", "" + allCount}); - } - - WordHelper.generateWord(source, target, null, addList); - } - - /** * 鍒涘缓 鏁版嵁閲忕粺璁� Word */ public void createCountSizesWord(String source, String target) { @@ -255,6 +244,29 @@ } if (addList.size() > 0) { addList.add(new String[]{"" + rows, "鎬昏", FileHelper.getSizes(allSize)}); + } + + WordHelper.generateWord(source, target, null, addList); + } + + /** + * 鍒涘缓 鏈嶅姟璋冪敤閲忕粺璁� Word + */ + public void createCountServicesWord(String source, String target) { + List<CountEntity> list = countServices(); + if (null == list || list.isEmpty()) { + return; + } + + int rows = 1, allCount = 0; + ArrayList<String[]> addList = new ArrayList<>(); + for (CountEntity ce : list) { + allCount += ce.getCount(); + String[] strs = new String[]{"" + rows++, ce.getM1(), ce.getCount().toString()}; + addList.add(strs); + } + if (addList.size() > 0) { + addList.add(new String[]{"" + rows, "鎬昏", "" + allCount}); } WordHelper.generateWord(source, target, null, addList); @@ -286,38 +298,60 @@ } /** - * 鍒涘缓 鐢ㄦ埛娴侀噺缁熻 Excel + * 鍒涘缓 鏁版嵁鏍煎紡缁熻 Word */ - public void createCountOperatesExcel(String source, String target) { - List<CountEntity> list = countOperates(); + public void createCountSizesByTypeWord(String source, String target) { + List<CountEntity> list = countSizesByType(); if (null == list || list.isEmpty()) { return; } int rows = 1, allCount = 0; + Double allSize = 0d; + ArrayList<String[]> addList = new ArrayList<>(); for (CountEntity ce : list) { - ce.setNo(rows++); + allSize += ce.getSizes(); allCount += ce.getCount(); + String[] strs = new String[]{"" + rows++, ce.getM1(), "" + ce.getCount(), FileHelper.getSizes(ce.getSizes())}; + addList.add(strs); } - if (list.size() > 0) { - CountEntity ce = new CountEntity(); - ce.setNo(rows); - ce.setM1("鎬昏"); - ce.setCount((long) allCount); - list.add(ce); + if (addList.size() > 0) { + addList.add(new String[]{"" + rows, "鎬昏", "" + allCount, FileHelper.getSizes(allSize)}); } - Map<String, List<CountEntity>> map = new HashMap<>(1); - map.put("data", list); - - ExcelHelper.writeToTemplate(source, target, map); + WordHelper.generateWord(source, target, null, addList); } /** - * 鍒涘缓 鏈嶅姟璋冪敤閲忕粺璁� Excel + * 鍒涘缓 椤圭洰鏁版嵁缁熻 Word */ - public void createCountServicesExcel(String source, String target) { - List<CountEntity> list = countServices(); + public void createCountSizesByPrjWord(String source, String target) { + List<CountEntity> list = countSizesByPrj(); + if (null == list || list.isEmpty()) { + return; + } + + int rows = 1, allCount = 0; + Double allSize = 0d; + ArrayList<String[]> addList = new ArrayList<>(); + for (CountEntity ce : list) { + allSize += ce.getSizes(); + allCount += ce.getCount(); + String[] strs = new String[]{"" + rows++, ce.getM1(), "" + ce.getCount(), FileHelper.getSizes(ce.getSizes())}; + addList.add(strs); + } + if (addList.size() > 0) { + addList.add(new String[]{"" + rows, "鎬昏", "" + allCount, FileHelper.getSizes(allSize)}); + } + + WordHelper.generateWord(source, target, null, addList); + } + + /** + * 鍒涘缓 鐢ㄦ埛娴侀噺缁熻 Excel + */ + public void createCountOperatesExcel(String source, String target) { + List<CountEntity> list = countOperates(); if (null == list || list.isEmpty()) { return; } @@ -372,6 +406,34 @@ } /** + * 鍒涘缓 鏈嶅姟璋冪敤閲忕粺璁� Excel + */ + public void createCountServicesExcel(String source, String target) { + List<CountEntity> list = countServices(); + if (null == list || list.isEmpty()) { + return; + } + + int rows = 1, allCount = 0; + for (CountEntity ce : list) { + ce.setNo(rows++); + allCount += ce.getCount(); + } + if (list.size() > 0) { + CountEntity ce = new CountEntity(); + ce.setNo(rows); + ce.setM1("鎬昏"); + ce.setCount((long) allCount); + list.add(ce); + } + + Map<String, List<CountEntity>> map = new HashMap<>(1); + map.put("data", list); + + ExcelHelper.writeToTemplate(source, target, map); + } + + /** * 鍒涘缓 閽诲瓟鏁版嵁缁熻 Excel */ public void createCountExplorationPointsExcel(String source, String target) { @@ -404,6 +466,70 @@ } /** + * 鍒涘缓 鏁版嵁鏍煎紡缁熻 Excel + */ + public void createCountSizesByTypeExcel(String source, String target) { + List<CountEntity> list = countSizesByType(); + if (null == list || list.isEmpty()) { + return; + } + + int rows = 1, allCount = 0; + Double allSize = 0d; + for (CountEntity ce : list) { + ce.setNo(rows++); + ce.setM2(FileHelper.getSizes(ce.getSizes())); + allCount += ce.getCount(); + allSize += ce.getSizes(); + } + if (list.size() > 0) { + CountEntity ce = new CountEntity(); + ce.setNo(rows); + ce.setM1("鎬昏"); + ce.setCount((long) allCount); + ce.setM2(FileHelper.getSizes(allSize)); + list.add(ce); + } + + Map<String, List<CountEntity>> map = new HashMap<>(1); + map.put("data", list); + + ExcelHelper.writeToTemplate(source, target, map); + } + + /** + * 鍒涘缓 椤圭洰鏁版嵁缁熻 Excel + */ + public void createCountSizesByPrjExcel(String source, String target) { + List<CountEntity> list = countSizesByPrj(); + if (null == list || list.isEmpty()) { + return; + } + + int rows = 1, allCount = 0; + Double allSize = 0d; + for (CountEntity ce : list) { + ce.setNo(rows++); + ce.setM2(FileHelper.getSizes(ce.getSizes())); + allCount += ce.getCount(); + allSize += ce.getSizes(); + } + if (list.size() > 0) { + CountEntity ce = new CountEntity(); + ce.setNo(rows); + ce.setM1("鎬昏"); + ce.setCount((long) allCount); + ce.setM2(FileHelper.getSizes(allSize)); + list.add(ce); + } + + Map<String, List<CountEntity>> map = new HashMap<>(1); + map.put("data", list); + + ExcelHelper.writeToTemplate(source, target, map); + } + + /** * 鑾峰彇涓嬭浇瀹炰綋绫� */ private DownloadEntity getDownloadEntity(UserEntity ue, String file) { -- Gitblit v1.9.3