<?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.nanometer.smartlab.dao.SysContainerSensorsDao">
|
<resultMap id="BaseResultMap" type="com.nanometer.smartlab.entity.SysContainerSensors">
|
<id column="id" jdbcType="VARCHAR" property="id" />
|
<result column="container_id" jdbcType="VARCHAR" property="containerId" />
|
<result column="warehouse_container_name" jdbcType="VARCHAR" property="warehouseContainerName" />
|
<result column="laboratory_container_name" jdbcType="VARCHAR" property="laboratoryContainerName" />
|
<result column="temp" jdbcType="DOUBLE" property="temp" />
|
<result column="humidity" jdbcType="INTEGER" property="humidity" />
|
<result column="voc1" jdbcType="DOUBLE" property="voc1" />
|
<result column="flag" jdbcType="INTEGER" property="flag" />
|
<result column="type" jdbcType="TINYINT" property="type" />
|
<result column="laboratory_name" jdbcType="VARCHAR" property="laboratoryName" />
|
<result column="warehouse_name" jdbcType="VARCHAR" property="warehouseName" />
|
<result column="laboratory_id" jdbcType="VARCHAR" property="laboratoryId" />
|
<result column="warehouse_id" jdbcType="VARCHAR" property="warehouseId" />
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
|
</resultMap>
|
<sql id="Base_Column_List">
|
id, container_id, temp, humidity, voc1, flag, type, update_time
|
</sql>
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from sys_container_sensors
|
where id = #{id,jdbcType=VARCHAR}
|
</select>
|
<delete id="deleteByPrimaryKey" >
|
delete from sys_container_sensors
|
where id = #{id,jdbcType=VARCHAR}
|
</delete>
|
<insert id="insertSelective" parameterType="com.nanometer.smartlab.entity.SysContainerSensors" useGeneratedKeys = "true" keyProperty = "id">
|
insert into sys_container_sensors
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="containerId != null">
|
container_id,
|
</if>
|
<if test="temp != null">
|
temp,
|
</if>
|
<if test="humidity != null">
|
humidity,
|
</if>
|
<if test="voc1 != null">
|
voc1,
|
</if>
|
<if test="flag != null">
|
flag,
|
</if>
|
<if test="type != null">
|
type,
|
</if>
|
<if test="updateTime != null">
|
update_time,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="containerId != null">
|
#{containerId,jdbcType=VARCHAR},
|
</if>
|
<if test="temp != null">
|
#{temp,jdbcType=DOUBLE},
|
</if>
|
<if test="humidity != null">
|
#{humidity,jdbcType=INTEGER},
|
</if>
|
<if test="voc1 != null">
|
#{voc1,jdbcType=INTEGER},
|
</if>
|
<if test="flag != null">
|
#{flag,jdbcType=INTEGER},
|
</if>
|
<if test="type != null">
|
#{type,jdbcType=BIT},
|
</if>
|
<if test="updateTime != null">
|
#{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKeySelective" parameterType="com.nanometer.smartlab.entity.SysContainerSensors">
|
update sys_container_sensors
|
<set>
|
<if test="containerId != null">
|
container_id = #{containerId,jdbcType=VARCHAR},
|
</if>
|
<if test="temp != null">
|
temp = #{temp,jdbcType=DOUBLE},
|
</if>
|
<if test="humidity != null">
|
humidity = #{humidity,jdbcType=INTEGER},
|
</if>
|
<if test="voc1 != null">
|
voc1 = #{voc1,jdbcType=INTEGER},
|
</if>
|
<if test="flag != null">
|
flag = #{flag,jdbcType=INTEGER},
|
</if>
|
<if test="type != null">
|
type = #{type,jdbcType=BIT},
|
</if>
|
<if test="updateTime != null">
|
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
</set>
|
where id = #{id,jdbcType=VARCHAR}
|
</update>
|
<sql id="sql_where">
|
<where>
|
<if test="containerId != null ">
|
and container_id = #{containerId,jdbcType=VARCHAR}
|
</if>
|
<if test="temp != null ">
|
and temp = #{temp,jdbcType=DOUBLE}
|
</if>
|
<if test="humidity != null ">
|
and humidity = #{humidity,jdbcType=INTEGER}
|
</if>
|
<if test="voc1 != null ">
|
and voc1 = #{voc1,jdbcType=INTEGER}
|
</if>
|
<if test="flag != null ">
|
and flag = #{flag,jdbcType=INTEGER}
|
</if>
|
<if test="type != null ">
|
and type = #{type,jdbcType=BIT}
|
</if>
|
<if test="updateTime != null ">
|
and update_time = #{updateTime,jdbcType=TIMESTAMP}
|
</if>
|
<if test="laboratoryName != null ">
|
and l.name = #{laboratoryName,jdbcType=VARCHAR}
|
</if>
|
<if test="warehouseName != null ">
|
and w.name = #{warehouseName,jdbcType=VARCHAR}
|
</if>
|
<if test="laboratoryNameLike != null ">
|
and l.name like CONCAT('%','${laboratoryName}','%')
|
</if>
|
<if test="warehouseNameLike != null ">
|
and w.name like CONCAT('%','${warehouseName}','%')
|
</if>
|
<if test="containerNameLike != null ">
|
and (lc.name like CONCAT('%','${containerNameLike}','%') or wc.name like CONCAT('%','${containerNameLike}','%'))
|
</if>
|
<if test="laboratoryOrwarehouseNameLike != null">
|
and (l.name like CONCAT('%','${laboratoryOrwarehouseNameLike}','%') or w.name like CONCAT('%','${laboratoryOrwarehouseNameLike}','%'))
|
</if>
|
<if test="beginUpdateTime != null ">
|
and s.update_time >= #{beginUpdateTime}
|
</if>
|
<if test="endUpdateTime != null ">
|
and s.update_time <= #{endUpdateTime}
|
</if>
|
</where>
|
</sql>
|
<sql id="sql_limit">
|
<if test="offset != null and limit != null">
|
limit #{offset} , #{limit}
|
</if>
|
</sql>
|
<sql id="sql_order">
|
<if test="orderby != null">
|
order by ${orderby}
|
</if>
|
</sql>
|
<sql id="sql_groupby">
|
<if test="groupby != null">
|
group by ${groupby}
|
</if>
|
</sql>
|
<select id="getListBySelective" parameterType="java.util.HashMap" resultMap="BaseResultMap">
|
select s.*,l.name laboratory_name,w.name warehouse_name,l.id laboratory_id,lc.name as laboratory_container_name, wc.name as warehouse_container_name, w.id warehouse_id from sys_container_sensors s
|
left join sys_warehouse_container wc on wc.id = s.container_id
|
left join sys_warehouse w on w.id = wc.warehouse_id
|
left join sys_laboratory_container lc on lc.id = s.container_id
|
left join sys_laboratory l on l.id = lc.laboratory_id
|
<include refid="sql_where" />
|
<include refid="sql_groupby" />
|
<include refid="sql_order" />
|
<include refid="sql_limit" />
|
</select>
|
<select id="countBySelective" parameterType="java.util.HashMap" resultType="int">
|
select count(*) from (
|
select count(distinct container_id) from sys_container_sensors s
|
left join sys_warehouse_container wc on wc.id = s.container_id
|
left join sys_warehouse w on w.id = wc.warehouse_id
|
left join sys_laboratory_container lc on lc.id = s.container_id
|
left join sys_laboratory l on l.id = lc.laboratory_id
|
<include refid="sql_where" />
|
<include refid="sql_groupby" />
|
) t
|
</select>
|
|
<select id="selectAll" parameterType="java.util.Map" resultType="com.nanometer.smartlab.entity.dto.ContainerStatusMngDto">
|
|
SELECT slc.id,slc.temp, slc.humidity,slc.voc1 ,sl.name as laboratoryName,slc.name laboratoryContainerName,slc.flag,
|
CASE
|
WHEN substring(flag, 1,1) = '1' THEN TRUE ELSE FALSE END AS lowTempAlert,
|
CASE
|
WHEN substring(flag, 2,1) = '1' THEN TRUE ELSE FALSE END AS highTempAlert,
|
CASE
|
WHEN substring(flag, 3,1) = '1' THEN TRUE ELSE FALSE END AS lowHumidityAlert,
|
CASE
|
WHEN substring(flag, 4,1) = '1' THEN TRUE ELSE FALSE END AS highHumidityAlert,
|
CASE
|
WHEN substring(flag, 5,1) = '1' THEN TRUE ELSE FALSE END AS voc1Alert
|
from sys_laboratory_container slc
|
LEFT JOIN sys_laboratory sl ON sl.id = slc.laboratory_id
|
|
<where>
|
slc.valid_flag=1
|
<if test="laboratoryName != null and laboratoryName!=''">
|
and sl.name like CONCAT('%','${laboratoryName}','%')
|
</if>
|
<if test="laboratoryContainerName != null and laboratoryContainerName!=''">
|
and slc.name like CONCAT('%','${laboratoryContainerName}','%')
|
</if>
|
</where>
|
ORDER BY
|
slc.update_time DESC
|
<include refid="sql_limit" />
|
|
</select>
|
|
<select id="countAll" resultType="int">
|
select count(slc.id)
|
from sys_laboratory_container slc
|
LEFT JOIN sys_laboratory sl ON sl.id = slc.laboratory_id
|
<where>
|
slc.valid_flag=1
|
<if test="laboratoryName != null and laboratoryName!=''">
|
and sl.name like CONCAT('%','${laboratoryName}','%')
|
</if>
|
<if test="laboratoryContainerName != null and laboratoryContainerName!=''">
|
and slc.name like CONCAT('%','${laboratoryContainerName}','%')
|
</if>
|
</where>
|
ORDER BY
|
slc.update_time DESC
|
</select>
|
<select id="getRowData" resultType="com.nanometer.smartlab.entity.dto.ContainerStatusMngDto">
|
SELECT slc.id,slc.temp, slc.humidity,slc.voc1 ,sl.name as laboratoryName,slc.name laboratoryContainerName,slc.flag,
|
CASE
|
WHEN substring(flag, 1,1) = '1' THEN TRUE ELSE FALSE END AS lowTempAlert,
|
CASE
|
WHEN substring(flag, 2,1) = '1' THEN TRUE ELSE FALSE END AS highTempAlert,
|
CASE
|
WHEN substring(flag, 3,1) = '1' THEN TRUE ELSE FALSE END AS lowHumidityAlert,
|
CASE
|
WHEN substring(flag, 4,1) = '1' THEN TRUE ELSE FALSE END AS highHumidityAlert,
|
CASE
|
WHEN substring(flag, 5,1) = '1' THEN TRUE ELSE FALSE END AS voc1Alert
|
from sys_laboratory_container slc
|
LEFT JOIN sys_laboratory sl ON sl.id = slc.laboratory_id
|
where slc.id = #{id}
|
|
|
</select>
|
<select id="selectMaxTemperature" resultType="java.util.Map">
|
select max(s.temp) maxTemperature,min(s.temp) minTemperature
|
from sys_container_sensors as s
|
where
|
s.container_id = #{id}
|
and s.update_time >= #{beginDate}
|
<if test="endDate != null">
|
and s.update_time < #{endDate}
|
</if>
|
</select>
|
<select id="selectMaxHumidity" resultType="java.util.Map">
|
select max(s.humidity) maxHumidity, min(s.humidity) minHumidity
|
from sys_container_sensors as s
|
where
|
s.container_id = #{id}
|
and s.update_time >= #{beginDate}
|
<if test="endDate != null">
|
and s.update_time < #{endDate}
|
</if>
|
</select>
|
<select id="selectMaxVoc" resultType="java.util.Map">
|
select max(s.voc1) maxVoc, min(s.voc1) minVoc
|
from sys_container_sensors as s
|
where
|
s.container_id = #{id}
|
and s.update_time >= #{beginDate}
|
<if test="endDate != null">
|
and s.update_time < #{endDate}
|
</if>
|
</select>
|
</mapper>
|