1
0
Просмотр исходного кода

收储进度报表-出入库报表

chenendian 4 дней назад
Родитель
Сommit
b6aadbafec

+ 18 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/controller/cadastre/StorageController.java

@@ -1,5 +1,6 @@
 package com.siwei.apply.controller.cadastre;
 
+import com.siwei.apply.domain.cadastre.LandStorageInOutReportDTO;
 import com.siwei.apply.domain.cadastre.LandStorageReportDTO;
 import com.siwei.apply.domain.cadastre.LandSupplyReportDTO;
 import com.siwei.apply.domain.res.StorageYearStatisticsRes;
@@ -192,6 +193,23 @@ public class StorageController extends BaseController {
 
 
 
+    @GetMapping("/report/inOutDetails")
+    public R<LandStorageInOutReportDTO> getInOutDetails() {
+        try {
+            LandStorageInOutReportDTO res =  storageServiceImpl.inOutDetails();
+            return R.ok(res);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return R.fail(e.getMessage());
+        }
+    }
+
+
+
+
+
+
+
 
 
 

+ 32 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/cadastre/LandStorageInOutReportDTO.java

@@ -0,0 +1,32 @@
+package com.siwei.apply.domain.cadastre;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class LandStorageInOutReportDTO {
+
+    private String title;
+    private CategoryDTO  summary;
+    private List<CategoryDTO> categoryList;
+
+    @Data
+    public static class CategoryDTO {
+        private String category;
+        private DetailDTO detail;
+    }
+
+    @Data
+    public static class DetailDTO {
+        private List<ItemDTO> in;
+        private List<ItemDTO> out;
+    }
+
+    @Data
+    public static class ItemDTO {
+        private String year; //年份
+        private String count; //个数(条数)
+    }
+
+}

+ 2 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/domain/res/TdgyStatisticsRes.java

@@ -35,6 +35,8 @@ public class TdgyStatisticsRes {
 
     private BigDecimal cost;
 
+    private String nf;
+
     private String geom;
 
 

+ 94 - 0
siwei-modules/siwei-apply/src/main/java/com/siwei/apply/service/cadastre/impl/StorageServiceImpl.java

@@ -1,5 +1,6 @@
 package com.siwei.apply.service.cadastre.impl;
 
+import com.siwei.apply.domain.cadastre.LandStorageInOutReportDTO;
 import com.siwei.apply.domain.cadastre.LandStorageReportDTO;
 import com.siwei.apply.domain.cadastre.LandSupplyReportDTO;
 import com.siwei.apply.domain.res.*;
@@ -26,6 +27,97 @@ public class StorageServiceImpl {
     private GjShouchuJihuaMapper gjShouchuJihuaMapper;
 
 
+    public LandStorageInOutReportDTO inOutDetails() {
+        LandStorageInOutReportDTO report = new LandStorageInOutReportDTO();
+        report.setTitle("收储出入库分析报表");
+        List<LandStorageInOutReportDTO.CategoryDTO> categoryList = new ArrayList();
+
+        List<TdgyStatisticsRes> completeList = gjShijiShouchuMapper.gjShijiShouchuListByYear(null, null,null,null, null, null);
+
+        String [] yearArr = {"all","2021","2022","2023","2024","2025","2026","other"};
+
+        Map<String, List<TdgyStatisticsRes>> groupedCompleteMap = completeList.stream()
+                .collect(Collectors.groupingBy(
+                        s -> {
+                            String tdyt = s.getTdyt();
+                            //为空赋值“其它”
+                            if (StringUtils.isBlank(tdyt)) {
+                                return "其它";
+                            }
+                            return tdyt;
+                        }
+                ));
+
+        Set<String> categorySet = new HashSet<>(groupedCompleteMap.keySet());
+        categorySet.add("其它");
+
+        for(String category  : categorySet){
+            List<TdgyStatisticsRes>   categoryCompleteList =  groupedCompleteMap.get(category);
+            if(CollectionUtils.isNotEmpty(categoryCompleteList)){
+                // 根据 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()
+                        ));
+
+                List<LandStorageInOutReportDTO.ItemDTO> inList = new ArrayList<>();
+                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)));
+                    }
+                    inList.add(item);
+                }
+
+                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);
+            }
+        }
+        report.setCategoryList(categoryList);
+
+
+
+
+
+
+        // -----------------第二部分计算----------------------------
+        //todo 这里计算加总,合计的一行,使用completeList 直接算每一年的值,
+        LandStorageInOutReportDTO.CategoryDTO  summary = new LandStorageInOutReportDTO.CategoryDTO();
+        summary.setCategory("合计");
+        LandStorageInOutReportDTO.DetailDTO totalDetail = new LandStorageInOutReportDTO.DetailDTO();
+        //todo 这里计算 totalInList
+        List<LandStorageInOutReportDTO.ItemDTO> totalInList = new ArrayList<>();
+        totalDetail.setIn(totalInList);
+        totalDetail.setOut(null);
+        summary.setDetail(totalDetail);
+        report.setSummary(summary);
+
+
+
+
+        return report;
+    }
+
+
+
+
     //统计分析
     public LandStorageReportDTO stroageProgress(String startYear, String endYear) {
         LandStorageReportDTO report = new LandStorageReportDTO();
@@ -151,6 +243,8 @@ public class StorageServiceImpl {
         totalCompleted.setCost(totalCost);
         double totalArea = completeList.stream().mapToDouble(item -> item.getMjMu().doubleValue()).sum();
         totalCompleted.setArea(totalArea);
+
+
         //这里处理计划的数据
         LandStorageReportDTO.PlanDTO totalPlan = new LandStorageReportDTO.PlanDTO();
         totalPlan.setCount(planList.size());

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

@@ -165,6 +165,7 @@
             ROUND("面积_亩", 2) AS mjMu,
             bz,
             sccb AS cost,
+            scnd   as nf,
             ST_AsEWKT(geom) AS geom
         FROM vector.gj_shiji_shouchu
         WHERE 1=1