| | |
| | | import com.flightfeather.obd.domain.mapper.ObdDataMapper |
| | | import com.flightfeather.obd.lightshare.bean.ObdDataVo |
| | | import com.flightfeather.obd.repository.ObdDataRepository |
| | | import com.flightfeather.obd.socket.bean.* |
| | | import com.flightfeather.obd.socket.eunm.ObdCommandUnit |
| | | import com.github.pagehelper.PageHelper |
| | | import org.springframework.beans.BeanUtils |
| | | import org.springframework.stereotype.Repository |
| | |
| | | @Repository |
| | | class ObdDataDaoImpl(val obdDataMapper: ObdDataMapper) : ObdDataRepository { |
| | | |
| | | override fun saveObdData(data: ObdDataVo) { |
| | | override fun saveObdData(data: ObdDataVo): Boolean { |
| | | val obdData = ObdData() |
| | | BeanUtils.copyProperties(data, obdData) |
| | | obdDataMapper.insert(obdData) |
| | | return obdDataMapper.insert(obdData) == 1 |
| | | } |
| | | |
| | | override fun getDataByVinCode(vinCode: String, pageNum: Int?, pageSize: Int?): MutableList<ObdDataVo> { |
| | |
| | | |
| | | //分页 |
| | | val offset = (pageSize?.times(pageNum?.minus(1) ?: 0)) ?: 0 |
| | | val a = PageHelper.offsetPage<ObdData>(offset, pageSize ?: 10) |
| | | PageHelper.offsetPage<ObdData>(offset, pageSize ?: 10) |
| | | val result = obdDataMapper.selectByExample(example) |
| | | |
| | | val resultList = mutableListOf<ObdDataVo>() |
| | |
| | | |
| | | return resultList |
| | | } |
| | | |
| | | override fun saveObdData(packageData: ObdPackageData): Boolean { |
| | | val obdData = ObdData().apply { |
| | | obdVin = packageData.deviceCode |
| | | } |
| | | when (packageData.commandUnit) { |
| | | ObdCommandUnit.CarRegister.value -> { |
| | | packageData.dataUnit.forEach { |
| | | when (it) { |
| | | is CarRegisterData -> { |
| | | obdData.apply { |
| | | obdTime = it.time |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ObdCommandUnit.RealTimeData.value, |
| | | ObdCommandUnit.ReplacementData.value -> { |
| | | packageData.dataUnit.forEach { |
| | | when (it) { |
| | | is com.flightfeather.obd.socket.bean.ObdData -> { |
| | | obdData.apply { |
| | | obdTime = it.time |
| | | obdProtocol = it.obdProtocol |
| | | obdMil = it.obdMil |
| | | obdIdCode = it.obdCrn |
| | | obdVerificationCode = it.obdCvn |
| | | obdFaultCodeNum = it.obdFaultCodeNum |
| | | obdFaultCode = it.obdFaultCode |
| | | } |
| | | } |
| | | is EngineDataStream -> { |
| | | obdData.apply { |
| | | obdTime = it.time |
| | | obdLng = it.obdLong |
| | | obdLat = it.obdLat |
| | | obdSpeed = it.obdSpeed?.toInt() |
| | | obdAirPressure = it.obdAirPressure |
| | | obdEngineTorque = it.obdEngineTorque |
| | | obdFrictionTorque = it.obdFrictionTorque |
| | | obdEngineRpm = it.obdEngineRpm?.toInt() |
| | | obdStartFuelFlow = it.obdEngineFuelFlow |
| | | obdScrUpstreamNo = it.obdScrUpstreamNo |
| | | obdScrDownstreamNo = it.obdScrDownstreamNo |
| | | obdRemainReactant = it.obdRemainReactant |
| | | obdAirInput = it.obdAirInput |
| | | obdScrInputTemp = it.obdScrInputTemp |
| | | obdScrOutputTemp = it.obdScrOutputTemp |
| | | obdDpf = it.obdDpf |
| | | obdEngineCoolantTemp = it.obdEngineCoolantTemp |
| | | obdFuelLevel = it.obdFuelLevel |
| | | obdLocationStatus = it.obdLocationStatus |
| | | obdTotalMileage = it.obdTotalMileage |
| | | } |
| | | } |
| | | is SupplementDataStream -> { |
| | | obdData.apply { |
| | | obdTime = it.time |
| | | obdEngineTorqueMode = it.obdEngineTorqueMode?.toString() |
| | | obdAcceleratorPedal = it.obdAcceleratorPedal |
| | | obdTotalOilConsumption = it.obdTotalOilConsumption |
| | | obdUreaBoxTemp = it.obdUreaBoxTemp |
| | | obdUreaVolume = it.obdUreaVolume?.toInt() |
| | | obdTotalUreaConsume = it.obdTotalUreaConsume |
| | | obdDpfTemp = it.obdDpfTemp |
| | | // obdFirmwareVersion = |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | ObdCommandUnit.CarLogOut.value -> { |
| | | packageData.dataUnit.forEach { |
| | | when (it) { |
| | | is CarLogOutData -> { |
| | | obdData.apply { |
| | | obdTime = it.time |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ObdCommandUnit.TimeCalibration.value -> { |
| | | packageData.dataUnit.forEach { |
| | | when (it) { |
| | | is TimeCalibrationData -> { |
| | | obdData.apply { |
| | | obdTime = it.time |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return obdDataMapper.insert(obdData) == 1 |
| | | } |
| | | } |