管道基础大数据平台系统开发-【后端】-Server
13693261870
2024-03-06 0cb3f66d6ea29da00a5fe8982d8b32926b399f72
反射查询方法
已修改1个文件
48 ■■■■ 文件已修改
src/main/java/com/lf/server/service/sys/ReportService.java 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/sys/ReportService.java
@@ -20,6 +20,7 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.lang.reflect.Method;
import java.util.*;
/**
@@ -313,7 +314,7 @@
     * 生成Excel
     */
    private void createExcel(String source, String target, ReportEntity re) {
        List<CountEntity> list = countExplorationPoints();
        List<CountEntity> list = selectListByMethodName(re);
        if (null == list || list.isEmpty()) {
            return;
        }
@@ -321,15 +322,6 @@
        int rows = 1, allCount = 0;
        Double allSize = 0d, allArea = 0d;
        for (CountEntity ce : list) {
            if (null == ce.getCount()) {
                ce.setCount(0L);
            }
            if (null == ce.getSizes()) {
                ce.setSizes(0d);
            }
            if (null == ce.getArea()) {
                ce.setArea(0d);
            }
            ce.setNo(rows++);
            ce.setM2(FileHelper.getSizes(ce.getSizes()));
            ce.setM3(FileHelper.getSquareMeter(ce.getArea()));
@@ -354,6 +346,42 @@
    }
    /**
     * 根据方法名称查询数据列表
     *
     * @param re
     * @return
     */
    private List<CountEntity> selectListByMethodName(ReportEntity re) {
        List<CountEntity> list = null;
        try {
            Method method = ReportService.class.getDeclaredMethod(re.getCode(), ReportService.class);
            Object obj = method.invoke(this);
            if (obj instanceof List<?>) {
                list = (List<CountEntity>) obj;
            }
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        }
        if (null == list || list.isEmpty()) {
            return list;
        }
        for (CountEntity ce : list) {
            if (null == ce.getCount()) {
                ce.setCount(0L);
            }
            if (null == ce.getSizes()) {
                ce.setSizes(0d);
            }
            if (null == ce.getArea()) {
                ce.setArea(0d);
            }
        }
        return list;
    }
    /**
     * 获取下载实体类
     */
    private DownloadEntity getDownloadEntity(UserEntity ue, String file) {