xuhy
2025-04-03 01e640e494e50448e9fac58fe34026bcf1fc2d4c
Merge branch 'dev' of http://120.76.84.145:10101/gitblit/r/java/xizang into dev
14个文件已修改
270 ■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ScreenController.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBillMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/THouseMapper.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TContractService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/THouseService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ScreenService.java 107 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TContractServiceImpl.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/THouseServiceImpl.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TContractMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/THouseMapper.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ScreenController.java
@@ -69,40 +69,11 @@
        return R.ok(screenService.rentIncomeTrend());
    }
    @GetMapping("/getTenantCountTrend")
    @ApiOperation(value = "租户数量趋势统计")
    public R<List<TenantCountTrendVO>> getTenantCountTrend() {
        String businessDeptId = SecurityUtils.getBusinessDeptId();
        Date currentDate = new Date();
        Date targetDate = DateUtils.addMonths(currentDate, -3 * 6);
        Map<String, Date> startQuarterDate = DateUtils.getQuarterDate(targetDate);
        Date targetDate2 = DateUtils.addMonths(currentDate, 0);
        Map<String, Date> endQuarterDate = DateUtils.getQuarterDate(targetDate2);
        List<TContract> contracts = contractService.list(new LambdaQueryWrapper<TContract>()
                .eq(!"0".equals(businessDeptId),TContract::getBusinessDeptId, businessDeptId)
                .isNotNull(TContract::getSignTime)
                .between(TContract::getSignTime, startQuarterDate.get("first"), endQuarterDate.get("last"))
                .orderByAsc(TContract::getSignTime));
        DateTimeFormatter quarterFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
        List<TenantCountTrendVO> trendData = contracts.stream()
                .collect(Collectors.groupingBy(contract -> {
                    LocalDate date = contract.getSignTime().toLocalDate();
                    int quarter = (date.getMonthValue() - 1) / 3 + 1;
                    return YearQuarter.from(date.withMonth(quarter * 3 - 2));
                }, TreeMap::new, Collectors.counting()))
                .entrySet().stream()
                .map(entry -> new TenantCountTrendVO(
                        entry.getKey().format(quarterFormatter),
                        entry.getValue()))
                .collect(Collectors.toList());
        return R.ok(trendData);
        return screenService.getTenantCountTrend();
    }
