|
|
@@ -0,0 +1,715 @@
|
|
|
+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.LandSupplyProjectVO;
|
|
|
+import com.siwei.apply.domain.vo.LandSupplyReportVO;
|
|
|
+import com.siwei.apply.enums.LandUseTypeEnum;
|
|
|
+import com.siwei.apply.mapper.GongdiJihuaMapper;
|
|
|
+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 org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.collections4.MapUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class ParcelServiceImpl implements IParcelService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZdjbxxMapper zdjbxxMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private GongdiJihuaMapper gongdiJihuaMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TdgyMapper dgyMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LandTypeMapper landTypeMapper;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object GetList(String param) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 地籍统计
|
|
|
+ * @param djzqdm
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ParcelStatisticsRes statistics(String djzqdm) {
|
|
|
+ ParcelStatisticsRes res = new ParcelStatisticsRes();
|
|
|
+ List<Zdjbxx> zdjbxxList = zdjbxxMapper.getListByDjzqdm(djzqdm);
|
|
|
+
|
|
|
+ List<ParcelStatisticsRes.DetailDTO> detailList = new ArrayList<>();
|
|
|
+ List<ParcelStatisticsRes.TdytDTO> tdytStatisticsList = new ArrayList<>();
|
|
|
+ List<ParcelStatisticsRes.QlxzDTO> qlxzStatisticsList = new ArrayList<>(); // 权利性质统计
|
|
|
+ List<ParcelStatisticsRes.QllxSuoyouquanDTO> qllxSuoyouquanStatisticsList= new ArrayList<>(); // 权利类型所有权统计
|
|
|
+ List<ParcelStatisticsRes.QllxShiyongquanDTO> qllxShiyongquanStatisticsList= new ArrayList<>(); // 权利类型使用权统计
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(zdjbxxList)) {
|
|
|
+ List<Zdjbxx> registeredList = new ArrayList<>();
|
|
|
+ List<Zdjbxx> unregisteredList = new ArrayList<>();
|
|
|
+
|
|
|
+ for (Zdjbxx zdjbxx : zdjbxxList) {
|
|
|
+ String djzt = zdjbxx.getDjzt();
|
|
|
+ if ("1".equals(djzt)) {
|
|
|
+ registeredList.add(zdjbxx);
|
|
|
+ } else if ("2".equals(djzt) || "3".equals(djzt)) {
|
|
|
+ unregisteredList.add(zdjbxx);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ detailList.add(buildDetailDTO(registeredList, "0"));
|
|
|
+ detailList.add(buildDetailDTO(unregisteredList, "2"));
|
|
|
+ detailList.add(buildDetailDTO(zdjbxxList, "1"));
|
|
|
+ res.setLandNumStatisticsList(detailList);
|
|
|
+
|
|
|
+ //todo 第二部分,主要填充tdytStatisticsList这个对象,统计查询出来的地籍数据的土地用途统计、
|
|
|
+ // 获取所有一级分类
|
|
|
+ List<LandType> landTypeList = landTypeMapper.selectFirstLevel();
|
|
|
+ Map<String,List<Zdjbxx>> groupedByYtMap = new LinkedHashMap<>();
|
|
|
+ landTypeList.forEach(item -> {
|
|
|
+ String value = item.getCode();
|
|
|
+ String name = item.getName();
|
|
|
+ List<Zdjbxx> filterList = zdjbxxList.stream().filter(zd-> StringUtils.isNotBlank(zd.getYt())).filter(zd -> value.equals(zd.getYt().substring(0,2))).collect(Collectors.toList());
|
|
|
+ if(CollectionUtils.isNotEmpty(filterList)){
|
|
|
+ groupedByYtMap.put(name, filterList);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //这里遍历map,然后进行统计数据;
|
|
|
+ if(MapUtils.isNotEmpty(groupedByYtMap)){
|
|
|
+ for(Map.Entry<String, List<Zdjbxx>> entry : groupedByYtMap.entrySet()){
|
|
|
+ ParcelStatisticsRes.TdytDTO tdytDTO = new ParcelStatisticsRes.TdytDTO();
|
|
|
+ tdytDTO.setTdytmc(entry.getKey());
|
|
|
+ double totalArea = 0.0;
|
|
|
+ for(Zdjbxx zd : entry.getValue()) {
|
|
|
+ totalArea += convertAreaToMu(zd.getZdmj(), zd.getMjdw());
|
|
|
+ }
|
|
|
+ tdytDTO.setTdytmj(String.format("%.2f", totalArea));
|
|
|
+ tdytStatisticsList.add(tdytDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ res.setTdytStatisticsList(tdytStatisticsList);
|
|
|
+ //todo 第三部分,权利性质统计和权利类型统计,这里需要根据查询出来的地籍数据中的权利性质和权利类型进行统计,统计出每种权利性质和权利类型的面积占比,然后填充到qlxzStatisticsList、qllxSuoyouquanStatisticsList、qllxShiyongquanStatisticsList这三个对象中
|
|
|
+ Map<String,List<Zdjbxx>> qlxzGroupedByYtMap = new LinkedHashMap<>();
|
|
|
+ zdjbxxMapper.getDictByType("A7").forEach(item -> {
|
|
|
+ String name = item.get("name").toString();
|
|
|
+ String value = item.get("value").toString();
|
|
|
+ List<Zdjbxx> filterList = zdjbxxList.stream().filter(zd-> StringUtils.isNotBlank(zd.getYt())).filter(zd -> value.equals(zd.getYt().substring(0,2))).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));
|
|
|
+ qlxzStatisticsList.add(qlxzDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ res.setQlxzStatisticsList(qlxzStatisticsList);
|
|
|
+
|
|
|
+
|
|
|
+ //todo 第四部分:
|
|
|
+ qllxSuoyouquanStatisticsList.add(null);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private ParcelStatisticsRes.DetailDTO buildDetailDTO(List<Zdjbxx> zdjbxxList, String djzt) {
|
|
|
+ ParcelStatisticsRes.DetailDTO detail = new ParcelStatisticsRes.DetailDTO();
|
|
|
+ detail.setDjzt(djzt);
|
|
|
+
|
|
|
+ int zds = zdjbxxList.size();
|
|
|
+ double totalZdmj = 0.0;
|
|
|
+ double totalZjzmj = 0.0;
|
|
|
+
|
|
|
+ for (Zdjbxx zdjbxx : zdjbxxList) {
|
|
|
+ double zdmj = convertAreaToMu(zdjbxx.getZdmj(), zdjbxx.getMjdw());
|
|
|
+ totalZdmj += zdmj;
|
|
|
+
|
|
|
+ double zjzmj = convertAreaToMu(zdjbxx.getZjzmj(), zdjbxx.getMjdw());
|
|
|
+ totalZjzmj += zjzmj;
|
|
|
+ }
|
|
|
+
|
|
|
+ detail.setZds(zds);
|
|
|
+ detail.setZdmj(totalZdmj);
|
|
|
+ detail.setJzzmj(totalZjzmj);
|
|
|
+
|
|
|
+ return detail;
|
|
|
+ }
|
|
|
+
|
|
|
+ private double convertAreaToMu(BigDecimal area, String mjdw) {
|
|
|
+ if (area == null) {
|
|
|
+ return 0.0;
|
|
|
+ }
|
|
|
+ double areaValue = area.doubleValue();
|
|
|
+ if (mjdw == null) {
|
|
|
+ return areaValue;
|
|
|
+ }
|
|
|
+ switch (mjdw) {
|
|
|
+ case "1":
|
|
|
+ return areaValue / 666.6666667;
|
|
|
+ case "2":
|
|
|
+ return areaValue;
|
|
|
+ case "3":
|
|
|
+ return areaValue * 15;
|
|
|
+ case "4":
|
|
|
+ return areaValue * 1500;
|
|
|
+ default:
|
|
|
+ return areaValue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param landType
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 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();
|
|
|
+ }
|
|
|
+
|
|
|
+ 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);
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * supplyType (1-计划,2-完成)
|
|
|
+ * @param year
|
|
|
+ * @param supplyType
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<LandSupplyProjectVO> projectList(String year, Integer supplyType) {
|
|
|
+ List<LandSupplyProjectVO> resList = new ArrayList<>();
|
|
|
+ if(supplyType== 1){
|
|
|
+ GongdiJihuaFilterVo filterVo = new GongdiJihuaFilterVo();
|
|
|
+ filterVo.setYear(year);
|
|
|
+ filterVo.setPageSize(100000);
|
|
|
+ List<GongdiJihua> planList = gongdiJihuaMapper.getList(filterVo);
|
|
|
+ resList = planList.stream().map(item -> {
|
|
|
+ LandSupplyProjectVO vo = new LandSupplyProjectVO();
|
|
|
+ vo.setProjectPropertyId(String.valueOf(item.getGid()));
|
|
|
+ vo.setProjectName(item.getXmmc());
|
|
|
+ vo.setCompanyName("暂无");
|
|
|
+ vo.setSupplyMethod(item.getGyfs());
|
|
|
+ vo.setSupplyType(supplyType.toString());
|
|
|
+ vo.setGeom(item.getGeom());
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }else if(supplyType == 2){
|
|
|
+ List<TdgyStatisticsRes> completeList = dgyMapper.getListByYear(year, null, null, null);
|
|
|
+ resList = completeList.stream().map(item -> {
|
|
|
+ LandSupplyProjectVO vo = new LandSupplyProjectVO();
|
|
|
+ vo.setProjectPropertyId(item.getProjectId());
|
|
|
+ vo.setProjectName(item.getXmmc());
|
|
|
+ vo.setCompanyName(item.getCompany());
|
|
|
+ vo.setSupplyMethod(item.getGyfs());
|
|
|
+ vo.setSupplyType(supplyType.toString());
|
|
|
+ vo.setNodeId(item.getNodeId());
|
|
|
+ vo.setGeom(item.getGeom());
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ } else if(supplyType == 0){
|
|
|
+
|
|
|
+ GongdiJihuaFilterVo filterVo = new GongdiJihuaFilterVo();
|
|
|
+ filterVo.setYear(year);
|
|
|
+ filterVo.setPageSize(100000);
|
|
|
+
|
|
|
+ List<GongdiJihua> planList = gongdiJihuaMapper.getList(filterVo);
|
|
|
+ List<LandSupplyProjectVO> resList1 = planList.stream().map(item -> {
|
|
|
+ LandSupplyProjectVO vo = new LandSupplyProjectVO();
|
|
|
+ vo.setProjectPropertyId(String.valueOf(item.getGid()));
|
|
|
+ vo.setProjectName(item.getXmmc());
|
|
|
+ vo.setCompanyName("暂无");
|
|
|
+ vo.setSupplyMethod(item.getGyfs());
|
|
|
+ vo.setSupplyType(supplyType.toString());
|
|
|
+ vo.setGeom(item.getGeom());
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ List<TdgyStatisticsRes> completeList = dgyMapper.getListByYear(year, null, null, null);
|
|
|
+ List<LandSupplyProjectVO> resList2 = completeList.stream().map(item -> {
|
|
|
+ LandSupplyProjectVO vo = new LandSupplyProjectVO();
|
|
|
+ vo.setProjectPropertyId(item.getProjectId());
|
|
|
+ vo.setProjectName(item.getXmmc());
|
|
|
+ vo.setCompanyName(item.getCompany());
|
|
|
+ vo.setSupplyMethod(item.getGyfs());
|
|
|
+ vo.setSupplyType(supplyType.toString());
|
|
|
+ vo.setNodeId(item.getNodeId());
|
|
|
+ vo.setGeom(item.getGeom());
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ if(CollectionUtils.isNotEmpty(resList1)) {
|
|
|
+ resList.addAll(resList1);
|
|
|
+ }
|
|
|
+ if(CollectionUtils.isNotEmpty(resList2)) {
|
|
|
+ resList.addAll(resList2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return resList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public GongdiJihua getPlanProject(String id) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<LandType> getLandTypeList() {
|
|
|
+ // 获取所有一级分类
|
|
|
+ List<LandType> landTypeList = landTypeMapper.selectFirstLevel();
|
|
|
+ return landTypeList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ 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 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;
|
|
|
+ }
|
|
|
+}
|