From 592ac14eba76040426f590d8eb079fc75e968b84 Mon Sep 17 00:00:00 2001
From: luofl <1442745593@qq.com>
Date: 星期五, 28 三月 2025 19:18:37 +0800
Subject: [PATCH] 1.租户数量趋势统计

---
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ScreenService.java |   55 +++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ScreenService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ScreenService.java
index 084db02..59f1cae 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ScreenService.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ScreenService.java
@@ -16,12 +16,7 @@
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 
 /**
  * @author mitao
@@ -41,36 +36,60 @@
         ScreenTopStaticsDataVO vo = new ScreenTopStaticsDataVO();
         //房屋总面积
         List<THouse> houseList = tHouseService.list();
-        Double totalArea = houseList.stream().map(item -> Double.parseDouble(item.getHouseArea())).reduce(0D, Double::sum);
+        Double totalArea = houseList.stream()
+                .map(item -> Double.parseDouble(item.getHouseArea()))
+                .reduce(0D, Double::sum);
         vo.setHouseTotalArea(totalArea);
         //已出租面积
-        Double totalRentedArea = houseList.stream().filter(item -> !item.getLeaseStatus().equals("1"))
-                .map(item -> Double.parseDouble(item.getHouseArea())).reduce(0D, Double::sum);
+        Double totalRentedArea = houseList.stream()
+                .filter(item -> !item.getLeaseStatus().equals("1"))
+                .map(item -> Double.parseDouble(item.getHouseArea()))
+                .reduce(0D, Double::sum);
         vo.setHouseRentedArea(totalRentedArea);
         //总计应收租金
         List<TBill> billList = tBillService.list();
-        BigDecimal totalReceivableRent = billList.stream().filter(item -> !item.getPayFeesStatus().equals("5"))
-                .map(TBill::getPayableFeesMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
+        BigDecimal totalReceivableRent = billList.stream()
+                .filter(item -> !item.getPayFeesStatus().equals("5"))
+                .map(TBill::getPayableFeesMoney)
+                .reduce(BigDecimal.ZERO, BigDecimal::add)
+                .divide(new BigDecimal("10000"),2, RoundingMode.HALF_UP);
         vo.setTotalReceivableRent(totalReceivableRent);
         //总计已收租金
-        BigDecimal totalReceivedRent = billList.stream().map(TBill::getPayFeesMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
+        BigDecimal totalReceivedRent = billList.stream()
+                .map(TBill::getPayFeesMoney)
+                .reduce(BigDecimal.ZERO, BigDecimal::add)
+                .divide(new BigDecimal("10000"),2, RoundingMode.HALF_UP);
         vo.setTotalReceivedRent(totalReceivedRent);
         //本月新增租户数
         Integer newTenantCount = tContractService.getCurrentMonthRentCount();
         vo.setNewTenantCount(newTenantCount);
         //总计租户数 系统租户列表里有生效合同绑定的租户总数。
-        Long count = tContractService.lambdaQuery().in(TContract::getStatus, "4", "5", "6", "7", "8", "9").groupBy(TContract::getTenantId).count();
-        vo.setTotalTenantCount(count.intValue());
+        List<TContract> tContracts = tContractService.lambdaQuery()
+                .in(TContract::getStatus, "4", "5", "6", "7", "8", "9")
+                .list();
+        long count = tContracts.stream()
+                .map(TContract::getTenantId)
+                .distinct()
+                .count();
+        vo.setTotalTenantCount((int) count);
         Map<String, Date> quarterDate = DateUtils.getQuarterDate(new Date());
         Date first = quarterDate.get("first");
         Date last = quarterDate.get("last");
-        List<TBill> currentQuarterBillList = tBillService.lambdaQuery().between(TBill::getPayableFeesTime, first, last).list();
+        List<TBill> currentQuarterBillList = tBillService.lambdaQuery()
+                .between(TBill::getPayableFeesTime, first, last)
+                .list();
         //本季度已交租金
-        BigDecimal totalRentPaid = currentQuarterBillList.stream().map(TBill::getPayFeesMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
+        BigDecimal totalRentPaid = currentQuarterBillList.stream()
+                .map(TBill::getPayFeesMoney)
+                .reduce(BigDecimal.ZERO, BigDecimal::add)
+                .divide(new BigDecimal("10000"),2, RoundingMode.HALF_UP);
         vo.setTotalRentPaid(totalRentPaid);
         //本季度应交租金
-        BigDecimal totalRentShould = currentQuarterBillList.stream().filter(item -> !item.getPayFeesStatus().equals("5"))
-                .map(TBill::getPayableFeesMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
+        BigDecimal totalRentShould = currentQuarterBillList.stream()
+                .filter(item -> !item.getPayFeesStatus().equals("5"))
+                .map(TBill::getPayableFeesMoney)
+                .reduce(BigDecimal.ZERO, BigDecimal::add)
+                .divide(new BigDecimal("10000"),2, RoundingMode.HALF_UP);
         vo.setTotalRentShould(totalRentShould);
         //本季度欠费
         BigDecimal totalRentOwe = currentQuarterBillList.stream()

--
Gitblit v1.7.1