123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?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.zcxk.smartcity.data.access.dao.DeviceDataDimMapper">
- <sql id="where">
- <where>
- <if test="params.device_no != null and params.device_no != ''">
- and device_no = #{params.deviceNo}
- </if>
- <if test="params.site_id != null and params.site_id != ''">
- and site_id = #{params.siteId}
- </if>
- <if test="params.sys_id != null and params.sys_id != ''">
- and sys_id = #{params.sysId}
- </if>
- <if test="params.building_id != null and params.building_id != ''">
- and building_id = #{params.buildingId}
- </if>
- <if test="params.floor != null and params.floor != ''">
- and floor = #{params.floor}
- </if>
- <if test="params.location != null and params.location != ''">
- and location = #{params.location}
- </if>
- <if test="params.send_date != null and params.send_date != ''">
- and send_date = #{params.sendDate}
- </if>
- <if test="params.measuring_id != null and params.measuring_id != ''">
- and measuring_id = #{params.measuringId}
- </if>
- <if test="params.measuring_code != null and params.measuring_code != ''">
- and measuring_code = #{params.measuringCode}
- </if>
- <if test="params.measuring_data != null and params.measuring_data != ''">
- and measuring_data = #{params.measuringData}
- </if>
- <if test="params.send_time != null and params.send_time != ''">
- and send_time = #{params.sendTime}
- </if>
- <if test="params.create_by != null and params.create_by != ''">
- and create_by = #{params.createBy}
- </if>
- <if test="params.date_create != null and params.date_create != ''">
- and date_create = #{params.dateCreate}
- </if>
-
- </where>
- </sql>
- <select id="count" resultType="int">
- select count(1) from sc_device_data_dim t
- <include refid="where" />
- </select>
- <select id="list" resultType="DeviceDataDim">
- select * from sc_device_data_dim t
- <include refid="where" />
- ${params.orderBy}
- limit #{offset}, #{limit}
- </select>
-
- <update id="update">
- update sc_device_data_dim t
- <set>
- <if test="device_no != null">
- device_no = #{deviceNo},
- </if>
- <if test="site_id != null">
- site_id = #{siteId},
- </if>
- <if test="sys_id != null">
- sys_id = #{sysId},
- </if>
- <if test="building_id != null">
- building_id = #{buildingId},
- </if>
- <if test="floor != null">
- floor = #{floor},
- </if>
- <if test="location != null">
- location = #{location},
- </if>
- <if test="send_date != null">
- send_date = #{sendDate},
- </if>
- <if test="measuring_id != null">
- measuring_id = #{measuringId},
- </if>
- <if test="measuring_code != null">
- measuring_code = #{measuringCode},
- </if>
- <if test="measuring_data != null">
- measuring_data = #{measuringData},
- </if>
- <if test="send_time != null">
- send_time = #{sendTime},
- </if>
- <if test="create_by != null">
- create_by = #{createBy},
- </if>
- <if test="date_create != null">
- date_create = #{dateCreate},
- </if>
- </set>
- where t.id = #{id}
- </update>
- <sql id="Base_Column_List">
- device_id,
- device_no,
- site_id,
- sys_id,
- building_id,
- floor,
- location,
- send_date,
- measuring_id,
- measuring_code,
- measuring_data,
- measuring_unit,
- send_time,
- create_by,
- date_create
- </sql>
- <select id="getDeviceDataBetweenDate" resultType="com.zcxk.smartcity.data.access.entity.DeviceDataDim">
- select
- <include refid="Base_Column_List" />
- from
- sc_device_data_dim
- where device_id = #{deviceId,jdbcType=BIGINT}
- and send_time > #{beginTime,jdbcType=TIMESTAMP}
- and send_time <![CDATA[ < ]]> #{endTime,jdbcType=TIMESTAMP}
- </select>
-
- <select id="getDeviceDataByTime" resultType="java.util.HashMap">
- SELECT
- dd.measuring_code as measuringCode,
- md.measuring_name as measuringName,
- measuring_data as measuringData,
- dd.measuring_unit as measuringUnit,
- tmp.data_name as measuringDataDesc
- FROM
- sc_device_data_dim dd
- LEFT JOIN sc_tpl_measuring_desc md on (dd.measuring_id = md.measuring_id and md.device_type = #{deviceTypeId} )
- LEFT JOIN (
- SELECT
- device_type,
- measuring_id ,
- measuring_code,
- measuring_name,
- measuring_unit,
- data_value,
- data_name
- FROM
- sc_tpl_measuring_desc md
- LEFT JOIN sc_tpl_measuring_data_def mdd ON ( md.id = mdd.measuring_desc )
- WHERE
- md.device_type = #{deviceTypeId}
- ) tmp ON ( dd.measuring_id = tmp.measuring_id AND dd.measuring_data = tmp.data_value )
- WHERE
- device_id = #{deviceId,jdbcType=BIGINT}
- AND send_time = #{sendTime,jdbcType=TIMESTAMP}
- </select>
- </mapper>
|