1
0
فهرست منبع

权利性质报表统计

chenendian 3 هفته پیش
والد
کامیت
f7e687acd4

+ 158 - 14
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/cadastre/ParcelAnalysisController.java

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

+ 2 - 4
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/cadastre/IParcelService.java

@@ -1,9 +1,6 @@
 package com.siwei.apply.service.cadastre;
 
-import com.siwei.apply.domain.cadastre.ParcelStatisticsRes;
-import com.siwei.apply.domain.cadastre.Zdjbxx;
-import com.siwei.apply.domain.cadastre.ZdqlReportVO;
-import com.siwei.apply.domain.cadastre.ZdytReportVO;
+import com.siwei.apply.domain.cadastre.*;
 
 import java.util.List;
 import java.util.Map;
@@ -20,6 +17,7 @@ public interface IParcelService {
 
     ZdytReportVO getZdytReport();
 
+    List<ParcelStatisticsRes.QlxzDTO> getZdqlxzReport();
 
 
 }

+ 63 - 4
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/cadastre/impl/ParcelServiceImpl.java

@@ -1,11 +1,8 @@
 package com.siwei.apply.service.cadastre.impl;
 
 import com.siwei.apply.domain.LandType;
-import com.siwei.apply.domain.cadastre.ParcelStatisticsRes;
-import com.siwei.apply.domain.cadastre.Zdjbxx;
-import com.siwei.apply.domain.cadastre.ZdqlReportVO;
+import com.siwei.apply.domain.cadastre.*;
 
-import com.siwei.apply.domain.cadastre.ZdytReportVO;
 import com.siwei.apply.mapper.LandTypeMapper;
 import com.siwei.apply.mapper.cadastre.ZdjbxxMapper;
 import com.siwei.apply.service.cadastre.IParcelService;
@@ -539,6 +536,62 @@ public class ParcelServiceImpl implements IParcelService {
     }
 
 
+    @Override
+    public List<ParcelStatisticsRes.QlxzDTO> getZdqlxzReport(){
+        List<ParcelStatisticsRes.QlxzDTO>  resList = new ArrayList<>();
+        List<Zdjbxx> zdjbxxList = zdjbxxMapper.getListByDjzqdm(null);
+        Map<String,List<Zdjbxx>> qlxzGroupedByYtMap = new LinkedHashMap<>();
+        zdjbxxMapper.getDictByType("A7",null).forEach(item -> {
+            String name = item.get("name").toString();
+            String value = item.get("value").toString();
+            List<Zdjbxx> filterList = zdjbxxList.stream().filter(zd-> StringUtils.isNotBlank(zd.getQlxz())).filter(zd -> value.equals(zd.getQlxz())).collect(Collectors.toList());
+            if(CollectionUtils.isNotEmpty(filterList)){
+                qlxzGroupedByYtMap.put(name, filterList);
+            }
+        });
+
+        //这里遍历map,然后进行统计数据;
+        if(MapUtils.isNotEmpty(qlxzGroupedByYtMap)){
+            for(Map.Entry<String, List<Zdjbxx>> entry : qlxzGroupedByYtMap.entrySet()){
+                ParcelStatisticsRes.QlxzDTO qlxzDTO = new ParcelStatisticsRes.QlxzDTO();
+                qlxzDTO.setQlxzmc(entry.getKey());
+                double totalArea = 0.0;
+                for(Zdjbxx zd : entry.getValue()) {
+                    totalArea += convertAreaToMu(zd.getZdmj(), zd.getMjdw());
+                }
+                if(entry.getKey().contains("国有土地")){
+                    qlxzDTO.setQlxzlx("100");
+                }else if(entry.getKey().contains("集体土地")){
+                    qlxzDTO.setQlxzlx("200");
+                }else {
+                    qlxzDTO.setQlxzlx("0");
+                }
+                qlxzDTO.setQlxzmj(String.format("%.2f", totalArea));
+                resList.add(qlxzDTO);
+            }
+
+            // ---- 数据行 & 计算合计 ----
+            double totalArea = 0.0;
+            for (ParcelStatisticsRes.QlxzDTO dto : resList) {
+                double areaVal = 0.0;
+                if (dto.getQlxzmj() != null && !dto.getQlxzmj().isEmpty()) {
+                    try {
+                        areaVal = Double.parseDouble(dto.getQlxzmj());
+                    } catch (NumberFormatException ignored) {
+                    }
+                }
+                totalArea += areaVal;
+            }
+            ParcelStatisticsRes.QlxzDTO qlxzDTO = new ParcelStatisticsRes.QlxzDTO();
+            qlxzDTO.setQlxzmj(String.format("%.2f", totalArea));
+            qlxzDTO.setQlxzmc("合计");
+            qlxzDTO.setQlxzlx("0");
+            resList.add(qlxzDTO);
+        }
+        return  resList;
+    }
+
+
     /**
      * 面积保留两位小数(四舍五入)
      */
@@ -546,4 +599,10 @@ public class ParcelServiceImpl implements IParcelService {
         return Math.round(value * 100.0) / 100.0;
     }
 
+
+
+
+
+
+
 }