|
|
@@ -489,22 +489,166 @@ public class ParcelAnalysisController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @GetMapping("/report/qlxz")
|
|
|
+ public R<List<ParcelStatisticsRes.QlxzDTO>> getZdqlxzReport() {
|
|
|
+ try {
|
|
|
+ List<ParcelStatisticsRes.QlxzDTO> res = parcelService.getZdqlxzReport();
|
|
|
+ return R.ok(res);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return R.fail(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出宗地权利性质报表(Excel格式)
|
|
|
+ * 表格结构(参照原型图):
|
|
|
+ * - 第1行:报表标题(跨2列合并)
|
|
|
+ * - 第2行:列头(统计项 | 宗地面积)
|
|
|
+ * - 数据行:各权利性质条目(qlxzmc | qlxzmj)
|
|
|
+ * - 末行:合计行(汇总所有行的宗地面积)
|
|
|
+ */
|
|
|
+ @PostMapping("/qlxz/export")
|
|
|
+ public void exportZdqlxzReport(HttpServletResponse response) {
|
|
|
+ try {
|
|
|
+ List<ParcelStatisticsRes.QlxzDTO> res = parcelService.getZdqlxzReport();
|
|
|
+ if (res == null || res.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Workbook workbook = new XSSFWorkbook();
|
|
|
+ Sheet sheet = workbook.createSheet("宗地权利性质报表");
|
|
|
|
|
|
+ // ---- 样式定义 ----
|
|
|
+ // 标题样式(居中、加粗、14号字、带边框)
|
|
|
+ CellStyle titleStyle = workbook.createCellStyle();
|
|
|
+ titleStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+ titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+ Font titleFont = workbook.createFont();
|
|
|
+ titleFont.setBold(true);
|
|
|
+ titleFont.setFontHeightInPoints((short) 14);
|
|
|
+ titleStyle.setFont(titleFont);
|
|
|
+ titleStyle.setBorderTop(BorderStyle.THIN);
|
|
|
+ titleStyle.setBorderBottom(BorderStyle.THIN);
|
|
|
+ titleStyle.setBorderLeft(BorderStyle.THIN);
|
|
|
+ titleStyle.setBorderRight(BorderStyle.THIN);
|
|
|
+
|
|
|
+ // 列头样式(灰色背景、加粗、居中、带边框)
|
|
|
+ CellStyle headerStyle = workbook.createCellStyle();
|
|
|
+ headerStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+ headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+ headerStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
|
|
|
+ headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
|
+ Font headerFont = workbook.createFont();
|
|
|
+ headerFont.setBold(true);
|
|
|
+ headerStyle.setFont(headerFont);
|
|
|
+ headerStyle.setBorderTop(BorderStyle.THIN);
|
|
|
+ headerStyle.setBorderBottom(BorderStyle.THIN);
|
|
|
+ headerStyle.setBorderLeft(BorderStyle.THIN);
|
|
|
+ headerStyle.setBorderRight(BorderStyle.THIN);
|
|
|
+
|
|
|
+ // 数据样式(居中、带边框)
|
|
|
+ CellStyle dataStyle = workbook.createCellStyle();
|
|
|
+ dataStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+ dataStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+ dataStyle.setBorderTop(BorderStyle.THIN);
|
|
|
+ dataStyle.setBorderBottom(BorderStyle.THIN);
|
|
|
+ dataStyle.setBorderLeft(BorderStyle.THIN);
|
|
|
+ dataStyle.setBorderRight(BorderStyle.THIN);
|
|
|
+
|
|
|
+ // 合计行样式(加粗、居中、带边框)
|
|
|
+ CellStyle totalStyle = workbook.createCellStyle();
|
|
|
+ totalStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+ totalStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+ Font totalFont = workbook.createFont();
|
|
|
+ totalFont.setBold(true);
|
|
|
+ totalStyle.setFont(totalFont);
|
|
|
+ totalStyle.setBorderTop(BorderStyle.THIN);
|
|
|
+ totalStyle.setBorderBottom(BorderStyle.THIN);
|
|
|
+ totalStyle.setBorderLeft(BorderStyle.THIN);
|
|
|
+ totalStyle.setBorderRight(BorderStyle.THIN);
|
|
|
+
|
|
|
+ int rowIndex = 0;
|
|
|
+
|
|
|
+ // ---- 第1行:报表标题(跨2列合并)----
|
|
|
+ Row titleRow = sheet.createRow(rowIndex++);
|
|
|
+ titleRow.setHeight((short) 500);
|
|
|
+ Cell titleCell = titleRow.createCell(0);
|
|
|
+ titleCell.setCellValue("宗地权利性质报表");
|
|
|
+ titleCell.setCellStyle(titleStyle);
|
|
|
+ // 填充合并区域内其余单元格的样式,避免边框缺失
|
|
|
+ Cell titleCell1 = titleRow.createCell(1);
|
|
|
+ titleCell1.setCellStyle(titleStyle);
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 1));
|
|
|
+
|
|
|
+ // ---- 第2行:列头 ----
|
|
|
+ Row headerRow = sheet.createRow(rowIndex++);
|
|
|
+ headerRow.setHeight((short) 400);
|
|
|
+ Cell headerStat = headerRow.createCell(0);
|
|
|
+ headerStat.setCellValue("统计项");
|
|
|
+ headerStat.setCellStyle(headerStyle);
|
|
|
+ Cell headerArea = headerRow.createCell(1);
|
|
|
+ headerArea.setCellValue("宗地面积");
|
|
|
+ headerArea.setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ // ---- 数据行 & 计算合计 ----
|
|
|
+ double totalArea = 0.0;
|
|
|
+ for (ParcelStatisticsRes.QlxzDTO dto : res) {
|
|
|
+ Row dataRow = sheet.createRow(rowIndex++);
|
|
|
+ dataRow.setHeight((short) 400);
|
|
|
+
|
|
|
+ Cell nameCell = dataRow.createCell(0);
|
|
|
+ nameCell.setCellValue(dto.getQlxzmc() != null ? dto.getQlxzmc() : "");
|
|
|
+ nameCell.setCellStyle(dataStyle);
|
|
|
+
|
|
|
+ double areaVal = 0.0;
|
|
|
+ if (dto.getQlxzmj() != null && !dto.getQlxzmj().isEmpty()) {
|
|
|
+ try {
|
|
|
+ areaVal = Double.parseDouble(dto.getQlxzmj());
|
|
|
+ } catch (NumberFormatException ignored) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Cell areaCell = dataRow.createCell(1);
|
|
|
+ areaCell.setCellValue(areaVal);
|
|
|
+ areaCell.setCellStyle(dataStyle);
|
|
|
+
|
|
|
+ totalArea += areaVal;
|
|
|
+ }
|
|
|
+
|
|
|
+ // ---- 合计行 ----
|
|
|
+ Row totalRow = sheet.createRow(rowIndex);
|
|
|
+ totalRow.setHeight((short) 400);
|
|
|
+ Cell totalNameCell = totalRow.createCell(0);
|
|
|
+ totalNameCell.setCellValue("合计");
|
|
|
+ totalNameCell.setCellStyle(totalStyle);
|
|
|
+ Cell totalAreaCell = totalRow.createCell(1);
|
|
|
+ totalAreaCell.setCellValue(totalArea);
|
|
|
+ totalAreaCell.setCellStyle(totalStyle);
|
|
|
+
|
|
|
+ // ---- 自动调整列宽 ----
|
|
|
+ for (int i = 0; i < 2; i++) {
|
|
|
+ sheet.autoSizeColumn(i);
|
|
|
+ int currentWidth = sheet.getColumnWidth(i);
|
|
|
+ if (currentWidth < 4000) {
|
|
|
+ sheet.setColumnWidth(i, 4000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // ---- 设置响应头并写出 ----
|
|
|
+ String fileName = "宗地权利性质报表";
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ String encodedName = URLEncoder.encode(fileName, StandardCharsets.UTF_8).replace("+", "%20");
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename*=UTF-8''" + encodedName);
|
|
|
+
|
|
|
+ workbook.write(response.getOutputStream());
|
|
|
+ workbook.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
-// /**
|
|
|
-// *
|
|
|
-// * 趋势统计
|
|
|
-// */
|
|
|
-// @GetMapping("/trendStatistics/{landType}")
|
|
|
-// public R<TrendStatisticsRes> getTrendStatistics(@PathVariable String landType) {
|
|
|
-// try {
|
|
|
-// TrendStatisticsRes res = supplyService.trendStatistics(landType);
|
|
|
-// return R.ok(res);
|
|
|
-// } catch (Exception e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// return R.fail(e.getMessage());
|
|
|
-// }
|
|
|
-// }
|
|
|
|
|
|
|
|
|
|