|
|
@@ -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());
|