From 052c104cbc2ccc13d83cd912e3b2bbf12c0d56bc Mon Sep 17 00:00:00 2001
From: 沈斌 <bluelazysb@hotmail.com>
Date: Fri, 27 Oct 2017 16:00:32 +0800
Subject: [PATCH] 批量更新,提升性能

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

diff --git a/src/main/resources/mapper/JobDao.xml b/src/main/resources/mapper/JobDao.xml
index 9bd84af..a2ff267 100644
--- a/src/main/resources/mapper/JobDao.xml
+++ b/src/main/resources/mapper/JobDao.xml
@@ -23,4 +23,22 @@
         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>
+
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0