From fb1dc85a9ae6a9b8426ec5e29eb0139933ebe233 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期日, 29 九月 2019 11:22:24 +0800
Subject: [PATCH] 新增接口: 1. 获取某设备某时间段的数据流个数

---
 src/main/kotlin/com/flightfeather/obd/repository/impl/DataStreamDaoImpl.kt |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/obd/repository/impl/DataStreamDaoImpl.kt b/src/main/kotlin/com/flightfeather/obd/repository/impl/DataStreamDaoImpl.kt
index 927f206..a72cc1a 100644
--- a/src/main/kotlin/com/flightfeather/obd/repository/impl/DataStreamDaoImpl.kt
+++ b/src/main/kotlin/com/flightfeather/obd/repository/impl/DataStreamDaoImpl.kt
@@ -110,6 +110,25 @@
         return resultList
     }
 
+    override fun getDataStreamCount(deviceCode: String, startTime: String?, endTime: String?): Int {
+        val sf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
+        val example = Example(DataStream::class.java).apply {
+            createCriteria().andEqualTo("obdDeviceCode", deviceCode).run {
+                startTime?.let {
+                    val st = sf.parse(startTime)
+                    andGreaterThanOrEqualTo("obdDataTime", st)
+                }
+                endTime?.let {
+                    val et = sf.parse(endTime)
+                    andLessThanOrEqualTo("obdDataTime", et)
+                }
+                orderBy("obdDataTime").desc()
+            }
+        }
+
+        return dataStreamMapper.selectCountByExample(example)
+    }
+
     override fun getCoordinate(deviceCode: String): LatLngVo {
         val example = Example(DataStream::class.java).apply {
             createCriteria().andEqualTo("obdDeviceCode", deviceCode).run {

--
Gitblit v1.9.3