2024-12-26 07:55:15 +08:00
|
|
|
<?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">
|
2025-01-28 08:35:07 +08:00
|
|
|
<mapper namespace="cn.iocoder.yudao.module.iot.dal.tdengine.IotDevicePropertyMapper">
|
2024-12-26 07:55:15 +08:00
|
|
|
|
|
|
|
<select id="getProductPropertySTableFieldList" resultType="cn.iocoder.yudao.module.iot.framework.tdengine.core.TDengineTableField">
|
|
|
|
DESCRIBE product_property_${productKey}
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<update id="createProductPropertySTable">
|
2025-01-27 21:32:33 +08:00
|
|
|
CREATE STABLE product_property_${productKey} (
|
|
|
|
ts TIMESTAMP,
|
|
|
|
report_time TIMESTAMP,
|
|
|
|
<foreach item="field" collection="fields" separator=",">
|
2024-12-26 07:55:15 +08:00
|
|
|
${field.field} ${field.type}
|
|
|
|
<if test="field.length != null and field.length > 0">
|
|
|
|
(${field.length})
|
|
|
|
</if>
|
|
|
|
</foreach>
|
2025-01-27 21:32:33 +08:00
|
|
|
)
|
2024-12-26 07:55:15 +08:00
|
|
|
TAGS (
|
|
|
|
device_key NCHAR(50)
|
|
|
|
)
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<update id="alterProductPropertySTableAddField">
|
|
|
|
ALTER STABLE product_property_${productKey}
|
|
|
|
ADD COLUMN ${field.field} ${field.type}
|
|
|
|
<if test="field.length != null and field.length > 0">
|
|
|
|
(${field.length})
|
|
|
|
</if>
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<update id="alterProductPropertySTableModifyField">
|
|
|
|
ALTER STABLE product_property_${productKey}
|
|
|
|
MODIFY COLUMN ${field.field} ${field.type}
|
|
|
|
<if test="field.length != null and field.length > 0">
|
|
|
|
(${field.length})
|
|
|
|
</if>
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<update id="alterProductPropertySTableDropField">
|
|
|
|
ALTER STABLE product_property_${productKey}
|
|
|
|
DROP COLUMN ${field.field}
|
|
|
|
</update>
|
|
|
|
|
2025-01-27 21:32:33 +08:00
|
|
|
<insert id="insert">
|
|
|
|
INSERT INTO device_property_${device.deviceKey}
|
|
|
|
USING product_property_${device.productKey}
|
|
|
|
TAGS ('${device.deviceKey}')
|
|
|
|
(ts, report_time,
|
|
|
|
<foreach item="key" collection="properties.keys" separator=",">
|
|
|
|
${key}
|
2025-01-24 15:56:01 +08:00
|
|
|
</foreach>
|
2025-01-27 21:32:33 +08:00
|
|
|
)
|
|
|
|
VALUES
|
|
|
|
(NOW, #{reportTime},
|
|
|
|
<foreach item="value" collection="properties.values" separator=",">
|
|
|
|
#{value}
|
2025-01-24 15:56:01 +08:00
|
|
|
</foreach>
|
|
|
|
)
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<select id="describeSuperTable" resultType="java.util.Map">
|
|
|
|
DESCRIBE product_property_${productKey}
|
|
|
|
</select>
|
|
|
|
|
2025-01-28 10:23:47 +08:00
|
|
|
<!-- TODO 芋艿:缺少时间范围 AND ts BETWEEN #{reqVO.startTime} AND #{reqVO.endTime} -->
|
|
|
|
<select id="selectPageByHistory" resultType="cn.iocoder.yudao.module.iot.controller.admin.device.vo.data.IotDevicePropertyRespVO">
|
|
|
|
SELECT ${reqVO.identifier} AS `value`, report_time AS update_time
|
|
|
|
FROM device_property_${reqVO.deviceKey}
|
|
|
|
WHERE ${reqVO.identifier} IS NOT NULL
|
2025-01-24 15:56:01 +08:00
|
|
|
ORDER BY ts DESC
|
|
|
|
</select>
|
|
|
|
|
2024-12-26 07:55:15 +08:00
|
|
|
</mapper>
|