@@ -152,8 +123,16 @@
        String businessDeptId = SecurityUtils.getBusinessDeptId();
        // 获取所有房屋信息
        List<TContract> tContracts = contractService.list(new LambdaQueryWrapper<TContract>()
                .eq(!"0".equals(businessDeptId), TContract::getBusinessDeptId, businessDeptId)
                .eq(TContract::getPayType, 1));
        List<String> houseIds = tContracts.stream().map(TContract::getHouseId).collect(Collectors.toList());
        if (houseIds.isEmpty()){
            return R.ok(new ArrayList<>());
        }
        List<THouse> houses = houseService.list(new LambdaQueryWrapper<THouse>()
                .eq(!"0".equals(businessDeptId),THouse::getBusinessDeptId, businessDeptId));
                .eq(!"0".equals(businessDeptId),THouse::getBusinessDeptId, businessDeptId)
                .in(THouse::getId, houseIds));
        List<HouseMapDistributionVO> result = new ArrayList<>();
        for (THouse house : houses) {
            HouseMapDistributionVO houseMapDistributionVO = new HouseMapDistributionVO();
@@ -164,6 +143,7 @@
            houseMapDistributionVO.setLatitude(house.getLatitude());
            TContract contract = contractService.getOne(new LambdaQueryWrapper<TContract>()
                    .eq(!"0".equals(businessDeptId),TContract::getBusinessDeptId, businessDeptId)
                    .eq(TContract::getPayType, 1)
                    .gt(TContract::getEndTime, LocalDate.now())
                    .eq(TContract::getHouseId, house.getId())
                    .eq(TContract::getStatus, 4)
@@ -182,11 +162,11 @@
                long monthsBetween = ChronoUnit.MONTHS.between(startTime, endTime);
                BigDecimal payableFeesMoney = monthRent.multiply(new BigDecimal(monthsBetween));
                BigDecimal paidAlready = tBills.stream()
                        .map(TBill::getPayableFeesMoney)
                BigDecimal payFeesMoney = tBills.stream()
                        .map(TBill::getPayFeesMoney)
                        .reduce(BigDecimal::add)
                        .orElse(BigDecimal.ZERO);
                String rentStatus = String.format("%.2f/%.2f", paidAlready, payableFeesMoney);
                String rentStatus = String.format("%.2f/%.2f", payFeesMoney, payableFeesMoney);
                houseMapDistributionVO.setRentStatus(rentStatus);
@@ -211,9 +191,9 @@
                    if ("4".equals(one.getPayFeesStatus())){
                        houseMapDistributionVO.setHouseStatus("4");
                    }
                    BigDecimal payFeesMoney = one.getPayFeesMoney();
                    BigDecimal payFeesMoney1 = one.getPayFeesMoney();
                    BigDecimal payableFeesMoney1 = one.getPayableFeesMoney();
                    String rent = String.format("%.2f/%.2f", payFeesMoney, payableFeesMoney1);
                    String rent = String.format("%.2f/%.2f", payFeesMoney1, payableFeesMoney1);
                    houseMapDistributionVO.setRent(rent);
                }else {
                    houseMapDistributionVO.setRent("暂无");
@@ -221,7 +201,7 @@
            }else {
                houseMapDistributionVO.setTenant("暂无");
                houseMapDistributionVO.setRentStatus("暂无");
                houseMapDistributionVO.setRent("暂无");
                houseMapDistributionVO.setRent("欠费");
            }
            result.add(houseMapDistributionVO);
        }
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java
@@ -80,7 +80,6 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
 * <p>
@@ -599,7 +598,7 @@
        if (Objects.isNull(contract)) {
            throw new ServiceException("合同不存在");
        }
        if (StringUtils.isNotBlank(contract.getContractFile())) {
  /*      if (StringUtils.isNotBlank(contract.getContractFile())) {
            List<String> contractFileList = Arrays.stream(contract.getContractFile().split(",")).collect(Collectors.toList());
            List<String> memoryList = Arrays.stream(contract.getMemory().split(",")).collect(Collectors.toList());
            List<String> contractNameList = Arrays.stream(contract.getContractFileName().split(",")).collect(Collectors.toList());
@@ -613,7 +612,10 @@
            contract.setContractFile(dto.getContractFile());
            contract.setContractFileName(dto.getContractFileName());
            contract.setMemory(dto.getMemory());
        }
        }*/
        contract.setContractFile(dto.getContractFile());
        contract.setContractFileName(dto.getContractFileName());
        contract.setMemory(dto.getMemory());
        return R.ok(contractService.updateById(contract));
    }
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBillMapper.java
@@ -10,6 +10,7 @@
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
@@ -51,4 +52,10 @@
     * @return
     */
    List<ScreenRentRankVO> getStreetRentRank(@Param("businessDeptId") String businessDeptId);
    /**
     * 查询季付账单
     * @param businessDeptId
     * @return
     */
    List<TBill> getJiFuBillList(@Param("businessDeptId") String businessDeptId, @Param("first") Date first, @Param("last") Date last);
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/THouseMapper.java
@@ -23,5 +23,10 @@
    List<THouse> houseList(@Param("req") THouseQuery query, @Param("pageInfo") PageInfo<THouse> pageInfo);
    List<HouseVO> userHistoryList(@Param("req")TUserHistoryQuery query, @Param("pageInfo")PageInfo<HouseVO> pageInfo);
    /**
     * 获取本季度已出租面积
     * @param businessDeptId
     * @return
     */
    Double getRentedArea(@Param("businessDeptId") String businessDeptId);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java
