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/ObdInfoDaoImpl.kt | 26 +++++++++++++++++++++++++- 1 files changed, 25 insertions(+), 1 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/obd/repository/impl/ObdInfoDaoImpl.kt b/src/main/kotlin/com/flightfeather/obd/repository/impl/ObdInfoDaoImpl.kt index 99fe315..69d464f 100644 --- a/src/main/kotlin/com/flightfeather/obd/repository/impl/ObdInfoDaoImpl.kt +++ b/src/main/kotlin/com/flightfeather/obd/repository/impl/ObdInfoDaoImpl.kt @@ -2,10 +2,14 @@ import com.flightfeather.obd.domain.entity.ObdInfo import com.flightfeather.obd.domain.mapper.ObdInfoMapper +import com.flightfeather.obd.lightshare.bean.ObdInfoVo import com.flightfeather.obd.repository.ObdInfoRepository import com.flightfeather.obd.socket.bean.ObdPackageData 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 /** * @author riku @@ -49,7 +53,27 @@ } else { false } - } + override fun getObdInfo(deviceCode: String, pageNum: Int?, pageSize: Int?): List<ObdInfoVo> { + val example = Example(ObdInfo::class.java).apply { + createCriteria().andEqualTo("obdDeviceCode", deviceCode).run { + orderBy("obdDataTime").desc() + } + } + + //鍒嗛〉 + val offset = (pageSize?.times(pageNum?.minus(1) ?: 0)) ?: 0 + PageHelper.offsetPage<ObdInfo>(offset, pageSize ?: 10) + val result = obdInfoMapper.selectByExample(example) + + val resultList = mutableListOf<ObdInfoVo>() + result.forEach { + val vo = ObdInfoVo() + BeanUtils.copyProperties(it, vo) + resultList.add(vo) + } + + return resultList + } } \ No newline at end of file -- Gitblit v1.9.3