riku
2019-09-16 6f6c35f0e0881d2bbf32ad62f6c59f0ab1504854
修改采样时间的存储问题
已修改2个文件
64 ■■■■■ 文件已修改
src/main/kotlin/com/flightfeather/obd/repository/impl/ObdDataDaoImpl.kt 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/obd/Test.kt 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/obd/repository/impl/ObdDataDaoImpl.kt
@@ -4,9 +4,7 @@
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.EngineDataFlow
import com.flightfeather.obd.socket.bean.ObdPackageData
import com.flightfeather.obd.socket.bean.SupplementDataFlow
import com.flightfeather.obd.socket.bean.*
import com.flightfeather.obd.socket.eunm.ObdCommandUnit
import com.github.pagehelper.PageHelper
import org.springframework.beans.BeanUtils
@@ -54,7 +52,15 @@
        }
        when (packageData.commandUnit) {
            ObdCommandUnit.CarRegister.value -> {
                packageData.dataUnit.forEach {
                    when (it) {
                        is CarRegisterData -> {
                            obdData.apply {
                                obdTime = it.time
                            }
                        }
                    }
                }
            }
            ObdCommandUnit.RealTimeData.value,
            ObdCommandUnit.ReplacementData.value -> {
@@ -73,6 +79,7 @@
                        }
                        is EngineDataFlow -> {
                            obdData.apply {
                                obdTime = it.time
                                obdLng = it.obdLong
                                obdLat = it.obdLat
                                obdSpeed = it.obdSpeed?.toInt()
@@ -96,6 +103,7 @@
                        }
                        is SupplementDataFlow -> {
                            obdData.apply {
                                obdTime = it.time
                                obdEngineTorqueMode = it.obdEngineTorqueMode?.toString()
                                obdAcceleratorPedal = it.obdAcceleratorPedal
                                obdTotalOilConsumption = it.obdTotalOilConsumption
@@ -111,10 +119,26 @@
            }
            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
                            }
                        }
                    }
                }
            }
        }
src/test/kotlin/com/flightfeather/obd/Test.kt
@@ -99,4 +99,32 @@
        }
        println(bcc.toString(16))
    }
    @Test
    fun foo11() {
        val b = mutableListOf<String>().apply {
            add("13")
            add("09")
            add("10")
            add("10")
            add("2b")
            add("2f")
        }
        if (b.size < 6) {
            println("null")
        }
        val year = b[0].toInt(16) + 2000
        if (year < 2000 || year > 2099) println("null")
        val month = b[1].toInt(16)
        val day = b[2].toInt(16)
        val hour = b[3].toInt(16)
        val min = b[4].toInt(16)
        val sec = b[5].toInt(16)
        val cal  = Calendar.getInstance().apply {
            set(year, month - 1, day, hour, min, sec)
        }
        println(SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cal.time))
    }
}