@@ -15,6 +15,7 @@
import javax.validation.constraints.NotEmpty;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.function.Consumer;
@@ -96,4 +97,20 @@
     * @return
     */
    List<ScreenRentRankVO> getStreetRentRank(String businessDeptId);
    /**
     * 查询季付账单
     * @param businessDeptId
     * @return
     */
    List<TBill> getJiFuBillList(String businessDeptId);
    /**
     * 查询当前季度的季付账单
     * @param businessDeptId
     * @param first
     * @param last
     * @return
     */
    List<TBill> getJiFuBillListByTime(String businessDeptId, Date first, Date last);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/TContractService.java
@@ -11,6 +11,7 @@
import com.ruoyi.system.query.TContractQuery;
import com.ruoyi.system.vo.BillVO;
import com.ruoyi.system.vo.CheckAcceptRecordVO;
import com.ruoyi.system.vo.ScreenRentIncomeTrendVO;
import java.util.List;
ruoyi-system/src/main/java/com/ruoyi/system/service/THouseService.java
@@ -20,4 +20,11 @@
    PageInfo<THouse> houseList(THouseQuery query);
    PageInfo<HouseVO> userHistoryList(TUserHistoryQuery query);
    /**
     * 获取本季度已出租面积
     * @param businessDeptId
     * @return
     */
    Double getRentedArea(String businessDeptId);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ScreenService.java
