Blame view

yudao-module-iot/yudao-module-iot-biz/src/main/resources/mapper/device/IotDevicePropertyMapper.xml 2.86 KB
064b3381   YunaiV   【代码重构】IoT:弱化 TdEn...
1
2
3
4
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE mapper
          PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
          "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
6071afea   YunaiV   【功能优化】Bpm:设备日志的展示
5
  <mapper namespace="cn.iocoder.yudao.module.iot.dal.tdengine.IotDevicePropertyMapper">
064b3381   YunaiV   【代码重构】IoT:弱化 TdEn...
6
7
  
      <select id="getProductPropertySTableFieldList" resultType="cn.iocoder.yudao.module.iot.framework.tdengine.core.TDengineTableField">
b37814ec   YunaiV   reactor:【IoT 物联网】...
8
          DESCRIBE product_property_${productId}
064b3381   YunaiV   【代码重构】IoT:弱化 TdEn...
9
10
11
      </select>
  
      <update id="createProductPropertySTable">
b37814ec   YunaiV   reactor:【IoT 物联网】...
12
          CREATE STABLE product_property_${productId} (
7745035f   YunaiV   【功能优化】IoT:设备属性日志表...
13
14
15
              ts TIMESTAMP,
              report_time TIMESTAMP,
          <foreach item="field" collection="fields" separator=",">
064b3381   YunaiV   【代码重构】IoT:弱化 TdEn...
16
17
18
19
20
              ${field.field} ${field.type}
              <if test="field.length != null and field.length > 0">
                  (${field.length})
              </if>
          </foreach>
7745035f   YunaiV   【功能优化】IoT:设备属性日志表...
21
          )
064b3381   YunaiV   【代码重构】IoT:弱化 TdEn...
22
          TAGS (
b37814ec   YunaiV   reactor:【IoT 物联网】...
23
              device_id BIGINT
064b3381   YunaiV   【代码重构】IoT:弱化 TdEn...
24
25
26
27
          )
      </update>
  
      <update id="alterProductPropertySTableAddField">
b37814ec   YunaiV   reactor:【IoT 物联网】...
28
          ALTER STABLE product_property_${productId}
064b3381   YunaiV   【代码重构】IoT:弱化 TdEn...
29
30
31
32
33
34
35
          ADD COLUMN ${field.field} ${field.type}
          <if test="field.length != null and field.length > 0">
              (${field.length})
          </if>
      </update>
  
      <update id="alterProductPropertySTableModifyField">
b37814ec   YunaiV   reactor:【IoT 物联网】...
36
          ALTER STABLE product_property_${productId}
064b3381   YunaiV   【代码重构】IoT:弱化 TdEn...
37
38
39
40
41
42
43
          MODIFY COLUMN ${field.field} ${field.type}
          <if test="field.length != null and field.length > 0">
              (${field.length})
          </if>
      </update>
  
      <update id="alterProductPropertySTableDropField">
b37814ec   YunaiV   reactor:【IoT 物联网】...
44
          ALTER STABLE product_property_${productId}
064b3381   YunaiV   【代码重构】IoT:弱化 TdEn...
45
46
47
          DROP COLUMN ${field.field}
      </update>
  
7745035f   YunaiV   【功能优化】IoT:设备属性日志表...
48
      <insert id="insert">
b37814ec   YunaiV   reactor:【IoT 物联网】...
49
50
51
          INSERT INTO device_property_${device.id}
          USING product_property_${device.productId}
          TAGS ('${device.id}')
7745035f   YunaiV   【功能优化】IoT:设备属性日志表...
52
53
          (ts, report_time,
          <foreach item="key" collection="properties.keys" separator=",">
f14cc470   YunaiV   【功能修复】IoT:解决物模型的 ...
54
              ${@cn.hutool.core.util.StrUtil@toUnderlineCase(key)}
03d4f60e   alwayssuper   [fix]:code review
55
          </foreach>
7745035f   YunaiV   【功能优化】IoT:设备属性日志表...
56
57
58
59
60
          )
          VALUES
          (NOW, #{reportTime},
          <foreach item="value" collection="properties.values" separator=",">
              #{value}
03d4f60e   alwayssuper   [fix]:code review
61
62
63
64
          </foreach>
          )
      </insert>
  
03d4f60e   alwayssuper   [fix]:code review
65
      <select id="describeSuperTable" resultType="java.util.Map">
b37814ec   YunaiV   reactor:【IoT 物联网】...
66
          DESCRIBE product_property_${productId}
03d4f60e   alwayssuper   [fix]:code review
67
68
      </select>
  
e476dcb2   YunaiV   feat:【IoT 物联网】设备属...
69
      <select id="selectListByHistory"
3f83569e   YunaiV   feat: 【IoT 物联网】新增...
70
              resultType="cn.iocoder.yudao.module.iot.controller.admin.device.vo.property.IotDevicePropertyRespVO">
f14cc470   YunaiV   【功能修复】IoT:解决物模型的 ...
71
          SELECT ${@cn.hutool.core.util.StrUtil@toUnderlineCase(reqVO.identifier)} AS `value`, ts AS update_time
b37814ec   YunaiV   reactor:【IoT 物联网】...
72
          FROM device_property_${reqVO.deviceId}
f14cc470   YunaiV   【功能修复】IoT:解决物模型的 ...
73
          WHERE ${@cn.hutool.core.util.StrUtil@toUnderlineCase(reqVO.identifier)} IS NOT NULL
0b16f167   YunaiV   【功能优化】Bpm:完善设备属性的历史值
74
            AND ts BETWEEN ${@cn.hutool.core.date.LocalDateTimeUtil@toEpochMilli(reqVO.times[0])}
3f83569e   YunaiV   feat: 【IoT 物联网】新增...
75
              AND ${@cn.hutool.core.date.LocalDateTimeUtil@toEpochMilli(reqVO.times[1])}
e9c5464a   YunaiV   feat:【IoT 物联网】获取设...
76
          ORDER BY ts DESC
03d4f60e   alwayssuper   [fix]:code review
77
78
      </select>
  
064b3381   YunaiV   【代码重构】IoT:弱化 TdEn...
79
  </mapper>