|
|
@@ -1,17 +1,11 @@
|
|
|
package com.siwei.apply.service.cadastre.impl;
|
|
|
|
|
|
-import com.siwei.apply.domain.GongdiJihua;
|
|
|
import com.siwei.apply.domain.LandType;
|
|
|
-import com.siwei.apply.domain.cadastre.LandSupplyReportDTO;
|
|
|
import com.siwei.apply.domain.cadastre.ParcelStatisticsRes;
|
|
|
import com.siwei.apply.domain.cadastre.Zdjbxx;
|
|
|
-import com.siwei.apply.domain.res.*;
|
|
|
-import com.siwei.apply.domain.vo.GongdiJihuaFilterVo;
|
|
|
-import com.siwei.apply.domain.vo.LandSupplyReportVO;
|
|
|
-import com.siwei.apply.enums.LandUseTypeEnum;
|
|
|
-import com.siwei.apply.mapper.GongdiJihuaMapper;
|
|
|
+import com.siwei.apply.domain.cadastre.ZdqlReportVO;
|
|
|
+
|
|
|
import com.siwei.apply.mapper.LandTypeMapper;
|
|
|
-import com.siwei.apply.mapper.TdgyMapper;
|
|
|
import com.siwei.apply.mapper.cadastre.ZdjbxxMapper;
|
|
|
import com.siwei.apply.service.cadastre.IParcelService;
|
|
|
import com.siwei.common.core.exception.ServiceException;
|
|
|
@@ -31,11 +25,6 @@ public class ParcelServiceImpl implements IParcelService {
|
|
|
@Autowired
|
|
|
private ZdjbxxMapper zdjbxxMapper;
|
|
|
|
|
|
- @Autowired
|
|
|
- private GongdiJihuaMapper gongdiJihuaMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private TdgyMapper dgyMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private LandTypeMapper landTypeMapper;
|
|
|
@@ -209,7 +198,6 @@ public class ParcelServiceImpl implements IParcelService {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
private ParcelStatisticsRes.QllxSuoyouquanDTO getQllxSuoyouquanDTO(Map.Entry<String, List<Zdjbxx>> entry) {
|
|
|
ParcelStatisticsRes.QllxSuoyouquanDTO qllxSuoyouquanDTO = new ParcelStatisticsRes.QllxSuoyouquanDTO();
|
|
|
qllxSuoyouquanDTO.setQllxsyqmc(entry.getKey());
|
|
|
@@ -295,395 +283,152 @@ public class ParcelServiceImpl implements IParcelService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
+ * 生成宗地权利报表
|
|
|
+ * <p>
|
|
|
+ * 报表结构:
|
|
|
+ * - 行:地籍子区(djzq)各一行 + 末尾合计行
|
|
|
+ * - 列:5种权利类型,每种包含(合计、已登记、未登记)3个统计值,共15列
|
|
|
+ * 权利类型代码(qllx字段,字典A6):
|
|
|
+ * 10 - 宅基地使用权和房屋使用权
|
|
|
+ * 11 - 集体建设用地使用权和房屋使用权
|
|
|
+ * 12 - 国有建设用地使用权和房屋使用权
|
|
|
+ * 40 - 林权
|
|
|
+ * 20 - 土地承包经营权
|
|
|
+ * - 面积单位:亩(根据 mjdw 字段自动换算)
|
|
|
+ * - 登记状态:djzt=1 已登记,djzt=2/3 未登记
|
|
|
+ * </p>
|
|
|
*
|
|
|
- * @param landType
|
|
|
- * @return
|
|
|
+ * @return ZdqlReportVO
|
|
|
*/
|
|
|
@Override
|
|
|
- public TrendStatisticsRes trendStatistics(String landType) {
|
|
|
-
|
|
|
- List<TdgyStatisticsRes> completeList = dgyMapper.getListByYear(null, landType, null, null);
|
|
|
-
|
|
|
- TrendStatisticsRes res = new TrendStatisticsRes();
|
|
|
- List<Map<String, Object>> areaTrendStatisticsList = new ArrayList<>();
|
|
|
- List<Map<String, Object>> supplyModeStatisticsList = new ArrayList<>();
|
|
|
-
|
|
|
- if (CollectionUtils.isNotEmpty(completeList)) {
|
|
|
- Map<Integer, Double> areaByYear = new LinkedHashMap<>();
|
|
|
- Map<Integer, Map<String, Double>> modeAreaByYear = new LinkedHashMap<>();
|
|
|
-
|
|
|
- for (TdgyStatisticsRes item : completeList) {
|
|
|
- if (item.getGysj() != null) {
|
|
|
- int year = item.getGysj().getYear() + 1900;
|
|
|
- double area = item.getMjMu() != null ? item.getMjMu().doubleValue() : 0.0;
|
|
|
- String gyfs = item.getGyfs();
|
|
|
-
|
|
|
- areaByYear.merge(year, area, Double::sum);
|
|
|
-
|
|
|
- Map<String, Double> yearModeMap = modeAreaByYear.computeIfAbsent(year, k -> new HashMap<>());
|
|
|
- if ("划拨".equals(gyfs)) {
|
|
|
- yearModeMap.merge("allocate", area, Double::sum);
|
|
|
- } else if ("出让".equals(gyfs)) {
|
|
|
- yearModeMap.merge("transfer", area, Double::sum);
|
|
|
- } else {
|
|
|
- yearModeMap.merge("other", area, Double::sum);
|
|
|
- }
|
|
|
- }
|
|
|
+ public ZdqlReportVO getZdqlReport() {
|
|
|
+ // ---------------------------------------------------
|
|
|
+ // 1. 定义报表关注的权利类型列(顺序即为展示顺序)
|
|
|
+ // ---------------------------------------------------
|
|
|
+ // qllx 字段对应字典 A6
|
|
|
+ LinkedHashMap<String, String> qllxDefMap = new LinkedHashMap<>();
|
|
|
+ qllxDefMap.put("3", "宅基地使用权和房屋使用权");
|
|
|
+ qllxDefMap.put("5", "集体建设用地使用权和房屋使用权");
|
|
|
+ qllxDefMap.put("6", "国有建设用地使用权和房屋使用权");
|
|
|
+ qllxDefMap.put("40", "林权");
|
|
|
+ qllxDefMap.put("20", "土地承包经营权");
|
|
|
+
|
|
|
+ List<String> qllxCodes = new ArrayList<>(qllxDefMap.keySet());
|
|
|
+
|
|
|
+ // ---------------------------------------------------
|
|
|
+ // 2. 查询原始聚合数据(地籍子区 × 权利类型 × 登记状态)
|
|
|
+ // ---------------------------------------------------
|
|
|
+ List<Map<String, Object>> rawData = zdjbxxMapper.getZdqlReportData(qllxCodes);
|
|
|
+
|
|
|
+ // ---------------------------------------------------
|
|
|
+ // 3. 按地籍子区聚合:Map<djzqdm, Map<qllx, double[2]>>
|
|
|
+ // double[0] = 已登记面积,double[1] = 未登记面积
|
|
|
+ // djzqmc 同步记录
|
|
|
+ // ---------------------------------------------------
|
|
|
+ LinkedHashMap<String, Map<String, double[]>> zqDataMap = new LinkedHashMap<>();
|
|
|
+ Map<String, String> djzqmcMap = new LinkedHashMap<>();
|
|
|
+
|
|
|
+ for (Map<String, Object> row : rawData) {
|
|
|
+ String djzqdm = (String) row.get("djzqdm");
|
|
|
+ String djzqmc = (String) row.get("djzqmc");
|
|
|
+ String qllx = (String) row.get("qllx");
|
|
|
+ String djzt = (String) row.get("djzt");
|
|
|
+ double areaMu = row.get("area_mu") != null ? ((Number) row.get("area_mu")).doubleValue() : 0.0;
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(djzqdm) || StringUtils.isBlank(qllx)) {
|
|
|
+ continue;
|
|
|
}
|
|
|
|
|
|
- areaByYear.forEach((year, area) -> {
|
|
|
- Map<String, Object> map = new LinkedHashMap<>();
|
|
|
- map.put("year", year);
|
|
|
- map.put("area", area);
|
|
|
- areaTrendStatisticsList.add(map);
|
|
|
- });
|
|
|
-
|
|
|
- modeAreaByYear.forEach((year, modeAreas) -> {
|
|
|
- Map<String, Object> map = new LinkedHashMap<>();
|
|
|
- map.put("year", year);
|
|
|
- map.put("transferArea", modeAreas.getOrDefault("transfer", 0.0));
|
|
|
- map.put("allocateArea", modeAreas.getOrDefault("allocate", 0.0));
|
|
|
- map.put("otherArea", modeAreas.getOrDefault("other", 0.0));
|
|
|
- supplyModeStatisticsList.add(map);
|
|
|
- });
|
|
|
- }
|
|
|
- res.setAreaTrendStatisticsList(areaTrendStatisticsList);
|
|
|
- res.setSupplyModeStatisticsList(supplyModeStatisticsList);
|
|
|
- return res;
|
|
|
- }
|
|
|
-
|
|
|
+ djzqmcMap.putIfAbsent(djzqdm, djzqmc != null ? djzqmc : "");
|
|
|
+ zqDataMap.computeIfAbsent(djzqdm, k -> new LinkedHashMap<>())
|
|
|
+ .computeIfAbsent(qllx, k -> new double[]{0.0, 0.0});
|
|
|
|
|
|
- @Override
|
|
|
- public LandSupplyReportDTO getTdgyReport(String startTime, String endTime) {
|
|
|
- LandSupplyReportDTO report = new LandSupplyReportDTO();
|
|
|
- report.setTitle("土地供应进度分析报表");
|
|
|
- report.setStatTimeRange(startTime + " 至 " + endTime);
|
|
|
-
|
|
|
- // 获取时间范围内的完成数据
|
|
|
- List<TdgyStatisticsRes> completeList = dgyMapper.getListByYear(null, null, startTime, endTime);
|
|
|
-
|
|
|
- // 获取时间范围内的计划数据
|
|
|
- Map<String, Object> planSummary = gongdiJihuaMapper.getPlanSummaryByTimeRange(startTime, endTime);
|
|
|
- List<Map<String, Object>> planStatsByLandType = gongdiJihuaMapper.getPlanStatsByLandType(startTime, endTime);
|
|
|
-
|
|
|
- // 获取所有一级分类
|
|
|
- List<LandType> landTypeList = landTypeMapper.selectFirstLevel();
|
|
|
- Map<String, String> codeToFirstName = landTypeList.stream()
|
|
|
- .collect(Collectors.toMap(LandType::getCode, LandType::getName, (v1, v2) -> v1));
|
|
|
-
|
|
|
- // 按一级分类名称汇总统计数据的 Map
|
|
|
- Map<String, LandSupplyReportDTO.DetailDTO> detailMap = new HashMap<>();
|
|
|
-
|
|
|
- // 1. 统计计划数据并按一级分类归类
|
|
|
- for (Map<String, Object> landTypeStat : planStatsByLandType) {
|
|
|
- String category = (String) landTypeStat.get("category");
|
|
|
- String parentName = "其他";
|
|
|
-
|
|
|
- // 通过枚举查找对应的一级分类名称
|
|
|
- for (LandUseTypeEnum type : LandUseTypeEnum.values()) {
|
|
|
- if (type.getName().equals(category)) {
|
|
|
- parentName = type.getParentName();
|
|
|
- break;
|
|
|
- }
|
|
|
+ double[] areaArr = zqDataMap.get(djzqdm).get(qllx);
|
|
|
+ if ("1".equals(djzt)) {
|
|
|
+ areaArr[0] += areaMu; // 已登记
|
|
|
+ } else if ("2".equals(djzt) || "3".equals(djzt)) {
|
|
|
+ areaArr[1] += areaMu; // 未登记
|
|
|
}
|
|
|
-
|
|
|
- LandSupplyReportDTO.DetailDTO detail = detailMap.computeIfAbsent(parentName, k -> {
|
|
|
- LandSupplyReportDTO.DetailDTO d = new LandSupplyReportDTO.DetailDTO();
|
|
|
- d.setCategory(k);
|
|
|
- d.setPlan(new LandSupplyReportDTO.PlanDTO());
|
|
|
- d.getPlan().setArea(0.0);
|
|
|
- d.getPlan().setCount(0);
|
|
|
- d.getPlan().setTransfer(0);
|
|
|
- d.getPlan().setAllocation(0);
|
|
|
- d.getPlan().setOther(0);
|
|
|
- d.setCompleted(new LandSupplyReportDTO.CompletedDTO());
|
|
|
- d.getCompleted().setArea(0.0);
|
|
|
- d.getCompleted().setCount(0);
|
|
|
- d.getCompleted().setTransfer(0);
|
|
|
- d.getCompleted().setAllocation(0);
|
|
|
- d.getCompleted().setOther(0);
|
|
|
- return d;
|
|
|
- });
|
|
|
-
|
|
|
- LandSupplyReportDTO.PlanDTO plan = detail.getPlan();
|
|
|
- plan.setArea(plan.getArea() + toDouble(landTypeStat.get("planmu")));
|
|
|
- plan.setCount(plan.getCount() + toInteger(landTypeStat.get("plancount")));
|
|
|
- plan.setTransfer(plan.getTransfer() + toInteger(landTypeStat.get("plantransfer")));
|
|
|
- plan.setAllocation(plan.getAllocation() + toInteger(landTypeStat.get("planallocation")));
|
|
|
- plan.setOther(plan.getOther() + toInteger(landTypeStat.get("planother")));
|
|
|
}
|
|
|
|
|
|
- // 2. 统计完成数据并按一级分类归类
|
|
|
- if (CollectionUtils.isNotEmpty(completeList)) {
|
|
|
- for (TdgyStatisticsRes item : completeList) {
|
|
|
- String tdyt = item.getTdyt();
|
|
|
- String parentName = "其他";
|
|
|
- if (tdyt != null && tdyt.length() >= 2) {
|
|
|
- String firstLevelCode = tdyt.substring(0, 2);
|
|
|
- parentName = codeToFirstName.getOrDefault(firstLevelCode, "其他");
|
|
|
- }
|
|
|
-
|
|
|
- LandSupplyReportDTO.DetailDTO detail = detailMap.computeIfAbsent(parentName, k -> {
|
|
|
- LandSupplyReportDTO.DetailDTO d = new LandSupplyReportDTO.DetailDTO();
|
|
|
- d.setCategory(k);
|
|
|
- d.setPlan(new LandSupplyReportDTO.PlanDTO());
|
|
|
- d.getPlan().setArea(0.0);
|
|
|
- d.getPlan().setCount(0);
|
|
|
- d.getPlan().setTransfer(0);
|
|
|
- d.getPlan().setAllocation(0);
|
|
|
- d.getPlan().setOther(0);
|
|
|
- d.setCompleted(new LandSupplyReportDTO.CompletedDTO());
|
|
|
- d.getCompleted().setArea(0.0);
|
|
|
- d.getCompleted().setCount(0);
|
|
|
- d.getCompleted().setTransfer(0);
|
|
|
- d.getCompleted().setAllocation(0);
|
|
|
- d.getCompleted().setOther(0);
|
|
|
- return d;
|
|
|
- });
|
|
|
-
|
|
|
- LandSupplyReportDTO.CompletedDTO completed = detail.getCompleted();
|
|
|
- double area = item.getMjMu() != null ? item.getMjMu().doubleValue() : 0.0;
|
|
|
- completed.setArea(completed.getArea() + area);
|
|
|
- completed.setCount(completed.getCount() + 1);
|
|
|
-
|
|
|
- String gyfs = item.getGyfs();
|
|
|
- if ("出让".equals(gyfs)) {
|
|
|
- int transfer = completed.getTransfer()+1;
|
|
|
- completed.setTransfer(transfer);
|
|
|
- } else if ("划拨".equals(gyfs)) {
|
|
|
- int allocation = completed.getAllocation()+1;
|
|
|
- completed.setAllocation(allocation);
|
|
|
- } else {
|
|
|
- int other = completed.getOther()+1;
|
|
|
- completed.setOther(other);
|
|
|
- }
|
|
|
+ // ---------------------------------------------------
|
|
|
+ // 4. 构建数据行列表
|
|
|
+ // ---------------------------------------------------
|
|
|
+ List<ZdqlReportVO.RowData> rows = new ArrayList<>();
|
|
|
+
|
|
|
+ // 合计行的累加器 Map<qllx, double[2]>
|
|
|
+ Map<String, double[]> totalAccMap = new LinkedHashMap<>();
|
|
|
+ qllxCodes.forEach(code -> totalAccMap.put(code, new double[]{0.0, 0.0}));
|
|
|
+
|
|
|
+ for (Map.Entry<String, Map<String, double[]>> zqEntry : zqDataMap.entrySet()) {
|
|
|
+ String djzqdm = zqEntry.getKey();
|
|
|
+ Map<String, double[]> qllxAreaMap = zqEntry.getValue();
|
|
|
+
|
|
|
+ ZdqlReportVO.RowData rowData = new ZdqlReportVO.RowData();
|
|
|
+ rowData.setDjzqdm(djzqdm);
|
|
|
+ rowData.setDjzqmc(djzqmcMap.getOrDefault(djzqdm, ""));
|
|
|
+
|
|
|
+ List<ZdqlReportVO.QllxStatCell> cells = new ArrayList<>();
|
|
|
+ for (String code : qllxCodes) {
|
|
|
+ double[] areaArr = qllxAreaMap.getOrDefault(code, new double[]{0.0, 0.0});
|
|
|
+ double registered = areaArr[0];
|
|
|
+ double unregistered = areaArr[1];
|
|
|
+ double total = registered + unregistered;
|
|
|
+
|
|
|
+ ZdqlReportVO.QllxStatCell cell = new ZdqlReportVO.QllxStatCell();
|
|
|
+ cell.setQllxCode(code);
|
|
|
+ cell.setQllxName(qllxDefMap.get(code)); // 融合 qllxName 到 cell 中
|
|
|
+ cell.setTotalArea(roundArea(total));
|
|
|
+ cell.setRegisteredArea(roundArea(registered));
|
|
|
+ cell.setUnregisteredArea(roundArea(unregistered));
|
|
|
+ cells.add(cell);
|
|
|
+
|
|
|
+ // 累计到合计行
|
|
|
+ totalAccMap.get(code)[0] += registered;
|
|
|
+ totalAccMap.get(code)[1] += unregistered;
|
|
|
}
|
|
|
+ rowData.setCells(cells);
|
|
|
+ rows.add(rowData);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- // 3. 构建 Summary
|
|
|
- LandSupplyReportDTO.SummaryDTO summary = new LandSupplyReportDTO.SummaryDTO();
|
|
|
- LandSupplyReportDTO.TotalDTO total = buildTotalDTO(planSummary);
|
|
|
-
|
|
|
- // 重新计算 Total 的 Completed 部分,因为之前 buildTotalDTO 填充的是 0
|
|
|
- if (CollectionUtils.isNotEmpty(completeList)) {
|
|
|
- double totalArea = completeList.stream().filter(g -> g.getMjMu() != null).mapToDouble(g -> g.getMjMu().doubleValue()).sum();
|
|
|
- long totalTransfer = completeList.stream().filter(g -> "出让".equals(g.getGyfs())).count();
|
|
|
- long totalAllocation = completeList.stream().filter(g -> "划拨".equals(g.getGyfs()) ).count();
|
|
|
- long totalOther = completeList.size() - totalTransfer - totalAllocation;
|
|
|
- total.setCompleted(buildCompletedDTO(totalArea, completeList.size(), (int) totalTransfer, (int) totalAllocation, (int) totalOther));
|
|
|
- double planArea = total.getPlan().getArea();
|
|
|
- if (planArea > 0) {
|
|
|
- total.setSupplyRate(String.format("%.2f%%", (totalArea / planArea) * 100));
|
|
|
- } else {
|
|
|
- total.setSupplyRate("0%");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- summary.setTotal(total);
|
|
|
- report.setSummary(summary);
|
|
|
-
|
|
|
- // 4. 构建 Details 列表并计算供应率
|
|
|
- List<LandSupplyReportDTO.DetailDTO> details = new ArrayList<>(detailMap.values());
|
|
|
- for (LandSupplyReportDTO.DetailDTO detail : details) {
|
|
|
- double planArea = detail.getPlan().getArea();
|
|
|
- double completedArea = detail.getCompleted().getArea();
|
|
|
- if (planArea > 0) {
|
|
|
- detail.setSupplyRate(String.format("%.2f%%", (completedArea / planArea) * 100));
|
|
|
- } else {
|
|
|
- detail.setSupplyRate("0%");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 按计划面积排序
|
|
|
- details.sort((d1, d2) -> d2.getPlan().getArea().compareTo(d1.getPlan().getArea()));
|
|
|
- report.setDetails(details);
|
|
|
-
|
|
|
- return report;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public LandSupplyReportVO getTdgyPurposeReport(String startYear, String endYear){
|
|
|
- //List<TdgyStatisticsRes> completeList = dgyMapper.getListByYear(null, null, startYear, endYear);
|
|
|
- //todo 这里需要修改
|
|
|
- SupplyYearStatisticsRes res = new SupplyYearStatisticsRes();
|
|
|
- GongdiJihuaFilterVo filterVo = new GongdiJihuaFilterVo();
|
|
|
- filterVo.setPageSize(100000);
|
|
|
- List<GongdiJihua> completeList = gongdiJihuaMapper.getList(filterVo);
|
|
|
-
|
|
|
- if (CollectionUtils.isEmpty(completeList)) {
|
|
|
- return new LandSupplyReportVO();
|
|
|
+ // ---------------------------------------------------
|
|
|
+ // 5. 构建合计行
|
|
|
+ // ---------------------------------------------------
|
|
|
+ ZdqlReportVO.RowData totalRow = new ZdqlReportVO.RowData();
|
|
|
+ totalRow.setDjzqdm(null);
|
|
|
+ totalRow.setDjzqmc("合计");
|
|
|
+ List<ZdqlReportVO.QllxStatCell> totalCells = new ArrayList<>();
|
|
|
+ for (String code : qllxCodes) {
|
|
|
+ double[] areaArr = totalAccMap.get(code);
|
|
|
+ double registered = areaArr[0];
|
|
|
+ double unregistered = areaArr[1];
|
|
|
+ ZdqlReportVO.QllxStatCell cell = new ZdqlReportVO.QllxStatCell();
|
|
|
+ cell.setQllxCode(code);
|
|
|
+ cell.setQllxName(qllxDefMap.get(code)); // 融合 qllxName 到 cell 中
|
|
|
+ cell.setTotalArea(roundArea(registered + unregistered));
|
|
|
+ cell.setRegisteredArea(roundArea(registered));
|
|
|
+ cell.setUnregisteredArea(roundArea(unregistered));
|
|
|
+ totalCells.add(cell);
|
|
|
}
|
|
|
-
|
|
|
- LandSupplyReportVO report = new LandSupplyReportVO();
|
|
|
-
|
|
|
- // 1. 获取一级分类映射
|
|
|
- List<LandType> landTypeList = landTypeMapper.selectFirstLevel();
|
|
|
- Map<String, String> codeToFirstName = landTypeList.stream()
|
|
|
- .collect(Collectors.toMap(LandType::getCode, LandType::getName, (v1, v2) -> v1));
|
|
|
-
|
|
|
- // 2. 统计年份并排序
|
|
|
- Set<Integer> yearSet = new TreeSet<>();
|
|
|
- for (GongdiJihua item : completeList) {
|
|
|
- if (item.getGysj() != null) {
|
|
|
- yearSet.add(item.getGysj().getYear() + 1900);
|
|
|
- }
|
|
|
- }
|
|
|
- report.setYears(new ArrayList<>(yearSet));
|
|
|
-
|
|
|
- // 3. 按一级分类、供应方式、年份进行汇总统计
|
|
|
- // Map<一级分类名称, Map<供应方式, Map<年份, 面积汇总>>>
|
|
|
- Map<String, Map<String, Map<String, Double>>> stats = new HashMap<>();
|
|
|
-
|
|
|
- for (GongdiJihua item : completeList) {
|
|
|
- if (item.getGysj() == null || item.getTdyt() == null || item.getTdyt().length() < 2) continue;
|
|
|
- String firstLevelCode = LandUseTypeEnum.getCodeByName(item.getTdyt());
|
|
|
- //todo 这里需要修改
|
|
|
- //String firstLevelCode = item.getTdyt().substring(0, 2);
|
|
|
- String parentName = codeToFirstName.getOrDefault(firstLevelCode, "其他");
|
|
|
- String year = String.valueOf(item.getGysj().getYear() + 1900);
|
|
|
- String gyfs = "划拨".equals(item.getGyfs()) ? "划拨" : ("出让".equals(item.getGyfs()) ? "出让" : "其他");
|
|
|
- double area = item.getMjMu() != null ? item.getMjMu().doubleValue() : 0.0;
|
|
|
-
|
|
|
- stats.computeIfAbsent(parentName, k -> new HashMap<>())
|
|
|
- .computeIfAbsent(gyfs, k -> new HashMap<>())
|
|
|
- .merge(year, area, Double::sum);
|
|
|
- }
|
|
|
-
|
|
|
- // 4. 构建返回对象数据
|
|
|
- List<LandSupplyReportVO.LandTypeData> dataList = new ArrayList<>();
|
|
|
-
|
|
|
- for (LandType lt : landTypeList) {
|
|
|
- String parentName = lt.getName();
|
|
|
- Map<String, Map<String, Double>> modeMap = stats.get(parentName);
|
|
|
- if (modeMap == null) continue;
|
|
|
-
|
|
|
- LandSupplyReportVO.LandTypeData landTypeData = new LandSupplyReportVO.LandTypeData();
|
|
|
- landTypeData.setLandType(parentName);
|
|
|
-
|
|
|
- // 划拨数据
|
|
|
- landTypeData.setAllocation(buildCategoryData(modeMap.get("划拨"), report.getYears()));
|
|
|
- // 出让数据
|
|
|
- landTypeData.setTransfer(buildCategoryData(modeMap.get("出让"), report.getYears()));
|
|
|
-
|
|
|
- // 总计数据
|
|
|
- LandSupplyReportVO.CategoryData totalData = new LandSupplyReportVO.CategoryData();
|
|
|
- Map<String, Double> totalYearData = new LinkedHashMap<>();
|
|
|
- double grandTotal = 0.0;
|
|
|
- for (Integer y : report.getYears()) {
|
|
|
- String yearStr = String.valueOf(y);
|
|
|
- double areaSum = 0.0;
|
|
|
- if (modeMap.get("划拨") != null) areaSum += modeMap.get("划拨").getOrDefault(yearStr, 0.0);
|
|
|
- if (modeMap.get("出让") != null) areaSum += modeMap.get("出让").getOrDefault(yearStr, 0.0);
|
|
|
- if (modeMap.get("其他") != null) areaSum += modeMap.get("其他").getOrDefault(yearStr, 0.0);
|
|
|
-
|
|
|
- totalYearData.put(yearStr, areaSum);
|
|
|
- grandTotal += areaSum;
|
|
|
- }
|
|
|
- totalData.setTotal(grandTotal);
|
|
|
- totalData.setYearData(totalYearData);
|
|
|
- landTypeData.setTotal(totalData);
|
|
|
-
|
|
|
- dataList.add(landTypeData);
|
|
|
- }
|
|
|
- report.setData(dataList);
|
|
|
-
|
|
|
+ totalRow.setCells(totalCells);
|
|
|
+
|
|
|
+ // ---------------------------------------------------
|
|
|
+ // 6. 组装返回结果
|
|
|
+ // ---------------------------------------------------
|
|
|
+ ZdqlReportVO report = new ZdqlReportVO();
|
|
|
+ report.setRows(rows);
|
|
|
+ report.setTotal(totalRow);
|
|
|
return report;
|
|
|
}
|
|
|
|
|
|
- private LandSupplyReportVO.CategoryData buildCategoryData(Map<String, Double> yearCounts, List<Integer> years) {
|
|
|
- LandSupplyReportVO.CategoryData data = new LandSupplyReportVO.CategoryData();
|
|
|
- Map<String, Double> yearData = new LinkedHashMap<>();
|
|
|
- double total = 0.0;
|
|
|
- for (Integer y : years) {
|
|
|
- String yearStr = String.valueOf(y);
|
|
|
- double areaSum = yearCounts != null ? yearCounts.getOrDefault(yearStr, 0.0) : 0.0;
|
|
|
- yearData.put(yearStr, areaSum);
|
|
|
- total += areaSum;
|
|
|
- }
|
|
|
- data.setTotal(total);
|
|
|
- data.setYearData(yearData);
|
|
|
- return data;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- private LandSupplyReportDTO.TotalDTO buildTotalDTO(Map<String, Object> summary) {
|
|
|
- LandSupplyReportDTO.TotalDTO total = new LandSupplyReportDTO.TotalDTO();
|
|
|
- total.setSupplyRate("0%");
|
|
|
-
|
|
|
- LandSupplyReportDTO.PlanDTO plan = new LandSupplyReportDTO.PlanDTO();
|
|
|
- plan.setArea(toDouble(summary.get("planmu")));
|
|
|
- plan.setCount(toInteger(summary.get("plancount")));
|
|
|
- plan.setTransfer(toInteger(summary.get("plantransfer")));
|
|
|
- plan.setAllocation(toInteger(summary.get("planallocation")));
|
|
|
- plan.setOther(toInteger(summary.get("planother")));
|
|
|
- total.setPlan(plan);
|
|
|
-
|
|
|
- LandSupplyReportDTO.CompletedDTO completed = new LandSupplyReportDTO.CompletedDTO();
|
|
|
- completed.setArea(0.0);
|
|
|
- completed.setCount(0);
|
|
|
- completed.setTransfer(0);
|
|
|
- completed.setAllocation(0);
|
|
|
- completed.setOther(0);
|
|
|
- total.setCompleted(completed);
|
|
|
-
|
|
|
- return total;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- private LandSupplyReportDTO.CompletedDTO buildCompletedDTO(Double area, Integer count, Integer transfer, Integer allocation, Integer other) {
|
|
|
- LandSupplyReportDTO.CompletedDTO completed = new LandSupplyReportDTO.CompletedDTO();
|
|
|
- completed.setArea(area);
|
|
|
- completed.setCount(count);
|
|
|
- completed.setTransfer(transfer);
|
|
|
- completed.setAllocation(allocation);
|
|
|
- completed.setOther(other);
|
|
|
- return completed;
|
|
|
+ /**
|
|
|
+ * 面积保留两位小数(四舍五入)
|
|
|
+ */
|
|
|
+ private double roundArea(double value) {
|
|
|
+ return Math.round(value * 100.0) / 100.0;
|
|
|
}
|
|
|
|
|
|
- private String convertCategory(String category) {
|
|
|
- if (category == null || category.equals("未知")) {
|
|
|
- return "其他";
|
|
|
- }
|
|
|
- return category;
|
|
|
- }
|
|
|
|
|
|
- private Double toDouble(Object value) {
|
|
|
- if (value == null) {
|
|
|
- return 0.0;
|
|
|
- }
|
|
|
- if (value instanceof Number) {
|
|
|
- return ((Number) value).doubleValue();
|
|
|
- }
|
|
|
- return 0.0;
|
|
|
- }
|
|
|
|
|
|
- private Integer toInteger(Object value) {
|
|
|
- if (value == null) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
- if (value instanceof Number) {
|
|
|
- return ((Number) value).intValue();
|
|
|
- }
|
|
|
- return 0;
|
|
|
- }
|
|
|
}
|