| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.lang.reflect.Method; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | * 生成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; |
| | | } |
| | |
| | | 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())); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据方法名称查询数据列表 |
| | | * |
| | | * @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) { |