¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.obd.common |
| | | |
| | | /** |
| | | * @author riku |
| | | * Date: 2019/9/20 |
| | | */ |
| | | //å端设å¤ä¼ è¾çæ æå¼ |
| | | const val INVALID_DATA_4_BYTE = "FFFFFFFF" |
| | | const val INVALID_DATA_2_BYTE = "FFFF" |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.obd.lightshare.bean |
| | | |
| | | import java.util.* |
| | | |
| | | /** |
| | | * @author riku |
| | | * Date: 2019/9/19 |
| | | */ |
| | | class CarLoginVo : BaseJson() { |
| | | var id: Int? = null |
| | | var obdDeviceCode: String? = null |
| | | var loginCreateTime: Date? = null |
| | | var loginDataTime: Date? = null |
| | | var loginSerialNum: Int? = null |
| | | var loginSimCode: String? = null |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.obd.lightshare.bean |
| | | |
| | | import java.util.* |
| | | |
| | | /** |
| | | * @author riku |
| | | * Date: 2019/9/19 |
| | | */ |
| | | class CarLogoutVo : BaseJson() { |
| | | var id: Int? = null |
| | | var obdDeviceCode: String? = null |
| | | var loginCreateTime: Date? = null |
| | | var loginDataTime: Date? = null |
| | | var loginSerialNum: Int? = null |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.obd.lightshare.bean |
| | | |
| | | import java.util.* |
| | | |
| | | /** |
| | | * @author riku |
| | | * Date: 2019/9/19 |
| | | */ |
| | | class DataStreamVo : BaseJson() { |
| | | var id: Int?= null |
| | | var obdDeviceCode: String?= null |
| | | var obdCreateTime: Date?= null |
| | | var obdDataTime: Date?= null |
| | | var obdSerialNum: Int?= null |
| | | var obdSpeed: Double?= null |
| | | var obdAirPressure: Double?= null |
| | | var obdEngineTorque: Double?= null |
| | | var obdFrictionTorque: Double?= null |
| | | var obdEngineRpm: Double?= null |
| | | var obdEngineFuelFlow: Double?= null |
| | | var obdScrUpstreamNox: Double?= null |
| | | var obdScrDownstreamNox: Double?= null |
| | | var obdRemainReactant: Double?= null |
| | | var obdAirInput: Double?= null |
| | | var obdScrInputTemp: Double?= null |
| | | var obdScrOutputTemp: Double?= null |
| | | var obdDpf: Double?= null |
| | | var obdEngineCoolantTemp: Double?= null |
| | | var obdFuelLevel: Double?= null |
| | | var obdLocationStatus: String?= null |
| | | var obdLong: Double?= null |
| | | var obdLat: Double?= null |
| | | var obdTotalMileage: Double?= null |
| | | var obdEngineTorqueMode: Int?= null |
| | | var obdAcceleratorPedal: Double?= null |
| | | var obdTotalOilConsumption: Double?= null |
| | | var obdUreaBoxTemp: Double?= null |
| | | var obdUreaVolume: Double?= null |
| | | var obdTotalUreaConsume: Double?= null |
| | | var obdDpfTemp: Double?= null |
| | | var obdStatus: Boolean?= null |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.obd.lightshare.bean |
| | | |
| | | import java.util.* |
| | | |
| | | /** |
| | | * @author riku |
| | | * Date: 2019/9/19 |
| | | */ |
| | | class LatLngVo : BaseJson() { |
| | | var deviceCode: String? = null |
| | | var obdDataTime: Date?= null |
| | | var lat: Double? = null |
| | | var lng: Double? = null |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.obd.lightshare.bean |
| | | |
| | | import java.util.* |
| | | |
| | | /** |
| | | * @author riku |
| | | * Date: 2019/9/19 |
| | | */ |
| | | class ObdInfoVo : BaseJson() { |
| | | var id: Int?= null |
| | | var obdDeviceCode: String?= null |
| | | var obdCreateTime: Date?= null |
| | | var obdDataTime: Date?= null |
| | | var obdSerialNum: Int?= null |
| | | var obdProtocol: Int?= null |
| | | var obdMil: Int?= null |
| | | var obdDiagnosisSupportStatus: String?= null |
| | | var obdDiagnosisReadyStatus: String?= null |
| | | var obdVin: String?= null |
| | | var obdCrn: String?= null |
| | | var obdCvn: String?= null |
| | | var obdIupr: String?= null |
| | | var obdFaultCodeNum: Int?= null |
| | | var obdFaultCode: String?= null |
| | | var obdStatus: Boolean?= null |
| | | } |
| | |
| | | package com.flightfeather.obd.lightshare.service |
| | | |
| | | import com.flightfeather.obd.lightshare.bean.ObdDataVo |
| | | import com.flightfeather.obd.lightshare.bean.* |
| | | |
| | | /** |
| | | * @author riku |
| | |
| | | */ |
| | | fun getDataByVinCode(vinCode: String, pageNum: Int?, pageSize: Int?): MutableList<ObdDataVo> |
| | | |
| | | /** |
| | | * æ ¹æ®ç»ç«¯è®¾å¤ç è·åç»å½æ°æ® |
| | | */ |
| | | fun getLoginData(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<CarLoginVo> |
| | | |
| | | /** |
| | | * æ ¹æ®ç»ç«¯è®¾å¤ç è·åç»åºæ°æ® |
| | | */ |
| | | fun getLogoutData(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<CarLogoutVo> |
| | | |
| | | /** |
| | | * æ ¹æ®ç»ç«¯è®¾å¤ç è·åobdæ°æ® |
| | | */ |
| | | fun getObdInfo(deviceCode: String, pageNum: Int?, pageSize: Int?): List<ObdInfoVo> |
| | | |
| | | /** |
| | | * æ ¹æ®ç»ç«¯è®¾å¤ç è·åæ°æ®æµæ°æ® |
| | | */ |
| | | fun getDataStream(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<DataStreamVo> |
| | | |
| | | /** |
| | | * æ ¹æ®ç»ç«¯è®¾å¤ç è·åææ°ç»çº¬åº¦ |
| | | */ |
| | | fun getCoordinate(deviceCode: String): LatLngVo |
| | | |
| | | } |
| | |
| | | package com.flightfeather.obd.lightshare.service.impl |
| | | |
| | | import com.flightfeather.obd.lightshare.bean.ObdDataVo |
| | | import com.flightfeather.obd.lightshare.bean.* |
| | | import com.flightfeather.obd.lightshare.service.ObdDataService |
| | | import com.flightfeather.obd.repository.ObdDataRepository |
| | | import com.flightfeather.obd.repository.* |
| | | import org.springframework.stereotype.Service |
| | | |
| | | /** |
| | |
| | | * Date: 2019/8/27 |
| | | */ |
| | | @Service |
| | | class ObdDataServiceImpl(val obdDataRepository: ObdDataRepository) : ObdDataService { |
| | | class ObdDataServiceImpl( |
| | | val obdDataRepository: ObdDataRepository, |
| | | val carLoginRepository: CarLoginRepository, |
| | | val carLogoutRepository: CarLogoutRepository, |
| | | val obdInfoRepository: ObdInfoRepository, |
| | | val dataStreamRepository: DataStreamRepository |
| | | ) : ObdDataService { |
| | | |
| | | override fun getDataByVinCode(vinCode: String, pageNum: Int?, pageSize: Int?): MutableList<ObdDataVo> { |
| | | return obdDataRepository.getDataByVinCode(vinCode, pageNum, pageSize) |
| | | } |
| | | override fun getDataByVinCode(vinCode: String, pageNum: Int?, pageSize: Int?): MutableList<ObdDataVo> |
| | | = obdDataRepository.getDataByVinCode(vinCode, pageNum, pageSize) |
| | | |
| | | override fun getLoginData(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<CarLoginVo> |
| | | = carLoginRepository.getLoginData(deviceCode, pageNum, pageSize, startTime, endTime) |
| | | |
| | | override fun getLogoutData(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<CarLogoutVo> |
| | | = carLogoutRepository.getLogoutData(deviceCode, pageNum, pageSize, startTime, endTime) |
| | | |
| | | override fun getObdInfo(deviceCode: String, pageNum: Int?, pageSize: Int?): List<ObdInfoVo> |
| | | = obdInfoRepository.getObdInfo(deviceCode, pageNum, pageSize) |
| | | |
| | | override fun getDataStream(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<DataStreamVo> |
| | | = dataStreamRepository.getDataStream(deviceCode, pageNum, pageSize, startTime, endTime) |
| | | |
| | | override fun getCoordinate(deviceCode: String): LatLngVo |
| | | = dataStreamRepository.getCoordinate(deviceCode) |
| | | } |
| | |
| | | @RequestParam("page", required = false) pageNum: Int?, |
| | | @RequestParam("per_page", required = false) pageSize: Int? |
| | | ) = obdDataService.getDataByVinCode(vinCode, pageNum, pageSize) |
| | | |
| | | @GetMapping("/login/{deviceCode}") |
| | | fun getLoginData( |
| | | @PathVariable("deviceCode") deviceCode: String, |
| | | @RequestParam("page", required = false) pageNum: Int?, |
| | | @RequestParam("per_page", required = false) pageSize: Int?, |
| | | @RequestParam("startTime", required = false) startTime: String?, |
| | | @RequestParam("endTime", required = false) endTime: String? |
| | | ) = obdDataService.getLoginData(deviceCode, pageNum, pageSize, startTime, endTime) |
| | | |
| | | @GetMapping("/logout/{deviceCode}") |
| | | fun getLogoutData( |
| | | @PathVariable("deviceCode") deviceCode: String, |
| | | @RequestParam("page", required = false) pageNum: Int?, |
| | | @RequestParam("per_page", required = false) pageSize: Int?, |
| | | @RequestParam("startTime", required = false) startTime: String?, |
| | | @RequestParam("endTime", required = false) endTime: String? |
| | | ) = obdDataService.getLogoutData(deviceCode, pageNum, pageSize, startTime, endTime) |
| | | |
| | | @GetMapping("/obdInfo/{deviceCode}") |
| | | fun getObdInfo( |
| | | @PathVariable("deviceCode") deviceCode: String, |
| | | @RequestParam("page", required = false) pageNum: Int?, |
| | | @RequestParam("per_page", required = false) pageSize: Int? |
| | | ) = obdDataService.getObdInfo(deviceCode, pageNum, pageSize) |
| | | |
| | | @GetMapping("/dataStream/{deviceCode}") |
| | | fun getDataStream( |
| | | @PathVariable("deviceCode") deviceCode: String, |
| | | @RequestParam("page", required = false) pageNum: Int?, |
| | | @RequestParam("per_page", required = false) pageSize: Int?, |
| | | @RequestParam("startTime", required = false) startTime: String?, |
| | | @RequestParam("endTime", required = false) endTime: String? |
| | | ) = obdDataService.getDataStream(deviceCode, pageNum, pageSize, startTime, endTime) |
| | | |
| | | @GetMapping("/coordinate/{deviceCode}") |
| | | fun getCoordinate( |
| | | @PathVariable("deviceCode") deviceCode: String |
| | | ) = obdDataService.getCoordinate(deviceCode) |
| | | } |
| | |
| | | package com.flightfeather.obd.repository |
| | | |
| | | import com.flightfeather.obd.lightshare.bean.CarLoginVo |
| | | import com.flightfeather.obd.socket.bean.ObdPackageData |
| | | |
| | | /** |
| | |
| | | * ä¿å车è¾ç»å
¥ä¿¡æ¯ |
| | | */ |
| | | fun saveCarLogin(packageData: ObdPackageData): Boolean |
| | | |
| | | /** |
| | | * æ ¹æ®ç»ç«¯è®¾å¤ç è·åç»å½æ°æ® |
| | | */ |
| | | fun getLoginData(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<CarLoginVo> |
| | | } |
| | |
| | | package com.flightfeather.obd.repository |
| | | |
| | | import com.flightfeather.obd.lightshare.bean.CarLogoutVo |
| | | import com.flightfeather.obd.socket.bean.ObdPackageData |
| | | |
| | | /** |
| | |
| | | * ä¿å 车è¾ç»åºå
¥ä¿¡æ¯ |
| | | */ |
| | | fun saveCarLogout(packageData: ObdPackageData): Boolean |
| | | |
| | | /** |
| | | * æ ¹æ®ç»ç«¯è®¾å¤ç è·åç»åºæ°æ® |
| | | */ |
| | | fun getLogoutData(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<CarLogoutVo> |
| | | } |
| | |
| | | package com.flightfeather.obd.repository |
| | | |
| | | import com.flightfeather.obd.lightshare.bean.DataStreamVo |
| | | import com.flightfeather.obd.lightshare.bean.LatLngVo |
| | | import com.flightfeather.obd.socket.bean.ObdPackageData |
| | | |
| | | /** |
| | |
| | | * ä¿å 宿¶ä¿¡æ¯æè¡¥ä¼ ä¿¡æ¯ ä¸ç æ°æ®æµä¿¡æ¯ å è¡¥å
æ°æ®æµ |
| | | */ |
| | | fun saveDataStream(packageData: ObdPackageData): Boolean |
| | | |
| | | /** |
| | | * æ ¹æ®ç»ç«¯è®¾å¤ç è·åæ°æ®æµæ°æ® |
| | | */ |
| | | fun getDataStream(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<DataStreamVo> |
| | | |
| | | /** |
| | | * æ ¹æ®ç»ç«¯è®¾å¤ç è·åææ°ç»çº¬åº¦ |
| | | */ |
| | | fun getCoordinate(deviceCode: String): LatLngVo |
| | | } |
| | |
| | | package com.flightfeather.obd.repository |
| | | |
| | | import com.flightfeather.obd.lightshare.bean.ObdInfoVo |
| | | import com.flightfeather.obd.socket.bean.ObdInfo |
| | | import com.flightfeather.obd.socket.bean.ObdPackageData |
| | | import com.flightfeather.obd.socket.bean.RealTimeData |
| | |
| | | * ä¿å 宿¶ä¿¡æ¯ @see [RealTimeData] æè¡¥ä¼ ä¿¡æ¯ @see [ReplacementData] ä¸ç obd æ°æ® @see [ObdInfo] |
| | | */ |
| | | fun saveObdInfo(packageData: ObdPackageData): Boolean |
| | | |
| | | /** |
| | | * æ ¹æ®ç»ç«¯è®¾å¤ç è·åobdæ°æ® |
| | | */ |
| | | fun getObdInfo(deviceCode: String, pageNum: Int?, pageSize: Int?): List<ObdInfoVo> |
| | | } |
| | |
| | | |
| | | import com.flightfeather.obd.domain.entity.CarLogin |
| | | import com.flightfeather.obd.domain.mapper.CarLoginMapper |
| | | import com.flightfeather.obd.lightshare.bean.CarLoginVo |
| | | import com.flightfeather.obd.repository.CarLoginRepository |
| | | import com.flightfeather.obd.socket.bean.CarRegisterData |
| | | 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 |
| | |
| | | false |
| | | } |
| | | } |
| | | |
| | | override fun getLoginData(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<CarLoginVo> { |
| | | val example = Example(CarLogin::class.java).apply { |
| | | createCriteria().andEqualTo("obdDeviceCode", deviceCode).run { |
| | | startTime?.let { andGreaterThanOrEqualTo("loginDataTime", it) } |
| | | endTime?.let { andLessThanOrEqualTo("loginDataTime", it) } |
| | | orderBy("loginDataTime").desc() |
| | | } |
| | | } |
| | | |
| | | //å页 |
| | | val offset = (pageSize?.times(pageNum?.minus(1) ?: 0)) ?: 0 |
| | | PageHelper.offsetPage<CarLogin>(offset, pageSize ?: 10) |
| | | val result = carLoginMapper.selectByExample(example) |
| | | |
| | | val resultList = mutableListOf<CarLoginVo>() |
| | | result.forEach { |
| | | val vo = CarLoginVo() |
| | | BeanUtils.copyProperties(it, vo) |
| | | resultList.add(vo) |
| | | } |
| | | |
| | | return resultList |
| | | } |
| | | } |
| | |
| | | |
| | | import com.flightfeather.obd.domain.entity.CarLogout |
| | | import com.flightfeather.obd.domain.mapper.CarLogoutMapper |
| | | import com.flightfeather.obd.lightshare.bean.CarLogoutVo |
| | | import com.flightfeather.obd.repository.CarLogoutRepository |
| | | import com.flightfeather.obd.socket.bean.CarLogOutData |
| | | 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 |
| | |
| | | false |
| | | } |
| | | } |
| | | |
| | | override fun getLogoutData(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<CarLogoutVo> { |
| | | val example = Example(CarLogout::class.java).apply { |
| | | createCriteria().andEqualTo("obdDeviceCode", deviceCode).run { |
| | | startTime?.let { andGreaterThanOrEqualTo("loginDataTime", it) } |
| | | endTime?.let { andLessThanOrEqualTo("loginDataTime", it) } |
| | | orderBy("loginDataTime").desc() |
| | | } |
| | | } |
| | | |
| | | //å页 |
| | | val offset = (pageSize?.times(pageNum?.minus(1) ?: 0)) ?: 0 |
| | | PageHelper.offsetPage<CarLogout>(offset, pageSize ?: 10) |
| | | val result = carLogoutMapper.selectByExample(example) |
| | | |
| | | val resultList = mutableListOf<CarLogoutVo>() |
| | | result.forEach { |
| | | val vo = CarLogoutVo() |
| | | BeanUtils.copyProperties(it, vo) |
| | | resultList.add(vo) |
| | | } |
| | | |
| | | return resultList |
| | | } |
| | | } |
| | |
| | | |
| | | 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 |
| | |
| | | } |
| | | } |
| | | |
| | | 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 |
| | | } |
| | | } |
| | |
| | | |
| | | 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 |
| | |
| | | } 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 |
| | | } |
| | | } |
| | |
| | | import com.flightfeather.obd.socket.decoder.DataUnitDecoder |
| | | import com.flightfeather.obd.socket.decoder.RealTimeDataDecoder |
| | | import com.flightfeather.obd.socket.eunm.ObdDataType |
| | | import org.slf4j.LoggerFactory |
| | | import java.lang.StringBuilder |
| | | import java.util.* |
| | | |
| | |
| | | */ |
| | | class DataUnitDecoderImpl : DataUnitDecoder { |
| | | |
| | | private val logger = LoggerFactory.getLogger(javaClass.name) |
| | | private var realTimeDataDecoder: RealTimeDataDecoder = RealTimeDataDecoderImpl() |
| | | |
| | | override fun getCarRegisterData(b: List<String>): List<CarRegisterData> { |
| | |
| | | } |
| | | }else if (dataList.isNotEmpty()) { |
| | | //æç
§è§å没æåå°ä¿¡æ¯ä½ï¼å¹¶ä¸åæ°æ®ä¸ä¸ºç©ºï¼è¡¨ç¤ºåæ°æ®æ ¼å¼é误ï¼éåºå¾ªç¯ |
| | | // break |
| | | logger.error("-------æ°æ®ä¿¡æ¯æµæè¡¥å
æ°æ®æµæ ¼å¼é误") |
| | | break |
| | | } |
| | | } |
| | | |
| | |
| | | package com.flightfeather.obd.socket.decoder.impl |
| | | |
| | | import com.flightfeather.obd.common.INVALID_DATA_4_BYTE |
| | | import com.flightfeather.obd.socket.bean.EngineDataStream |
| | | import com.flightfeather.obd.socket.bean.ObdInfo |
| | | import com.flightfeather.obd.socket.bean.SupplementDataStream |
| | |
| | | |
| | | return if (dataList.size >= 37) { |
| | | EngineDataStream(time, serialNum).apply { |
| | | obdSpeed = "${dataList[0]}${dataList[1]}".toIntOrNull(16)?.toDouble()?.times((1 / 256).toDouble()) |
| | | obdSpeed = "${dataList[0]}${dataList[1]}".toIntOrNull(16)?.toDouble()?.div(256) |
| | | obdAirPressure = dataList[2].toIntOrNull(16)?.toDouble()?.times(0.5) |
| | | obdEngineTorque = dataList[3].toIntOrNull(16)?.minus(125)?.toDouble()?.div(100) |
| | | obdFrictionTorque = dataList[4].toIntOrNull(16)?.minus(125)?.toDouble()?.div(100) |
| | | obdEngineRpm = "${dataList[5]}${dataList[6]}".toIntOrNull(16)?.toDouble()?.times(0.125) |
| | | obdEngineFuelFlow = "${dataList[7]}${dataList[8]}".toIntOrNull(16)?.toDouble()?.times(0.05) |
| | | obdScrUpstreamNox = "${dataList[9]}${dataList[10]}".toIntOrNull(16)?.minus(200)?.toDouble()?.times(0.05) |
| | | obdScrDownstreamNox = "${dataList[11]}${dataList[12]}".toIntOrNull(16)?.minus(200)?.toDouble()?.times(0.05) |
| | | obdScrUpstreamNox = "${dataList[9]}${dataList[10]}".toIntOrNull(16)?.times(0.05)?.minus(200) |
| | | obdScrDownstreamNox = "${dataList[11]}${dataList[12]}".toIntOrNull(16)?.times(0.05)?.minus(200) |
| | | obdRemainReactant = dataList[13].toIntOrNull(16)?.toDouble()?.times(0.4)?.div(100) |
| | | obdAirInput = "${dataList[14]}${dataList[15]}".toIntOrNull(16)?.toDouble()?.times(0.05) |
| | | obdScrInputTemp = "${dataList[16]}${dataList[17]}".toIntOrNull(16)?.minus(273)?.toDouble()?.times(0.03125) |
| | | obdScrOutputTemp = "${dataList[18]}${dataList[19]}".toIntOrNull(16)?.minus(273)?.toDouble()?.times(0.03125) |
| | | obdScrInputTemp = "${dataList[16]}${dataList[17]}".toIntOrNull(16)?.times(0.03125)?.minus(273) |
| | | obdScrOutputTemp = "${dataList[18]}${dataList[19]}".toIntOrNull(16)?.times(0.03125)?.minus(273) |
| | | obdDpf = "${dataList[20]}${dataList[21]}".toIntOrNull(16)?.toDouble()?.times(0.1) |
| | | obdEngineCoolantTemp = dataList[22].toIntOrNull(16)?.minus(40)?.toDouble() |
| | | obdFuelLevel = dataList[23].toIntOrNull(16)?.toDouble()?.times(0.4) |
| | | obdLocationStatus = dataList[24].toIntOrNull(16) |
| | | obdLong = "${dataList[25]}${dataList[26]}${dataList[27]}${dataList[28]}".toIntOrNull(16)?.toDouble()?.times(0.000001) |
| | | obdLat = "${dataList[29]}${dataList[30]}${dataList[31]}${dataList[32]}".toIntOrNull(16)?.toDouble()?.times(0.000001) |
| | | obdTotalMileage = "${dataList[33]}${dataList[34]}${dataList[35]}${dataList[36]}".toIntOrNull(16)?.toDouble()?.times(0.1) |
| | | with("${dataList[25]}${dataList[26]}${dataList[27]}${dataList[28]}") { |
| | | obdLong = if (toUpperCase() == INVALID_DATA_4_BYTE) { -1.0 } else { toBigIntegerOrNull(16)?.toDouble()?.times(0.000001) } |
| | | } |
| | | with("${dataList[29]}${dataList[30]}${dataList[31]}${dataList[32]}") { |
| | | obdLat = if (toUpperCase() == INVALID_DATA_4_BYTE) { -1.0 } else { toBigIntegerOrNull(16)?.toDouble()?.times(0.000001) } |
| | | } |
| | | with("${dataList[33]}${dataList[34]}${dataList[35]}${dataList[36]}") { |
| | | obdTotalMileage = if (toUpperCase() == INVALID_DATA_4_BYTE) { -1.0 } else { toBigIntegerOrNull(16)?.toDouble()?.times(0.1) } |
| | | } |
| | | } |
| | | } else { |
| | | null |
| | |
| | | SupplementDataStream(time, serialNum).apply { |
| | | obdEngineTorqueMode = dataList[0].toIntOrNull(16) |
| | | obdAcceleratorPedal = dataList[1].toIntOrNull(16)?.toDouble()?.times(0.4)?.div(100) |
| | | obdTotalOilConsumption = "${dataList[2]}${dataList[3]}${dataList[4]}${dataList[5]}".toIntOrNull(16)?.toDouble()?.times(0.5) |
| | | with("${dataList[2]}${dataList[3]}${dataList[4]}${dataList[5]}") { |
| | | obdTotalOilConsumption = if (toUpperCase() == INVALID_DATA_4_BYTE) -1.0 else toBigIntegerOrNull(16)?.toDouble()?.times(0.5) |
| | | } |
| | | obdUreaBoxTemp = dataList[6].toIntOrNull(16)?.toDouble()?.minus(40) |
| | | obdUreaVolume = "${dataList[7]}${dataList[8]}${dataList[9]}${dataList[10]}".toIntOrNull(16)?.toDouble()?.times(0.01) |
| | | obdTotalUreaConsume = "${dataList[11]}${dataList[12]}${dataList[13]}${dataList[14]}".toIntOrNull(16)?.toDouble() |
| | | obdDpfTemp = "${dataList[15]}${dataList[16]}".toIntOrNull(16)?.minus(273)?.toDouble()?.times(0.03125) |
| | | with("${dataList[7]}${dataList[8]}${dataList[9]}${dataList[10]}") { |
| | | obdUreaVolume = if (toUpperCase() == INVALID_DATA_4_BYTE) -1.0 else toBigIntegerOrNull(16)?.toDouble()?.times(0.01) |
| | | } |
| | | with("${dataList[11]}${dataList[12]}${dataList[13]}${dataList[14]}") { |
| | | obdTotalUreaConsume = if (toUpperCase() == INVALID_DATA_4_BYTE) -1.0 else toBigIntegerOrNull(16)?.toDouble() |
| | | } |
| | | obdDpfTemp = "${dataList[15]}${dataList[16]}".toIntOrNull(16)?.times(0.03125)?.minus(273) |
| | | } |
| | | } else { |
| | | null |
| | |
| | | when (list[0].toIntOrNull(16)) { |
| | | ObdDataType.ObdData.value -> { |
| | | |
| | | //ä»èµ·å§åè 1 å¼å§ï¼åºå®æ97个åèçæ°æ® |
| | | if (list.size >= 97) { |
| | | //ä»èµ·å§åè 1 å¼å§ï¼åºå®æ96个åèçæ°æ® |
| | | for (i in 1..96) { |
| | | resultList.add(list[i]) |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ObdDataType.EngineDataFlow.value -> { |
| | | |
| | | if (list.size >= 38) { |
| | | //ä»èµ·å§åè 1 å¼å§ï¼åºå®æ37个åèçæ°æ® |
| | | for (i in 1..37) { |
| | | resultList.add(list[i]) |
| | | } |
| | | } |
| | | } |
| | | ObdDataType.SupplementDataFlow.value -> { |
| | | |
| | | if (list.size>= 18) { |
| | | //ä»èµ·å§åè 1 å¼å§ï¼åºå®æ17个åèçæ°æ® |
| | | for (i in 1..17) { |
| | | resultList.add(list[i]) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return resultList |
| | | } |
| | |
| | | spring: |
| | | datasource: |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | | url: jdbc:mysql://47.100.191.150:3306/obd?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false |
| | | username: obd |
| | | password: obd2019 |
| | | url: jdbc:mysql://192.168.0.200:3306/obd?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false |
| | | username: root |
| | | password: cn.FLIGHTFEATHER |
| | | |
| | | mybatis: |
| | | type-aliases-package: com.flightfeather.obd.domain.entity |
| | |
| | | |
| | | @Test |
| | | fun f0012() { |
| | | ByteArray(3).forEach { |
| | | println(it) |
| | | return |
| | | } |
| | | |
| | | println("end") |
| | | val a = "80ffffff".toBigInteger(16) |
| | | val b = a?.toDouble() |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | @Test |
| | | fun decode() { |
| | | val msg = "23 23 02 31 37 36 39 31 35 33 31 39 30 39 31 32 30 30 30 32 01 01 00 85 13 09 12 15 01 2d 00 08 01 00 01 60 00 00 00 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 07 00 00 04 20 00 00 04 20 00 00 c1 13 00 00 00 73 00 00 30 28 00 00 30 25 00 00 30 56 1d" |
| | | val msg = "23 23 02 31 37 36 39 31 35 33 31 39 30 39 31 32 30 30 31 36 01 01 00 40 13 09 17 09 05 29 00 cd 02 17 00 da fd ff 12 c0 ff ff 00 c8 04 ec ff 15 a9 ff ff ff ff ff ff 73 00 00 07 43 ec 88 01 d6 de cc ff ff ff ff 80 ff 00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff f6" |
| | | val msg2 = "23 23 02 31 37 36 39 31 35 33 31 39 30 39 31 32 30 30 30 36 01 01 00 42 13 09 11 08 3b 36 02 00 3b 00 00 d4 00 00 12 c0 09 5e 00 c8 00 c8 00 15 a9 00 00 00 00 00 00 73 00 00 00 b9 1b c7 00 2e e1 25 00 00 00 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 dc" |
| | | val packageData = vehicleDataDecoder.decode(msg) |
| | | |