From 14ce5d2ccfae554497763da846ffb9eb39cd6d34 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期一, 23 九月 2019 12:55:26 +0800 Subject: [PATCH] 1. 修改实时数据各项的转换逻辑 --- src/main/kotlin/com/flightfeather/obd/repository/impl/DataStreamDaoImpl.kt | 62 +++++++++++++++++++++++++++++++ 1 files changed, 62 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 12d1583..927f206 100644 --- a/src/main/kotlin/com/flightfeather/obd/repository/impl/DataStreamDaoImpl.kt +++ b/src/main/kotlin/com/flightfeather/obd/repository/impl/DataStreamDaoImpl.kt @@ -2,13 +2,19 @@ import com.flightfeather.obd.domain.entity.DataStream import com.flightfeather.obd.domain.mapper.DataStreamMapper +import com.flightfeather.obd.lightshare.bean.DataStreamVo +import com.flightfeather.obd.lightshare.bean.LatLngVo import com.flightfeather.obd.repository.DataStreamRepository import com.flightfeather.obd.socket.bean.EngineDataStream import com.flightfeather.obd.socket.bean.ObdPackageData import com.flightfeather.obd.socket.bean.ReplacementData import com.flightfeather.obd.socket.bean.SupplementDataStream import com.flightfeather.obd.socket.eunm.ObdCommandUnit +import com.github.pagehelper.PageHelper +import org.springframework.beans.BeanUtils import org.springframework.stereotype.Repository +import tk.mybatis.mapper.entity.Example +import java.text.SimpleDateFormat /** * @author riku @@ -73,4 +79,60 @@ } } + override fun getDataStream(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<DataStreamVo> { + 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() + } + } + + //鍒嗛〉 + val offset = (pageSize?.times(pageNum?.minus(1) ?: 0)) ?: 0 + PageHelper.offsetPage<DataStream>(offset, pageSize ?: 10) + val result = dataStreamMapper.selectByExample(example) + + val resultList = mutableListOf<DataStreamVo>() + result.forEach { + val vo = DataStreamVo() + BeanUtils.copyProperties(it, vo) + resultList.add(vo) + } + + return resultList + } + + override fun getCoordinate(deviceCode: String): LatLngVo { + val example = Example(DataStream::class.java).apply { + createCriteria().andEqualTo("obdDeviceCode", deviceCode).run { + orderBy("obdDataTime").desc() + } + } + + //鑾峰彇鏈�鏂扮殑涓�涓� + PageHelper.offsetPage<DataStream>(0, 1) + val result = dataStreamMapper.selectByExample(example) + + val latLngVo = LatLngVo() + if (result.isNotEmpty()) { + result[0].let { + latLngVo.apply { + this.deviceCode = it.obdDeviceCode + obdDataTime = it.obdDataTime + lat = it.obdLat + lng = it.obdLong + } + } + } + + return latLngVo + } } \ No newline at end of file -- Gitblit v1.9.3