Explorar o código

面积趋势分析方法

chenendian hai 1 mes
pai
achega
9f569eb303

+ 23 - 13
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/cadastre/SupplyController.java

@@ -30,14 +30,11 @@ public class SupplyController extends BaseController {
 
     private final LinkedHashMap<String, OGRVectorTiler> m_TilerMap = new LinkedHashMap<String, OGRVectorTiler>();
 
-
-
     @Autowired
     private ISupplyService supplyService;
 
 
 
-
     /**
      *
      * 年度统计
@@ -55,7 +52,6 @@ public class SupplyController extends BaseController {
     }
 
 
-
     /**
      *
      * 年度统计2
@@ -168,13 +164,19 @@ public class SupplyController extends BaseController {
     }
 
 
-
-
-
-
-
-
-
+    /**
+     *
+     * 趋势统计
+     */
+    @GetMapping("/trendStatistics/{landType}")
+    public R<TrendStatisticsRes> getTrendStatistics(@PathVariable String landType) {
+        try {
+            TrendStatisticsRes res =  supplyService.trendStatistics(landType);
+            return R.ok(res);
+        } catch (Exception e) {
+            return R.fail(e.getMessage());
+        }
+    }
 
 
     /**
@@ -182,8 +184,8 @@ public class SupplyController extends BaseController {
      * 趋势统计
      *
      */
-    @GetMapping("/trendStatistics/{landType}")
-    public R<TrendStatisticsRes> getTrendStatistics(@PathVariable String landType) {
+    @GetMapping("/trendStatistics2/{landType}")
+    public R<TrendStatisticsRes> getTrendStatistics2(@PathVariable String landType) {
         try {
             TrendStatisticsRes res = new TrendStatisticsRes();
             List<Map<String, Object>> areaTrendStatisticsList = new java.util.ArrayList<>(List.of()); // 面积趋势分析list
@@ -232,6 +234,10 @@ public class SupplyController extends BaseController {
     }
 
 
+
+
+
+
     @GetMapping("/getTestList")
     public R<String> getTestList(String param) {
         //ogr.RegisterAll();
@@ -252,6 +258,10 @@ public class SupplyController extends BaseController {
         return null;
     }
 
+
+
+
+
     private static void printLayerInfo(Layer layer) {
         System.out.println("=============");
         System.out.println("图层名: " + layer.GetName());

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

@@ -59,10 +59,7 @@ public interface TdgyMapper {
     List<ProjectSupplyRes> countAndSumByGdType(@Param("projectType") Integer projectType);
 
 
-
-    List<TdgyStatisticsRes> getListByYear(@Param("year") String year);
-
-
+    List<TdgyStatisticsRes> getListByYear(@Param("year") String year,@Param("landTypeCode") String landTypeCode);
 
 
 

+ 5 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/cadastre/ISupplyService.java

@@ -3,6 +3,7 @@ package com.siwei.apply.service.cadastre;
 
 import com.siwei.apply.domain.cadastre.LandSupplyReportDTO;
 import com.siwei.apply.domain.res.SupplyYearStatisticsRes;
+import com.siwei.apply.domain.res.TrendStatisticsRes;
 import com.siwei.common.core.domain.R;
 
 
@@ -14,4 +15,8 @@ public interface ISupplyService {
 
     SupplyYearStatisticsRes yearStatistics(String year);
 
+    TrendStatisticsRes trendStatistics(String landType);
+
+
+
 }

+ 99 - 66
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/cadastre/impl/SupplyServiceImpl.java

@@ -1,6 +1,5 @@
 package com.siwei.apply.service.cadastre.impl;
 
-import com.siwei.apply.common.Constant;
 import com.siwei.apply.domain.GongdiJihua;
 import com.siwei.apply.domain.LandType;
 import com.siwei.apply.domain.cadastre.*;
@@ -15,8 +14,6 @@ import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.math.BigDecimal;
-import java.math.RoundingMode;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -56,8 +53,11 @@ 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);
 
         if(CollectionUtils.isNotEmpty(list)) {
             double completeRate =0;
@@ -120,7 +120,6 @@ public class SupplyServiceImpl implements ISupplyService {
                     }
                 }
             }
-
             Set<String> allCategories = new HashSet<>(planAreaMap.keySet());
             allCategories.addAll(completeAreaMap.keySet());
 
@@ -133,86 +132,120 @@ public class SupplyServiceImpl implements ISupplyService {
             }
             res.setLandUseStatisticsList(landUseStatisticsList);
 
-
-
-
-
-            // 根据当前list中的字段,统计不同供应方式(gyfs)进行分组,如果是 gyfs=划拨或出让分别分组,其它为一组,然后分别计算每个供应方式的计划供应面积(mjMu)和完成供应面积(0填充),最后封装成 ProjectSupplyRes 对象添加到 projectSupplyList 中
             List<ProjectSupplyRes> projectSupplyList = new ArrayList<>(); // 供应方式
 
-            // 预先按供应方式对已完成列表进行分组求和
-            Map<String, Double> completeModeAreaMap = new HashMap<>();
-            if (CollectionUtils.isNotEmpty(completeList)) {
-                for (TdgyStatisticsRes g : completeList) {
-                    String mode = g.getGyfs();
-                    String category = ("划拨".equals(mode) || "出让".equals(mode)) ? mode : "其它";
-                    double area = g.getMjMu() != null ? g.getMjMu().doubleValue() : 0.0;
-                    completeModeAreaMap.put(category, completeModeAreaMap.getOrDefault(category, 0.0) + area);
-                }
-            }
-
             // 1. 划拨
-            List<GongdiJihua> hbList = list.stream()
+            List<TdgyStatisticsRes> hbList = completeList.stream()
                     .filter(g -> "划拨".equals(g.getGyfs()))
                     .collect(Collectors.toList());
-            if (CollectionUtils.isNotEmpty(hbList)) {
-                ProjectSupplyRes resHb = new ProjectSupplyRes();
-                resHb.setGdType("划拨");
-                resHb.setGdUnit("亩");
-                resHb.setCount(hbList.size());
-                float hbPlanArea = (float) hbList.stream()
-                        .filter(g -> g.getMjMu() != null)
-                        .mapToDouble(g -> g.getMjMu().doubleValue())
-                        .sum();
-                resHb.setPlanArea(hbPlanArea);
-                resHb.setGdArea(hbPlanArea);
-                resHb.setCompleteArea(completeModeAreaMap.getOrDefault("划拨", 0.0).floatValue());
-                projectSupplyList.add(resHb);
-            }
+            ProjectSupplyRes resHb = new ProjectSupplyRes();
+            resHb.setGdType("划拨");
+            resHb.setGdUnit("亩");
+            resHb.setCount(hbList.size());
+            float hbPlanArea = (float) hbList.stream()
+                    .filter(g -> g.getMjMu() != null)
+                    .mapToDouble(g -> g.getMjMu().doubleValue())
+                    .sum();
+            resHb.setGdArea(hbPlanArea);
+            projectSupplyList.add(resHb);
+
 
             // 2. 出让
-            List<GongdiJihua> crList = list.stream()
+            List<TdgyStatisticsRes> crList = completeList.stream()
                     .filter(g -> "出让".equals(g.getGyfs()))
                     .collect(Collectors.toList());
-            if (CollectionUtils.isNotEmpty(crList)) {
-                ProjectSupplyRes resCr = new ProjectSupplyRes();
-                resCr.setGdType("出让");
-                resCr.setGdUnit("亩");
-                resCr.setCount(crList.size());
-                float crPlanArea = (float) crList.stream()
-                        .filter(g -> g.getMjMu() != null)
-                        .mapToDouble(g -> g.getMjMu().doubleValue())
-                        .sum();
-                resCr.setPlanArea(crPlanArea);
-                resCr.setGdArea(crPlanArea);
-                resCr.setCompleteArea(completeModeAreaMap.getOrDefault("出让", 0.0).floatValue());
-                projectSupplyList.add(resCr);
-            }
+            ProjectSupplyRes resCr = new ProjectSupplyRes();
+            resCr.setGdType("出让");
+            resCr.setGdUnit("亩");
+            resCr.setCount(crList.size());
+            float crPlanArea = (float) crList.stream()
+                    .filter(g -> g.getMjMu() != null)
+                    .mapToDouble(g -> g.getMjMu().doubleValue())
+                    .sum();
+            resCr.setGdArea(crPlanArea);
+            projectSupplyList.add(resCr);
 
             // 3. 其它
-            List<GongdiJihua> qtList = list.stream()
+            List<TdgyStatisticsRes> qtList = completeList.stream()
                     .filter(g -> !"划拨".equals(g.getGyfs()) && !"出让".equals(g.getGyfs()))
                     .collect(Collectors.toList());
-            if (CollectionUtils.isNotEmpty(qtList)) {
-                ProjectSupplyRes resQt = new ProjectSupplyRes();
-                resQt.setGdType("其它");
-                resQt.setGdUnit("亩");
-                resQt.setCount(qtList.size());
-                float qtPlanArea = (float) qtList.stream()
-                        .filter(g -> g.getMjMu() != null)
-                        .mapToDouble(g -> g.getMjMu().doubleValue())
-                        .sum();
-                resQt.setPlanArea(qtPlanArea);
-                resQt.setGdArea(qtPlanArea);
-                resQt.setCompleteArea(completeModeAreaMap.getOrDefault("其它", 0.0).floatValue());
-                projectSupplyList.add(resQt);
-            }
+            ProjectSupplyRes resQt = new ProjectSupplyRes();
+            resQt.setGdType("其它");
+            resQt.setGdUnit("亩");
+            resQt.setCount(qtList.size());
+            float qtPlanArea = (float) qtList.stream()
+                    .filter(g -> g.getMjMu() != null)
+                    .mapToDouble(g -> g.getMjMu().doubleValue())
+                    .sum();
+            resQt.setGdArea(qtPlanArea);
+            projectSupplyList.add(resQt);
             res.setProjectSupplyList(projectSupplyList);
         }
         return res;
     }
 
 
+    /**
+     *
+     * @param landType
+     * @return
+     */
+    @Override
+    public TrendStatisticsRes trendStatistics(String landType) {
+
+        List<TdgyStatisticsRes> completeList = dgyMapper.getListByYear(null, landType);
+
+        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) {

+ 3 - 1
siwei-modules/siwei-apply/src/main/resources/mapper/TdgyMapper.xml

@@ -156,9 +156,11 @@
         <if test="year != null">
             AND  LEFT(t_node.hbcrht_date, 4) = #{year}
         </if>
+        <if test="landTypeCode != null">
+            LEFT(t_node.tdyt,2)=#{landTypeCode}
+        </if>
     </select>
 
 
 
-
 </mapper>