@@ -1,5 +1,7 @@
package com.ruoyi.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BillTypeEnum;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
@@ -12,18 +14,14 @@
import com.ruoyi.system.vo.ScreenRentIncomeTrendVO;
import com.ruoyi.system.vo.ScreenRentRankVO;
import com.ruoyi.system.vo.ScreenTopStaticsDataVO;
import com.ruoyi.system.vo.TenantCountTrendVO;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
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
@@ -35,12 +33,16 @@
    private final THouseService tHouseService;
    private final TContractService tContractService;
    private final TBillService tBillService;
    private final TContractService contractService;
    /**
     * 获取顶部统计数据
     * @return
     */
    public ScreenTopStaticsDataVO getTopStaticsData() {
        String businessDeptId = SecurityUtils.getBusinessDeptId();
        Map<String, Date> quarterDate = DateUtils.getQuarterDate(new Date());
        Date first = quarterDate.get("first");
        Date last = quarterDate.get("last");
        ScreenTopStaticsDataVO vo = new ScreenTopStaticsDataVO();
        //房屋总面积
        List<THouse> houseList = tHouseService.lambdaQuery()
@@ -51,16 +53,10 @@
                .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 =  tHouseService.getRentedArea(businessDeptId);
        vo.setHouseRentedArea(totalRentedArea);
        //总计应收租金
        List<TBill> billList = tBillService.lambdaQuery()
                .eq(!businessDeptId.equals("0"), TBill::getBusinessDeptId, businessDeptId)
                .eq(TBill::getBillType, BillTypeEnum.Zujin.getCode())
                .list();
        List<TBill> billList = tBillService.getJiFuBillList(businessDeptId);
        BigDecimal totalReceivableRent = billList.stream()
                .filter(item -> !item.getPayFeesStatus().equals("5"))
                .map(TBill::getPayableFeesMoney)
@@ -78,6 +74,7 @@
        vo.setNewTenantCount(newTenantCount);
        //总计租户数 系统租户列表里有生效合同绑定的租户总数。
        List<TContract> tContracts = tContractService.lambdaQuery()
                .eq(TContract::getPayType,2) //季付
                .in(TContract::getStatus, "4", "5", "6", "7", "8", "9")
                .eq(!businessDeptId.equals("0"), TContract::getBusinessDeptId, businessDeptId)
                .list();
@@ -86,15 +83,7 @@
                .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()
                .eq(!businessDeptId.equals("0"), TBill::getBusinessDeptId, businessDeptId)
                .between(TBill::getPayableFeesTime, first, last)
                .eq(TBill::getBillType, BillTypeEnum.Zujin.getCode())
                .ne(TBill::getPayFeesStatus, 5)
                .list();
        List<TBill> currentQuarterBillList = tBillService.getJiFuBillListByTime(businessDeptId, first, last);
        //本季度已交租金
        BigDecimal totalRentPaid = currentQuarterBillList.stream()
                .map(TBill::getPayFeesMoney)
@@ -115,12 +104,7 @@
                .divide(BigDecimal.valueOf(10000L), 2, RoundingMode.HALF_UP);
        vo.setTotalRentOwe(totalRentOwe);
        //总计欠费
        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()
        BigDecimal totalRentOweAll = billList.stream()
                .map(TBill::getOutstandingMoney)
                .reduce(BigDecimal.ZERO, BigDecimal::add)
                .divide(BigDecimal.valueOf(10000L), 2, RoundingMode.HALF_UP);
@@ -159,11 +143,7 @@
            Date quarterEnd = quarterDate.get("last");
            // 获取该季度的账单数据
            List<TBill> quarterBills = tBillService.lambdaQuery()
                    .between(TBill::getPayableFeesTime, quarterStart, quarterEnd)
                    .eq(TBill::getBillType, BillTypeEnum.Zujin.getCode())
                    .eq(!businessDeptId.equals("0"), TBill::getBusinessDeptId, businessDeptId)
                    .list();
            List<TBill> quarterBills = tBillService.getJiFuBillListByTime(businessDeptId, quarterStart, quarterEnd);
            // 计算季度租金收入总和
            BigDecimal quarterIncome = quarterBills.stream()
@@ -197,6 +177,65 @@
        return vo;
    }
    public R<List<TenantCountTrendVO>> getTenantCountTrend() {
        // 获取当前日期
        Date currentDate = new Date();
        String businessDeptId = SecurityUtils.getBusinessDeptId();
        List<TenantCountTrendVO> list = new ArrayList<>();
        for (int i = 6; i >= 0; i--) {
            Date targetDate = DateUtils.addMonths(currentDate, -3 * i);
            Map<String, Date> quarterDate = DateUtils.getQuarterDate(targetDate);
            Date quarterStart = quarterDate.get("first");
            Date quarterEnd = quarterDate.get("last");
            System.out.println("第" + (i + 1) + "季度的起止时间:" + quarterStart + " - " + quarterEnd);
            List<TContract> contracts = contractService.list(new LambdaQueryWrapper<TContract>()
                    .eq(!"0".equals(businessDeptId), TContract::getBusinessDeptId, businessDeptId)
                    .eq(TContract::getPayType, 1)
                    .isNotNull(TContract::getSignTime)
                    .between(TContract::getSignTime, quarterStart, quarterEnd)
                    .orderByAsc(TContract::getSignTime));
            TenantCountTrendVO vo = new TenantCountTrendVO();
            // 生成季度标签 (格式: YY-MM月)
            Calendar cal = Calendar.getInstance();
            cal.setTime(quarterEnd);
            String label = String.format("%02d-%d月",
                    cal.get(Calendar.YEAR) % 100,
                    cal.get(Calendar.MONTH) + 1);
            vo.setDate(label);
            long count = contracts.stream().map(TContract::getTenantId).distinct().count();
            vo.setCount(count);
            list.add(vo);
        }
        return R.ok(list);
    }
