From c34ac6ee5f8aa80dff5026f0f38c26215fbd37c5 Mon Sep 17 00:00:00 2001
From: 沈斌 <bluelazysb@hotmail.com>
Date: Tue, 07 Nov 2017 08:55:41 +0800
Subject: [PATCH] insert hostory data to mongo

---
 src/main/resources/mapper/JobDao.xml |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/src/main/resources/mapper/JobDao.xml b/src/main/resources/mapper/JobDao.xml
index 1e091e1..d4baa19 100644
--- a/src/main/resources/mapper/JobDao.xml
+++ b/src/main/resources/mapper/JobDao.xml
@@ -19,4 +19,34 @@
         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