Kaynağa Gözat

收储进度报表优化

chenendian 5 saat önce
ebeveyn
işleme
0763c36010

+ 8 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/mapper/TdgyMapper.java

@@ -65,4 +65,12 @@ public interface TdgyMapper {
     Map<String,Object> getActualProject( @Param("gid") String gid);
     Map<String,Object> getActualProject( @Param("gid") String gid);
 
 
 
 
+    List<TdgyStatisticsRes> getSjgdListByNf(@Param("startYear") String startYear,@Param("endYear") String endYear);
+
+
+
+
+
 }
 }
+
+

+ 61 - 14
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/cadastre/impl/StorageServiceImpl.java

@@ -7,6 +7,7 @@ import com.siwei.apply.domain.res.*;
 import com.siwei.apply.domain.vo.LandSupplyProjectVO;
 import com.siwei.apply.domain.vo.LandSupplyProjectVO;
 import com.siwei.apply.mapper.GjShijiShouchuMapper;
 import com.siwei.apply.mapper.GjShijiShouchuMapper;
 import com.siwei.apply.mapper.GjShouchuJihuaMapper;
 import com.siwei.apply.mapper.GjShouchuJihuaMapper;
+import com.siwei.apply.mapper.TdgyMapper;
 import com.siwei.common.core.utils.StringUtils;
 import com.siwei.common.core.utils.StringUtils;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -26,6 +27,10 @@ public class StorageServiceImpl {
     @Autowired
     @Autowired
     private GjShouchuJihuaMapper gjShouchuJihuaMapper;
     private GjShouchuJihuaMapper gjShouchuJihuaMapper;
 
 
+    @Autowired
+    private TdgyMapper tdgyMapper;
+
+
 
 
     public LandStorageInOutReportDTO inOutDetails() {
     public LandStorageInOutReportDTO inOutDetails() {
         LandStorageInOutReportDTO report = new LandStorageInOutReportDTO();
         LandStorageInOutReportDTO report = new LandStorageInOutReportDTO();
@@ -33,6 +38,9 @@ public class StorageServiceImpl {
         List<LandStorageInOutReportDTO.CategoryDTO> categoryList = new ArrayList();
         List<LandStorageInOutReportDTO.CategoryDTO> categoryList = new ArrayList();
 
 
         List<TdgyStatisticsRes> completeList = gjShijiShouchuMapper.gjShijiShouchuListByYear(null, null,null,null, null, null);
         List<TdgyStatisticsRes> completeList = gjShijiShouchuMapper.gjShijiShouchuListByYear(null, null,null,null, null, null);
+        //出库数据
+        List<TdgyStatisticsRes> completeSjgdList = tdgyMapper.getSjgdListByNf("2021", "2026");
+
 
 
         String [] yearArr = {"all","2021","2022","2023","2024","2025","2026","other"};
         String [] yearArr = {"all","2021","2022","2023","2024","2025","2026","other"};
 
 
@@ -51,8 +59,25 @@ public class StorageServiceImpl {
         Set<String> categorySet = new HashSet<>(groupedCompleteMap.keySet());
         Set<String> categorySet = new HashSet<>(groupedCompleteMap.keySet());
         categorySet.add("其它");
         categorySet.add("其它");
 
 
+        //实际供地数据需要根据其情况进行统计
+        Map<String, List<TdgyStatisticsRes>> groupedCompleteSjgdMap = completeSjgdList.stream()
+                .collect(Collectors.groupingBy(
+                        s -> {
+                            String tdyt = s.getTdyt();
+                            if (StringUtils.isNotBlank(tdyt) && categorySet.contains(tdyt)) {
+                                return tdyt;
+                            }
+                            return "其它";
+                        }
+                ));
+
         for(String category  : categorySet){
         for(String category  : categorySet){
             List<TdgyStatisticsRes>   categoryCompleteList =  groupedCompleteMap.get(category);
             List<TdgyStatisticsRes>   categoryCompleteList =  groupedCompleteMap.get(category);
+            List<TdgyStatisticsRes>   groupedCompleteSjgdList = groupedCompleteSjgdMap.get(category);
+
+            List<LandStorageInOutReportDTO.ItemDTO> inList = new ArrayList<>();
+            List<LandStorageInOutReportDTO.ItemDTO> outList = new ArrayList<>();
+
             if(CollectionUtils.isNotEmpty(categoryCompleteList)){
             if(CollectionUtils.isNotEmpty(categoryCompleteList)){
                 // 根据 nf 字段分组:在 yearArr 中年份相等的归到对应年份,不在 yearArr 中的归到 other
                 // 根据 nf 字段分组:在 yearArr 中年份相等的归到对应年份,不在 yearArr 中的归到 other
                 Set<String> definedYears = new HashSet<>(Arrays.asList("2021","2022","2023","2024","2025","2026"));
                 Set<String> definedYears = new HashSet<>(Arrays.asList("2021","2022","2023","2024","2025","2026"));
@@ -68,7 +93,6 @@ public class StorageServiceImpl {
                                 Collectors.counting()
                                 Collectors.counting()
                         ));
                         ));
 
 
-                List<LandStorageInOutReportDTO.ItemDTO> inList = new ArrayList<>();
                 for (String year : yearArr) {
                 for (String year : yearArr) {
                     LandStorageInOutReportDTO.ItemDTO item = new LandStorageInOutReportDTO.ItemDTO();
                     LandStorageInOutReportDTO.ItemDTO item = new LandStorageInOutReportDTO.ItemDTO();
                     item.setYear(year);
                     item.setYear(year);
@@ -80,24 +104,47 @@ public class StorageServiceImpl {
                     }
                     }
                     inList.add(item);
                     inList.add(item);
                 }
                 }
+            }
+            //这里解析out数据
+            if(CollectionUtils.isNotEmpty(groupedCompleteSjgdList)){
+                // 根据 nf 字段分组:在 yearArr 中年份相等的归到对应年份,不在 yearArr 中的归到 other
+                Set<String> definedYears = new HashSet<>(Arrays.asList("2021","2022","2023","2024","2025","2026"));
+                Map<String, Long> yearCountMap = categoryCompleteList.stream()
+                        .collect(Collectors.groupingBy(
+                                s -> {
+                                    String nf = s.getNf();
+                                    if (StringUtils.isNotBlank(nf) && definedYears.contains(nf)) {
+                                        return nf;
+                                    }
+                                    return "other";
+                                },
+                                Collectors.counting()
+                        ));
 
 
-                LandStorageInOutReportDTO.CategoryDTO categoryDTO = new LandStorageInOutReportDTO.CategoryDTO();
-                LandStorageInOutReportDTO.DetailDTO inOut =  new LandStorageInOutReportDTO.DetailDTO();
-                inOut.setIn(inList);
-                inOut.setOut(null); //这里暂时为空
-                categoryDTO.setCategory(category);
-                categoryDTO.setDetail(inOut);
-                categoryList.add(categoryDTO);
+                for (String year : yearArr) {
+                    LandStorageInOutReportDTO.ItemDTO item = new LandStorageInOutReportDTO.ItemDTO();
+                    item.setYear(year);
+                    if ("all".equals(year)) {
+                        // all 统计当前分类下不区分 nf 的所有数据加总
+                        item.setCount(String.valueOf(categoryCompleteList.size()));
+                    } else {
+                        item.setCount(String.valueOf(yearCountMap.getOrDefault(year, 0L)));
+                    }
+                    outList.add(item);
+                }
             }
             }
+
+            LandStorageInOutReportDTO.CategoryDTO categoryDTO = new LandStorageInOutReportDTO.CategoryDTO();
+            LandStorageInOutReportDTO.DetailDTO inOut =  new LandStorageInOutReportDTO.DetailDTO();
+            inOut.setIn(inList);
+            inOut.setOut(outList);
+            categoryDTO.setCategory(category);
+            categoryDTO.setDetail(inOut);
+            categoryList.add(categoryDTO);
         }
         }
         report.setCategoryList(categoryList);
         report.setCategoryList(categoryList);
 
 
-
-
-
-
-
-        // -----------------第二部分计算----------------------------
+        // -----------------第二部分合计行的计算----------------------------
         //todo 这里计算加总,合计的一行,使用completeList 直接算每一年的值,
         //todo 这里计算加总,合计的一行,使用completeList 直接算每一年的值,
         LandStorageInOutReportDTO.CategoryDTO  summary = new LandStorageInOutReportDTO.CategoryDTO();
         LandStorageInOutReportDTO.CategoryDTO  summary = new LandStorageInOutReportDTO.CategoryDTO();
         summary.setCategory("合计");
         summary.setCategory("合计");

+ 33 - 0
siwei-modules/siwei-apply/src/main/resources/mapper/TdgyMapper.xml

@@ -206,6 +206,39 @@
         LIMIT 41
         LIMIT 41
     </select>
     </select>
 
 
+    <!-- 根据年份查询当前存量土地实际供应情况! -->
+    <select id="getSjgdListByNf" resultType="com.siwei.apply.domain.res.TdgyStatisticsRes" parameterType="String">
+        SELECT
+        '' AS projectId,
+        xmmc AS xmmc,
+        srr AS company,
+        gid AS nodeId,
+        tdyt,
+        COALESCE ( land.code, '23' ) AS tdyt2,
+        gyfs,
+        qdrq AS gysj,
+        ROUND(COALESCE ( gymj, 0 ) / 666.6666667,2)     AS mjMu,-- 平方米 -> 亩
+        '' AS geomDbId,
+        '' AS uploadId,
+        '' AS geomJson,
+        left(gj_gd_data.nf,4) as nf,
+        0 AS sort
+        FROM
+        vector.gj_gd_data
+        LEFT JOIN public.land_type land ON land.NAME = gj_gd_data.tdyt
+        WHERE 1=1
+        <if test="(startYear != null and startYear != null) and (endYear != '' and endYear != '')">
+            AND left(gj_gd_data.nf,4)::NUMERIC BETWEEN #{startYear}::NUMERIC AND #{endYear}::NUMERIC
+        </if>
+
+    </select>
+
+
+
+
+
+
+
     <select id="getActualProject" resultType="Map" parameterType="String">
     <select id="getActualProject" resultType="Map" parameterType="String">
         SELECT
         SELECT
         "gid",
         "gid",