From cdcc163408a45578880c91ca79d865e0e5e86b65 Mon Sep 17 00:00:00 2001
From: fengxiang <fengxiang@blit.7drlb>
Date: Thu, 09 Nov 2017 10:04:36 +0800
Subject: [PATCH] redis缓存开发

---
 src/main/resources/mapper/JobDao.xml |   46 +++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/src/main/resources/mapper/JobDao.xml b/src/main/resources/mapper/JobDao.xml
index 1e091e1..e132f52 100644
--- a/src/main/resources/mapper/JobDao.xml
+++ b/src/main/resources/mapper/JobDao.xml
@@ -6,17 +6,53 @@
 <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" />
+        <result column="owner_id"   property="orgId" javaType="java.lang.String" />
+        <result column="areacode"   property="areaCode" javaType="java.lang.String" />
+        <result column="monitorpoint"   property="monitorpointId" javaType="java.lang.String" />
+        <collection property="adjusts" column="id" javaType="java.util.List"  ofType="java.util.Map">
+		        <result column="mac_key" property="key" javaType="java.lang.String"/>  
+		        <result column="value" property="value" javaType="java.lang.Float"/>  
+        </collection>    
     </resultMap>
 
-    <select id="findAdjustByMac" resultMap="adjustResultMap">
-        select c.mac_key, d.`value`
+    <select id="findEquWithAdjustsByMac" resultMap="adjustResultMap">
+        select a.id,a.owner_id,a.monitorpoint,e.areacode,c.mac_key,d.`value`
         from equipment a
-        inner join mac b on a.id = b.equipment_id
+        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
+		left join monitorpoint e on e.id = a.monitorpoint
         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 history where mac=#{0} order by time DESC limit 1
+    </select>
+
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0