|
|
@@ -5,6 +5,7 @@ import com.siwei.apply.domain.LandType;
|
|
|
import com.siwei.apply.domain.cadastre.*;
|
|
|
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.mapper.LandTypeMapper;
|
|
|
@@ -35,7 +36,6 @@ public class SupplyServiceImpl implements ISupplyService {
|
|
|
@Override
|
|
|
public Object GetList(String param) {
|
|
|
|
|
|
- ///Map<String, Object> planSummary = gongdiJihuaMapper.getList(startTime, endTime);
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
@@ -53,11 +53,7 @@ public class SupplyServiceImpl implements ISupplyService {
|
|
|
filterVo.setYear(year);
|
|
|
filterVo.setPageSize(100000);
|
|
|
List<GongdiJihua> list = gongdiJihuaMapper.getList(filterVo);
|
|
|
- List<TdgyStatisticsRes> completeList = dgyMapper.getListByYear(year,null);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ List<TdgyStatisticsRes> completeList = dgyMapper.getListByYear(year, null, null, null);
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(list)) {
|
|
|
double completeRate =0;
|
|
|
@@ -193,7 +189,7 @@ public class SupplyServiceImpl implements ISupplyService {
|
|
|
@Override
|
|
|
public TrendStatisticsRes trendStatistics(String landType) {
|
|
|
|
|
|
- List<TdgyStatisticsRes> completeList = dgyMapper.getListByYear(null, landType);
|
|
|
+ List<TdgyStatisticsRes> completeList = dgyMapper.getListByYear(null, landType, null, null);
|
|
|
|
|
|
TrendStatisticsRes res = new TrendStatisticsRes();
|
|
|
List<Map<String, Object>> areaTrendStatisticsList = new ArrayList<>();
|
|
|
@@ -244,18 +240,281 @@ public class SupplyServiceImpl implements ISupplyService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @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.0);
|
|
|
+ d.getPlan().setAllocation(0.0);
|
|
|
+ d.getPlan().setOther(0.0);
|
|
|
+ d.setCompleted(new LandSupplyReportDTO.CompletedDTO());
|
|
|
+ d.getCompleted().setArea(0.0);
|
|
|
+ d.getCompleted().setCount(0);
|
|
|
+ d.getCompleted().setTransfer(0.0);
|
|
|
+ d.getCompleted().setAllocation(0.0);
|
|
|
+ d.getCompleted().setOther(0.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() + toDouble(landTypeStat.get("plantransfer")));
|
|
|
+ plan.setAllocation(plan.getAllocation() + toDouble(landTypeStat.get("planallocation")));
|
|
|
+ plan.setOther(plan.getOther() + toDouble(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.0);
|
|
|
+ d.getPlan().setAllocation(0.0);
|
|
|
+ d.getPlan().setOther(0.0);
|
|
|
+ d.setCompleted(new LandSupplyReportDTO.CompletedDTO());
|
|
|
+ d.getCompleted().setArea(0.0);
|
|
|
+ d.getCompleted().setCount(0);
|
|
|
+ d.getCompleted().setTransfer(0.0);
|
|
|
+ d.getCompleted().setAllocation(0.0);
|
|
|
+ d.getCompleted().setOther(0.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)) {
|
|
|
+ completed.setTransfer(completed.getTransfer() + area);
|
|
|
+ } else if ("划拨".equals(gyfs)) {
|
|
|
+ completed.setAllocation(completed.getAllocation() + area);
|
|
|
+ } else {
|
|
|
+ completed.setOther(completed.getOther() + area);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 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();
|
|
|
+ double totalTransfer = completeList.stream().filter(g -> "出让".equals(g.getGyfs()) && g.getMjMu() != null).mapToDouble(g -> g.getMjMu().doubleValue()).sum();
|
|
|
+ double totalAllocation = completeList.stream().filter(g -> "划拨".equals(g.getGyfs()) && g.getMjMu() != null).mapToDouble(g -> g.getMjMu().doubleValue()).sum();
|
|
|
+ double totalOther = totalArea - totalTransfer - totalAllocation;
|
|
|
+
|
|
|
+ total.setCompleted(buildCompletedDTO(totalArea, completeList.size(), totalTransfer, totalAllocation, 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 LandSupplyReportDTO getTdgyReport(String startTime, String endTime) {
|
|
|
+ public LandSupplyReportVO getTdgyPurposeReport(String startYear, String endYear){
|
|
|
+ List<TdgyStatisticsRes> completeList2 = dgyMapper.getListByYear(null, null, startYear, endYear);
|
|
|
+
|
|
|
+ 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());
|
|
|
+ //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 HashMap<>();
|
|
|
+ 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 HashMap<>();
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public LandSupplyReportDTO getTdgyReport222(String startTime, String endTime) {
|
|
|
LandSupplyReportDTO report = new LandSupplyReportDTO();
|
|
|
report.setTitle("土地供应统计报表");
|
|
|
report.setStatTimeRange(startTime + " 至 " + endTime);
|
|
|
|
|
|
Map<String, Object> planSummary = gongdiJihuaMapper.getPlanSummaryByTimeRange(startTime, endTime);
|
|
|
List<Map<String, Object>> planStatsByLandType = gongdiJihuaMapper.getPlanStatsByLandType(startTime, endTime);
|
|
|
- List<Map<String, Object>> planStatsBySupplyMode = gongdiJihuaMapper.getPlanStatsBySupplyMode(startTime, endTime);
|
|
|
+ //List<Map<String, Object>> planStatsBySupplyMode = gongdiJihuaMapper.getPlanStatsBySupplyMode(startTime, endTime);
|
|
|
|
|
|
LandSupplyReportDTO.SummaryDTO summary = new LandSupplyReportDTO.SummaryDTO();
|
|
|
LandSupplyReportDTO.TotalDTO total = buildTotalDTO(planSummary);
|
|
|
@@ -276,6 +535,7 @@ public class SupplyServiceImpl implements ISupplyService {
|
|
|
return report;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private LandSupplyReportDTO.TotalDTO buildTotalDTO(Map<String, Object> summary) {
|
|
|
LandSupplyReportDTO.TotalDTO total = new LandSupplyReportDTO.TotalDTO();
|
|
|
total.setSupplyRate("0%");
|
|
|
@@ -309,6 +569,16 @@ public class SupplyServiceImpl implements ISupplyService {
|
|
|
return plan;
|
|
|
}
|
|
|
|
|
|
+ private LandSupplyReportDTO.CompletedDTO buildCompletedDTO(Double area, Integer count, Double transfer, Double allocation, Double 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 "其他";
|