From fd6e1e93f65bde3e1c8c15f36b2ff6324d071966 Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期五, 21 三月 2025 10:57:13 +0800 Subject: [PATCH] Merge branch 'dev' of http://120.76.84.145:10101/gitblit/r/java/xizang --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ScreenController.java | 61 ++++++++++++++++++++++++++++++ 1 files changed, 60 insertions(+), 1 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ScreenController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ScreenController.java index 354a246..86431c2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ScreenController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ScreenController.java @@ -1,10 +1,26 @@ package com.ruoyi.web.controller.api; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.system.model.TContract; +import com.ruoyi.system.service.TContractService; import com.ruoyi.system.service.impl.ScreenService; +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 io.swagger.annotations.Api; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Lazy; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; + +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.stream.Collectors; /** * @author mitao @@ -13,7 +29,50 @@ @Api(tags = {"大屏相关接口"}) @RestController @RequestMapping("/screen") -@RequiredArgsConstructor +@RequiredArgsConstructor(onConstructor_ = {@Lazy}) public class ScreenController { private final ScreenService screenService; + @GetMapping("/statics-data") + @ApiOperation(value = "获取顶部统计数据") + public R<ScreenTopStaticsDataVO> getTopStaticsData() { + return R.ok(screenService.getTopStaticsData()); + } + @GetMapping("/rent-rank") + @ApiOperation("区域租金排名") + public R<List<ScreenRentRankVO>> rentRank() { + return R.ok(screenService.streetRentRank()); + } + @GetMapping("/rent-income-trend") + @ApiOperation("租金收入趋势") + public R<ScreenRentIncomeTrendVO> rentIncomeTrend() { + return R.ok(screenService.rentIncomeTrend()); + } + private final TContractService contractService; + + + @GetMapping("/getTenantCountTrend") + @ApiModelProperty(value = "租户数量趋势统计") + public R<?> getTenantCountTrend() { + // 获取所有签约时间不为空的合同 + List<TContract> contracts = contractService.list(new LambdaQueryWrapper<TContract>() + .isNotNull(TContract::getSignTime)); + + // 使用年-月格式化日期,并按此分组计算每个时间段的合同数量 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yy-M"); + + List<TenantCountTrendVO> trendData = contracts.stream() + .collect(Collectors.groupingBy(contract -> contract.getSignTime().toLocalDate() + .withDayOfMonth(1) // 将日期调整为该月的第一天,以便正确分组 + .atStartOfDay())) + .entrySet().stream() + .map(entry -> { + String period = entry.getKey().format(formatter); + long count = entry.getValue().size(); + return new TenantCountTrendVO(period, count); + }) + .collect(Collectors.toList()); + + return R.ok(trendData); + } + } -- Gitblit v1.7.1