| | |
| | | fun getCoordinate(deviceCode: String): LatLngVo |
| | | |
| | | /** |
| | | * 根据终端设备码以及时长t 获取t之前到现在的所有轨迹坐标 |
| | | */ |
| | | fun getTrack(deviceCode: String, startTime: String, endTime: String): List<LatLngVo> |
| | | |
| | | /** |
| | | * 获取最新的车辆坐标信息 |
| | | */ |
| | | fun getLatestCoordinate(pageNum: Int?, pageSize: Int?): List<LatLngVo> |
| | |
| | | override fun getDataStreamCount(deviceCode: String, startTime: String?, endTime: String?): Int |
| | | = dataStreamRepository.getDataStreamCount(deviceCode, startTime, endTime) |
| | | |
| | | override fun getCoordinate(deviceCode: String): LatLngVo |
| | | = dataStreamRepository.getCoordinate(deviceCode) |
| | | override fun getCoordinate(deviceCode: String): LatLngVo{ |
| | | val latLngVo = LatLngVo() |
| | | dataStreamRepository.getLatestDataStream(deviceCode)?.let { |
| | | latLngVo.apply { |
| | | this.deviceCode = it.obdDeviceCode |
| | | obdDataTime = it.obdDataTime |
| | | lat = it.obdLat |
| | | lng = it.obdLong |
| | | } |
| | | } |
| | | |
| | | return latLngVo |
| | | } |
| | | |
| | | override fun getTrack(deviceCode: String, startTime: String, endTime: String): List<LatLngVo> { |
| | | val resultList = mutableListOf<LatLngVo>() |
| | | //2019.10.30 目前前端安卓设定最长获取的时长为6小时前至现在的数据,按照obd 每10秒中产生一条数据,最多4 * 360 = 1440 条 |
| | | dataStreamRepository.getDataStream(deviceCode, 1, 1500, startTime, endTime).forEach { |
| | | val latLngVo = LatLngVo().apply { |
| | | this.deviceCode = it.obdDeviceCode |
| | | obdDataTime = it.obdDataTime |
| | | lat = it.obdLat |
| | | lng = it.obdLong |
| | | } |
| | | resultList.add(latLngVo) |
| | | } |
| | | return resultList |
| | | } |
| | | |
| | | override fun getLatestCoordinate(pageNum: Int?, pageSize: Int?): List<LatLngVo> { |
| | | val resultList = mutableListOf<LatLngVo>() |
| | |
| | | |
| | | import com.flightfeather.obd.lightshare.service.ObdDataService |
| | | import org.springframework.web.bind.annotation.* |
| | | import java.time.Duration |
| | | |
| | | /** |
| | | * @author riku |
| | |
| | | @PathVariable("deviceCode") deviceCode: String |
| | | ) = obdDataService.getCoordinate(deviceCode) |
| | | |
| | | @GetMapping("/coordinate/track") |
| | | fun getTrack( |
| | | @RequestParam("deviceCode") deviceCode: String, |
| | | @RequestParam("startTime") startTime: String, |
| | | @RequestParam("endTime") endTime: String |
| | | ) = obdDataService.getTrack(deviceCode, startTime, endTime) |
| | | |
| | | @GetMapping("/coordinate/latest") |
| | | fun getCoordinate( |
| | | @RequestParam("page", required = false) pageNum: Int?, |
| | |
| | | fun getDataStreamCount(deviceCode: String, startTime: String?, endTime: String?): Int |
| | | |
| | | /** |
| | | * 根据终端设备码获取最新经纬度 |
| | | */ |
| | | fun getCoordinate(deviceCode: String): LatLngVo |
| | | |
| | | /** |
| | | * 获取一辆车最新的一条状态信息 |
| | | */ |
| | | fun getLatestDataStream(deviceCode: String): DataStream? |
| | |
| | | import org.springframework.stereotype.Repository |
| | | import tk.mybatis.mapper.entity.Example |
| | | import java.text.SimpleDateFormat |
| | | import java.util.* |
| | | |
| | | /** |
| | | * @author riku |
| | |
| | | } |
| | | |
| | | override fun getDataStreamCount(deviceCode: String, startTime: String?, endTime: String?): Int { |
| | | val sf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") |
| | | val sf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA) |
| | | val example = Example(DataStream::class.java).apply { |
| | | createCriteria().andEqualTo("obdDeviceCode", deviceCode).run { |
| | | startTime?.let { |
| | |
| | | } |
| | | |
| | | return dataStreamMapper.selectCountByExample(example) |
| | | } |
| | | |
| | | 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 |
| | | } |
| | | |
| | | override fun getLatestDataStream(deviceCode: String): DataStream? { |