mitao
2025-04-03 4e1d9877d6f2652dafb0fed1ee27f25ba11afcc6
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ScreenService.java
@@ -1,6 +1,8 @@
package com.ruoyi.system.service.impl;
import com.ruoyi.common.enums.BillTypeEnum;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.model.TBill;
import com.ruoyi.system.model.TContract;
import com.ruoyi.system.model.THouse;
@@ -38,39 +40,73 @@
     * @return
     */
    public ScreenTopStaticsDataVO getTopStaticsData() {
        String businessDeptId = SecurityUtils.getBusinessDeptId();
        ScreenTopStaticsDataVO vo = new ScreenTopStaticsDataVO();
        //房屋总面积
        List<THouse> houseList = tHouseService.list();
        Double totalArea = houseList.stream().map(item -> Double.parseDouble(item.getHouseArea())).reduce(0D, Double::sum);
        List<THouse> houseList = tHouseService.lambdaQuery()
                .eq(!businessDeptId.equals("0"), THouse::getBusinessDeptId, businessDeptId)
                .list();
        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);
        List<TBill> billList = tBillService.lambdaQuery()
                .eq(!businessDeptId.equals("0"), TBill::getBusinessDeptId, businessDeptId)
                .eq(TBill::getBillType, BillTypeEnum.Zujin.getCode())
                .list();
        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();
        Integer newTenantCount = tContractService.getCurrentMonthRentCount(businessDeptId);
        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")
                .eq(!businessDeptId.equals("0"), TContract::getBusinessDeptId, businessDeptId)
                .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()
                .eq(!businessDeptId.equals("0"), TBill::getBusinessDeptId, businessDeptId)
                .between(TBill::getPayableFeesTime, first, last)
                .eq(TBill::getBillType, BillTypeEnum.Zujin.getCode())
                .ne(TBill::getPayFeesStatus, 5)
                .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()
@@ -79,7 +115,11 @@
                .divide(BigDecimal.valueOf(10000L), 2, RoundingMode.HALF_UP);
        vo.setTotalRentOwe(totalRentOwe);
        //总计欠费
        List<TBill> allBillList = tBillService.lambdaQuery().le(TBill::getPayableFeesTime, last).list();
        List<TBill> allBillList = tBillService.lambdaQuery()
                .eq(TBill::getBillType, BillTypeEnum.Zujin.getCode())
                .eq(!businessDeptId.equals("0"), TBill::getBusinessDeptId, businessDeptId)
                //.le(TBill::getPayableFeesTime, last)
                .list();
        BigDecimal totalRentOweAll = allBillList.stream()
                .map(TBill::getOutstandingMoney)
                .reduce(BigDecimal.ZERO, BigDecimal::add)
@@ -93,7 +133,8 @@
     * @return
     */
    public List<ScreenRentRankVO> streetRentRank() {
        return  tBillService.getStreetRentRank();
        String businessDeptId = SecurityUtils.getBusinessDeptId();
        return  tBillService.getStreetRentRank(businessDeptId);
    }
    /**
@@ -102,7 +143,7 @@
     */
    public ScreenRentIncomeTrendVO rentIncomeTrend() {
        ScreenRentIncomeTrendVO vo = new ScreenRentIncomeTrendVO();
        String businessDeptId = SecurityUtils.getBusinessDeptId();
        // 获取当前日期
        Date currentDate = new Date();
        List<String> quarterLabels = new ArrayList<>(); // 季度标签列表
@@ -120,6 +161,8 @@
            // 获取该季度的账单数据
            List<TBill> quarterBills = tBillService.lambdaQuery()
                    .between(TBill::getPayableFeesTime, quarterStart, quarterEnd)
                    .eq(TBill::getBillType, BillTypeEnum.Zujin.getCode())
                    .eq(!businessDeptId.equals("0"), TBill::getBusinessDeptId, businessDeptId)
                    .list();
            // 计算季度租金收入总和