场景模型测试工具
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
scmy/psdc-business/src/main/resources/mapper/business/PsdcThermometerHtdataMapper...

165 lines
7.6 KiB

2 years ago
<?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.psdc.mapper.PsdcThermometerHtdataMapper">
<resultMap type="com.psdc.entity.PsdcThermometerHtdata" id="PsdcThermometerHtdataMap">
<result property="thermometerHtdataId" column="thermometer_htdata_id" />
<result property="deviceId" column="device_id" />
<result property="thermometerValue" column="thermometer_value" />
<result property="thermometerValueIn" column="thermometer_value_in" />
<result property="thermometerValueOut" column="thermometer_value_out" />
<result property="updateTime" column="update_time" />
</resultMap>
<!-- 通过ID查询单条数据 -->
<select id="queryById" resultMap="PsdcThermometerHtdataMap">
select
thermometer_htdata_id,device_id,thermometer_value,thermometer_value_in,thermometer_value_out,update_time
from psdc_thermometer_htdata
where thermometer_htdata_id = #{thermometerHtdataId}
</select>
<select id="selTodayThermometer" resultMap="PsdcThermometerHtdataMap">
Select thermometer_htdata_id,device_id,thermometer_value,thermometer_value_in,thermometer_value_out,update_time From psdc_thermometer_htdata
<where>
<if test="deviceId != null and deviceId != ''">
device_id = #{deviceId}
</if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
And date_format(update_time,'%Y-%m-%d %H:%i:%S') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%S')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
And date_format(update_time,'%Y-%m-%d %H:%i:%S') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%S')
</if>
</where>
ORDER BY update_time
</select>
<select id="selTodayThermometer2" resultMap="PsdcThermometerHtdataMap">
Select thermometer_htdata_id, SUM(thermometer_value) As thermometer_value, pth.update_time
From psdc_thermometer_htdata pth
LEFT JOIN psdc_device pd On pd.device_id = pth.device_id
<where>
pd.device_model = "温度传感器"
<if test="installAddress != null and installAddress != ''">
And pd.device_address LIKE concat('%', #{installAddress}, '%')
</if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
And date_format(pth.update_time,'%Y-%m-%d %H:%i:%S') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%S')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
And date_format(pth.update_time,'%Y-%m-%d %H:%i:%S') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%S')
</if>
</where>
GROUP BY date_format(pth.update_time,'%Y-%m-%d %H:%i')
ORDER BY pth.update_time
</select>
<select id="selHtCount" resultType="java.lang.Integer">
Select Count(1) From psdc_thermometer_htdata pth
<where>
<if test="deviceId != null and deviceId != ''">
And device_id = #{deviceId}
</if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
And date_format(pth.update_time,'%Y-%m-%d %H:%i:%S') &gt;= date_format(#{beginTime},'%Y-%m-%d %H:%i:%S')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
And date_format(pth.update_time,'%Y-%m-%d %H:%i:%S') &lt;= date_format(#{endTime},'%Y-%m-%d %H:%i:%S')
</if>
</where>
</select>
2 years ago
<!--分页查询指定行数据-->
<select id="queryAllByLimit" resultMap="PsdcThermometerHtdataMap">
Select
2 years ago
thermometer_htdata_id,device_id,thermometer_value,thermometer_value_in,thermometer_value_out,update_time
From psdc_thermometer_htdata
2 years ago
<where>
<if test="thermometerHtdataId != null and thermometerHtdataId != ''">
and thermometer_htdata_id = #{thermometerHtdataId}
</if>
<if test="deviceId != null and deviceId != ''">
and device_id = #{deviceId}
</if>
<if test="thermometerValue != null and thermometerValue != ''">
and thermometer_value = #{thermometerValue}
</if>
<if test="thermometerValueIn != null and thermometerValueIn != ''">
and thermometer_value_in = #{thermometerValueIn}
</if>
<if test="thermometerValueOut != null and thermometerValueOut != ''">
and thermometer_value_out = #{thermometerValueOut}
</if>
<if test="updateTime != null and updateTime != ''">
and update_time = #{updateTime}
</if>
</where>
limit #{pageable.offset}, #{pageable.pageSize}
</select>
<!--统计总行数-->
<select id="count" resultType="java.lang.Long">
select count(1)
from psdc_thermometer_htdata
<where>
<if test="thermometerHtdataId != null and thermometerHtdataId != ''">
and thermometer_htdata_id = #{thermometerHtdataId}
</if>
<if test="deviceId != null and deviceId != ''">
and device_id = #{deviceId}
</if>
<if test="thermometerValue != null and thermometerValue != ''">
and thermometer_value = #{thermometerValue}
</if>
<if test="thermometerValueIn != null and thermometerValueIn != ''">
and thermometer_value_in = #{thermometerValueIn}
</if>
<if test="thermometerValueOut != null and thermometerValueOut != ''">
and thermometer_value_out = #{thermometerValueOut}
</if>
<if test="updateTime != null and updateTime != ''">
and update_time = #{updateTime}
</if>
</where>
</select>
<!--新增数据-->
<insert id="insert" >
insert into psdc_thermometer_htdata(thermometer_htdata_id,device_id,thermometer_value,thermometer_value_in,thermometer_value_out,update_time)
values (#{thermometerHtdataId},#{deviceId},#{thermometerValue},#{thermometerValueIn},#{thermometerValueOut},#{updateTime})
</insert>
<!-- 更新数据 -->
<update id="update">
update psdc_thermometer_htdata
<set>
<if test="thermometerHtdataId != null and thermometerHtdataId != ''">
thermometer_htdata_id = #{thermometerHtdataId},
</if>
<if test="deviceId != null and deviceId != ''">
device_id = #{deviceId},
</if>
<if test="thermometerValue != null and thermometerValue != ''">
thermometer_value = #{thermometerValue},
</if>
<if test="thermometerValueIn != null and thermometerValueIn != ''">
thermometer_value_in = #{thermometerValueIn},
</if>
<if test="thermometerValueOut != null and thermometerValueOut != ''">
thermometer_value_out = #{thermometerValueOut},
</if>
<if test="updateTime != null and updateTime != ''">
update_time = #{updateTime},
</if>
</set>
where thermometer_htdata_id = #{thermometerHtdataId}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete from psdc_thermometer_htdata where thermometer_htdata_id = #{thermometerHtdataId}
</delete>
</mapper>