|
@@ -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);
|
|
|
}
|