riku
2019-09-29 fb1dc85a9ae6a9b8426ec5e29eb0139933ebe233
新增接口:
1. 获取某设备某时间段的数据流个数
已修改5个文件
42 ■■■■■ 文件已修改
src/main/kotlin/com/flightfeather/obd/lightshare/service/ObdDataService.kt 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/obd/lightshare/service/impl/ObdDataServiceImpl.kt 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/obd/lightshare/web/ObdDataController.kt 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/obd/repository/DataStreamRepository.kt 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/obd/repository/impl/DataStreamDaoImpl.kt 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/obd/lightshare/service/ObdDataService.kt
@@ -34,8 +34,16 @@
    fun getDataStream(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<DataStreamVo>
    /**
     * 根据终端设备码获取数据流数据计数
     */
    fun getDataStreamCount(deviceCode: String, startTime: String?, endTime: String?): Int
    /**
     * 根据终端设备码获取最新经纬度
     */
    fun getCoordinate(deviceCode: String): LatLngVo
    /**
     * 根据终端设备码及时间段,给出此段时间内
     */
}
src/main/kotlin/com/flightfeather/obd/lightshare/service/impl/ObdDataServiceImpl.kt
@@ -33,6 +33,9 @@
    override fun getDataStream(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<DataStreamVo>
            = dataStreamRepository.getDataStream(deviceCode, pageNum, pageSize, startTime, endTime)
    override fun getDataStreamCount(deviceCode: String, startTime: String?, endTime: String?): Int
            = dataStreamRepository.getDataStreamCount(deviceCode, startTime, endTime)
    override fun getCoordinate(deviceCode: String): LatLngVo
            = dataStreamRepository.getCoordinate(deviceCode)
}
src/main/kotlin/com/flightfeather/obd/lightshare/web/ObdDataController.kt
@@ -52,6 +52,13 @@
            @RequestParam("endTime", required = false) endTime: String?
    ) = obdDataService.getDataStream(deviceCode, pageNum, pageSize, startTime, endTime)
    @GetMapping("/dataStream/count")
    fun getDataStreamCount(
            @RequestParam("deviceCode") deviceCode: String = "",
            @RequestParam("startTime", required = false) startTime: String?,
            @RequestParam("endTime", required = false) endTime: String?
    ) = obdDataService.getDataStreamCount(deviceCode, startTime, endTime)
    @GetMapping("/coordinate/{deviceCode}")
    fun getCoordinate(
            @PathVariable("deviceCode") deviceCode: String
src/main/kotlin/com/flightfeather/obd/repository/DataStreamRepository.kt
@@ -21,6 +21,11 @@
    fun getDataStream(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<DataStreamVo>
    /**
     * 根据终端设备码获取数据流数据计数
     */
    fun getDataStreamCount(deviceCode: String, startTime: String?, endTime: String?): Int
    /**
     * 根据终端设备码获取最新经纬度
     */
    fun getCoordinate(deviceCode: String): LatLngVo
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 {