1
0
chenendian 14 часов назад
Родитель
Сommit
ef7300e0a4

+ 295 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/cadastre/ReportBatchController.java

@@ -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();
+        }
+    }
+
+
+
+
+
+
+
+
+
+
+
+
 }

+ 1 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/YdbpDataMapper.java

@@ -54,6 +54,7 @@ public interface YdbpDataMapper {
     void updateHasOnchain(@Param("id") String id, @Param("hasOnchain") Boolean hasOnchain);
 
     List<YdbpData> getStatisticsList(@Param("year") String year,
+                                     @Param("startYear") String startYear,@Param("endYear") String endYear,
                                      @Param("keyWord") String keyWord,@Param("hasGeom")Boolean hasGeom);
 
     List<Map<String,Object>> queryRemainGeomAreaByYear();

+ 4 - 1
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/YdbpMapper.java

@@ -54,9 +54,12 @@ public interface YdbpMapper {
     void updateHasOnchain(@Param("id") String id, @Param("hasOnchain") Boolean hasOnchain);
 
 
-    List<Map<String, Object>> getStatisticsList(@Param("year") String year,
+    List<Map<String, Object>> getStatisticsList(@Param("year") String year,@Param("startYear") String startYear,@Param("endYear") String endYear,
                                                 @Param("keyWord") String keyWord,@Param("hasGeom") Boolean hasGeom);
 
 
 
+
+
+
 }

+ 10 - 16
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/cadastre/impl/BatchServiceImpl.java

@@ -67,7 +67,7 @@ public class BatchServiceImpl{
 
 
     private List<Map<String,Object>> buildSingleProjectList(String year, String keyWord) {
-        List<Map<String,Object>> singleBatchList =  ydbpMapper.getStatisticsList(year,keyWord,true);
+        List<Map<String,Object>> singleBatchList =  ydbpMapper.getStatisticsList(year,keyWord,"","",true);
         if (CollectionUtils.isEmpty(singleBatchList)) {
             return new ArrayList<>();
         }
@@ -81,7 +81,7 @@ public class BatchServiceImpl{
     }
 
     private List<YdbpData> buildReportProjectList(String year, String keyWord) {
-        List<YdbpData> reportBatchList =  ydbpDataMapper.getStatisticsList(year,keyWord,true);
+        List<YdbpData> reportBatchList =  ydbpDataMapper.getStatisticsList(year,keyWord,"","",true);
         if (CollectionUtils.isEmpty(reportBatchList)) {
             return new ArrayList<>();
         }
@@ -108,15 +108,11 @@ public class BatchServiceImpl{
         if(StringUtils.isBlank(startYear)||StringUtils.isBlank(endYear)){
             throw new  ServiceException("年份不能为空");
         }
-
-        startYear = "";
-        endYear  = "";
-
         BatchTrendReportVO batchTrendReportVO = new BatchTrendReportVO();
         List<BatchTrendReportVO.RowData> rows = new ArrayList<>();
 
-        List<Map<String,Object>> singleBatchList =  ydbpMapper.getStatisticsList(startYear,"",false);
-        List<YdbpData> reportBatchList =  ydbpDataMapper.getStatisticsList(startYear,"",false);
+        List<Map<String,Object>> singleBatchList =  ydbpMapper.getStatisticsList("",startYear,endYear,"",false);
+        List<YdbpData> reportBatchList =  ydbpDataMapper.getStatisticsList("",startYear,endYear,"",false);
 
         Map<String,List<Map<String,Object>>> groupedSingleBatch = new HashMap<>();
         Map<String, List<YdbpData>> groupedReportBatch = new HashMap<>();
@@ -223,18 +219,16 @@ public class BatchServiceImpl{
 
 
 
-
-
     public List<YdbpData> billProjectList(String year) {
         if(StringUtils.isBlank(year)){
             throw new  ServiceException("年份不能为空");
         }
         List<YdbpData> resList = new ArrayList<>();
-        List<YdbpData> reportBatchList =  ydbpDataMapper.getStatisticsList(year,"",false);
+        List<YdbpData> reportBatchList =  ydbpDataMapper.getStatisticsList(year,"","","",false);
         if(CollectionUtils.isNotEmpty(reportBatchList)){
             resList.addAll(reportBatchList);
         }
-        List<Map<String,Object>> singleBatchList =  ydbpMapper.getStatisticsList(year,"",false);
+        List<Map<String,Object>> singleBatchList =  ydbpMapper.getStatisticsList(year,"","","",false);
         if(CollectionUtils.isNotEmpty(singleBatchList)){
             singleBatchList.stream().map(s->{
                 YdbpData ydbpData = new YdbpData();
@@ -334,8 +328,8 @@ public class BatchServiceImpl{
         }
 
         List<Map<String,Object>> resList = new ArrayList<>();
-        List<Map<String,Object>> singleBatchList =  ydbpMapper.getStatisticsList(year,"",false);
-        List<YdbpData> reportBatchList =  ydbpDataMapper.getStatisticsList(year,"",false);
+        List<Map<String,Object>> singleBatchList =  ydbpMapper.getStatisticsList(year,"","","",false);
+        List<YdbpData> reportBatchList =  ydbpDataMapper.getStatisticsList(year,"","","",false);
 
         Map<String,List<Map<String,Object>>> groupedSingleBatch = new HashMap<>();
         Map<String, List<YdbpData>> groupedReportBatch = new HashMap<>();
@@ -404,8 +398,8 @@ public class BatchServiceImpl{
             year="";
         }
         BatchRateRes res = new BatchRateRes();
-        List<Map<String,Object>> singleBatchList =  ydbpMapper.getStatisticsList(year,"",false);
-        List<YdbpData> reportBatchList =  ydbpDataMapper.getStatisticsList(year,"",false);
+        List<Map<String,Object>> singleBatchList =  ydbpMapper.getStatisticsList(year,"","","",false);
+        List<YdbpData> reportBatchList =  ydbpDataMapper.getStatisticsList(year,"","","",false);
         if(CollectionUtils.isNotEmpty(singleBatchList)) {
             res.setSingleArea(sumAreaForSingle(singleBatchList));
             res.setSingleProjectCount(singleBatchList.size());

+ 4 - 0
siwei-modules/siwei-apply/src/main/resources/mapper/YdbpDataMapper.xml

@@ -155,6 +155,10 @@
         <if test="year != null and year != '' ">
             AND left(bp.pf_date,4) = #{year}
         </if>
+        <if test="(startYear != null and startYear != null) and (endYear != '' and endYear != '')">
+            AND left(bp.pf_date,4)::NUMERIC BETWEEN #{startYear}::NUMERIC AND #{endYear}::NUMERIC
+        </if>
+
         <if test="keyWord != null and keyWord != ''">
             AND (
                 COALESCE(bp.name, '') LIKE CONCAT('%', #{keyWord}, '%')

+ 3 - 4
siwei-modules/siwei-apply/src/main/resources/mapper/YdbpMapper.xml

@@ -100,8 +100,9 @@
             AND left(bp.pf_date,4) = #{year}
         </if>
 
-
-
+        <if test="(startYear != null and startYear != null) and (endYear != '' and endYear != '')">
+            AND left(bp.pf_date,4)::NUMERIC BETWEEN #{startYear}::NUMERIC AND #{endYear}::NUMERIC
+        </if>
         <if test="keyWord != null and keyWord != ''">
             AND (
             COALESCE(pro.name, '') LIKE CONCAT('%', #{keyWord}, '%')
@@ -110,8 +111,6 @@
         </if>
 
 
-
-
     </select>