| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <?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">
- <mapper namespace="com.sckw.slope.detection.dao.tdengine.SlopeDataMapper">
- <resultMap id="BaseResultMap" type="com.sckw.slope.detection.model.dos.tdengine.SlopeData">
- <!--@mbg.generated-->
- <!--@Table slope_data-->
- <id column="ts" jdbcType="TIMESTAMP" property="ts"/>
- <result column="rawTs" jdbcType="TIMESTAMP" property="rawId"/>
- <result column="tslverId" jdbcType="TINYINT" property="tslverId"/>
- <result column="guid" jdbcType="VARCHAR" property="guid"/>
- <result column="line" jdbcType="VARCHAR" property="line"/>
- <result column="val" jdbcType="VARCHAR" property="val"/>
- <result column="createTime" jdbcType="TIMESTAMP" property="createTime"/>
- <!-- <result column="msgId" jdbcType="VARCHAR" property="msgId"/>-->
- <!-- <result column="name" jdbcType="TINYINT" property="name"/>-->
- </resultMap>
- <select id="selectList" resultType="com.sckw.slope.detection.model.vo.SlopeDataVo">
- <!-- ts, raw_id , device_id, item_name as itemName, item_value as itemValue, create_time as createTime-->
- SELECT ts,
- raw_ts as rawId,
- tslver_id as tslverId,
- guid,
- line,
- val,
- create_time as createTime,
- msg_id as msgId,
- name,
- json_text as jsonText
- FROM devicesv2.device_67
- </select>
- <sql id="Base_List">
- ts,
- raw_ts as rawId,
- tslver_id as tslverId,
- line,
- val
- </sql>
- <select id="selectListByLine" resultType="com.sckw.slope.detection.model.dos.tdengine.SlopeData">
- SELECT
- <include refid="Base_List">
- </include>
- FROM devicesv2.device_#{snCode}
- where line = #{item}
- order by ts desc limit 1
- </select>
- <select id="selectListByLineOrderByCreateTime" resultType="com.sckw.slope.detection.model.dos.tdengine.SlopeData">
- SELECT
- <include refid="Base_List">
- </include>
- FROM devicesv2.device_#{snCode}
- where line = #{item}
- order by ts desc limit 2
- </select>
- <insert id="insertData" parameterType="com.sckw.slope.detection.model.dos.tdengine.SlopeData">
- <!-- insert into devices.devicesv2202_2021-->
- insert into devicesv2.devices_#{slopeData.serialNumber} using devicesv2.devices (#{slopeData.tagsTitle}) tags (#{slopeData.tags})
- (ts, raw_ts, tslver_id, guid, line, val, create_time)
- VALUES (#{slopeData.ts}, #{slopeData.rawId},
- #{slopeData.tslverId}, #{slopeData.guid},
- #{slopeData.line}, #{slopeData.val}, #{slopeData.createTime})
- <!-- VALUES('2023-12-12 00:00:00.100', '2023-12-12 00:00:00.100', 111, '111', '1111', '111', '2023-12-12 00:00:00.100');-->
- </insert>
- <select id="selectLineList" resultType="com.sckw.slope.detection.model.dos.tdengine.SlopeData">
- SELECT
- <include refid="Base_List">
- </include>
- FROM devicesv2.device_#{snCode}
- where line = #{item} and ts >= #{dateStart} and ts <= #{dateEnd} order by ts desc
- </select>
- <select id="selectTableIsExit">
- select * from information_schema.ins_tables a where a.db_name = 'devices' and a.table_name = #{name}
- </select>
- <insert id="createTable">
- CREATE TABLE #{name} (
- ts TIMESTAMP,
- raw_id TIMESTAMP,
- tslver_id TINYINT(4),
- guid VARCHAR(64),
- line VARCHAR(16),
- val VARCHAR(16),
- create_time TIMESTAMP
- )
- </insert>
- <select id="selectListByMaster" resultType="com.sckw.slope.detection.model.vo.SlopeDataVo">
- SELECT
- <include refid="Base_List">
- </include>
- FROM devicesv2.devices
- <!-- <if test="(page != null and page !='') and ( pageSize != null and pageSize != '')">-->
- <if test="page != null and pageSize != null ">
- limit #{page},#{pageSize}
- </if>
- <!-- SELECT-->
- <!-- t1.ts,-->
- <!-- t1.raw_id as rawId,-->
- <!-- t1.tslver_id as tslverId,-->
- <!-- t1.guid,-->
- <!-- t1.line,-->
- <!-- t1.val,-->
- <!-- t1.create_time as createTime,-->
- <!-- t2.json_text as jsonText-->
- <!-- FROM devices.slope_data AS t1-->
- <!-- LEFT JOIN devices.slope_raw AS t2 ON t1.guid = t2.guid-->
- </select>
- <select id="selectListByMasterCount" resultType="com.sckw.slope.detection.model.vo.SlopeDataVo">
- SELECT
- <include refid="Base_List">
- </include>
- FROM devicesv2.devices
- </select>
- <select id="selectLastData" resultType="com.sckw.slope.detection.model.dos.tdengine.SlopeData">
- SELECT
- <include refid="Base_List">
- </include>
- FROM devicesv2.device_${deviceCode}
- order by ts desc limit 1
- </select>
- </mapper>
|