Bladeren bron

[fix]:iot home count

alwayssuper 5 maanden geleden
bovenliggende
commit
6cf7a67406

+ 7 - 5
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/statistics/IotStatisticsController.java

@@ -1,6 +1,7 @@
 package cn.iocoder.yudao.module.iot.controller.admin.statistics;
 
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.module.iot.controller.admin.statistics.vo.IotStatisticsReqVO;
 import cn.iocoder.yudao.module.iot.controller.admin.statistics.vo.IotStatisticsRespVO;
 import cn.iocoder.yudao.module.iot.enums.device.IotDeviceStateEnum;
 import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
@@ -10,6 +11,7 @@ import cn.iocoder.yudao.module.iot.service.product.IotProductService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import jakarta.annotation.Resource;
+import jakarta.validation.Valid;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -37,9 +39,9 @@ public class IotStatisticsController {
     private IotDeviceLogService iotDeviceLogService;
 
 
-    @GetMapping("/count")
+    @GetMapping("/main")
     @Operation(summary = "获取IOT首页的数据统计", description = "用于IOT首页的数据统计")
-    public CommonResult<IotStatisticsRespVO> getIotCount(){
+    public CommonResult<IotStatisticsRespVO> getIotMainStats(@Valid IotStatisticsReqVO reqVO){
         IotStatisticsRespVO iotStatisticsRespVO = new IotStatisticsRespVO();
         // 获取总数
         iotStatisticsRespVO.setCategoryTotal(iotProductCategoryService.getProductCategoryCount(null));
@@ -64,9 +66,9 @@ public class IotStatisticsController {
         iotStatisticsRespVO.setOfflineTotal(iotDeviceService.getDeviceCountByState(IotDeviceStateEnum.OFFLINE.getState()));
         iotStatisticsRespVO.setNeverOnlineTotal(iotDeviceService.getDeviceCountByState(IotDeviceStateEnum.INACTIVE.getState()));
 
-        // 获取设备上下行消息数量统计
-        iotStatisticsRespVO.setDeviceUpMessageStats(iotDeviceLogService.getDeviceLogUpCountByHour(null,null,null));
-        iotStatisticsRespVO.setDeviceDownMessageStats(iotDeviceLogService.getDeviceLogDownCountByHour(null,null,null));
+        // 根据传入时间范围获取设备上下行消息数量统计
+        iotStatisticsRespVO.setDeviceUpMessageStats(iotDeviceLogService.getDeviceLogUpCountByHour(null, reqVO.getStartTime(), reqVO.getEndTime()));
+        iotStatisticsRespVO.setDeviceDownMessageStats(iotDeviceLogService.getDeviceLogDownCountByHour(null, reqVO.getStartTime(), reqVO.getEndTime()));
 
         return CommonResult.success(iotStatisticsRespVO);
     }

+ 16 - 0
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/statistics/vo/IotStatisticsReqVO.java

@@ -0,0 +1,16 @@
+package cn.iocoder.yudao.module.iot.controller.admin.statistics.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+@Schema(description = "管理后台 - Iot统计 Request VO")
+@Data
+public class IotStatisticsReqVO {
+    @Schema(description = "查询起始时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "177")
+    @NotNull(message = "查询起始时间不能为空")
+    Long startTime;
+    @Schema(description = "查询结束时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "177")
+    @NotNull(message = "查询结束时间不能为空")
+    Long endTime;
+}