| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.core.domain.R; |
| | | 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; |
| | |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static org.checkerframework.checker.units.qual.Prefix.one; |
| | | |
| | | /** |
| | | * @author mitao |
| | |
| | | @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)); |
| | | |
| | | // 创建季度格式化工具(示例:2025-Q1) |
| | | DateTimeFormatter quarterFormatter = DateTimeFormatter.ofPattern("yyyy-'Q'Q"); |
| | | DateTimeFormatter quarterFormatter = DateTimeFormatter.ofPattern("yyyy-MM"); |
| | | |
| | | List<TenantCountTrendVO> trendData = contracts.stream() |
| | | .collect(Collectors.groupingBy(contract -> { |
| | |
| | | @ApiOperation("获取实时租赁数据") |
| | | public R<List<RealTimeRentDataVO>> getRealTimeRentData() { |
| | | // 随机获取十条房源 |
| | | String businessDeptId = SecurityUtils.getBusinessDeptId(); |
| | | List<THouse> houses = houseService.list(new LambdaQueryWrapper<THouse>() |
| | | .eq(!"0".equals(businessDeptId),THouse::getBusinessDeptId, businessDeptId) |
| | | .last("ORDER BY RAND() LIMIT 10")); |
| | | |
| | | if (CollectionUtil.isEmpty(houses)){ |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | |
| | | // 提取streetIds |
| | | List<String> streetIds = houses.stream() |
| | |
| | | List<RealTimeRentDataVO> result = houses.stream().map(house -> { |
| | | RealTimeRentDataVO vo = new RealTimeRentDataVO(); |
| | | vo.setStreetName(streetMap.getOrDefault(house.getStreetId(), "未知")); |
| | | vo.setRoomName(house.getRoomNumber()); |
| | | vo.setRoomName(house.getHouseName()); |
| | | vo.setLeaseStatus(house.getLeaseStatus()); |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | |
| | | @GetMapping("/getHouseMapDistribution") |
| | | @ApiOperation("获取房屋地图分布") |
| | | public R<List<HouseMapDistributionVO>> getHouseMapDistribution() { |
| | | |
| | | String businessDeptId = SecurityUtils.getBusinessDeptId(); |
| | | // 获取所有房屋信息 |
| | | List<THouse> houses = houseService.list(); |
| | | List<THouse> houses = houseService.list(new LambdaQueryWrapper<THouse>() |
| | | .eq(!"0".equals(businessDeptId),THouse::getBusinessDeptId, businessDeptId)); |
| | | List<HouseMapDistributionVO> result = new ArrayList<>(); |
| | | for (THouse house : houses) { |
| | | HouseMapDistributionVO houseMapDistributionVO = new HouseMapDistributionVO(); |
| | |
| | | houseMapDistributionVO.setLongitude(house.getLongitude()); |
| | | houseMapDistributionVO.setLatitude(house.getLatitude()); |
| | | TContract contract = contractService.getOne(new LambdaQueryWrapper<TContract>() |
| | | .eq(!"0".equals(businessDeptId),TContract::getBusinessDeptId, businessDeptId) |
| | | .gt(TContract::getEndTime, LocalDate.now()) |
| | | .eq(TContract::getHouseId, house.getId()) |
| | | .eq(TContract::getStatus, 4) |
| | |
| | | |
| | | if (contract != null){ |
| | | List<TBill> tBills = billService.list(new LambdaQueryWrapper<TBill>() |
| | | .eq(!"0".equals(businessDeptId),TBill::getBusinessDeptId, businessDeptId) |
| | | .eq(TBill::getContractId, contract.getId()) |
| | | .eq(TBill::getBillType, 1)); |
| | | houseMapDistributionVO.setTenant(contract.getPartyTwoName()); |
| | |
| | | houseMapDistributionVO.setRentStatus(rentStatus); |
| | | |
| | | |
| | | TBill one = billService.getOne(new LambdaQueryWrapper<TBill>() |
| | | // TBill one = billService.getOne(new LambdaQueryWrapper<TBill>() |
| | | // .le(TBill::getStartTime, LocalDate.now()) |
| | | // .ge(TBill::getEndTime, LocalDate.now()) |
| | | // .eq(TBill::getBillType, 1) |
| | | // .eq(TBill::getContractId, contract.getId())); |
| | | |
| | | List<TBill> ones = billService.list(new LambdaQueryWrapper<TBill>() |
| | | .eq(!"0".equals(businessDeptId),TBill::getBusinessDeptId, businessDeptId) |
| | | .le(TBill::getStartTime, LocalDate.now()) |
| | | .ge(TBill::getEndTime, LocalDate.now()) |
| | | .eq(TBill::getBillType, 1) |
| | | .eq(TBill::getContractId, contract.getId())); |
| | | |
| | | if ("4".equals(one.getPayFeesStatus())){ |
| | | houseMapDistributionVO.setHouseStatus("4"); |
| | | TBill one = null; |
| | | if (!ones.isEmpty()){ |
| | | one = ones.get(0); |
| | | } |
| | | |
| | | |
| | | |
| | | BigDecimal payFeesMoney = one.getPayFeesMoney(); |
| | | BigDecimal payableFeesMoney1 = one.getPayableFeesMoney(); |
| | | String rent = String.format("%.2f/%.2f", payFeesMoney, payableFeesMoney1); |
| | | |
| | | houseMapDistributionVO.setRent(rent); |
| | | if (one != null){ |
| | | if ("4".equals(one.getPayFeesStatus())){ |
| | | houseMapDistributionVO.setHouseStatus("4"); |
| | | } |
| | | BigDecimal payFeesMoney = one.getPayFeesMoney(); |
| | | BigDecimal payableFeesMoney1 = one.getPayableFeesMoney(); |
| | | String rent = String.format("%.2f/%.2f", payFeesMoney, payableFeesMoney1); |
| | | houseMapDistributionVO.setRent(rent); |
| | | }else { |
| | | houseMapDistributionVO.setRent("暂无"); |
| | | } |
| | | }else { |
| | | houseMapDistributionVO.setTenant("暂无"); |
| | | houseMapDistributionVO.setRentStatus("暂无"); |