Przeglądaj źródła

趋势分析统计

chenendian 4 dni temu
rodzic
commit
1600fac3bb

+ 2 - 19
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/cadastre/ReportBatchController.java

@@ -11,7 +11,6 @@ import com.siwei.apply.domain.vo.LandSupplyReportVO;
 import com.siwei.apply.domain.vo.YdbpDataFilterVo;
 import com.siwei.apply.service.cadastre.ISupplyService;
 import com.siwei.apply.service.cadastre.impl.BatchServiceImpl;
-import com.siwei.apply.service.cadastre.impl.StorageServiceImpl;
 import com.siwei.common.core.domain.R;
 import com.siwei.common.core.web.controller.BaseController;
 import org.apache.poi.ss.usermodel.*;
@@ -35,11 +34,9 @@ public class ReportBatchController extends BaseController {
     @Autowired
     private ISupplyService supplyService;
 
-
     @Autowired
     private BatchServiceImpl batchServiceImpl;
 
-
     /**
      *
      * 年度统计
@@ -56,19 +53,14 @@ public class ReportBatchController extends BaseController {
         }
     }
 
-
-
-
-
-
     /**
      *
      * 趋势分析
      */
     @GetMapping("/trendStatistics")
-    public R<BatchRateRes> getTrendStatistics() {
+    public R<List<Map<String,Object>>> getTrendStatistics() {
         try {
-            BatchRateRes res =  batchServiceImpl.trendStatistics("");
+            List<Map<String,Object>> res =  batchServiceImpl.trendStatistics("");
             return R.ok(res);
         } catch (Exception e) {
             e.printStackTrace();
@@ -79,15 +71,6 @@ public class ReportBatchController extends BaseController {
 
 
 
-
-
-
-
-
-
-
-
-
     /**
      * 根据年份和供地类型查询土地供应统计报表数据
      * @param year

+ 61 - 9
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/cadastre/impl/BatchServiceImpl.java

@@ -7,12 +7,12 @@ import com.siwei.common.core.utils.StringUtils;
 import com.siwei.spatial.api.RemoteSpatialFilesDbService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
 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;
 
 
 @Slf4j
@@ -37,24 +37,76 @@ public class BatchServiceImpl{
     @Autowired
     private YdbpDataMapper ydbpDataMapper;
 
-
-
-
-
     /**
      * 年度统计
      * @param year
      * @return
      */
-    public BatchRateRes trendStatistics(String year) {
+    public List<Map<String,Object>> trendStatistics(String year) {
         if (StringUtils.isBlank(year) || "0".equals(year)) {
             year = "";
         }
-        BatchRateRes res = new BatchRateRes();
-        return null;
+
+        List<Map<String,Object>> resList = new ArrayList<>();
+        List<Map<String,Object>> singleBatchList =  ydbpMapper.getStatisticsList(year);
+        List<YdbpData> reportBatchList =  ydbpDataMapper.getStatisticsList(year);
+
+        Map<String,List<Map<String,Object>>> groupedSingleBatch = new HashMap<>();
+        Map<String, List<YdbpData>> groupedReportBatch = new HashMap<>();
+
+        if(CollectionUtils.isNotEmpty(singleBatchList)) {
+            groupedSingleBatch = singleBatchList.stream()
+                    .collect(Collectors.groupingBy(s->{
+                        Object nfStr = s.get("nf");
+                        if(nfStr==null || String.valueOf(nfStr).isEmpty()){
+                            return "其它";
+                        }
+                        return String.valueOf(nfStr);
+                    }));
+        }
+
+        if(CollectionUtils.isNotEmpty(reportBatchList)) {
+            groupedReportBatch = reportBatchList.stream()
+                    .collect(Collectors.groupingBy(s->{
+                       String pfDate = s.getPfDate();
+                       if(StringUtils.isBlank(pfDate)){
+                           return "其它";
+                       }
+                        pfDate = StringUtils.substring(pfDate,0,4);
+                        return pfDate;
+                    }));
+        }
+
+        Set<String> yearSet = new LinkedHashSet<>();
+        if(MapUtils.isNotEmpty(groupedSingleBatch)) {
+            yearSet.addAll(groupedSingleBatch.keySet());
+        }
+        if(MapUtils.isNotEmpty(groupedReportBatch)) {
+            yearSet.addAll(groupedReportBatch.keySet());
+        }
+
+        for(String yearKey : yearSet){
+            List<Map<String,Object>> singleList = groupedSingleBatch.get(yearKey);
+            List<YdbpData> reportList = groupedReportBatch.get(yearKey);
+            Double singleArea = sumAreaForSingle(singleList);
+            Double reportArea = sumArea(reportList);
+            Integer singleCount = singleList==null?0:singleList.size();
+            Integer reportCount = reportList==null?0:reportList.size();
+            Map<String,Object> itemMap = new HashMap<>();
+            itemMap.put("year",yearKey);
+            itemMap.put("singleArea",singleArea);
+            itemMap.put("reportArea",reportArea);
+            itemMap.put("singleCount",singleCount);
+            itemMap.put("reportCount",reportCount);
+            resList.add(itemMap);
+        }
+        return resList;
     }
 
 
+
+
+
     /**
      * 年度统计
      * @param year

+ 5 - 0
siwei-modules/siwei-apply/src/main/resources/mapper/GjShouchuJihuaMapper.xml

@@ -14,6 +14,7 @@
         <if test="year != null and year != '' and year != '0'">
             AND scnf = #{year}
         </if>
+        AND source_type='0'
     </select>
 
     <select id="getPlanStatsByLandUse" resultType="map">
@@ -25,6 +26,7 @@
         <if test="year != null and year != '' and year != '0'">
             AND scnf = #{year}
         </if>
+        AND source_type='0'
         GROUP BY COALESCE(ghyt, '其他')
         ORDER BY plan_area DESC
     </select>
@@ -38,6 +40,7 @@
         <if test="year != null and year != '' and year != '0'">
             AND scnf = #{year}
         </if>
+        AND source_type='0'
         GROUP BY COALESCE(scfs, '其他')
         ORDER BY plan_area DESC
     </select>
@@ -72,6 +75,7 @@
         <if test="(startYear != null and startYear != '') and (endYear != null and endYear != '')">
             AND scnf::NUMERIC BETWEEN #{startYear}::NUMERIC AND #{endYear}::NUMERIC
         </if>
+        AND source_type='0'
         ORDER BY gid
     </select>
 
@@ -108,6 +112,7 @@
             ST_AsEWKT(geom) AS geom
         FROM vector.gj_shouchu_xiangmu
         WHERE gid::varchar = #{gid}
+        AND source_type='0'
         LIMIT 1
     </select>
 

+ 1 - 0
siwei-modules/siwei-apply/src/main/resources/mapper/YdbpDataMapper.xml

@@ -123,6 +123,7 @@
             END,
             0
         ) AS zs_area ,
+        -- left(pf_date,4) AS nf,
         '亩' as  zs_unit,
         has_zz, bp_date, pfwh, pf_date, creator_id, created_at, updated_at,has_onchain
         FROM t_ydbp_data

+ 1 - 0
siwei-modules/siwei-apply/src/main/resources/mapper/YdbpMapper.xml

@@ -53,6 +53,7 @@
             pro.ID AS project_id,
             bp.ID AS node_id,
             bp.zs_area,
+            left(bp.pf_date,4) AS nf,
             bp.zs_unit,
             COALESCE (
                     CASE