//
//
//
//
//
//
//
//        DateTimeFormatter quarterFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
//
//        List<TenantCountTrendVO> trendData = contracts.stream()
//                .collect(Collectors.groupingBy(contract -> {
//                    LocalDate date = contract.getSignTime().toLocalDate();
//                    int quarter = (date.getMonthValue() - 1) / 3 + 1;
//                    return YearQuarter.from(date.withMonth(quarter * 3 - 2));
//                }, TreeMap::new, Collectors.counting()))
//                .entrySet().stream()
//                .map(entry -> new TenantCountTrendVO(
//                        entry.getKey().format(quarterFormatter),
//                        entry.getValue()))
//                .collect(Collectors.toList());
//
//        return R.ok(trendData);
//    }
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java
@@ -588,4 +588,25 @@
    public List<ScreenRentRankVO> getStreetRentRank(String businessDeptId) {
        return baseMapper.getStreetRentRank(businessDeptId);
    }
    /**
     * 查询季付账单
     * @param businessDeptId
     * @return
     */
    @Override
    public List<TBill> getJiFuBillList(String businessDeptId) {
        return baseMapper.getJiFuBillList(businessDeptId,null,null);
    }
    /**
     * 查询当前季度的季付账单
     * @param businessDeptId
     * @param first
     * @param last
     * @return
     */
    @Override
    public List<TBill> getJiFuBillListByTime(String businessDeptId, Date first, Date last) {
        return baseMapper.getJiFuBillList(businessDeptId,first,last);
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TContractServiceImpl.java
@@ -31,6 +31,7 @@
import com.ruoyi.system.service.TContractService;
import com.ruoyi.system.vo.BillVO;
import com.ruoyi.system.vo.CheckAcceptRecordVO;
import com.ruoyi.system.vo.ScreenRentIncomeTrendVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -221,4 +222,5 @@
        pageInfo = this.baseMapper.page(pageInfo,query);
        return pageInfo;
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/THouseServiceImpl.java
@@ -78,4 +78,14 @@
        pageInfo.setRecords(list);
        return pageInfo;
    }
    /**
     * 获取本季度已出租面积
     *
     * @param businessDeptId
     * @return
     */
    @Override
    public Double getRentedArea(String businessDeptId) {
        return baseMapper.getRentedArea(businessDeptId);
    }
}
ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml
@@ -213,6 +213,7 @@
                LEFT JOIN t_contract tc ON tc.house_id = th.id
                LEFT JOIN t_bill tb ON tc.id = tb.contract_id
            <where>
               tc.pay_type = 2 AND tb.pay_fees_status != 5
                <if test="businessDeptId != 0">
                    AND th.business_dept_id = #{businessDeptId}
                </if>
@@ -220,4 +221,16 @@
        GROUP BY ts.id
        ORDER BY rentAmount DESC
    </select>
    <select id="getJiFuBillList" resultType="com.ruoyi.system.model.TBill" parameterType="java.lang.String">
        SELECT tb.* FROM t_bill tb LEFT JOIN t_contract tt ON tb.contract_id = tt.id
        <where>
            tt.pay_type = 2 AND tb.bill_type = ${@com.ruoyi.common.enums.BillTypeEnum@Zujin.getCode()} AND tb.pay_fees_status != 5
            <if test="businessDeptId != null and businessDeptId != 0">
                AND tb.business_dept_id = #{businessDeptId}
            </if>
            <if test="first!=null and last !=null">
                AND tb.payable_fees_time BETWEEN #{first} AND #{last}
            </if>
        </where>
    </select>
</mapper>
ruoyi-system/src/main/resources/mapper/system/TContractMapper.xml
@@ -132,7 +132,7 @@
        FROM t_contract tc
        <where>
            -- 筛选本月签订的合同
            DATE_FORMAT(tc.sign_time, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m') AND tc.status IN ("4", "5", "6", "7", "8", "9")
            DATE_FORMAT(tc.sign_time, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m') AND tc.status IN ("4", "5", "6", "7", "8", "9") AND tc.pay_type = 2
            -- 且租户在本月前从未签订过任何合同
            AND NOT EXISTS (
            SELECT 1
ruoyi-system/src/main/resources/mapper/system/THouseMapper.xml
@@ -86,5 +86,17 @@
          AND t1.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
    </select>
    <select id="getRentedArea" resultType="java.lang.Double">
        SELECT COALESCE(SUM(t1.house_area),0) FROM t_house t1
        LEFT JOIN t_contract t2 ON t1.id = t2.house_id
        <where>
            t2.pay_type = 2 AND t1.lease_status != 1
            <if test="businessDeptId!=0">
                AND t1.business_dept_id = #{businessDeptId}
            </if>
            AND t1.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        GROUP BY t1.id
    </select>
</mapper>