<?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.moral.monitor.dao.JobDao">
|
|
<resultMap type="HashMap" id="adjustResultMap">
|
<result column="mac_key" property="key" javaType="java.lang.String" />
|
<result column="value" property="value" javaType="java.lang.Float" />
|
</resultMap>
|
|
<select id="findAdjustByMac" resultMap="adjustResultMap">
|
select c.mac_key, d.`value`
|
from equipment a
|
inner join mac b on a.id = b.equipment_id
|
inner join sensor c on b.sensor = c.id
|
left join sensoradjust d on b.id = d.sen_dev_id
|
where a.mac = #{0}
|
</select>
|
|
<update id="updateStateByMac">
|
UPDATE equipment SET state=#{1} WHERE mac=#{0}
|
</update>
|
|
<insert id="batchInsertHistory" parameterType="java.util.List" >
|
<selectKey resultType ="java.lang.Integer" keyProperty="id" order="AFTER">
|
SELECT LAST_INSERT_ID()
|
</selectKey >
|
insert into history
|
(mac, sensor, mac_key, mac_value, time)
|
values
|
<foreach collection="list" item="item" index="index" separator=",">
|
(
|
#{item.mac},
|
#{item.sensor},
|
#{item.mac_key},
|
#{item.mac_value},
|
#{item.time}
|
)
|
</foreach>
|
</insert>
|
|
<select id="getAllEquipment" resultType="com.moral.monitor.entity.Equipment">
|
select mac from equipment
|
</select>
|
|
<select id="getLoggerByMac" resultType="com.moral.monitor.entity.Logger">
|
select time from logger where mac=#{0} order by time DESC limit 1
|
</select>
|
|
</mapper>
|