|
|
@@ -3,16 +3,24 @@ package com.siwei.apply.controller.cadastre;
|
|
|
import com.siwei.apply.domain.YdbpData;
|
|
|
import com.siwei.apply.domain.res.BatchRateRes;
|
|
|
import com.siwei.apply.domain.vo.BatchTrendReportVO;
|
|
|
+import com.siwei.apply.domain.vo.LandSupplyReportVO;
|
|
|
import com.siwei.apply.service.cadastre.ISupplyService;
|
|
|
import com.siwei.apply.service.cadastre.impl.BatchServiceImpl;
|
|
|
import com.siwei.common.core.domain.R;
|
|
|
import com.siwei.common.core.web.controller.BaseController;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -160,6 +168,126 @@ public class ReportBatchController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //台账导出
|
|
|
+ @PostMapping("/bill/export")
|
|
|
+ public void exportBillReport(HttpServletResponse response, @RequestParam String year) {
|
|
|
+ try {
|
|
|
+ List<YdbpData> resList = batchServiceImpl.billProjectList(year);
|
|
|
+
|
|
|
+ if (resList == null || CollectionUtils.isEmpty(resList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Workbook workbook = new XSSFWorkbook();
|
|
|
+ Sheet sheet = workbook.createSheet("土地报批台账");
|
|
|
+
|
|
|
+ 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);
|
|
|
+
|
|
|
+ String[] headers = {"序号", "项目名称", "批次类型", "用地面积(亩)", "占用面积(亩)", "报批日期", "批复文号", "批复日期"};
|
|
|
+
|
|
|
+ int rowIndex = 0;
|
|
|
+
|
|
|
+ Row titleRow = sheet.createRow(rowIndex++);
|
|
|
+ Cell titleCell = titleRow.createCell(0);
|
|
|
+ titleCell.setCellValue("土地报批台账(" + year + "年)");
|
|
|
+ titleCell.setCellStyle(titleStyle);
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, headers.length - 1));
|
|
|
+ titleRow.setHeight((short) 600);
|
|
|
+
|
|
|
+ Row headerRow = sheet.createRow(rowIndex++);
|
|
|
+ for (int i = 0; i < headers.length; i++) {
|
|
|
+ Cell cell = headerRow.createCell(i);
|
|
|
+ cell.setCellValue(headers[i]);
|
|
|
+ cell.setCellStyle(headerStyle);
|
|
|
+ }
|
|
|
+
|
|
|
+ int seq = 1;
|
|
|
+ for (YdbpData data : resList) {
|
|
|
+ Row dataRow = sheet.createRow(rowIndex++);
|
|
|
+
|
|
|
+ Cell seqCell = dataRow.createCell(0);
|
|
|
+ seqCell.setCellValue(seq++);
|
|
|
+ seqCell.setCellStyle(dataStyle);
|
|
|
+
|
|
|
+ Cell nameCell = dataRow.createCell(1);
|
|
|
+ nameCell.setCellValue(data.getName() != null ? data.getName() : "");
|
|
|
+ nameCell.setCellStyle(dataStyle);
|
|
|
+
|
|
|
+ Cell typeCell = dataRow.createCell(2);
|
|
|
+ typeCell.setCellValue("1".equals(data.getBatchType()) ? "单独选址批次" : ("2".equals(data.getBatchType()) ? "报批项目批次" : (data.getBatchType() != null ? data.getBatchType() : "")));
|
|
|
+ typeCell.setCellStyle(dataStyle);
|
|
|
+
|
|
|
+ Cell ydAreaCell = dataRow.createCell(3);
|
|
|
+ ydAreaCell.setCellValue(data.getYdArea() != null ? data.getYdArea() : 0.0);
|
|
|
+ ydAreaCell.setCellStyle(dataStyle);
|
|
|
+
|
|
|
+ Cell zsAreaCell = dataRow.createCell(4);
|
|
|
+ zsAreaCell.setCellValue(data.getZsArea() != null ? data.getZsArea() : 0.0);
|
|
|
+ zsAreaCell.setCellStyle(dataStyle);
|
|
|
+
|
|
|
+ Cell bpDateCell = dataRow.createCell(5);
|
|
|
+ bpDateCell.setCellValue(data.getBpDate() != null ? data.getBpDate() : "");
|
|
|
+ bpDateCell.setCellStyle(dataStyle);
|
|
|
+
|
|
|
+ Cell pfwhCell = dataRow.createCell(6);
|
|
|
+ pfwhCell.setCellValue(data.getPfwh() != null ? data.getPfwh() : "");
|
|
|
+ pfwhCell.setCellStyle(dataStyle);
|
|
|
+
|
|
|
+ Cell pfDateCell = dataRow.createCell(7);
|
|
|
+ pfDateCell.setCellValue(data.getPfDate() != null ? data.getPfDate() : "");
|
|
|
+ pfDateCell.setCellStyle(dataStyle);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < headers.length; i++) {
|
|
|
+ sheet.autoSizeColumn(i);
|
|
|
+ }
|
|
|
+
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ String fileName = "土地报批台账.xlsx";
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 趋势分析报表
|
|
|
*/
|
|
|
@@ -175,4 +303,171 @@ public class ReportBatchController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
+ @PostMapping("/trend/export")
|
|
|
+ public void exportTrendReport(HttpServletResponse response, @RequestParam String startYear, @RequestParam String endYear) {
|
|
|
+ try {
|
|
|
+ BatchTrendReportVO res = batchServiceImpl.trendReport(startYear,endYear);
|
|
|
+
|
|
|
+ if (res == null || CollectionUtils.isEmpty(res.getRows())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Workbook workbook = new XSSFWorkbook();
|
|
|
+ Sheet sheet = workbook.createSheet("报批趋势分析报表");
|
|
|
+
|
|
|
+ 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);
|
|
|
+ totalStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
|
|
|
+ totalStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
|
+ 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);
|
|
|
+
|
|
|
+ String[] categories = {"单独选址", "批次报批", "合计"};
|
|
|
+ String[] subHeaders = {"项目数", "占用面积(亩)"};
|
|
|
+
|
|
|
+ int rowIndex = 0;
|
|
|
+
|
|
|
+ Row titleRow = sheet.createRow(rowIndex++);
|
|
|
+ Cell titleCell = titleRow.createCell(0);
|
|
|
+ titleCell.setCellValue("报批趋势分析报表(" + startYear + "-" + endYear + ")");
|
|
|
+ titleCell.setCellStyle(titleStyle);
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 1 + categories.length * 2));
|
|
|
+ titleRow.setHeight((short) 600);
|
|
|
+
|
|
|
+ Row headerRow1 = sheet.createRow(rowIndex++);
|
|
|
+ Row headerRow2 = sheet.createRow(rowIndex++);
|
|
|
+
|
|
|
+ Cell yearHeader = headerRow1.createCell(0);
|
|
|
+ yearHeader.setCellValue("年份");
|
|
|
+ yearHeader.setCellStyle(headerStyle);
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(1, 2, 0, 0));
|
|
|
+ headerRow2.createCell(0).setCellStyle(headerStyle);
|
|
|
+
|
|
|
+ int colIndex = 1;
|
|
|
+ for (int i = 0; i < categories.length; i++) {
|
|
|
+ Cell categoryCell = headerRow1.createCell(colIndex);
|
|
|
+ categoryCell.setCellValue(categories[i]);
|
|
|
+ categoryCell.setCellStyle(headerStyle);
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(1, 1, colIndex, colIndex + 1));
|
|
|
+
|
|
|
+ for (int j = 0; j < subHeaders.length; j++) {
|
|
|
+ Cell subCell = headerRow2.createCell(colIndex + j);
|
|
|
+ subCell.setCellValue(subHeaders[j]);
|
|
|
+ subCell.setCellStyle(headerStyle);
|
|
|
+ }
|
|
|
+ colIndex += 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (BatchTrendReportVO.RowData rowData : res.getRows()) {
|
|
|
+ Row dataRow = sheet.createRow(rowIndex++);
|
|
|
+
|
|
|
+ Cell yearCell = dataRow.createCell(0);
|
|
|
+ yearCell.setCellValue(rowData.getYear() != null ? rowData.getYear() : "");
|
|
|
+ yearCell.setCellStyle(dataStyle);
|
|
|
+
|
|
|
+ int dataColIndex = 1;
|
|
|
+ BatchTrendReportVO.TrendData[] trendArr = {rowData.getSignleData(), rowData.getReportData(), rowData.getTotalData()};
|
|
|
+ for (BatchTrendReportVO.TrendData trendData : trendArr) {
|
|
|
+ Cell countCell = dataRow.createCell(dataColIndex++);
|
|
|
+ countCell.setCellValue(trendData != null && trendData.getCount() != null ? trendData.getCount() : 0);
|
|
|
+ countCell.setCellStyle(dataStyle);
|
|
|
+
|
|
|
+ Cell areaCell = dataRow.createCell(dataColIndex++);
|
|
|
+ areaCell.setCellValue(trendData != null && trendData.getArea() != null ? trendData.getArea() : 0.0);
|
|
|
+ areaCell.setCellStyle(dataStyle);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Row totalRow = sheet.createRow(rowIndex++);
|
|
|
+ Cell totalLabelCell = totalRow.createCell(0);
|
|
|
+ totalLabelCell.setCellValue("合计");
|
|
|
+ totalLabelCell.setCellStyle(totalStyle);
|
|
|
+
|
|
|
+ int totalColIndex = 1;
|
|
|
+ BatchTrendReportVO.TrendData[] totalTrendArr = {
|
|
|
+ res.getTotal() != null ? res.getTotal().getSignleData() : null,
|
|
|
+ res.getTotal() != null ? res.getTotal().getReportData() : null,
|
|
|
+ res.getTotal() != null ? res.getTotal().getTotalData() : null
|
|
|
+ };
|
|
|
+ for (BatchTrendReportVO.TrendData trendData : totalTrendArr) {
|
|
|
+ Cell countCell = totalRow.createCell(totalColIndex++);
|
|
|
+ countCell.setCellValue(trendData != null && trendData.getCount() != null ? trendData.getCount() : 0);
|
|
|
+ countCell.setCellStyle(totalStyle);
|
|
|
+
|
|
|
+ Cell areaCell = totalRow.createCell(totalColIndex++);
|
|
|
+ areaCell.setCellValue(trendData != null && trendData.getArea() != null ? trendData.getArea() : 0.0);
|
|
|
+ areaCell.setCellStyle(totalStyle);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i <= 1 + categories.length * 2; i++) {
|
|
|
+ sheet.autoSizeColumn(i);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ String fileName = "报批趋势分析报表.xlsx";
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|