TaosMapper.xml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.middle.platform.data.biz.mapper.TaosMapper">
  4. <update id="createProduct">
  5. CREATE STABLE IF NOT EXISTS product_${code} (ts TIMESTAMP, line NCHAR(32),val NCHAR(32),msg_id
  6. NCHAR(64),reserve NCHAR(64),origin_time TIMESTAMP) TAGS (guid NCHAR(32))
  7. </update>
  8. <update id="createDeviceTable">
  9. CREATE TABLE IF NOT EXISTS device_${code}_${guid} using product_${code} TAGS (#{guid})
  10. </update>
  11. <insert id="insert">
  12. INSERT INTO device_${code}_${guid} (ts, line, val, msg_id,reserve, origin_time)
  13. VALUES (#{ts}, #{line}, #{val}, #{msgId}, #{reserve}, #{originTime})
  14. </insert>
  15. <insert id="batchInsert">
  16. INSERT INTO device_${code}_${guid} (ts, line, val, msg_id, reserve, origin_time) VALUES
  17. <foreach collection='list' item='item' index='index' separator=','>
  18. (#{item.ts}, #{item.line}, #{item.val}, #{item.msgId}, #{item.reserve}, #{item.originTime})
  19. </foreach>
  20. </insert>
  21. <!--源数据-->
  22. <select id="createOriginal" >
  23. create STABLE IF NOT EXISTS original_${code} (ts TIMESTAMP, raw_str varchar(10000),msg_id NCHAR(64)) tags (guid varchar(64));
  24. </select>
  25. <select id="createOriginalTable" >
  26. CREATE TABLE IF NOT EXISTS original_${code}_${guid} using original_${code} TAGS (#{guid})
  27. </select>
  28. <insert id="insertOriginal">
  29. INSERT INTO original_${code}_${guid} (ts, raw_str,msg_id)
  30. VALUES (#{ts}, #{rawStr}, #{msgId})
  31. </insert>
  32. <select id="batchInsertOriginal" resultType="int">
  33. INSERT INTO original_${code}_${guid} (ts, raw_str,msg_id) VALUES
  34. <foreach collection='list' item='item' index='index' separator=',' >
  35. (#{item.ts}, #{item.rawStr}, #{item.msgId})
  36. </foreach>
  37. </select>
  38. </mapper>