【代码评审】IoT:首页统计
This commit is contained in:
parent
2a65e3bd2e
commit
6e1ec8b3eb
|
@ -19,7 +19,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - IoT 数据统计")
|
||||
@RestController
|
||||
@RequestMapping("/iot/statistics")
|
||||
|
@ -27,48 +26,47 @@ import java.time.LocalDateTime;
|
|||
public class IotStatisticsController {
|
||||
|
||||
@Resource
|
||||
private IotDeviceService iotDeviceService;
|
||||
|
||||
private IotDeviceService deviceService;
|
||||
@Resource
|
||||
private IotProductCategoryService iotProductCategoryService;
|
||||
|
||||
private IotProductCategoryService productCategoryService;
|
||||
@Resource
|
||||
private IotProductService iotProductService;
|
||||
|
||||
private IotProductService productService;
|
||||
@Resource
|
||||
private IotDeviceLogService iotDeviceLogService;
|
||||
|
||||
private IotDeviceLogService deviceLogService;
|
||||
|
||||
// TODO @super:description 非必要,可以不写哈
|
||||
@GetMapping("/main")
|
||||
@Operation(summary = "获取IOT首页的数据统计", description = "用于IOT首页的数据统计")
|
||||
@Operation(summary = "获取首页的数据统计", description = "用于IOT首页的数据统计")
|
||||
public CommonResult<IotStatisticsRespVO> getIotMainStats(@Valid IotStatisticsReqVO reqVO){
|
||||
// TODO @super:新增 get-summary 接口,返回:总数、今日新增、数量、状态
|
||||
IotStatisticsRespVO iotStatisticsRespVO = new IotStatisticsRespVO();
|
||||
// 获取总数
|
||||
iotStatisticsRespVO.setCategoryTotal(iotProductCategoryService.getProductCategoryCount(null));
|
||||
iotStatisticsRespVO.setProductTotal(iotProductService.getProductCount(null));
|
||||
iotStatisticsRespVO.setDeviceTotal(iotDeviceService.getDeviceCount(null));
|
||||
iotStatisticsRespVO.setReportTotal(iotDeviceLogService.getDeviceLogCount(null));
|
||||
iotStatisticsRespVO.setCategoryTotal(productCategoryService.getProductCategoryCount(null));
|
||||
iotStatisticsRespVO.setProductTotal(productService.getProductCount(null));
|
||||
iotStatisticsRespVO.setDeviceTotal(deviceService.getDeviceCount(null));
|
||||
iotStatisticsRespVO.setReportTotal(deviceLogService.getDeviceLogCount(null));
|
||||
|
||||
// 获取今日新增数量
|
||||
LocalDateTime todayStart = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0);
|
||||
iotStatisticsRespVO.setCategoryTodayTotal(iotProductCategoryService.getProductCategoryCount(todayStart));
|
||||
iotStatisticsRespVO.setProductTodayTotal(iotProductService.getProductCount(todayStart));
|
||||
iotStatisticsRespVO.setDeviceTodayTotal(iotDeviceService.getDeviceCount(todayStart));
|
||||
iotStatisticsRespVO.setReportTodayTotal(iotDeviceLogService.getDeviceLogCount(todayStart));
|
||||
iotStatisticsRespVO.setCategoryTodayTotal(productCategoryService.getProductCategoryCount(todayStart));
|
||||
iotStatisticsRespVO.setProductTodayTotal(productService.getProductCount(todayStart));
|
||||
iotStatisticsRespVO.setDeviceTodayTotal(deviceService.getDeviceCount(todayStart));
|
||||
iotStatisticsRespVO.setReportTodayTotal(deviceLogService.getDeviceLogCount(todayStart));
|
||||
|
||||
// 获取各个品类下设备数量统计
|
||||
iotStatisticsRespVO.setDeviceStatsOfCategory(
|
||||
iotProductCategoryService.getDeviceCountsOfProductCategory()
|
||||
productCategoryService.getDeviceCountsOfProductCategory()
|
||||
);
|
||||
|
||||
// 获取设备状态数量统计
|
||||
iotStatisticsRespVO.setOnlineTotal(iotDeviceService.getDeviceCountByState(IotDeviceStateEnum.ONLINE.getState()));
|
||||
iotStatisticsRespVO.setOfflineTotal(iotDeviceService.getDeviceCountByState(IotDeviceStateEnum.OFFLINE.getState()));
|
||||
iotStatisticsRespVO.setNeverOnlineTotal(iotDeviceService.getDeviceCountByState(IotDeviceStateEnum.INACTIVE.getState()));
|
||||
iotStatisticsRespVO.setOnlineTotal(deviceService.getDeviceCountByState(IotDeviceStateEnum.ONLINE.getState()));
|
||||
iotStatisticsRespVO.setOfflineTotal(deviceService.getDeviceCountByState(IotDeviceStateEnum.OFFLINE.getState()));
|
||||
iotStatisticsRespVO.setNeverOnlineTotal(deviceService.getDeviceCountByState(IotDeviceStateEnum.INACTIVE.getState()));
|
||||
|
||||
// TODO @super:新增 get-log-summary 接口,返回
|
||||
// 根据传入时间范围获取设备上下行消息数量统计
|
||||
iotStatisticsRespVO.setDeviceUpMessageStats(iotDeviceLogService.getDeviceLogUpCountByHour(null, reqVO.getStartTime(), reqVO.getEndTime()));
|
||||
iotStatisticsRespVO.setDeviceDownMessageStats(iotDeviceLogService.getDeviceLogDownCountByHour(null, reqVO.getStartTime(), reqVO.getEndTime()));
|
||||
iotStatisticsRespVO.setDeviceUpMessageStats(deviceLogService.getDeviceLogUpCountByHour(null, reqVO.getStartTime(), reqVO.getEndTime()));
|
||||
iotStatisticsRespVO.setDeviceDownMessageStats(deviceLogService.getDeviceLogDownCountByHour(null, reqVO.getStartTime(), reqVO.getEndTime()));
|
||||
|
||||
return CommonResult.success(iotStatisticsRespVO);
|
||||
}
|
||||
|
|
|
@ -7,10 +7,16 @@ import lombok.Data;
|
|||
@Schema(description = "管理后台 - Iot统计 Request VO")
|
||||
@Data
|
||||
public class IotStatisticsReqVO {
|
||||
|
||||
// TODO @supper:times 直接传递哈;
|
||||
// TODO 2super:private 不要丢了
|
||||
|
||||
@Schema(description = "查询起始时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "177")
|
||||
@NotNull(message = "查询起始时间不能为空")
|
||||
Long startTime;
|
||||
|
||||
@Schema(description = "查询结束时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "177")
|
||||
@NotNull(message = "查询结束时间不能为空")
|
||||
Long endTime;
|
||||
|
||||
}
|
||||
|
|
|
@ -5,10 +5,16 @@ import lombok.Data;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - Iot统计 Response VO")
|
||||
// TODO @super:Total 全部改成 Count
|
||||
// TODO @super:IotStatisticsSummaryRespVO
|
||||
/**
|
||||
* 管理后台 - Iot 统计 Response VO
|
||||
*/
|
||||
@Schema(description = "管理后台 - Iot 统计 Response VO")
|
||||
@Data
|
||||
public class IotStatisticsRespVO {
|
||||
|
||||
// TODO @super:productCategory 哈
|
||||
@Schema(description = "品类数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
private long categoryTotal;
|
||||
|
||||
|
@ -18,9 +24,11 @@ public class IotStatisticsRespVO {
|
|||
@Schema(description = "设备数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private long deviceTotal;
|
||||
|
||||
// TODO @super:deviceMessageCount;设备消息数量
|
||||
@Schema(description = "上报数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
|
||||
private long reportTotal;
|
||||
|
||||
// TODO @super:productCategory 哈
|
||||
@Schema(description = "今日新增品类数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||
private long categoryTodayTotal;
|
||||
|
||||
|
@ -30,30 +38,42 @@ public class IotStatisticsRespVO {
|
|||
@Schema(description = "今日新增设备数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private long deviceTodayTotal;
|
||||
|
||||
// TODO @super:deviceMessageCount;今日设备消息数量
|
||||
@Schema(description = "今日新增上报数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
|
||||
private long reportTodayTotal;
|
||||
|
||||
// TODO @super:deviceOnlineCount
|
||||
|
||||
@Schema(description = "在线数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "80")
|
||||
private long onlineTotal;
|
||||
|
||||
// TODO @super:deviceOfflineCount
|
||||
|
||||
@Schema(description = "离线数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15")
|
||||
private long offlineTotal;
|
||||
|
||||
// TODO @super:deviceInactivECount
|
||||
|
||||
@Schema(description = "待激活设备数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
|
||||
private long neverOnlineTotal;
|
||||
|
||||
// TODO @super:1)类型改成 Map,key 分类名、value 设备数量;2)deviceStatsOfCategory => productCategoryDeviceCounts
|
||||
@Schema(description = "按品类统计的设备数量")
|
||||
private List<DataItem> deviceStatsOfCategory;
|
||||
|
||||
// TODO @super:貌似界面里,用不到这个字段???
|
||||
@Schema(description = "上报数据数量统计")
|
||||
private List<TimeData> reportDataStats;
|
||||
|
||||
// TODO @super:deviceUpMessageStats、deviceDownMessageStats 单独抽到 IotStatisticsDeviceMessageSummaryRespVO,然后里面属性就是 upstreamCounts、downstreamCounts
|
||||
|
||||
@Schema(description = "上行数据数量统计")
|
||||
private List<TimeData> deviceUpMessageStats;
|
||||
|
||||
@Schema(description = "下行数据数量统计")
|
||||
private List<TimeData> deviceDownMessageStats;
|
||||
|
||||
@Schema(description = "按品类统计的设备数量")
|
||||
private List<DataItem> deviceStatsOfCategory;
|
||||
|
||||
// TODO @super:如果只有这两个字段,使用 KeyValue 这个键值对
|
||||
@Schema(description = "时间数据")
|
||||
@Data
|
||||
public static class TimeData {
|
||||
|
@ -63,6 +83,7 @@ public class IotStatisticsRespVO {
|
|||
|
||||
@Schema(description = "数据值", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private Object data;
|
||||
|
||||
}
|
||||
|
||||
@Schema(description = "数据项")
|
||||
|
@ -74,5 +95,7 @@ public class IotStatisticsRespVO {
|
|||
|
||||
@Schema(description = "数据项值", requiredMode = Schema.RequiredMode.REQUIRED, example = "50")
|
||||
private Object value;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -70,24 +71,12 @@ public interface IotDeviceMapper extends BaseMapperX<IotDeviceDO> {
|
|||
.apply("FIND_IN_SET(" + groupId + ",group_ids) > 0"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计设备数量
|
||||
*
|
||||
* @param createTime 创建时间,如果为空,则统计所有设备数量
|
||||
* @return 设备数量
|
||||
*/
|
||||
default Long selectCountByCreateTime(LocalDateTime createTime) {
|
||||
default Long selectCountByCreateTime(@Nullable LocalDateTime createTime) {
|
||||
return selectCount(new LambdaQueryWrapperX<IotDeviceDO>()
|
||||
.geIfPresent(IotDeviceDO::getCreateTime, createTime));
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计指定状态的设备数量
|
||||
*
|
||||
* @param state 状态
|
||||
* @return 设备数量
|
||||
*/
|
||||
default Long selectCountByState(Integer state) {
|
||||
default Long selectCountByState(@Nullable Integer state) {
|
||||
return selectCount(new LambdaQueryWrapperX<IotDeviceDO>()
|
||||
.eqIfPresent(IotDeviceDO::getState, state));
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|||
import cn.iocoder.yudao.module.iot.controller.admin.product.vo.category.IotProductCategoryPageReqVO;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductCategoryDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -30,13 +30,7 @@ public interface IotProductCategoryMapper extends BaseMapperX<IotProductCategory
|
|||
return selectList(IotProductCategoryDO::getStatus, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计产品分类数量
|
||||
*
|
||||
* @param createTime 创建时间,如果为空,则统计所有分类数量
|
||||
* @return 产品分类数量
|
||||
*/
|
||||
default Long selectCountByCreateTime(LocalDateTime createTime) {
|
||||
default Long selectCountByCreateTime(@Nullable LocalDateTime createTime) {
|
||||
return selectCount(new LambdaQueryWrapperX<IotProductCategoryDO>()
|
||||
.geIfPresent(IotProductCategoryDO::getCreateTime, createTime));
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -31,23 +32,11 @@ public interface IotProductMapper extends BaseMapperX<IotProductDO> {
|
|||
.apply("LOWER(product_key) = {0}", productKey.toLowerCase()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计产品数量
|
||||
*
|
||||
* @param createTime 创建时间,如果为空,则统计所有产品数量
|
||||
* @return 产品数量
|
||||
*/
|
||||
default Long selectCountByCreateTime(LocalDateTime createTime) {
|
||||
default Long selectCountByCreateTime(@Nullable LocalDateTime createTime) {
|
||||
return selectCount(new LambdaQueryWrapperX<IotProductDO>()
|
||||
.geIfPresent(IotProductDO::getCreateTime, createTime));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得产品列表,基于分类编号
|
||||
*
|
||||
* @param categoryId 分类编号
|
||||
* @return 产品列表
|
||||
*/
|
||||
default List<IotProductDO> selectListByCategoryId(Long categoryId) {
|
||||
return selectList(new LambdaQueryWrapperX<IotProductDO>()
|
||||
.eq(IotProductDO::getCategoryId, categoryId)
|
||||
|
|
|
@ -73,6 +73,7 @@ public interface IotThingModelMapper extends BaseMapperX<IotThingModelDO> {
|
|||
IotThingModelDO::getName, name);
|
||||
}
|
||||
|
||||
// TODO @super:用不到,删除下;
|
||||
/**
|
||||
* 统计物模型数量
|
||||
*
|
||||
|
|
|
@ -9,7 +9,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -58,6 +57,8 @@ public interface IotDeviceLogMapper {
|
|||
*/
|
||||
Long selectCountByCreateTime(@Param("createTime") Long createTime);
|
||||
|
||||
// TODO @super:1)上行、下行,不写在 mapper 里,而是通过参数传递,这样,selectDeviceLogUpCountByHour、selectDeviceLogDownCountByHour 可以合并;
|
||||
// TODO @super:2)不能只基于 identifier 来计算,而是要 type + identifier 成对
|
||||
/**
|
||||
* 获得每个小时设备上行消息数量统计
|
||||
*
|
||||
|
|
|
@ -192,7 +192,7 @@ public interface IotDeviceService {
|
|||
* @param createTime 创建时间,如果为空,则统计所有设备数量
|
||||
* @return 设备数量
|
||||
*/
|
||||
Long getDeviceCount(LocalDateTime createTime);
|
||||
Long getDeviceCount(@Nullable LocalDateTime createTime);
|
||||
|
||||
/**
|
||||
* 获得设备数量,基于状态
|
||||
|
|
|
@ -429,6 +429,7 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
|||
return deviceMapper.selectCountByCreateTime(createTime);
|
||||
}
|
||||
|
||||
// TODO @super:是不是 groupby 查询,更高效;不过 controller,还是要考虑 null 的情况;不过可以直接枚举 foreach 处理下
|
||||
@Override
|
||||
public Long getDeviceCountByState(Integer state) {
|
||||
return deviceMapper.selectCountByState(state);
|
||||
|
|
|
@ -5,8 +5,8 @@ import cn.iocoder.yudao.module.iot.controller.admin.device.vo.data.IotDeviceLogP
|
|||
import cn.iocoder.yudao.module.iot.controller.admin.statistics.vo.IotStatisticsRespVO;
|
||||
import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceLogDO;
|
||||
import cn.iocoder.yudao.module.iot.mq.message.IotDeviceMessage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -45,7 +45,7 @@ public interface IotDeviceLogService {
|
|||
* @param createTime 创建时间,如果为空,则统计所有日志数量
|
||||
* @return 日志数量
|
||||
*/
|
||||
Long getDeviceLogCount(LocalDateTime createTime);
|
||||
Long getDeviceLogCount(@Nullable LocalDateTime createTime);
|
||||
|
||||
/**
|
||||
* 获得每个小时设备上行消息数量统计
|
||||
|
@ -55,7 +55,9 @@ public interface IotDeviceLogService {
|
|||
* @param endTime 结束时间,如果为空,则不限制结束时间
|
||||
* @return 每小时消息数量统计列表
|
||||
*/
|
||||
List<IotStatisticsRespVO.TimeData> getDeviceLogUpCountByHour(String deviceKey, Long startTime, Long endTime);
|
||||
List<IotStatisticsRespVO.TimeData> getDeviceLogUpCountByHour(@Nullable String deviceKey,
|
||||
@Nullable Long startTime,
|
||||
@Nullable Long endTime);
|
||||
|
||||
/**
|
||||
* 获得每个小时设备下行消息数量统计
|
||||
|
@ -65,6 +67,8 @@ public interface IotDeviceLogService {
|
|||
* @param endTime 结束时间,如果为空,则不限制结束时间
|
||||
* @return 每小时消息数量统计列表
|
||||
*/
|
||||
List<IotStatisticsRespVO.TimeData> getDeviceLogDownCountByHour( String deviceKey, Long startTime, Long endTime);
|
||||
List<IotStatisticsRespVO.TimeData> getDeviceLogDownCountByHour(@Nullable String deviceKey,
|
||||
@Nullable Long startTime,
|
||||
@Nullable Long endTime);
|
||||
|
||||
}
|
||||
|
|
|
@ -73,11 +73,13 @@ public class IotDeviceLogServiceImpl implements IotDeviceLogService {
|
|||
public Long getDeviceLogCount(LocalDateTime createTime) {
|
||||
Long time = null;
|
||||
if (createTime != null) {
|
||||
// todo @super:1)LocalDateTimeUtil.toEpochMilli(createTime);2)直接表达式,更简洁 time != null ? createTime.toInstant(ZoneOffset.UTC).toEpochMilli() : null;
|
||||
time = createTime.toInstant(ZoneOffset.UTC).toEpochMilli();
|
||||
}
|
||||
return deviceLogMapper.selectCountByCreateTime(time);
|
||||
}
|
||||
|
||||
// TODO @super:加一个参数,Boolean upstream:true 上行,false 下行,null 不过滤
|
||||
@Override
|
||||
public List<IotStatisticsRespVO.TimeData> getDeviceLogUpCountByHour(String deviceKey, Long startTime, Long endTime) {
|
||||
try {
|
||||
|
|
|
@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.iot.controller.admin.statistics.vo.IotStatisticsR
|
|||
import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductCategoryDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
@ -91,8 +92,9 @@ public interface IotProductCategoryService {
|
|||
* @param createTime 创建时间,如果为空,则统计所有分类数量
|
||||
* @return 产品分类数量
|
||||
*/
|
||||
Long getProductCategoryCount(LocalDateTime createTime);
|
||||
Long getProductCategoryCount(@Nullable LocalDateTime createTime);
|
||||
|
||||
// TODO @super:1)Map<ProductCategory, Count> 虽然有点怪哈,然后 Controller 按需转换成 Map<String, Integer> ;2)名字 getProductCategoryDeviceCountMap 方法
|
||||
/**
|
||||
* 获得各个品类下设备数量统计
|
||||
*
|
||||
|
|
|
@ -11,7 +11,6 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductCategoryDO;
|
|||
import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
|
||||
import cn.iocoder.yudao.module.iot.dal.mysql.product.IotProductCategoryMapper;
|
||||
import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
|
||||
import cn.iocoder.yudao.module.iot.service.product.IotProductCategoryService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
@ -108,6 +107,7 @@ public class IotProductCategoryServiceImpl implements IotProductCategoryService
|
|||
// 1. 获取所有数据
|
||||
List<IotProductCategoryDO> categoryList = productCategoryMapper.selectList();
|
||||
List<IotProductDO> productList = productService.getProductList();
|
||||
// TODO @super:不要 list 查询,返回内存,而是查询一个 Map<productId, count>
|
||||
List<IotDeviceDO> deviceList = deviceService.getDeviceList();
|
||||
|
||||
// 2. 统计每个分类下的设备数量
|
||||
|
@ -116,6 +116,7 @@ public class IotProductCategoryServiceImpl implements IotProductCategoryService
|
|||
// 2.1 初始化所有分类的计数为0
|
||||
for (IotProductCategoryDO category : categoryList) {
|
||||
categoryDeviceCountMap.put(category.getName(), 0);
|
||||
// TODO @super:直接这里面计算,不用多个循环。产品本身也不多,不用构建 Map,直接 filter 就好了
|
||||
}
|
||||
|
||||
// 2.2 构建产品ID到分类的映射
|
||||
|
|
|
@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.iot.controller.admin.product.vo.product.IotProduc
|
|||
import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -99,8 +100,9 @@ public interface IotProductService {
|
|||
* @param createTime 创建时间,如果为空,则统计所有产品数量
|
||||
* @return 产品数量
|
||||
*/
|
||||
Long getProductCount(LocalDateTime createTime);
|
||||
Long getProductCount(@Nullable LocalDateTime createTime);
|
||||
|
||||
// TODO @super:用不到的,删除下哈
|
||||
/**
|
||||
* 获得产品列表,基于分类编号
|
||||
*
|
||||
|
|
|
@ -81,6 +81,7 @@ public interface IotThingModelService {
|
|||
*/
|
||||
List<IotThingModelDO> getThingModelList(IotThingModelListReqVO reqVO);
|
||||
|
||||
// TODO @super:用不到,删除下哈。
|
||||
/**
|
||||
* 获得物模型数量
|
||||
*
|
||||
|
|
|
@ -364,6 +364,7 @@ public class IotThingModelServiceImpl implements IotThingModelService {
|
|||
return SpringUtil.getBean(getClass());
|
||||
}
|
||||
|
||||
// TODO @super:用不到,删除下;
|
||||
@Override
|
||||
public Long getThingModelCount(LocalDateTime createTime) {
|
||||
return thingModelMapper.selectCountByCreateTime(createTime);
|
||||
|
|
Loading…
Reference in New Issue