管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-02-11 23bbee889008c89ca39632ff4c86724d57517906
src/main/java/com/lf/server/service/sys/ReportService.java
@@ -14,9 +14,7 @@
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
/**
 * 报告模板
@@ -153,7 +151,17 @@
                    break;
            }
        } else {
            //
            switch (re.getCode()) {
                case "countOperates ":
                    createCountOperatesExcel(source, target);
                    break;
                case "countSizes":
                    createCountSizesExcel(source, target);
                    break;
                default:
                    createCountServicesExcel(source, target);
                    break;
            }
        }
    }
@@ -215,6 +223,67 @@
    }
    /**
     * 创建 用户流量统计 Excel
     */
    public void createCountOperatesExcel(String source, String target) {
        List<CountEntity> list = countOperates();
        if (null == list || list.isEmpty()) {
            return;
        }
        int rows = 1;
        for (CountEntity ce : list) {
            ce.setNo(rows++);
        }
        Map<String, List<CountEntity>> map = new HashMap<>();
        map.put("data", list);
        ExcelHelper.writeToTemplate(source, target, map);
    }
    /**
     * 创建 服务调用量统计 Excel
     */
    public void createCountServicesExcel(String source, String target) {
        List<CountEntity> list = countServices();
        if (null == list || list.isEmpty()) {
            return;
        }
        int rows = 1;
        for (CountEntity ce : list) {
            ce.setNo(rows++);
        }
        Map<String, List<CountEntity>> map = new HashMap<>();
        map.put("data", list);
        ExcelHelper.writeToTemplate(source, target, map);
    }
    /**
     * 创建 数据量统计 Excel
     */
    public void createCountSizesExcel(String source, String target) {
        List<CountEntity> list = countSizes();
        if (null == list || list.isEmpty()) {
            return;
        }
        int rows = 1;
        for (CountEntity ce : list) {
            ce.setNo(rows++);
            ce.setM2(FileHelper.getSizes(ce.getSizes()));
        }
        Map<String, List<CountEntity>> map = new HashMap<>();
        map.put("data", list);
        ExcelHelper.writeToTemplate(source, target, map);
    }
    /**
     * 获取下载实体类
     */
    private DownloadEntity getDownloadEntity(UserEntity ue, String file) {