2026-06-24 f4bd1f3c89d906131495a0aca5aaf82966378510
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package cn.iocoder.yudao.module.iot.dal.tdengine;
 
import cn.iocoder.yudao.module.iot.controller.admin.device.vo.message.IotDeviceMessagePageReqVO;
import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceMessageDO;
import cn.iocoder.yudao.module.iot.framework.tdengine.core.annotation.TDengineDS;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
 
import java.util.Collection;
import java.util.List;
import java.util.Map;
 
/**
 * 设备消息 {@link IotDeviceMessageDO} Mapper 接口
 */
@Mapper
@TDengineDS
@InterceptorIgnore(tenantLine = "true") // 避免 SQL 解析,因为 JSqlParser 对 TDengine 的 SQL 解析会报错
public interface IotDeviceMessageMapper {
 
    /**
     * 创建设备消息超级表
     */
    void createSTable();
 
    /**
     * 查询设备消息表是否存在
     *
     * @return 存在则返回表名;不存在则返回 null
     */
    String showSTable();
 
    /**
     * 插入设备消息数据
     *
     * 如果子表不存在,会自动创建子表
     *
     * @param message 设备消息数据
     */
    void insert(IotDeviceMessageDO message);
 
    /**
     * 获得设备消息分页
     *
     * @param reqVO 分页查询条件
     * @return 设备消息列表
     */
    IPage<IotDeviceMessageDO> selectPage(IPage<IotDeviceMessageDO> page,
                                         @Param("reqVO") IotDeviceMessagePageReqVO reqVO);
 
    /**
     * 统计设备消息数量
     *
     * @param createTime 创建时间,如果为空,则统计所有消息数量
     * @return 消息数量
     */
    Long selectCountByCreateTime(@Param("createTime") Long createTime);
 
    /**
     * 按照 requestIds 批量查询消息
     *
     * @param deviceId 设备编号
     * @param requestIds 请求编号集合
     * @param reply 是否回复消息
     * @return 消息列表
     */
    List<IotDeviceMessageDO> selectListByRequestIdsAndReply(@Param("deviceId") Long deviceId,
                                                            @Param("requestIds") Collection<String> requestIds,
                                                            @Param("reply") Boolean reply);
 
    /**
     * 按照时间范围(小时),统计设备的消息数量
     */
    List<Map<String, Object>> selectDeviceMessageCountGroupByDate(@Param("startTime") Long startTime,
                                                                  @Param("endTime") Long endTime);
 
}