Commit 6cf7a67406929df0e4cd9c57e844c4ce8f777269

Authored by alwayssuper
1 parent 8daa2131

[fix]:iot home count

yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/statistics/IotStatisticsController.java
1 1 package cn.iocoder.yudao.module.iot.controller.admin.statistics;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.module.iot.controller.admin.statistics.vo.IotStatisticsReqVO;
4 5 import cn.iocoder.yudao.module.iot.controller.admin.statistics.vo.IotStatisticsRespVO;
5 6 import cn.iocoder.yudao.module.iot.enums.device.IotDeviceStateEnum;
6 7 import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
... ... @@ -10,6 +11,7 @@ import cn.iocoder.yudao.module.iot.service.product.IotProductService;
10 11 import io.swagger.v3.oas.annotations.Operation;
11 12 import io.swagger.v3.oas.annotations.tags.Tag;
12 13 import jakarta.annotation.Resource;
  14 +import jakarta.validation.Valid;
13 15 import org.springframework.validation.annotation.Validated;
14 16 import org.springframework.web.bind.annotation.GetMapping;
15 17 import org.springframework.web.bind.annotation.RequestMapping;
... ... @@ -37,9 +39,9 @@ public class IotStatisticsController {
37 39 private IotDeviceLogService iotDeviceLogService;
38 40  
39 41  
40   - @GetMapping("/count")
  42 + @GetMapping("/main")
41 43 @Operation(summary = "获取IOT首页的数据统计", description = "用于IOT首页的数据统计")
42   - public CommonResult<IotStatisticsRespVO> getIotCount(){
  44 + public CommonResult<IotStatisticsRespVO> getIotMainStats(@Valid IotStatisticsReqVO reqVO){
43 45 IotStatisticsRespVO iotStatisticsRespVO = new IotStatisticsRespVO();
44 46 // 获取总数
45 47 iotStatisticsRespVO.setCategoryTotal(iotProductCategoryService.getProductCategoryCount(null));
... ... @@ -64,9 +66,9 @@ public class IotStatisticsController {
64 66 iotStatisticsRespVO.setOfflineTotal(iotDeviceService.getDeviceCountByState(IotDeviceStateEnum.OFFLINE.getState()));
65 67 iotStatisticsRespVO.setNeverOnlineTotal(iotDeviceService.getDeviceCountByState(IotDeviceStateEnum.INACTIVE.getState()));
66 68  
67   - // 获取设备上下行消息数量统计
68   - iotStatisticsRespVO.setDeviceUpMessageStats(iotDeviceLogService.getDeviceLogUpCountByHour(null,null,null));
69   - iotStatisticsRespVO.setDeviceDownMessageStats(iotDeviceLogService.getDeviceLogDownCountByHour(null,null,null));
  69 + // 根据传入时间范围获取设备上下行消息数量统计
  70 + iotStatisticsRespVO.setDeviceUpMessageStats(iotDeviceLogService.getDeviceLogUpCountByHour(null, reqVO.getStartTime(), reqVO.getEndTime()));
  71 + iotStatisticsRespVO.setDeviceDownMessageStats(iotDeviceLogService.getDeviceLogDownCountByHour(null, reqVO.getStartTime(), reqVO.getEndTime()));
70 72  
71 73 return CommonResult.success(iotStatisticsRespVO);
72 74 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/statistics/vo/IotStatisticsReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.controller.admin.statistics.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import jakarta.validation.constraints.NotNull;
  5 +import lombok.Data;
  6 +
  7 +@Schema(description = "管理后台 - Iot统计 Request VO")
  8 +@Data
  9 +public class IotStatisticsReqVO {
  10 + @Schema(description = "查询起始时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "177")
  11 + @NotNull(message = "查询起始时间不能为空")
  12 + Long startTime;
  13 + @Schema(description = "查询结束时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "177")
  14 + @NotNull(message = "查询结束时间不能为空")
  15 + Long endTime;
  16 +}
... ...