riku
2020-06-02 9a5f9bfc4f4b153dd0175c63f563d8047e1e2515
切换为无人机多参数接收服务端
已删除1个文件
已添加101个文件
已重命名1个文件
6776 ■■■■■ 文件已修改
src/main/kotlin/com/flightfeather/obd/ObdApplication.kt 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/ServletInitializer.kt 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/UAVApplication.kt 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/common/Contanst.kt 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/common/utils/FileUtil.kt 108 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/common/utils/TimeUtil.kt 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/MyMapper.kt 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/entity/AlarmData.java 619 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/entity/CarLogin.java 109 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/entity/CarLogout.java 92 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/entity/DataStream.java 551 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/entity/ObdData.java 622 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/entity/ObdInfo.java 279 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/entity/ObdUser.java 91 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/entity/OriginData.java 108 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/entity/ThresholdValue.java 499 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/entity/VehicleInfo.java 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/mapper/AlarmDataMapper.kt 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/mapper/CarLoginMapper.kt 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/mapper/CarLogoutMapper.kt 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/mapper/DataStreamMapper.kt 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/mapper/ObdDataMapper.kt 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/mapper/ObdInfoMapper.kt 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/mapper/ObdUserMapper.kt 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/mapper/OriginDataMapper.kt 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/mapper/ThresholdValueMapper.kt 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/mapper/VehicleInfoMapper.kt 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/AlarmDataVo.kt 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/BaseJson.kt 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/CarLoginVo.kt 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/CarLogoutVo.kt 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/DataStreamVo.kt 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/LatLngVo.kt 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/ObdDataVo.kt 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/ObdInfoVo.kt 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/ObdUserVo.kt 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/ThresholdValueVo.kt 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/VehicleInfoVo.kt 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/eunm/CarStatus.kt 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/eunm/CarType.kt 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/ObdAlarmService.kt 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/ObdDataService.kt 60 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/ObdThresholdValueService.kt 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/ObdUserService.kt 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/VehicleService.kt 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ObdAlarmServiceImpl.kt 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ObdDataServiceImpl.kt 164 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ObdThresholdValueServiceImpl.kt 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ObdUserServiceImpl.kt 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/VehicleServiceImpl.kt 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/web/ObdAlarmController.kt 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/web/ObdDataController.kt 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/web/ObdThresholdController.kt 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/web/ObdUserController.kt 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/web/VehicleInfoController.kt 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/CarLoginRepository.kt 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/CarLogoutRepository.kt 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/DataStreamRepository.kt 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/ObdAlarmRepository.kt 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/ObdDataRepository.kt 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/ObdInfoRepository.kt 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/ObdThresholdValueRepository.kt 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/ObdUserRepository.kt 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/OriginDataRepository.kt 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/VehicleRepository.kt 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/impl/CarLoginDaoImpl.kt 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/impl/CarLogoutDaoImpl.kt 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/impl/DataStreamDaoImpl.kt 157 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/impl/ObdAlarmDaoImpl.kt 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/impl/ObdDataDaoImpl.kt 147 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/impl/ObdInfoDaoImpl.kt 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/impl/ObdThresholdValueDaoImpl.kt 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/impl/ObdUserDaoImpl.kt 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/impl/OriginDataDaoImpl.kt 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/impl/VehicleRepositoryImpl.kt 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/DeviceSession.kt 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/MessageManager.kt 205 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/ObdByteDataDecoder.kt 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/ServerHandler.kt 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/SocketServerClient.kt 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/bean/CarLogOutData.kt 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/bean/CarRegisterData.kt 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/bean/DataUnit.kt 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/bean/EngineDataStream.kt 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/bean/ObdInfo.kt 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/bean/ObdPackageData.kt 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/bean/RealTimeData.kt 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/bean/ReplacementData.kt 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/bean/SupplementDataStream.kt 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/bean/TimeCalibrationData.kt 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/decoder/DataPackageDecoder.kt 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/decoder/DataUnitDecoder.kt 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/decoder/RealTimeDataDecoder.kt 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/decoder/VehicleDataDecoder.kt 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/decoder/impl/DataPackageDecoderImpl.kt 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/decoder/impl/DataUnitDecoderImpl.kt 127 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/decoder/impl/RealTimeDataDecoderImpl.kt 185 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/eunm/ObdCommandUnit.kt 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/eunm/ObdDataType.kt 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/Test.kt 150 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/UAVApplicationTests.kt 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/socket/MessageManagerTest.kt 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/socket/decoder/VehicleDataDecoderTest.kt 102 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/obd/ObdApplication.kt
ÎļþÒÑɾ³ý
src/main/kotlin/com/flightfeather/uav/ServletInitializer.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,12 @@
package com.flightfeather.uav
import org.springframework.boot.builder.SpringApplicationBuilder
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer
class ServletInitializer : SpringBootServletInitializer() {
    override fun configure(application: SpringApplicationBuilder): SpringApplicationBuilder {
        return application.sources(UAVApplication::class.java)
    }
}
src/main/kotlin/com/flightfeather/uav/UAVApplication.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
package com.flightfeather.uav
import com.flightfeather.uav.socket.SocketServerClient
import org.springframework.boot.ApplicationRunner
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.context.annotation.Bean
@SpringBootApplication
class UAVApplication{
    @Bean
    fun runner() = ApplicationRunner{
        SocketServerClient().startServer(9000)
    }
}
fun main(args: Array<String>) {
    runApplication<UAVApplication>(*args)
}
src/main/kotlin/com/flightfeather/uav/common/Contanst.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,9 @@
package com.flightfeather.uav.common
/**
 * @author riku
 * Date: 2019/9/20
 */
//前端设备传输的无效值
const val INVALID_DATA_4_BYTE = "FFFFFFFF"
const val INVALID_DATA_2_BYTE = "FFFF"
src/main/kotlin/com/flightfeather/uav/common/utils/FileUtil.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,108 @@
package com.flightfeather.uav.common.utils
import java.io.BufferedWriter
import java.io.File
import java.io.FileWriter
import java.text.SimpleDateFormat
import java.util.*
/**
 * @author riku
 * Date: 2019/9/11
 */
class FileUtil {
    private var file: File
    private var basePath:String = "${File.separator}ObdData${File.separator}"
    private var closeThread: Thread? = null
    private var fw: FileWriter? = null
    private var bw: BufferedWriter? = null
    private var oldTime: Date
    init {
        val fileName = "data-${SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(Date())}.txt"
        val path = "$basePath$fileName"
        file = File(path)
        oldTime = Date()
    }
    companion object{
        var instance: FileUtil? = null
        get() {
            if (field == null) {
                field = FileUtil()
            }
            return field
        }
    }
    fun saveObdData(str: String) {
        //检查文档是否存在
        if (!file.exists()) {
            file.parentFile.mkdirs()
            println("----创建文件夹:${file.parentFile.absolutePath}")
            file.createNewFile()
            println("----创建文件:${file.absolutePath}")
        }
        //文件最大512Kb,超过后新建文档
        if (file.length() + str.toByteArray().size > 512 * 1024 || TimeUtil.isNextDay(oldTime, Date())) {
            //超过一天后,更新当前时间
            oldTime = Date()
            val fileName = "data-${SimpleDateFormat("yyyy-MM-dd-hh-mm-ss").format(Date())}.txt"
            val path = "$basePath$fileName"
            file = File(path)
            file.createNewFile()
            //关闭原有输出流
            bw?.run {
                flush()
                close()
            }
            fw?.run {
                flush()
                close()
            }
            //新建输出流
            fw = FileWriter(file, true)
            bw = BufferedWriter(fw)
        }
        //第一次写文档时初始化输出流
        if (bw == null || fw == null) {
            fw = FileWriter(file, true)
            bw = BufferedWriter(fw)
        }
        bw?.run {
            write(str)
            newLine()
            flush()
        }
        readyToShutDownStream(bw, fw)
        println("----写入完成")
    }
    private fun readyToShutDownStream(bw: BufferedWriter?, fw:FileWriter?) {
        //终端上一次的计时线程
        closeThread?.interrupt()
        closeThread = Thread(Runnable {
            //2分钟没有新的数据写入就关闭输出流
            try {
                Thread.sleep(20 * 1000)
            } catch (e: Throwable) {
            }
            bw?.run {
                close()
            }
            this.bw = null
            fw?.run {
                close()
            }
            this.fw = null
        }).also {
            it.start()
        }
    }
}
src/main/kotlin/com/flightfeather/uav/common/utils/TimeUtil.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,31 @@
package com.flightfeather.uav.common.utils
import java.util.*
/**
 * @author riku
 * Date: 2019/9/16
 */
class TimeUtil {
    companion object {
        /**
         * æ˜¯å¦æ˜¯ç¬¬äºŒå¤©æˆ–更新的时间
         */
        fun isNextDay(oldTime: Date, newTime: Date): Boolean {
            val oldC = Calendar.getInstance().apply {
                time = oldTime
            }
            val newC = Calendar.getInstance().apply {
                time = newTime
            }
            return when {
                newC[Calendar.YEAR] > oldC[Calendar.YEAR] -> true
                newC[Calendar.YEAR] == oldC[Calendar.YEAR] -> newC[Calendar.DAY_OF_YEAR] > oldC[Calendar.DAY_OF_YEAR]
                else -> false
            }
        }
    }
}
src/main/kotlin/com/flightfeather/uav/domain/MyMapper.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
package com.flightfeather.uav.domain
import tk.mybatis.mapper.common.Mapper
import tk.mybatis.mapper.common.MySqlMapper
interface MyMapper<T> : Mapper<T>, MySqlMapper<T> {
}
src/main/kotlin/com/flightfeather/uav/domain/entity/AlarmData.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,619 @@
package com.flightfeather.uav.domain.entity;
import java.util.Date;
import javax.persistence.*;
@Table(name = "obd_alarm_data")
public class AlarmData {
    @Id
    private Integer id;
    @Column(name = "obd_vin")
    private String obdVin;
    @Column(name = "alarm_time")
    private Date alarmTime;
    @Column(name = "alarm_lng")
    private Double alarmLng;
    @Column(name = "alarm_lat")
    private Double alarmLat;
    @Column(name = "alarm_protocol")
    private Integer alarmProtocol;
    @Column(name = "alarm_mil")
    private Integer alarmMil;
    @Column(name = "alarm_id_code")
    private String alarmIdCode;
    @Column(name = "alarm_verification_code")
    private String alarmVerificationCode;
    @Column(name = "alarm_fault_code_num")
    private Integer alarmFaultCodeNum;
    @Column(name = "alarm_fault_code")
    private String alarmFaultCode;
    @Column(name = "alarm_speed")
    private Integer alarmSpeed;
    @Column(name = "alarm_air_pressure")
    private Double alarmAirPressure;
    @Column(name = "alarm_engine_torque")
    private Double alarmEngineTorque;
    @Column(name = "alarm_friction_torque")
    private Double alarmFrictionTorque;
    @Column(name = "alarm_engine_rpm")
    private Integer alarmEngineRpm;
    @Column(name = "alarm_start_fuel_flow")
    private Double alarmStartFuelFlow;
    @Column(name = "alarm_scr_upstream_NO")
    private Double alarmScrUpstreamNo;
    @Column(name = "alarm_scr_downstream_NO")
    private Double alarmScrDownstreamNo;
    @Column(name = "alarm_remain_reactant")
    private Double alarmRemainReactant;
    @Column(name = "alarm_air_input")
    private Double alarmAirInput;
    @Column(name = "alarm_scr_input_temp")
    private Double alarmScrInputTemp;
    @Column(name = "alarm_scr_output_temp")
    private Double alarmScrOutputTemp;
    @Column(name = "alarm_DPF")
    private Double alarmDpf;
    @Column(name = "alarm_engine_coolant_temp")
    private Double alarmEngineCoolantTemp;
    @Column(name = "alarm_fuel_level")
    private Double alarmFuelLevel;
    @Column(name = "alarm_location_status")
    private Integer alarmLocationStatus;
    @Column(name = "alarm_total_mileage")
    private Double alarmTotalMileage;
    @Column(name = "alarm_engine_torque_mode")
    private String alarmEngineTorqueMode;
    @Column(name = "alarm_accelerator_pedal")
    private Double alarmAcceleratorPedal;
    @Column(name = "alarm_total_oil_consumption")
    private Double alarmTotalOilConsumption;
    @Column(name = "alarm_urea_box_temp")
    private Double alarmUreaBoxTemp;
    @Column(name = "alarm_urea_volume")
    private Integer alarmUreaVolume;
    @Column(name = "alarm_total_urea_consume")
    private Double alarmTotalUreaConsume;
    @Column(name = "alarm_DPF_temp")
    private Double alarmDpfTemp;
    @Column(name = "alarm_firmware_version")
    private String alarmFirmwareVersion;
    /**
     * @return id
     */
    public Integer getId() {
        return id;
    }
    /**
     * @param id
     */
    public void setId(Integer id) {
        this.id = id;
    }
    /**
     * @return obd_vin
     */
    public String getObdVin() {
        return obdVin;
    }
    /**
     * @param obdVin
     */
    public void setObdVin(String obdVin) {
        this.obdVin = obdVin == null ? null : obdVin.trim();
    }
    /**
     * @return alarm_time
     */
    public Date getAlarmTime() {
        return alarmTime;
    }
    /**
     * @param alarmTime
     */
    public void setAlarmTime(Date alarmTime) {
        this.alarmTime = alarmTime;
    }
    /**
     * @return alarm_lng
     */
    public Double getAlarmLng() {
        return alarmLng;
    }
    /**
     * @param alarmLng
     */
    public void setAlarmLng(Double alarmLng) {
        this.alarmLng = alarmLng;
    }
    /**
     * @return alarm_lat
     */
    public Double getAlarmLat() {
        return alarmLat;
    }
    /**
     * @param alarmLat
     */
    public void setAlarmLat(Double alarmLat) {
        this.alarmLat = alarmLat;
    }
    /**
     * @return alarm_protocol
     */
    public Integer getAlarmProtocol() {
        return alarmProtocol;
    }
    /**
     * @param alarmProtocol
     */
    public void setAlarmProtocol(Integer alarmProtocol) {
        this.alarmProtocol = alarmProtocol;
    }
    /**
     * @return alarm_mil
     */
    public Integer getAlarmMil() {
        return alarmMil;
    }
    /**
     * @param alarmMil
     */
    public void setAlarmMil(Integer alarmMil) {
        this.alarmMil = alarmMil;
    }
    /**
     * @return alarm_id_code
     */
    public String getAlarmIdCode() {
        return alarmIdCode;
    }
    /**
     * @param alarmIdCode
     */
    public void setAlarmIdCode(String alarmIdCode) {
        this.alarmIdCode = alarmIdCode == null ? null : alarmIdCode.trim();
    }
    /**
     * @return alarm_verification_code
     */
    public String getAlarmVerificationCode() {
        return alarmVerificationCode;
    }
    /**
     * @param alarmVerificationCode
     */
    public void setAlarmVerificationCode(String alarmVerificationCode) {
        this.alarmVerificationCode = alarmVerificationCode == null ? null : alarmVerificationCode.trim();
    }
    /**
     * @return alarm_fault_code_num
     */
    public Integer getAlarmFaultCodeNum() {
        return alarmFaultCodeNum;
    }
    /**
     * @param alarmFaultCodeNum
     */
    public void setAlarmFaultCodeNum(Integer alarmFaultCodeNum) {
        this.alarmFaultCodeNum = alarmFaultCodeNum;
    }
    /**
     * @return alarm_fault_code
     */
    public String getAlarmFaultCode() {
        return alarmFaultCode;
    }
    /**
     * @param alarmFaultCode
     */
    public void setAlarmFaultCode(String alarmFaultCode) {
        this.alarmFaultCode = alarmFaultCode == null ? null : alarmFaultCode.trim();
    }
    /**
     * @return alarm_speed
     */
    public Integer getAlarmSpeed() {
        return alarmSpeed;
    }
    /**
     * @param alarmSpeed
     */
    public void setAlarmSpeed(Integer alarmSpeed) {
        this.alarmSpeed = alarmSpeed;
    }
    /**
     * @return alarm_air_pressure
     */
    public Double getAlarmAirPressure() {
        return alarmAirPressure;
    }
    /**
     * @param alarmAirPressure
     */
    public void setAlarmAirPressure(Double alarmAirPressure) {
        this.alarmAirPressure = alarmAirPressure;
    }
    /**
     * @return alarm_engine_torque
     */
    public Double getAlarmEngineTorque() {
        return alarmEngineTorque;
    }
    /**
     * @param alarmEngineTorque
     */
    public void setAlarmEngineTorque(Double alarmEngineTorque) {
        this.alarmEngineTorque = alarmEngineTorque;
    }
    /**
     * @return alarm_friction_torque
     */
    public Double getAlarmFrictionTorque() {
        return alarmFrictionTorque;
    }
    /**
     * @param alarmFrictionTorque
     */
    public void setAlarmFrictionTorque(Double alarmFrictionTorque) {
        this.alarmFrictionTorque = alarmFrictionTorque;
    }
    /**
     * @return alarm_engine_rpm
     */
    public Integer getAlarmEngineRpm() {
        return alarmEngineRpm;
    }
    /**
     * @param alarmEngineRpm
     */
    public void setAlarmEngineRpm(Integer alarmEngineRpm) {
        this.alarmEngineRpm = alarmEngineRpm;
    }
    /**
     * @return alarm_start_fuel_flow
     */
    public Double getAlarmStartFuelFlow() {
        return alarmStartFuelFlow;
    }
    /**
     * @param alarmStartFuelFlow
     */
    public void setAlarmStartFuelFlow(Double alarmStartFuelFlow) {
        this.alarmStartFuelFlow = alarmStartFuelFlow;
    }
    /**
     * @return alarm_scr_upstream_NO
     */
    public Double getAlarmScrUpstreamNo() {
        return alarmScrUpstreamNo;
    }
    /**
     * @param alarmScrUpstreamNo
     */
    public void setAlarmScrUpstreamNo(Double alarmScrUpstreamNo) {
        this.alarmScrUpstreamNo = alarmScrUpstreamNo;
    }
    /**
     * @return alarm_scr_downstream_NO
     */
    public Double getAlarmScrDownstreamNo() {
        return alarmScrDownstreamNo;
    }
    /**
     * @param alarmScrDownstreamNo
     */
    public void setAlarmScrDownstreamNo(Double alarmScrDownstreamNo) {
        this.alarmScrDownstreamNo = alarmScrDownstreamNo;
    }
    /**
     * @return alarm_remain_reactant
     */
    public Double getAlarmRemainReactant() {
        return alarmRemainReactant;
    }
    /**
     * @param alarmRemainReactant
     */
    public void setAlarmRemainReactant(Double alarmRemainReactant) {
        this.alarmRemainReactant = alarmRemainReactant;
    }
    /**
     * @return alarm_air_input
     */
    public Double getAlarmAirInput() {
        return alarmAirInput;
    }
    /**
     * @param alarmAirInput
     */
    public void setAlarmAirInput(Double alarmAirInput) {
        this.alarmAirInput = alarmAirInput;
    }
    /**
     * @return alarm_scr_input_temp
     */
    public Double getAlarmScrInputTemp() {
        return alarmScrInputTemp;
    }
    /**
     * @param alarmScrInputTemp
     */
    public void setAlarmScrInputTemp(Double alarmScrInputTemp) {
        this.alarmScrInputTemp = alarmScrInputTemp;
    }
    /**
     * @return alarm_scr_output_temp
     */
    public Double getAlarmScrOutputTemp() {
        return alarmScrOutputTemp;
    }
    /**
     * @param alarmScrOutputTemp
     */
    public void setAlarmScrOutputTemp(Double alarmScrOutputTemp) {
        this.alarmScrOutputTemp = alarmScrOutputTemp;
    }
    /**
     * @return alarm_DPF
     */
    public Double getAlarmDpf() {
        return alarmDpf;
    }
    /**
     * @param alarmDpf
     */
    public void setAlarmDpf(Double alarmDpf) {
        this.alarmDpf = alarmDpf;
    }
    /**
     * @return alarm_engine_coolant_temp
     */
    public Double getAlarmEngineCoolantTemp() {
        return alarmEngineCoolantTemp;
    }
    /**
     * @param alarmEngineCoolantTemp
     */
    public void setAlarmEngineCoolantTemp(Double alarmEngineCoolantTemp) {
        this.alarmEngineCoolantTemp = alarmEngineCoolantTemp;
    }
    /**
     * @return alarm_fuel_level
     */
    public Double getAlarmFuelLevel() {
        return alarmFuelLevel;
    }
    /**
     * @param alarmFuelLevel
     */
    public void setAlarmFuelLevel(Double alarmFuelLevel) {
        this.alarmFuelLevel = alarmFuelLevel;
    }
    /**
     * @return alarm_location_status
     */
    public Integer getAlarmLocationStatus() {
        return alarmLocationStatus;
    }
    /**
     * @param alarmLocationStatus
     */
    public void setAlarmLocationStatus(Integer alarmLocationStatus) {
        this.alarmLocationStatus = alarmLocationStatus;
    }
    /**
     * @return alarm_total_mileage
     */
    public Double getAlarmTotalMileage() {
        return alarmTotalMileage;
    }
    /**
     * @param alarmTotalMileage
     */
    public void setAlarmTotalMileage(Double alarmTotalMileage) {
        this.alarmTotalMileage = alarmTotalMileage;
    }
    /**
     * @return alarm_engine_torque_mode
     */
    public String getAlarmEngineTorqueMode() {
        return alarmEngineTorqueMode;
    }
    /**
     * @param alarmEngineTorqueMode
     */
    public void setAlarmEngineTorqueMode(String alarmEngineTorqueMode) {
        this.alarmEngineTorqueMode = alarmEngineTorqueMode == null ? null : alarmEngineTorqueMode.trim();
    }
    /**
     * @return alarm_accelerator_pedal
     */
    public Double getAlarmAcceleratorPedal() {
        return alarmAcceleratorPedal;
    }
    /**
     * @param alarmAcceleratorPedal
     */
    public void setAlarmAcceleratorPedal(Double alarmAcceleratorPedal) {
        this.alarmAcceleratorPedal = alarmAcceleratorPedal;
    }
    /**
     * @return alarm_total_oil_consumption
     */
    public Double getAlarmTotalOilConsumption() {
        return alarmTotalOilConsumption;
    }
    /**
     * @param alarmTotalOilConsumption
     */
    public void setAlarmTotalOilConsumption(Double alarmTotalOilConsumption) {
        this.alarmTotalOilConsumption = alarmTotalOilConsumption;
    }
    /**
     * @return alarm_urea_box_temp
     */
    public Double getAlarmUreaBoxTemp() {
        return alarmUreaBoxTemp;
    }
    /**
     * @param alarmUreaBoxTemp
     */
    public void setAlarmUreaBoxTemp(Double alarmUreaBoxTemp) {
        this.alarmUreaBoxTemp = alarmUreaBoxTemp;
    }
    /**
     * @return alarm_urea_volume
     */
    public Integer getAlarmUreaVolume() {
        return alarmUreaVolume;
    }
    /**
     * @param alarmUreaVolume
     */
    public void setAlarmUreaVolume(Integer alarmUreaVolume) {
        this.alarmUreaVolume = alarmUreaVolume;
    }
    /**
     * @return alarm_total_urea_consume
     */
    public Double getAlarmTotalUreaConsume() {
        return alarmTotalUreaConsume;
    }
    /**
     * @param alarmTotalUreaConsume
     */
    public void setAlarmTotalUreaConsume(Double alarmTotalUreaConsume) {
        this.alarmTotalUreaConsume = alarmTotalUreaConsume;
    }
    /**
     * @return alarm_DPF_temp
     */
    public Double getAlarmDpfTemp() {
        return alarmDpfTemp;
    }
    /**
     * @param alarmDpfTemp
     */
    public void setAlarmDpfTemp(Double alarmDpfTemp) {
        this.alarmDpfTemp = alarmDpfTemp;
    }
    /**
     * @return alarm_firmware_version
     */
    public String getAlarmFirmwareVersion() {
        return alarmFirmwareVersion;
    }
    /**
     * @param alarmFirmwareVersion
     */
    public void setAlarmFirmwareVersion(String alarmFirmwareVersion) {
        this.alarmFirmwareVersion = alarmFirmwareVersion == null ? null : alarmFirmwareVersion.trim();
    }
}
src/main/kotlin/com/flightfeather/uav/domain/entity/CarLogin.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,109 @@
package com.flightfeather.uav.domain.entity;
import java.util.Date;
import javax.persistence.*;
@Table(name = "obd_car_login")
public class CarLogin {
    @Id
    private Integer id;
    @Column(name = "obd_device_code")
    private String obdDeviceCode;
    @Column(name = "login_create_time")
    private Date loginCreateTime;
    @Column(name = "login_data_time")
    private Date loginDataTime;
    @Column(name = "login_serial_num")
    private Integer loginSerialNum;
    @Column(name = "login_sim_code")
    private String loginSimCode;
    /**
     * @return id
     */
    public Integer getId() {
        return id;
    }
    /**
     * @param id
     */
    public void setId(Integer id) {
        this.id = id;
    }
    /**
     * @return obd_device_code
     */
    public String getObdDeviceCode() {
        return obdDeviceCode;
    }
    /**
     * @param obdDeviceCode
     */
    public void setObdDeviceCode(String obdDeviceCode) {
        this.obdDeviceCode = obdDeviceCode == null ? null : obdDeviceCode.trim();
    }
    /**
     * @return login_create_time
     */
    public Date getLoginCreateTime() {
        return loginCreateTime;
    }
    /**
     * @param loginCreateTime
     */
    public void setLoginCreateTime(Date loginCreateTime) {
        this.loginCreateTime = loginCreateTime;
    }
    /**
     * @return login_data_time
     */
    public Date getLoginDataTime() {
        return loginDataTime;
    }
    /**
     * @param loginDataTime
     */
    public void setLoginDataTime(Date loginDataTime) {
        this.loginDataTime = loginDataTime;
    }
    /**
     * @return login_serial_num
     */
    public Integer getLoginSerialNum() {
        return loginSerialNum;
    }
    /**
     * @param loginSerialNum
     */
    public void setLoginSerialNum(Integer loginSerialNum) {
        this.loginSerialNum = loginSerialNum;
    }
    /**
     * @return login_sim_code
     */
    public String getLoginSimCode() {
        return loginSimCode;
    }
    /**
     * @param loginSimCode
     */
    public void setLoginSimCode(String loginSimCode) {
        this.loginSimCode = loginSimCode == null ? null : loginSimCode.trim();
    }
}
src/main/kotlin/com/flightfeather/uav/domain/entity/CarLogout.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,92 @@
package com.flightfeather.uav.domain.entity;
import java.util.Date;
import javax.persistence.*;
@Table(name = "obd_car_logout")
public class CarLogout {
    @Id
    private Integer id;
    @Column(name = "obd_device_code")
    private String obdDeviceCode;
    @Column(name = "logout_create_time")
    private Date logoutCreateTime;
    @Column(name = "logout_data_time")
    private Date logoutDataTime;
    @Column(name = "logout_serial_num")
    private Integer logoutSerialNum;
    /**
     * @return id
     */
    public Integer getId() {
        return id;
    }
    /**
     * @param id
     */
    public void setId(Integer id) {
        this.id = id;
    }
    /**
     * @return obd_device_code
     */
    public String getObdDeviceCode() {
        return obdDeviceCode;
    }
    /**
     * @param obdDeviceCode
     */
    public void setObdDeviceCode(String obdDeviceCode) {
        this.obdDeviceCode = obdDeviceCode == null ? null : obdDeviceCode.trim();
    }
    /**
     * @return logout_create_time
     */
    public Date getLogoutCreateTime() {
        return logoutCreateTime;
    }
    /**
     * @param logoutCreateTime
     */
    public void setLogoutCreateTime(Date logoutCreateTime) {
        this.logoutCreateTime = logoutCreateTime;
    }
    /**
     * @return logout_data_time
     */
    public Date getLogoutDataTime() {
        return logoutDataTime;
    }
    /**
     * @param logoutDataTime
     */
    public void setLogoutDataTime(Date logoutDataTime) {
        this.logoutDataTime = logoutDataTime;
    }
    /**
     * @return logout_serial_num
     */
    public Integer getLogoutSerialNum() {
        return logoutSerialNum;
    }
    /**
     * @param logoutSerialNum
     */
    public void setLogoutSerialNum(Integer logoutSerialNum) {
        this.logoutSerialNum = logoutSerialNum;
    }
}
src/main/kotlin/com/flightfeather/uav/domain/entity/DataStream.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,551 @@
package com.flightfeather.uav.domain.entity;
import java.util.Date;
import javax.persistence.*;
@Table(name = "obd_data_stream")
public class DataStream {
    @Id
    private Integer id;
    @Column(name = "obd_device_code")
    private String obdDeviceCode;
    @Column(name = "obd_create_time")
    private Date obdCreateTime;
    @Column(name = "obd_data_time")
    private Date obdDataTime;
    @Column(name = "obd_serial_num")
    private Integer obdSerialNum;
    @Column(name = "obd_speed")
    private Double obdSpeed;
    @Column(name = "obd_air_pressure")
    private Double obdAirPressure;
    @Column(name = "obd_engine_torque")
    private Double obdEngineTorque;
    @Column(name = "obd_friction_torque")
    private Double obdFrictionTorque;
    @Column(name = "obd_engine_rpm")
    private Double obdEngineRpm;
    @Column(name = "obd_engine_fuel_flow")
    private Double obdEngineFuelFlow;
    @Column(name = "obd_scr_upstream_NOx")
    private Double obdScrUpstreamNox;
    @Column(name = "obd_scr_downstream_NOx")
    private Double obdScrDownstreamNox;
    @Column(name = "obd_remain_reactant")
    private Double obdRemainReactant;
    @Column(name = "obd_air_input")
    private Double obdAirInput;
    @Column(name = "obd_scr_input_temp")
    private Double obdScrInputTemp;
    @Column(name = "obd_scr_output_temp")
    private Double obdScrOutputTemp;
    @Column(name = "obd_DPF")
    private Double obdDpf;
    @Column(name = "obd_engine_coolant_temp")
    private Double obdEngineCoolantTemp;
    @Column(name = "obd_fuel_level")
    private Double obdFuelLevel;
    @Column(name = "obd_location_status")
    private String obdLocationStatus;
    @Column(name = "obd_long")
    private Double obdLong;
    @Column(name = "obd_lat")
    private Double obdLat;
    @Column(name = "obd_total_mileage")
    private Double obdTotalMileage;
    @Column(name = "obd_engine_torque_mode")
    private Integer obdEngineTorqueMode;
    @Column(name = "obd_accelerator_pedal")
    private Double obdAcceleratorPedal;
    @Column(name = "obd_total_oil_consumption")
    private Double obdTotalOilConsumption;
    @Column(name = "obd_urea_box_temp")
    private Double obdUreaBoxTemp;
    @Column(name = "obd_urea_volume")
    private Double obdUreaVolume;
    @Column(name = "obd_total_urea_consume")
    private Double obdTotalUreaConsume;
    @Column(name = "obd_DPF_temp")
    private Double obdDpfTemp;
    @Column(name = "obd_status")
    private Boolean obdStatus;
    /**
     * @return id
     */
    public Integer getId() {
        return id;
    }
    /**
     * @param id
     */
    public void setId(Integer id) {
        this.id = id;
    }
    /**
     * @return obd_device_code
     */
    public String getObdDeviceCode() {
        return obdDeviceCode;
    }
    /**
     * @param obdDeviceCode
     */
    public void setObdDeviceCode(String obdDeviceCode) {
        this.obdDeviceCode = obdDeviceCode == null ? null : obdDeviceCode.trim();
    }
    /**
     * @return obd_create_time
     */
    public Date getObdCreateTime() {
        return obdCreateTime;
    }
    /**
     * @param obdCreateTime
     */
    public void setObdCreateTime(Date obdCreateTime) {
        this.obdCreateTime = obdCreateTime;
    }
    /**
     * @return obd_data_time
     */
    public Date getObdDataTime() {
        return obdDataTime;
    }
    /**
     * @param obdDataTime
     */
    public void setObdDataTime(Date obdDataTime) {
        this.obdDataTime = obdDataTime;
    }
    /**
     * @return obd_serial_num
     */
    public Integer getObdSerialNum() {
        return obdSerialNum;
    }
    /**
     * @param obdSerialNum
     */
    public void setObdSerialNum(Integer obdSerialNum) {
        this.obdSerialNum = obdSerialNum;
    }
    /**
     * @return obd_speed
     */
    public Double getObdSpeed() {
        return obdSpeed;
    }
    /**
     * @param obdSpeed
     */
    public void setObdSpeed(Double obdSpeed) {
        this.obdSpeed = obdSpeed;
    }
    /**
     * @return obd_air_pressure
     */
    public Double getObdAirPressure() {
        return obdAirPressure;
    }
    /**
     * @param obdAirPressure
     */
    public void setObdAirPressure(Double obdAirPressure) {
        this.obdAirPressure = obdAirPressure;
    }
    /**
     * @return obd_engine_torque
     */
    public Double getObdEngineTorque() {
        return obdEngineTorque;
    }
    /**
     * @param obdEngineTorque
     */
    public void setObdEngineTorque(Double obdEngineTorque) {
        this.obdEngineTorque = obdEngineTorque;
    }
    /**
     * @return obd_friction_torque
     */
    public Double getObdFrictionTorque() {
        return obdFrictionTorque;
    }
    /**
     * @param obdFrictionTorque
     */
    public void setObdFrictionTorque(Double obdFrictionTorque) {
        this.obdFrictionTorque = obdFrictionTorque;
    }
    /**
     * @return obd_engine_rpm
     */
    public Double getObdEngineRpm() {
        return obdEngineRpm;
    }
    /**
     * @param obdEngineRpm
     */
    public void setObdEngineRpm(Double obdEngineRpm) {
        this.obdEngineRpm = obdEngineRpm;
    }
    /**
     * @return obd_engine_fuel_flow
     */
    public Double getObdEngineFuelFlow() {
        return obdEngineFuelFlow;
    }
    /**
     * @param obdEngineFuelFlow
     */
    public void setObdEngineFuelFlow(Double obdEngineFuelFlow) {
        this.obdEngineFuelFlow = obdEngineFuelFlow;
    }
    /**
     * @return obd_scr_upstream_NOx
     */
    public Double getObdScrUpstreamNox() {
        return obdScrUpstreamNox;
    }
    /**
     * @param obdScrUpstreamNox
     */
    public void setObdScrUpstreamNox(Double obdScrUpstreamNox) {
        this.obdScrUpstreamNox = obdScrUpstreamNox;
    }
    /**
     * @return obd_scr_downstream_NOx
     */
    public Double getObdScrDownstreamNox() {
        return obdScrDownstreamNox;
    }
    /**
     * @param obdScrDownstreamNox
     */
    public void setObdScrDownstreamNox(Double obdScrDownstreamNox) {
        this.obdScrDownstreamNox = obdScrDownstreamNox;
    }
    /**
     * @return obd_remain_reactant
     */
    public Double getObdRemainReactant() {
        return obdRemainReactant;
    }
    /**
     * @param obdRemainReactant
     */
    public void setObdRemainReactant(Double obdRemainReactant) {
        this.obdRemainReactant = obdRemainReactant;
    }
    /**
     * @return obd_air_input
     */
    public Double getObdAirInput() {
        return obdAirInput;
    }
    /**
     * @param obdAirInput
     */
    public void setObdAirInput(Double obdAirInput) {
        this.obdAirInput = obdAirInput;
    }
    /**
     * @return obd_scr_input_temp
     */
    public Double getObdScrInputTemp() {
        return obdScrInputTemp;
    }
    /**
     * @param obdScrInputTemp
     */
    public void setObdScrInputTemp(Double obdScrInputTemp) {
        this.obdScrInputTemp = obdScrInputTemp;
    }
    /**
     * @return obd_scr_output_temp
     */
    public Double getObdScrOutputTemp() {
        return obdScrOutputTemp;
    }
    /**
     * @param obdScrOutputTemp
     */
    public void setObdScrOutputTemp(Double obdScrOutputTemp) {
        this.obdScrOutputTemp = obdScrOutputTemp;
    }
    /**
     * @return obd_DPF
     */
    public Double getObdDpf() {
        return obdDpf;
    }
    /**
     * @param obdDpf
     */
    public void setObdDpf(Double obdDpf) {
        this.obdDpf = obdDpf;
    }
    /**
     * @return obd_engine_coolant_temp
     */
    public Double getObdEngineCoolantTemp() {
        return obdEngineCoolantTemp;
    }
    /**
     * @param obdEngineCoolantTemp
     */
    public void setObdEngineCoolantTemp(Double obdEngineCoolantTemp) {
        this.obdEngineCoolantTemp = obdEngineCoolantTemp;
    }
    /**
     * @return obd_fuel_level
     */
    public Double getObdFuelLevel() {
        return obdFuelLevel;
    }
    /**
     * @param obdFuelLevel
     */
    public void setObdFuelLevel(Double obdFuelLevel) {
        this.obdFuelLevel = obdFuelLevel;
    }
    /**
     * @return obd_location_status
     */
    public String getObdLocationStatus() {
        return obdLocationStatus;
    }
    /**
     * @param obdLocationStatus
     */
    public void setObdLocationStatus(String obdLocationStatus) {
        this.obdLocationStatus = obdLocationStatus == null ? null : obdLocationStatus.trim();
    }
    /**
     * @return obd_long
     */
    public Double getObdLong() {
        return obdLong;
    }
    /**
     * @param obdLong
     */
    public void setObdLong(Double obdLong) {
        this.obdLong = obdLong;
    }
    /**
     * @return obd_lat
     */
    public Double getObdLat() {
        return obdLat;
    }
    /**
     * @param obdLat
     */
    public void setObdLat(Double obdLat) {
        this.obdLat = obdLat;
    }
    /**
     * @return obd_total_mileage
     */
    public Double getObdTotalMileage() {
        return obdTotalMileage;
    }
    /**
     * @param obdTotalMileage
     */
    public void setObdTotalMileage(Double obdTotalMileage) {
        this.obdTotalMileage = obdTotalMileage;
    }
    /**
     * @return obd_engine_torque_mode
     */
    public Integer getObdEngineTorqueMode() {
        return obdEngineTorqueMode;
    }
    /**
     * @param obdEngineTorqueMode
     */
    public void setObdEngineTorqueMode(Integer obdEngineTorqueMode) {
        this.obdEngineTorqueMode = obdEngineTorqueMode;
    }
    /**
     * @return obd_accelerator_pedal
     */
    public Double getObdAcceleratorPedal() {
        return obdAcceleratorPedal;
    }
    /**
     * @param obdAcceleratorPedal
     */
    public void setObdAcceleratorPedal(Double obdAcceleratorPedal) {
        this.obdAcceleratorPedal = obdAcceleratorPedal;
    }
    /**
     * @return obd_total_oil_consumption
     */
    public Double getObdTotalOilConsumption() {
        return obdTotalOilConsumption;
    }
    /**
     * @param obdTotalOilConsumption
     */
    public void setObdTotalOilConsumption(Double obdTotalOilConsumption) {
        this.obdTotalOilConsumption = obdTotalOilConsumption;
    }
    /**
     * @return obd_urea_box_temp
     */
    public Double getObdUreaBoxTemp() {
        return obdUreaBoxTemp;
    }
    /**
     * @param obdUreaBoxTemp
     */
    public void setObdUreaBoxTemp(Double obdUreaBoxTemp) {
        this.obdUreaBoxTemp = obdUreaBoxTemp;
    }
    /**
     * @return obd_urea_volume
     */
    public Double getObdUreaVolume() {
        return obdUreaVolume;
    }
    /**
     * @param obdUreaVolume
     */
    public void setObdUreaVolume(Double obdUreaVolume) {
        this.obdUreaVolume = obdUreaVolume;
    }
    /**
     * @return obd_total_urea_consume
     */
    public Double getObdTotalUreaConsume() {
        return obdTotalUreaConsume;
    }
    /**
     * @param obdTotalUreaConsume
     */
    public void setObdTotalUreaConsume(Double obdTotalUreaConsume) {
        this.obdTotalUreaConsume = obdTotalUreaConsume;
    }
    /**
     * @return obd_DPF_temp
     */
    public Double getObdDpfTemp() {
        return obdDpfTemp;
    }
    /**
     * @param obdDpfTemp
     */
    public void setObdDpfTemp(Double obdDpfTemp) {
        this.obdDpfTemp = obdDpfTemp;
    }
    /**
     * @return obd_status
     */
    public Boolean getObdStatus() {
        return obdStatus;
    }
    /**
     * @param obdStatus
     */
    public void setObdStatus(Boolean obdStatus) {
        this.obdStatus = obdStatus;
    }
}
src/main/kotlin/com/flightfeather/uav/domain/entity/ObdData.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,622 @@
package com.flightfeather.uav.domain.entity;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Date;
import javax.persistence.*;
@Table(name = "obd_data")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ObdData {
    @Id
    private Integer id;
    @Column(name = "obd_vin")
    private String obdVin;
    @Column(name = "obd_time")
    private Date obdTime;
    @Column(name = "obd_lng")
    private Double obdLng;
    @Column(name = "obd_lat")
    private Double obdLat;
    @Column(name = "obd_protocol")
    private Integer obdProtocol;
    @Column(name = "obd_mil")
    private Integer obdMil;
    @Column(name = "obd_id_code")
    private String obdIdCode;
    @Column(name = "obd_verification_code")
    private String obdVerificationCode;
    @Column(name = "obd_fault_code_num")
    private Integer obdFaultCodeNum;
    @Column(name = "obd_fault_code")
    private String obdFaultCode;
    @Column(name = "obd_speed")
    private Integer obdSpeed;
    @Column(name = "obd_air_pressure")
    private Double obdAirPressure;
    @Column(name = "obd_engine_torque")
    private Double obdEngineTorque;
    @Column(name = "obd_friction_torque")
    private Double obdFrictionTorque;
    @Column(name = "obd_engine_rpm")
    private Integer obdEngineRpm;
    @Column(name = "obd_start_fuel_flow")
    private Double obdStartFuelFlow;
    @Column(name = "obd_scr_upstream_NO")
    private Double obdScrUpstreamNo;
    @Column(name = "obd_scr_downstream_NO")
    private Double obdScrDownstreamNo;
    @Column(name = "obd_remain_reactant")
    private Double obdRemainReactant;
    @Column(name = "obd_air_input")
    private Double obdAirInput;
    @Column(name = "obd_scr_input_temp")
    private Double obdScrInputTemp;
    @Column(name = "obd_scr_output_temp")
    private Double obdScrOutputTemp;
    @Column(name = "obd_DPF")
    private Double obdDpf;
    @Column(name = "obd_engine_coolant_temp")
    private Double obdEngineCoolantTemp;
    @Column(name = "obd_fuel_level")
    private Double obdFuelLevel;
    @Column(name = "obd_location_status")
    private Integer obdLocationStatus;
    @Column(name = "obd_total_mileage")
    private Double obdTotalMileage;
    @Column(name = "obd_engine_torque_mode")
    private String obdEngineTorqueMode;
    @Column(name = "obd_accelerator_pedal")
    private Double obdAcceleratorPedal;
    @Column(name = "obd_total_oil_consumption")
    private Double obdTotalOilConsumption;
    @Column(name = "obd_urea_box_temp")
    private Double obdUreaBoxTemp;
    @Column(name = "obd_urea_volume")
    private Integer obdUreaVolume;
    @Column(name = "obd_total_urea_consume")
    private Double obdTotalUreaConsume;
    @Column(name = "obd_DPF_temp")
    private Double obdDpfTemp;
    @Column(name = "obd_firmware_version")
    private String obdFirmwareVersion;
    /**
     * @return id
     */
    public Integer getId() {
        return id;
    }
    /**
     * @param id
     */
    public void setId(Integer id) {
        this.id = id;
    }
    /**
     * @return obd_vin
     */
    public String getObdVin() {
        return obdVin;
    }
    /**
     * @param obdVin
     */
    public void setObdVin(String obdVin) {
        this.obdVin = obdVin == null ? null : obdVin.trim();
    }
    /**
     * @return obd_time
     */
    public Date getObdTime() {
        return obdTime;
    }
    /**
     * @param obdTime
     */
    public void setObdTime(Date obdTime) {
        this.obdTime = obdTime;
    }
    /**
     * @return obd_lng
     */
    public Double getObdLng() {
        return obdLng;
    }
    /**
     * @param obdLng
     */
    public void setObdLng(Double obdLng) {
        this.obdLng = obdLng;
    }
    /**
     * @return obd_lat
     */
    public Double getObdLat() {
        return obdLat;
    }
    /**
     * @param obdLat
     */
    public void setObdLat(Double obdLat) {
        this.obdLat = obdLat;
    }
    /**
     * @return obd_protocol
     */
    public Integer getObdProtocol() {
        return obdProtocol;
    }
    /**
     * @param obdProtocol
     */
    public void setObdProtocol(Integer obdProtocol) {
        this.obdProtocol = obdProtocol;
    }
    /**
     * @return obd_mil
     */
    public Integer getObdMil() {
        return obdMil;
    }
    /**
     * @param obdMil
     */
    public void setObdMil(Integer obdMil) {
        this.obdMil = obdMil;
    }
    /**
     * @return obd_id_code
     */
    public String getObdIdCode() {
        return obdIdCode;
    }
    /**
     * @param obdIdCode
     */
    public void setObdIdCode(String obdIdCode) {
        this.obdIdCode = obdIdCode == null ? null : obdIdCode.trim();
    }
    /**
     * @return obd_verification_code
     */
    public String getObdVerificationCode() {
        return obdVerificationCode;
    }
    /**
     * @param obdVerificationCode
     */
    public void setObdVerificationCode(String obdVerificationCode) {
        this.obdVerificationCode = obdVerificationCode == null ? null : obdVerificationCode.trim();
    }
    /**
     * @return obd_fault_code_num
     */
    public Integer getObdFaultCodeNum() {
        return obdFaultCodeNum;
    }
    /**
     * @param obdFaultCodeNum
     */
    public void setObdFaultCodeNum(Integer obdFaultCodeNum) {
        this.obdFaultCodeNum = obdFaultCodeNum;
    }
    /**
     * @return obd_fault_code
     */
    public String getObdFaultCode() {
        return obdFaultCode;
    }
    /**
     * @param obdFaultCode
     */
    public void setObdFaultCode(String obdFaultCode) {
        this.obdFaultCode = obdFaultCode == null ? null : obdFaultCode.trim();
    }
    /**
     * @return obd_speed
     */
    public Integer getObdSpeed() {
        return obdSpeed;
    }
    /**
     * @param obdSpeed
     */
    public void setObdSpeed(Integer obdSpeed) {
        this.obdSpeed = obdSpeed;
    }
    /**
     * @return obd_air_pressure
     */
    public Double getObdAirPressure() {
        return obdAirPressure;
    }
    /**
     * @param obdAirPressure
     */
    public void setObdAirPressure(Double obdAirPressure) {
        this.obdAirPressure = obdAirPressure;
    }
    /**
     * @return obd_engine_torque
     */
    public Double getObdEngineTorque() {
        return obdEngineTorque;
    }
    /**
     * @param obdEngineTorque
     */
    public void setObdEngineTorque(Double obdEngineTorque) {
        this.obdEngineTorque = obdEngineTorque;
    }
    /**
     * @return obd_friction_torque
     */
    public Double getObdFrictionTorque() {
        return obdFrictionTorque;
    }
    /**
     * @param obdFrictionTorque
     */
    public void setObdFrictionTorque(Double obdFrictionTorque) {
        this.obdFrictionTorque = obdFrictionTorque;
    }
    /**
     * @return obd_engine_rpm
     */
    public Integer getObdEngineRpm() {
        return obdEngineRpm;
    }
    /**
     * @param obdEngineRpm
     */
    public void setObdEngineRpm(Integer obdEngineRpm) {
        this.obdEngineRpm = obdEngineRpm;
    }
    /**
     * @return obd_start_fuel_flow
     */
    public Double getObdStartFuelFlow() {
        return obdStartFuelFlow;
    }
    /**
     * @param obdStartFuelFlow
     */
    public void setObdStartFuelFlow(Double obdStartFuelFlow) {
        this.obdStartFuelFlow = obdStartFuelFlow;
    }
    /**
     * @return obd_scr_upstream_NO
     */
    public Double getObdScrUpstreamNo() {
        return obdScrUpstreamNo;
    }
    /**
     * @param obdScrUpstreamNo
     */
    public void setObdScrUpstreamNo(Double obdScrUpstreamNo) {
        this.obdScrUpstreamNo = obdScrUpstreamNo;
    }
    /**
     * @return obd_scr_downstream_NO
     */
    public Double getObdScrDownstreamNo() {
        return obdScrDownstreamNo;
    }
    /**
     * @param obdScrDownstreamNo
     */
    public void setObdScrDownstreamNo(Double obdScrDownstreamNo) {
        this.obdScrDownstreamNo = obdScrDownstreamNo;
    }
    /**
     * @return obd_remain_reactant
     */
    public Double getObdRemainReactant() {
        return obdRemainReactant;
    }
    /**
     * @param obdRemainReactant
     */
    public void setObdRemainReactant(Double obdRemainReactant) {
        this.obdRemainReactant = obdRemainReactant;
    }
    /**
     * @return obd_air_input
     */
    public Double getObdAirInput() {
        return obdAirInput;
    }
    /**
     * @param obdAirInput
     */
    public void setObdAirInput(Double obdAirInput) {
        this.obdAirInput = obdAirInput;
    }
    /**
     * @return obd_scr_input_temp
     */
    public Double getObdScrInputTemp() {
        return obdScrInputTemp;
    }
    /**
     * @param obdScrInputTemp
     */
    public void setObdScrInputTemp(Double obdScrInputTemp) {
        this.obdScrInputTemp = obdScrInputTemp;
    }
    /**
     * @return obd_scr_output_temp
     */
    public Double getObdScrOutputTemp() {
        return obdScrOutputTemp;
    }
    /**
     * @param obdScrOutputTemp
     */
    public void setObdScrOutputTemp(Double obdScrOutputTemp) {
        this.obdScrOutputTemp = obdScrOutputTemp;
    }
    /**
     * @return obd_DPF
     */
    public Double getObdDpf() {
        return obdDpf;
    }
    /**
     * @param obdDpf
     */
    public void setObdDpf(Double obdDpf) {
        this.obdDpf = obdDpf;
    }
    /**
     * @return obd_engine_coolant_temp
     */
    public Double getObdEngineCoolantTemp() {
        return obdEngineCoolantTemp;
    }
    /**
     * @param obdEngineCoolantTemp
     */
    public void setObdEngineCoolantTemp(Double obdEngineCoolantTemp) {
        this.obdEngineCoolantTemp = obdEngineCoolantTemp;
    }
    /**
     * @return obd_fuel_level
     */
    public Double getObdFuelLevel() {
        return obdFuelLevel;
    }
    /**
     * @param obdFuelLevel
     */
    public void setObdFuelLevel(Double obdFuelLevel) {
        this.obdFuelLevel = obdFuelLevel;
    }
    /**
     * @return obd_location_status
     */
    public Integer getObdLocationStatus() {
        return obdLocationStatus;
    }
    /**
     * @param obdLocationStatus
     */
    public void setObdLocationStatus(Integer obdLocationStatus) {
        this.obdLocationStatus = obdLocationStatus;
    }
    /**
     * @return obd_total_mileage
     */
    public Double getObdTotalMileage() {
        return obdTotalMileage;
    }
    /**
     * @param obdTotalMileage
     */
    public void setObdTotalMileage(Double obdTotalMileage) {
        this.obdTotalMileage = obdTotalMileage;
    }
    /**
     * @return obd_engine_torque_mode
     */
    public String getObdEngineTorqueMode() {
        return obdEngineTorqueMode;
    }
    /**
     * @param obdEngineTorqueMode
     */
    public void setObdEngineTorqueMode(String obdEngineTorqueMode) {
        this.obdEngineTorqueMode = obdEngineTorqueMode == null ? null : obdEngineTorqueMode.trim();
    }
    /**
     * @return obd_accelerator_pedal
     */
    public Double getObdAcceleratorPedal() {
        return obdAcceleratorPedal;
    }
    /**
     * @param obdAcceleratorPedal
     */
    public void setObdAcceleratorPedal(Double obdAcceleratorPedal) {
        this.obdAcceleratorPedal = obdAcceleratorPedal;
    }
    /**
     * @return obd_total_oil_consumption
     */
    public Double getObdTotalOilConsumption() {
        return obdTotalOilConsumption;
    }
    /**
     * @param obdTotalOilConsumption
     */
    public void setObdTotalOilConsumption(Double obdTotalOilConsumption) {
        this.obdTotalOilConsumption = obdTotalOilConsumption;
    }
    /**
     * @return obd_urea_box_temp
     */
    public Double getObdUreaBoxTemp() {
        return obdUreaBoxTemp;
    }
    /**
     * @param obdUreaBoxTemp
     */
    public void setObdUreaBoxTemp(Double obdUreaBoxTemp) {
        this.obdUreaBoxTemp = obdUreaBoxTemp;
    }
    /**
     * @return obd_urea_volume
     */
    public Integer getObdUreaVolume() {
        return obdUreaVolume;
    }
    /**
     * @param obdUreaVolume
     */
    public void setObdUreaVolume(Integer obdUreaVolume) {
        this.obdUreaVolume = obdUreaVolume;
    }
    /**
     * @return obd_total_urea_consume
     */
    public Double getObdTotalUreaConsume() {
        return obdTotalUreaConsume;
    }
    /**
     * @param obdTotalUreaConsume
     */
    public void setObdTotalUreaConsume(Double obdTotalUreaConsume) {
        this.obdTotalUreaConsume = obdTotalUreaConsume;
    }
    /**
     * @return obd_DPF_temp
     */
    public Double getObdDpfTemp() {
        return obdDpfTemp;
    }
    /**
     * @param obdDpfTemp
     */
    public void setObdDpfTemp(Double obdDpfTemp) {
        this.obdDpfTemp = obdDpfTemp;
    }
    /**
     * @return obd_firmware_version
     */
    public String getObdFirmwareVersion() {
        return obdFirmwareVersion;
    }
    /**
     * @param obdFirmwareVersion
     */
    public void setObdFirmwareVersion(String obdFirmwareVersion) {
        this.obdFirmwareVersion = obdFirmwareVersion == null ? null : obdFirmwareVersion.trim();
    }
}
src/main/kotlin/com/flightfeather/uav/domain/entity/ObdInfo.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,279 @@
package com.flightfeather.uav.domain.entity;
import java.util.Date;
import javax.persistence.*;
@Table(name = "obd_info")
public class ObdInfo {
    @Id
    private Integer id;
    @Column(name = "obd_device_code")
    private String obdDeviceCode;
    @Column(name = "obd_create_time")
    private Date obdCreateTime;
    @Column(name = "obd_data_time")
    private Date obdDataTime;
    @Column(name = "obd_serial_num")
    private Integer obdSerialNum;
    @Column(name = "obd_protocol")
    private Integer obdProtocol;
    @Column(name = "obd_mil")
    private Integer obdMil;
    @Column(name = "obd_diagnosis_support_status")
    private String obdDiagnosisSupportStatus;
    @Column(name = "obd_diagnosis_ready_status")
    private String obdDiagnosisReadyStatus;
    @Column(name = "obd_vin")
    private String obdVin;
    @Column(name = "obd_crn")
    private String obdCrn;
    @Column(name = "obd_cvn")
    private String obdCvn;
    @Column(name = "obd_iupr")
    private String obdIupr;
    @Column(name = "obd_fault_code_num")
    private Integer obdFaultCodeNum;
    @Column(name = "obd_fault_code")
    private String obdFaultCode;
    @Column(name = "obd_status")
    private Boolean obdStatus;
    /**
     * @return id
     */
    public Integer getId() {
        return id;
    }
    /**
     * @param id
     */
    public void setId(Integer id) {
        this.id = id;
    }
    /**
     * @return obd_device_code
     */
    public String getObdDeviceCode() {
        return obdDeviceCode;
    }
    /**
     * @param obdDeviceCode
     */
    public void setObdDeviceCode(String obdDeviceCode) {
        this.obdDeviceCode = obdDeviceCode == null ? null : obdDeviceCode.trim();
    }
    /**
     * @return obd_create_time
     */
    public Date getObdCreateTime() {
        return obdCreateTime;
    }
    /**
     * @param obdCreateTime
     */
    public void setObdCreateTime(Date obdCreateTime) {
        this.obdCreateTime = obdCreateTime;
    }
    /**
     * @return obd_data_time
     */
    public Date getObdDataTime() {
        return obdDataTime;
    }
    /**
     * @param obdDataTime
     */
    public void setObdDataTime(Date obdDataTime) {
        this.obdDataTime = obdDataTime;
    }
    /**
     * @return obd_serial_num
     */
    public Integer getObdSerialNum() {
        return obdSerialNum;
    }
    /**
     * @param obdSerialNum
     */
    public void setObdSerialNum(Integer obdSerialNum) {
        this.obdSerialNum = obdSerialNum;
    }
    /**
     * @return obd_protocol
     */
    public Integer getObdProtocol() {
        return obdProtocol;
    }
    /**
     * @param obdProtocol
     */
    public void setObdProtocol(Integer obdProtocol) {
        this.obdProtocol = obdProtocol;
    }
    /**
     * @return obd_mil
     */
    public Integer getObdMil() {
        return obdMil;
    }
    /**
     * @param obdMil
     */
    public void setObdMil(Integer obdMil) {
        this.obdMil = obdMil;
    }
    /**
     * @return obd_diagnosis_support_status
     */
    public String getObdDiagnosisSupportStatus() {
        return obdDiagnosisSupportStatus;
    }
    /**
     * @param obdDiagnosisSupportStatus
     */
    public void setObdDiagnosisSupportStatus(String obdDiagnosisSupportStatus) {
        this.obdDiagnosisSupportStatus = obdDiagnosisSupportStatus == null ? null : obdDiagnosisSupportStatus.trim();
    }
    /**
     * @return obd_diagnosis_ready_status
     */
    public String getObdDiagnosisReadyStatus() {
        return obdDiagnosisReadyStatus;
    }
    /**
     * @param obdDiagnosisReadyStatus
     */
    public void setObdDiagnosisReadyStatus(String obdDiagnosisReadyStatus) {
        this.obdDiagnosisReadyStatus = obdDiagnosisReadyStatus == null ? null : obdDiagnosisReadyStatus.trim();
    }
    /**
     * @return obd_vin
     */
    public String getObdVin() {
        return obdVin;
    }
    /**
     * @param obdVin
     */
    public void setObdVin(String obdVin) {
        this.obdVin = obdVin == null ? null : obdVin.trim();
    }
    /**
     * @return obd_crn
     */
    public String getObdCrn() {
        return obdCrn;
    }
    /**
     * @param obdCrn
     */
    public void setObdCrn(String obdCrn) {
        this.obdCrn = obdCrn == null ? null : obdCrn.trim();
    }
    /**
     * @return obd_cvn
     */
    public String getObdCvn() {
        return obdCvn;
    }
    /**
     * @param obdCvn
     */
    public void setObdCvn(String obdCvn) {
        this.obdCvn = obdCvn == null ? null : obdCvn.trim();
    }
    /**
     * @return obd_iupr
     */
    public String getObdIupr() {
        return obdIupr;
    }
    /**
     * @param obdIupr
     */
    public void setObdIupr(String obdIupr) {
        this.obdIupr = obdIupr == null ? null : obdIupr.trim();
    }
    /**
     * @return obd_fault_code_num
     */
    public Integer getObdFaultCodeNum() {
        return obdFaultCodeNum;
    }
    /**
     * @param obdFaultCodeNum
     */
    public void setObdFaultCodeNum(Integer obdFaultCodeNum) {
        this.obdFaultCodeNum = obdFaultCodeNum;
    }
    /**
     * @return obd_fault_code
     */
    public String getObdFaultCode() {
        return obdFaultCode;
    }
    /**
     * @param obdFaultCode
     */
    public void setObdFaultCode(String obdFaultCode) {
        this.obdFaultCode = obdFaultCode == null ? null : obdFaultCode.trim();
    }
    /**
     * @return obd_status
     */
    public Boolean getObdStatus() {
        return obdStatus;
    }
    /**
     * @param obdStatus
     */
    public void setObdStatus(Boolean obdStatus) {
        this.obdStatus = obdStatus;
    }
}
src/main/kotlin/com/flightfeather/uav/domain/entity/ObdUser.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,91 @@
package com.flightfeather.uav.domain.entity;
import javax.persistence.*;
@Table(name = "obd_user")
public class ObdUser {
    @Id
    private Integer id;
    @Column(name = "obd_vin")
    private String obdVin;
    @Column(name = "obd_user_id")
    private Double obdUserId;
    @Column(name = "obd_user_name")
    private String obdUserName;
    @Column(name = "obd_user_password")
    private String obdUserPassword;
    /**
     * @return id
     */
    public Integer getId() {
        return id;
    }
    /**
     * @param id
     */
    public void setId(Integer id) {
        this.id = id;
    }
    /**
     * @return obd_vin
     */
    public String getObdVin() {
        return obdVin;
    }
    /**
     * @param obdVin
     */
    public void setObdVin(String obdVin) {
        this.obdVin = obdVin == null ? null : obdVin.trim();
    }
    /**
     * @return obd_user_id
     */
    public Double getObdUserId() {
        return obdUserId;
    }
    /**
     * @param obdUserId
     */
    public void setObdUserId(Double obdUserId) {
        this.obdUserId = obdUserId;
    }
    /**
     * @return obd_user_name
     */
    public String getObdUserName() {
        return obdUserName;
    }
    /**
     * @param obdUserName
     */
    public void setObdUserName(String obdUserName) {
        this.obdUserName = obdUserName == null ? null : obdUserName.trim();
    }
    /**
     * @return obd_user_password
     */
    public String getObdUserPassword() {
        return obdUserPassword;
    }
    /**
     * @param obdUserPassword
     */
    public void setObdUserPassword(String obdUserPassword) {
        this.obdUserPassword = obdUserPassword == null ? null : obdUserPassword.trim();
    }
}
src/main/kotlin/com/flightfeather/uav/domain/entity/OriginData.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,108 @@
package com.flightfeather.uav.domain.entity;
import javax.persistence.*;
@Table(name = "obd_origin_data")
public class OriginData {
    @Id
    private Integer id;
    @Column(name = "obd_device_code")
    private String obdDeviceCode;
    @Column(name = "obd_terminal_software_version")
    private Integer obdTerminalSoftwareVersion;
    @Column(name = "obd_encryption_way")
    private Integer obdEncryptionWay;
    @Column(name = "obd_command_unit")
    private Integer obdCommandUnit;
    @Column(name = "obd_content")
    private String obdContent;
    /**
     * @return id
     */
    public Integer getId() {
        return id;
    }
    /**
     * @param id
     */
    public void setId(Integer id) {
        this.id = id;
    }
    /**
     * @return obd_device_code
     */
    public String getObdDeviceCode() {
        return obdDeviceCode;
    }
    /**
     * @param obdDeviceCode
     */
    public void setObdDeviceCode(String obdDeviceCode) {
        this.obdDeviceCode = obdDeviceCode == null ? null : obdDeviceCode.trim();
    }
    /**
     * @return obd_terminal_software_version
     */
    public Integer getObdTerminalSoftwareVersion() {
        return obdTerminalSoftwareVersion;
    }
    /**
     * @param obdTerminalSoftwareVersion
     */
    public void setObdTerminalSoftwareVersion(Integer obdTerminalSoftwareVersion) {
        this.obdTerminalSoftwareVersion = obdTerminalSoftwareVersion;
    }
    /**
     * @return obd_encryption_way
     */
    public Integer getObdEncryptionWay() {
        return obdEncryptionWay;
    }
    /**
     * @param obdEncryptionWay
     */
    public void setObdEncryptionWay(Integer obdEncryptionWay) {
        this.obdEncryptionWay = obdEncryptionWay;
    }
    /**
     * @return obd_command_unit
     */
    public Integer getObdCommandUnit() {
        return obdCommandUnit;
    }
    /**
     * @param obdCommandUnit
     */
    public void setObdCommandUnit(Integer obdCommandUnit) {
        this.obdCommandUnit = obdCommandUnit;
    }
    /**
     * @return obd_content
     */
    public String getObdContent() {
        return obdContent;
    }
    /**
     * @param obdContent
     */
    public void setObdContent(String obdContent) {
        this.obdContent = obdContent == null ? null : obdContent.trim();
    }
}
src/main/kotlin/com/flightfeather/uav/domain/entity/ThresholdValue.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,499 @@
package com.flightfeather.uav.domain.entity;
import javax.persistence.*;
@Table(name = "obd_threshold_value")
public class ThresholdValue {
    @Id
    private Integer id;
    @Column(name = "obd_vin")
    private String obdVin;
    @Column(name = "th_mil")
    private Integer thMil;
    @Column(name = "th_fault_code_num")
    private Integer thFaultCodeNum;
    @Column(name = "th_fault_code")
    private String thFaultCode;
    @Column(name = "th_speed")
    private Integer thSpeed;
    @Column(name = "th_air_pressure")
    private Double thAirPressure;
    @Column(name = "th_engine_torque")
    private Double thEngineTorque;
    @Column(name = "th_friction_torque")
    private Double thFrictionTorque;
    @Column(name = "th_engine_rpm")
    private Integer thEngineRpm;
    @Column(name = "th_start_fuel_flow")
    private Double thStartFuelFlow;
    @Column(name = "th_scr_upstream_NO")
    private Double thScrUpstreamNo;
    @Column(name = "th_scr_downstream_NO")
    private Double thScrDownstreamNo;
    @Column(name = "th_remain_reactant")
    private Double thRemainReactant;
    @Column(name = "th_air_input")
    private Double thAirInput;
    @Column(name = "th_scr_input_temp")
    private Double thScrInputTemp;
    @Column(name = "th_scr_output_temp")
    private Double thScrOutputTemp;
    @Column(name = "th_DPF")
    private Double thDpf;
    @Column(name = "th_engine_coolant_temp")
    private Double thEngineCoolantTemp;
    @Column(name = "th_fuel_level")
    private Double thFuelLevel;
    @Column(name = "th_location_status")
    private Integer thLocationStatus;
    @Column(name = "th_total_mileage")
    private Double thTotalMileage;
    @Column(name = "th_engine_torque_mode")
    private String thEngineTorqueMode;
    @Column(name = "th_accelerator_pedal")
    private Double thAcceleratorPedal;
    @Column(name = "th_total_oil_consumption")
    private Double thTotalOilConsumption;
    @Column(name = "th_urea_box_temp")
    private Double thUreaBoxTemp;
    @Column(name = "th_urea_volume")
    private Integer thUreaVolume;
    @Column(name = "th_total_urea_consume")
    private Double thTotalUreaConsume;
    @Column(name = "th_DPF_temp")
    private Double thDpfTemp;
    /**
     * @return id
     */
    public Integer getId() {
        return id;
    }
    /**
     * @param id
     */
    public void setId(Integer id) {
        this.id = id;
    }
    /**
     * @return obd_vin
     */
    public String getObdVin() {
        return obdVin;
    }
    /**
     * @param obdVin
     */
    public void setObdVin(String obdVin) {
        this.obdVin = obdVin == null ? null : obdVin.trim();
    }
    /**
     * @return th_mil
     */
    public Integer getThMil() {
        return thMil;
    }
    /**
     * @param thMil
     */
    public void setThMil(Integer thMil) {
        this.thMil = thMil;
    }
    /**
     * @return th_fault_code_num
     */
    public Integer getThFaultCodeNum() {
        return thFaultCodeNum;
    }
    /**
     * @param thFaultCodeNum
     */
    public void setThFaultCodeNum(Integer thFaultCodeNum) {
        this.thFaultCodeNum = thFaultCodeNum;
    }
    /**
     * @return th_fault_code
     */
    public String getThFaultCode() {
        return thFaultCode;
    }
    /**
     * @param thFaultCode
     */
    public void setThFaultCode(String thFaultCode) {
        this.thFaultCode = thFaultCode == null ? null : thFaultCode.trim();
    }
    /**
     * @return th_speed
     */
    public Integer getThSpeed() {
        return thSpeed;
    }
    /**
     * @param thSpeed
     */
    public void setThSpeed(Integer thSpeed) {
        this.thSpeed = thSpeed;
    }
    /**
     * @return th_air_pressure
     */
    public Double getThAirPressure() {
        return thAirPressure;
    }
    /**
     * @param thAirPressure
     */
    public void setThAirPressure(Double thAirPressure) {
        this.thAirPressure = thAirPressure;
    }
    /**
     * @return th_engine_torque
     */
    public Double getThEngineTorque() {
        return thEngineTorque;
    }
    /**
     * @param thEngineTorque
     */
    public void setThEngineTorque(Double thEngineTorque) {
        this.thEngineTorque = thEngineTorque;
    }
    /**
     * @return th_friction_torque
     */
    public Double getThFrictionTorque() {
        return thFrictionTorque;
    }
    /**
     * @param thFrictionTorque
     */
    public void setThFrictionTorque(Double thFrictionTorque) {
        this.thFrictionTorque = thFrictionTorque;
    }
    /**
     * @return th_engine_rpm
     */
    public Integer getThEngineRpm() {
        return thEngineRpm;
    }
    /**
     * @param thEngineRpm
     */
    public void setThEngineRpm(Integer thEngineRpm) {
        this.thEngineRpm = thEngineRpm;
    }
    /**
     * @return th_start_fuel_flow
     */
    public Double getThStartFuelFlow() {
        return thStartFuelFlow;
    }
    /**
     * @param thStartFuelFlow
     */
    public void setThStartFuelFlow(Double thStartFuelFlow) {
        this.thStartFuelFlow = thStartFuelFlow;
    }
    /**
     * @return th_scr_upstream_NO
     */
    public Double getThScrUpstreamNo() {
        return thScrUpstreamNo;
    }
    /**
     * @param thScrUpstreamNo
     */
    public void setThScrUpstreamNo(Double thScrUpstreamNo) {
        this.thScrUpstreamNo = thScrUpstreamNo;
    }
    /**
     * @return th_scr_downstream_NO
     */
    public Double getThScrDownstreamNo() {
        return thScrDownstreamNo;
    }
    /**
     * @param thScrDownstreamNo
     */
    public void setThScrDownstreamNo(Double thScrDownstreamNo) {
        this.thScrDownstreamNo = thScrDownstreamNo;
    }
    /**
     * @return th_remain_reactant
     */
    public Double getThRemainReactant() {
        return thRemainReactant;
    }
    /**
     * @param thRemainReactant
     */
    public void setThRemainReactant(Double thRemainReactant) {
        this.thRemainReactant = thRemainReactant;
    }
    /**
     * @return th_air_input
     */
    public Double getThAirInput() {
        return thAirInput;
    }
    /**
     * @param thAirInput
     */
    public void setThAirInput(Double thAirInput) {
        this.thAirInput = thAirInput;
    }
    /**
     * @return th_scr_input_temp
     */
    public Double getThScrInputTemp() {
        return thScrInputTemp;
    }
    /**
     * @param thScrInputTemp
     */
    public void setThScrInputTemp(Double thScrInputTemp) {
        this.thScrInputTemp = thScrInputTemp;
    }
    /**
     * @return th_scr_output_temp
     */
    public Double getThScrOutputTemp() {
        return thScrOutputTemp;
    }
    /**
     * @param thScrOutputTemp
     */
    public void setThScrOutputTemp(Double thScrOutputTemp) {
        this.thScrOutputTemp = thScrOutputTemp;
    }
    /**
     * @return th_DPF
     */
    public Double getThDpf() {
        return thDpf;
    }
    /**
     * @param thDpf
     */
    public void setThDpf(Double thDpf) {
        this.thDpf = thDpf;
    }
    /**
     * @return th_engine_coolant_temp
     */
    public Double getThEngineCoolantTemp() {
        return thEngineCoolantTemp;
    }
    /**
     * @param thEngineCoolantTemp
     */
    public void setThEngineCoolantTemp(Double thEngineCoolantTemp) {
        this.thEngineCoolantTemp = thEngineCoolantTemp;
    }
    /**
     * @return th_fuel_level
     */
    public Double getThFuelLevel() {
        return thFuelLevel;
    }
    /**
     * @param thFuelLevel
     */
    public void setThFuelLevel(Double thFuelLevel) {
        this.thFuelLevel = thFuelLevel;
    }
    /**
     * @return th_location_status
     */
    public Integer getThLocationStatus() {
        return thLocationStatus;
    }
    /**
     * @param thLocationStatus
     */
    public void setThLocationStatus(Integer thLocationStatus) {
        this.thLocationStatus = thLocationStatus;
    }
    /**
     * @return th_total_mileage
     */
    public Double getThTotalMileage() {
        return thTotalMileage;
    }
    /**
     * @param thTotalMileage
     */
    public void setThTotalMileage(Double thTotalMileage) {
        this.thTotalMileage = thTotalMileage;
    }
    /**
     * @return th_engine_torque_mode
     */
    public String getThEngineTorqueMode() {
        return thEngineTorqueMode;
    }
    /**
     * @param thEngineTorqueMode
     */
    public void setThEngineTorqueMode(String thEngineTorqueMode) {
        this.thEngineTorqueMode = thEngineTorqueMode == null ? null : thEngineTorqueMode.trim();
    }
    /**
     * @return th_accelerator_pedal
     */
    public Double getThAcceleratorPedal() {
        return thAcceleratorPedal;
    }
    /**
     * @param thAcceleratorPedal
     */
    public void setThAcceleratorPedal(Double thAcceleratorPedal) {
        this.thAcceleratorPedal = thAcceleratorPedal;
    }
    /**
     * @return th_total_oil_consumption
     */
    public Double getThTotalOilConsumption() {
        return thTotalOilConsumption;
    }
    /**
     * @param thTotalOilConsumption
     */
    public void setThTotalOilConsumption(Double thTotalOilConsumption) {
        this.thTotalOilConsumption = thTotalOilConsumption;
    }
    /**
     * @return th_urea_box_temp
     */
    public Double getThUreaBoxTemp() {
        return thUreaBoxTemp;
    }
    /**
     * @param thUreaBoxTemp
     */
    public void setThUreaBoxTemp(Double thUreaBoxTemp) {
        this.thUreaBoxTemp = thUreaBoxTemp;
    }
    /**
     * @return th_urea_volume
     */
    public Integer getThUreaVolume() {
        return thUreaVolume;
    }
    /**
     * @param thUreaVolume
     */
    public void setThUreaVolume(Integer thUreaVolume) {
        this.thUreaVolume = thUreaVolume;
    }
    /**
     * @return th_total_urea_consume
     */
    public Double getThTotalUreaConsume() {
        return thTotalUreaConsume;
    }
    /**
     * @param thTotalUreaConsume
     */
    public void setThTotalUreaConsume(Double thTotalUreaConsume) {
        this.thTotalUreaConsume = thTotalUreaConsume;
    }
    /**
     * @return th_DPF_temp
     */
    public Double getThDpfTemp() {
        return thDpfTemp;
    }
    /**
     * @param thDpfTemp
     */
    public void setThDpfTemp(Double thDpfTemp) {
        this.thDpfTemp = thDpfTemp;
    }
}
src/main/kotlin/com/flightfeather/uav/domain/entity/VehicleInfo.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,98 @@
package com.flightfeather.uav.domain.entity;
import javax.persistence.*;
@Table(name = "obd_vehicle_info")
public class VehicleInfo {
    @Id
    private Integer id;
    @Column(name = "obd_device_code")
    private String obdDeviceCode;
    @Column(name = "obd_vin")
    private String obdVin;
    @Column(name = "obd_licence_plate")
    private String obdLicencePlate;
    /**
     * 0: é›†å¡ï¼› 1:渣土车
     */
    @Column(name = "obd_vehicle_type")
    private Integer obdVehicleType;
    /**
     * @return id
     */
    public Integer getId() {
        return id;
    }
    /**
     * @param id
     */
    public void setId(Integer id) {
        this.id = id;
    }
    /**
     * @return obd_device_code
     */
    public String getObdDeviceCode() {
        return obdDeviceCode;
    }
    /**
     * @param obdDeviceCode
     */
    public void setObdDeviceCode(String obdDeviceCode) {
        this.obdDeviceCode = obdDeviceCode == null ? null : obdDeviceCode.trim();
    }
    /**
     * @return obd_vin
     */
    public String getObdVin() {
        return obdVin;
    }
    /**
     * @param obdVin
     */
    public void setObdVin(String obdVin) {
        this.obdVin = obdVin == null ? null : obdVin.trim();
    }
    /**
     * @return obd_licence_plate
     */
    public String getObdLicencePlate() {
        return obdLicencePlate;
    }
    /**
     * @param obdLicencePlate
     */
    public void setObdLicencePlate(String obdLicencePlate) {
        this.obdLicencePlate = obdLicencePlate == null ? null : obdLicencePlate.trim();
    }
    /**
     * èŽ·å–1: é›†å¡ï¼› 2:渣土车
     *
     * @return obd_vehicle_type - 1: é›†å¡ï¼› 2:渣土车
     */
    public Integer getObdVehicleType() {
        return obdVehicleType;
    }
    /**
     * è®¾ç½®1: é›†å¡ï¼› 2:渣土车
     *
     * @param obdVehicleType 1: é›†å¡ï¼› 2:渣土车
     */
    public void setObdVehicleType(Integer obdVehicleType) {
        this.obdVehicleType = obdVehicleType;
    }
}
src/main/kotlin/com/flightfeather/uav/domain/mapper/AlarmDataMapper.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
package com.flightfeather.uav.domain.mapper
import com.flightfeather.uav.domain.MyMapper
import com.flightfeather.uav.domain.entity.AlarmData
import org.apache.ibatis.annotations.Mapper
@Mapper
interface AlarmDataMapper : MyMapper<AlarmData>
src/main/kotlin/com/flightfeather/uav/domain/mapper/CarLoginMapper.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
package com.flightfeather.uav.domain.mapper
import com.flightfeather.uav.domain.MyMapper
import com.flightfeather.uav.domain.entity.CarLogin
import org.apache.ibatis.annotations.Mapper
@Mapper
interface CarLoginMapper : MyMapper<CarLogin>
src/main/kotlin/com/flightfeather/uav/domain/mapper/CarLogoutMapper.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
package com.flightfeather.uav.domain.mapper
import com.flightfeather.uav.domain.MyMapper
import com.flightfeather.uav.domain.entity.CarLogout
import org.apache.ibatis.annotations.Mapper
@Mapper
interface CarLogoutMapper : MyMapper<CarLogout>
src/main/kotlin/com/flightfeather/uav/domain/mapper/DataStreamMapper.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
package com.flightfeather.uav.domain.mapper
import com.flightfeather.uav.domain.MyMapper
import com.flightfeather.uav.domain.entity.DataStream
import org.apache.ibatis.annotations.Mapper
@Mapper
interface DataStreamMapper : MyMapper<DataStream>
src/main/kotlin/com/flightfeather/uav/domain/mapper/ObdDataMapper.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
package com.flightfeather.uav.domain.mapper
import com.flightfeather.uav.domain.MyMapper
import com.flightfeather.uav.domain.entity.ObdData
import org.apache.ibatis.annotations.Mapper
@Mapper
interface ObdDataMapper : MyMapper<ObdData>
src/main/kotlin/com/flightfeather/uav/domain/mapper/ObdInfoMapper.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
package com.flightfeather.uav.domain.mapper
import com.flightfeather.uav.domain.MyMapper
import com.flightfeather.uav.domain.entity.ObdInfo
import org.apache.ibatis.annotations.Mapper
@Mapper
interface ObdInfoMapper : MyMapper<ObdInfo>
src/main/kotlin/com/flightfeather/uav/domain/mapper/ObdUserMapper.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
package com.flightfeather.uav.domain.mapper
import com.flightfeather.uav.domain.MyMapper
import com.flightfeather.uav.domain.entity.ObdUser
import org.apache.ibatis.annotations.Mapper
@Mapper
interface ObdUserMapper : MyMapper<ObdUser>
src/main/kotlin/com/flightfeather/uav/domain/mapper/OriginDataMapper.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
package com.flightfeather.uav.domain.mapper
import com.flightfeather.uav.domain.MyMapper
import com.flightfeather.uav.domain.entity.OriginData
import org.apache.ibatis.annotations.Mapper
@Mapper
interface OriginDataMapper : MyMapper<OriginData>
src/main/kotlin/com/flightfeather/uav/domain/mapper/ThresholdValueMapper.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
package com.flightfeather.uav.domain.mapper
import com.flightfeather.uav.domain.MyMapper
import com.flightfeather.uav.domain.entity.ThresholdValue
import org.apache.ibatis.annotations.Mapper
@Mapper
interface ThresholdValueMapper : MyMapper<ThresholdValue>
src/main/kotlin/com/flightfeather/uav/domain/mapper/VehicleInfoMapper.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,8 @@
package com.flightfeather.uav.domain.mapper
import com.flightfeather.uav.domain.MyMapper
import com.flightfeather.uav.domain.entity.VehicleInfo
import org.apache.ibatis.annotations.Mapper
@Mapper
interface VehicleInfoMapper : MyMapper<VehicleInfo>
src/main/kotlin/com/flightfeather/uav/lightshare/bean/AlarmDataVo.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,46 @@
package com.flightfeather.uav.lightshare.bean
import java.util.*
/**
 * @author riku
 * Date: 2019/9/2
 */
class AlarmDataVo :BaseJson() {
    var id: Int? = null
    var obdVin: String? = null
    var alarmTime: Date? = null
    var alarmLng: Double? = null
    var alarmLat: Double? = null
    var alarmProtocol: Int? = null
    var alarmMil: Int? = null
    var alarmIdCode: String? = null
    var alarmVerificationCode: String? = null
    var alarmFaultCodeNum: Int? = null
    var alarmFaultCode: String? = null
    var alarmSpeed: Int? = null
    var alarmAirPressure: Double? = null
    var alarmEngineTorque: Double? = null
    var alarmFrictionTorque: Double? = null
    var alarmEngineRpm: Int? = null
    var alarmStartFuelFlow: Double? = null
    var alarmScrUpstreamNo: Double? = null
    var alarmScrDownstreamNo: Double? = null
    var alarmRemainReactant: Double? = null
    var alarmAirInput: Double? = null
    var alarmScrInputTemp: Double? = null
    var alarmScrOutputTemp: Double? = null
    var alarmDpf: Double? = null
    var alarmEngineCoolantTemp: Double? = null
    var alarmFuelLevel: Double? = null
    var alarmLocationStatus: Int? = null
    var alarmTotalMileage: Double? = null
    var alarmEngineTorqueMode: String? = null
    var alarmAcceleratorPedal: Double? = null
    var alarmTotalOilConsumption: Double? = null
    var alarmUreaBoxTemp: Double? = null
    var alarmUreaVolume: Int? = null
    var alarmTotalUreaConsume: Double? = null
    var alarmDpfTemp: Double? = null
    var alarmFirmwareVersion: String? = null
}
src/main/kotlin/com/flightfeather/uav/lightshare/bean/BaseJson.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,15 @@
package com.flightfeather.uav.lightshare.bean
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonInclude
/**
 * åŸºç¡€Json结构,所有的数据以此为基类
 * @author riku
 * Date: 2019/8/27
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
open class BaseJson{
    val cmdCode: Int? = null
}
src/main/kotlin/com/flightfeather/uav/lightshare/bean/CarLoginVo.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
package com.flightfeather.uav.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
}
src/main/kotlin/com/flightfeather/uav/lightshare/bean/CarLogoutVo.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,15 @@
package com.flightfeather.uav.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
}
src/main/kotlin/com/flightfeather/uav/lightshare/bean/DataStreamVo.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,42 @@
package com.flightfeather.uav.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
}
src/main/kotlin/com/flightfeather/uav/lightshare/bean/LatLngVo.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
package com.flightfeather.uav.lightshare.bean
import java.util.*
/**
 * @author riku
 * Date: 2019/9/19
 */
class LatLngVo : BaseJson() {
    var deviceCode: String? = null
    var vin: String? = null
    var license: String? = null
    var obdDataTime: Date? = null
    //车辆类型
    var carType: Int? = null
    //车辆状态
    var status: Int = 0
    var lat: Double? = null
    var lng: Double? = null
}
src/main/kotlin/com/flightfeather/uav/lightshare/bean/ObdDataVo.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,45 @@
package com.flightfeather.uav.lightshare.bean
import com.google.gson.annotations.SerializedName
import java.util.*
class ObdDataVo :  BaseJson() {
    var id: Int? = null
    @SerializedName("vin")
    var obdVin: String? = null
    var obdTime: Date? = null
    var obdLng: Double? = null
    var obdLat: Double? = null
    @SerializedName("protocol")
    var obdProtocol: Int? = null
    var obdMil: Int? = null
    var obdIdCode: String? = null
    var obdVerificationCode: String? = null
    var obdFaultCodeNum: Int? = null
    var obdFaultCode: String? = null
    var obdSpeed: Int? = null
    var obdAirPressure: Double? = null
    var obdEngineTorque: Double? = null
    var obdFrictionTorque: Double? = null
    var obdEngineRpm: Int? = null
    var obdEngineFuelFlow: Double? = null
    var obdScrUpstreamNo: Double? = null
    var obdScrDownstreamNo: 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: Int? = null
    var obdTotalMileage: Double? = null
    var obdEngineTorqueMode: String? = null
    var obdAcceleratorPedal: Double? = null
    var obdTotalOilConsumption: Double? = null
    var obdUreaBoxTemp: Double? = null
    var obdUreaVolume: Int? = null
    var obdTotalUreaConsume: Double? = null
    var obdDpfTemp: Double? = null
    var obdFirmwareVersion: String? = null
}
src/main/kotlin/com/flightfeather/uav/lightshare/bean/ObdInfoVo.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,26 @@
package com.flightfeather.uav.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
}
src/main/kotlin/com/flightfeather/uav/lightshare/bean/ObdUserVo.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,13 @@
package com.flightfeather.uav.lightshare.bean
/**
 * @author riku
 * Date: 2019/9/2
 */
class ObdUserVo : BaseJson() {
    var id: Int? = null
    var obdVin: String? = null
    var obdUserId: Double? = null
    var obdUserName: String? = null
}
src/main/kotlin/com/flightfeather/uav/lightshare/bean/ThresholdValueVo.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,37 @@
package com.flightfeather.uav.lightshare.bean
/**
 * @author riku
 * Date: 2019/9/2
 */
class ThresholdValueVo : BaseJson() {
    var id:Int? = null
    var obdVin:String? = null
    var thMil:Int? = null
    var thFaultCodeNum:Int? = null
    var thFaultCode:String? = null
    var thSpeed:Int? = null
    var thAirPressure:Double? = null
    var thEngineTorque:Double? = null
    var thFrictionTorque:Double? = null
    var thEngineRpm:Int? = null
    var thStartFuelFlow:Double? = null
    var thScrUpstreamNo:Double? = null
    var thScrDownstreamNo:Double? = null
    var thRemainReactant:Double? = null
    var thAirInput:Double? = null
    var thScrInputTemp:Double? = null
    var thScrOutputTemp:Double? = null
    var thDpf:Double? = null
    var thEngineCoolantTemp:Double? = null
    var thFuelLevel:Double? = null
    var thLocationStatus:Int? = null
    var thTotalMileage:Double? = null
    var thEngineTorqueMode:String? = null
    var thAcceleratorPedal:Double? = null
    var thTotalOilConsumption:Double? = null
    var thUreaBoxTemp:Double? = null
    var thUreaVolume:Int? = null
    var thTotalUreaConsume:Double? = null
    var thDpfTemp:Double? = null
}
src/main/kotlin/com/flightfeather/uav/lightshare/bean/VehicleInfoVo.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
package com.flightfeather.uav.lightshare.bean
/**
 * @author riku
 * Date: 2019/10/25
 */
class VehicleInfoVo : BaseJson() {
    var id: Int? = null
    var obdDeviceCode: String? = null
    var obdVin: String? = null
    var obdLicencePlate: String? = null
    /**
     * 0: é›†å¡ï¼› 1:渣土车
     */
    var obdVehicleType: Int? = null
}
src/main/kotlin/com/flightfeather/uav/lightshare/eunm/CarStatus.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
package com.flightfeather.uav.lightshare.eunm
/**
 * @author riku
 * Date: 2019/9/26
 * è½¦è¾†çŠ¶æ€
 * 0:离线
 * 1:在线
 * 2:警报
 * 3:超标
 */
enum class CarStatus(val value: Int) {
    OffLine(0),
    OnLine(1),
    Warn(2),
    Exceed(3)
}
src/main/kotlin/com/flightfeather/uav/lightshare/eunm/CarType.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,12 @@
package com.flightfeather.uav.lightshare.eunm
/**
 * @author riku
 * Date: 2019/9/26
 */
enum class CarType(val value: Int){
    //集装箱卡车
    ContainerTruck(0),
    //渣土车
    SlagCar(1)
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/ObdAlarmService.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
package com.flightfeather.uav.lightshare.service
import com.flightfeather.uav.lightshare.bean.AlarmDataVo
/**
 * @author riku
 * Date: 2019/9/5
 */
interface ObdAlarmService {
    /**
     * æ ¹æ®vin码获取警报数据
     */
    fun getAlarmByVinCode(vinCode: String, pageNum: Int?, pageSize: Int?): MutableList<AlarmDataVo>
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/ObdDataService.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,60 @@
package com.flightfeather.uav.lightshare.service
import com.flightfeather.uav.lightshare.bean.*
/**
 * @author riku
 * Date: 2019/8/27
 */
interface ObdDataService {
    /**
     * æ ¹æ®vin码获取对应数据
     */
    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 getDataStreamCount(deviceCode: String, startTime: String?, endTime: String?): Int
    /**
     * æ ¹æ®ç»ˆç«¯è®¾å¤‡ç èŽ·å–æœ€æ–°ç»çº¬åº¦
     */
    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>
    /**
     * æ ¹æ®ç»ˆç«¯è®¾å¤‡ç åŠæ—¶é—´æ®µï¼Œç»™å‡ºæ­¤æ®µæ—¶é—´å†…的坐标
     */
    //TODO
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/ObdThresholdValueService.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,26 @@
package com.flightfeather.uav.lightshare.service
import com.flightfeather.uav.lightshare.bean.ThresholdValueVo
/**
 * @author riku
 * Date: 2019/9/5
 */
interface ObdThresholdValueService {
    /**
     * ä¿å­˜
     */
    fun save(userId: String, thresholdValueVo: ThresholdValueVo): Boolean
    /**
     * æ›´æ–°
     */
    fun update(userId: String, thresholdValueVo: ThresholdValueVo): Boolean
    /**
     * æ ¹æ®vin码获取对应阈值
     */
    fun getDataByVinCode(vinCode: String): ThresholdValueVo?
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/ObdUserService.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,13 @@
package com.flightfeather.uav.lightshare.service
import com.flightfeather.uav.lightshare.bean.ObdUserVo
/**
 * @author riku
 * Date: 2019/9/6
 */
interface ObdUserService {
    fun getUserInfo(userId: String): ObdUserVo?
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/VehicleService.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
package com.flightfeather.uav.lightshare.service
import com.flightfeather.uav.lightshare.bean.VehicleInfoVo
/**
 * @author riku
 * Date: 2019/10/25
 * è½¦è¾†ç›¸å…³ä¿¡æ¯æŽ¥å£
 */
interface VehicleService {
    /**
     * èŽ·å–è½¦è¾†ä¿¡æ¯
     */
    fun getVehicleInfo(pageNum: Int?, pageSize: Int?): List<VehicleInfoVo>
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ObdAlarmServiceImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,19 @@
package com.flightfeather.uav.lightshare.service.impl
import com.flightfeather.uav.lightshare.bean.AlarmDataVo
import com.flightfeather.uav.lightshare.service.ObdAlarmService
import com.flightfeather.uav.repository.ObdAlarmRepository
import org.springframework.stereotype.Service
/**
 * @author riku
 * Date: 2019/9/5
 */
@Service
class ObdAlarmServiceImpl(val obdAlarmRepository: ObdAlarmRepository) : ObdAlarmService {
    override fun getAlarmByVinCode(vinCode: String, pageNum: Int?, pageSize: Int?): MutableList<AlarmDataVo> {
        return obdAlarmRepository.getAlarmByVinCode(vinCode, pageNum, pageSize)
    }
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ObdDataServiceImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,164 @@
package com.flightfeather.uav.lightshare.service.impl
import com.flightfeather.uav.lightshare.bean.*
import com.flightfeather.uav.lightshare.eunm.CarStatus
import com.flightfeather.uav.lightshare.service.ObdDataService
import com.flightfeather.uav.repository.*
import org.springframework.beans.BeanUtils
import org.springframework.stereotype.Service
import java.time.LocalDateTime
import java.time.ZoneId
/**
 * @author riku
 * Date: 2019/8/27
 */
@Service
class ObdDataServiceImpl(
        val obdDataRepository: ObdDataRepository,
        val carLoginRepository: CarLoginRepository,
        val carLogoutRepository: CarLogoutRepository,
        val obdInfoRepository: ObdInfoRepository,
        val dataStreamRepository: DataStreamRepository,
        val vehicleRepository: VehicleRepository
) : ObdDataService {
    override fun getDataByVinCode(vinCode: String?, pageNum: Int?, pageSize: Int?): MutableList<ObdDataVo>{
        val resultList = mutableListOf<ObdDataVo>()
        vehicleRepository.getVehicleInfo(pageNum, pageSize).forEach { vehicleInfo ->
            val dataStream = dataStreamRepository.getLatestDataStream(vehicleInfo.obdDeviceCode)
            val obdInfo = obdInfoRepository.getObdInfo(vehicleInfo.obdDeviceCode, 1, 1).takeIf { it.isNotEmpty() }?.get(0)
            resultList.add(ObdDataVo().apply {
                obdVin = obdInfo?.obdDeviceCode
                obdTime = dataStream?.obdDataTime
                obdLng = dataStream?.obdLong
                obdLat = dataStream?.obdLat
                obdProtocol = obdInfo?.obdProtocol
                obdMil = obdInfo?.obdMil
//                obdIdCode
//                obdVerificationCode
                obdFaultCodeNum = obdInfo?.obdFaultCodeNum
                obdFaultCode = obdInfo?.obdFaultCode
                obdSpeed = dataStream?.obdSpeed?.toInt()
                obdAirPressure = dataStream?.obdAirPressure
                obdEngineTorque = dataStream?.obdEngineTorque
                obdFrictionTorque = dataStream?.obdFrictionTorque
                obdEngineRpm = dataStream?.obdEngineRpm?.toInt()
                obdEngineFuelFlow = dataStream?.obdEngineFuelFlow
                obdScrUpstreamNo = dataStream?.obdScrUpstreamNox
                obdScrDownstreamNo = dataStream?.obdScrDownstreamNox
                obdRemainReactant = dataStream?.obdRemainReactant
                obdAirInput = dataStream?.obdAirInput
                obdScrInputTemp = dataStream?.obdScrInputTemp
                obdScrOutputTemp = dataStream?.obdScrOutputTemp
                obdDpf = dataStream?.obdDpf
                obdEngineCoolantTemp = dataStream?.obdEngineCoolantTemp
                obdFuelLevel = dataStream?.obdFuelLevel
//                obdLocationStatus = dataStream?.obdLocationStatus
                obdTotalMileage = dataStream?.obdTotalMileage
                obdEngineTorqueMode = dataStream?.obdEngineTorqueMode?.toString()
                obdAcceleratorPedal = dataStream?.obdAcceleratorPedal
                obdTotalOilConsumption = dataStream?.obdTotalOilConsumption
                obdUreaBoxTemp = dataStream?.obdUreaBoxTemp
                obdUreaVolume = dataStream?.obdUreaVolume?.toInt()
                obdTotalUreaConsume = dataStream?.obdTotalUreaConsume
                obdDpfTemp = dataStream?.obdDpfTemp
//                obdFirmwareVersion = dataStream?.
            })
        }
        return resultList
    }
    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>{
        val resultList = mutableListOf<ObdInfoVo>()
        obdInfoRepository.getObdInfo(deviceCode, pageNum, pageSize).forEach {
            val vo = ObdInfoVo()
            BeanUtils.copyProperties(it, vo)
            resultList.add(vo)
        }
        return resultList
    }
    override fun getDataStream(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<DataStreamVo>
            = dataStreamRepository.getDataStream(deviceCode, pageNum, pageSize, startTime, endTime)
    override fun getDataStreamCount(deviceCode: String, startTime: String?, endTime: String?): Int
            = dataStreamRepository.getDataStreamCount(deviceCode, startTime, endTime)
    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).run {
            sortedBy {
                it.obdDataTime
            }
        }.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>()
        val now = LocalDateTime.now()
        vehicleRepository.getVehicleInfo(pageNum, pageSize).forEach { vehicleInfo ->
            val dataStream = dataStreamRepository.getLatestDataStream(vehicleInfo.obdDeviceCode)
            val obdInfo = obdInfoRepository.getObdInfo(vehicleInfo.obdDeviceCode, 1, 1).takeIf { it.isNotEmpty() }?.get(0)
            //获取数据采样时间,如果为空,则取当前时间的前24小时
            val dataTime = dataStream?.obdDataTime?.toInstant()?.atZone(ZoneId.systemDefault())?.toLocalDateTime()
                    ?: LocalDateTime.now().minusDays(1)
            resultList.add(LatLngVo().apply {
                deviceCode = vehicleInfo.obdDeviceCode
                vin = obdInfo?.obdVin
                license = vehicleInfo.obdLicencePlate
                obdDataTime = dataStream?.obdDataTime
                carType = vehicleInfo.obdVehicleType
                //采样时间和当前时间相差超过10分钟认为设备处于离线状态
                //todo 2019.10.25 å…¶ä½™ä¸¤ç§è½¦è¾†çŠ¶æ€ï¼ŒåŽç»­éœ€å¤„ç†
                status = if (now.minusMinutes(10).isAfter(dataTime)) {
                    CarStatus.OffLine.value
                } else {
                    CarStatus.OnLine.value
                }
                lat = dataStream?.obdLat
                lng = dataStream?.obdLong
            })
        }
        return resultList
    }
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ObdThresholdValueServiceImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,27 @@
package com.flightfeather.uav.lightshare.service.impl
import com.flightfeather.uav.lightshare.bean.ThresholdValueVo
import com.flightfeather.uav.lightshare.service.ObdThresholdValueService
import com.flightfeather.uav.repository.ObdThresholdValueRepository
import org.springframework.stereotype.Service
/**
 * @author riku
 * Date: 2019/9/5
 */
@Service
class ObdThresholdValueServiceImpl(val obdThresholdValueRepository: ObdThresholdValueRepository) : ObdThresholdValueService {
    override fun save(userId: String, thresholdValueVo: ThresholdValueVo): Boolean {
        return obdThresholdValueRepository.save(userId, thresholdValueVo)
    }
    override fun update(userId: String, thresholdValueVo: ThresholdValueVo): Boolean {
        return obdThresholdValueRepository.update(userId, thresholdValueVo)
    }
    override fun getDataByVinCode(vinCode: String): ThresholdValueVo? {
        return obdThresholdValueRepository.getByVinCode(vinCode)
    }
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/ObdUserServiceImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,18 @@
package com.flightfeather.uav.lightshare.service.impl
import com.flightfeather.uav.lightshare.bean.ObdUserVo
import com.flightfeather.uav.lightshare.service.ObdUserService
import com.flightfeather.uav.repository.ObdUserRepository
import org.springframework.stereotype.Service
/**
 * @author riku
 * Date: 2019/9/6
 */
@Service
class ObdUserServiceImpl(val userRepository: ObdUserRepository) :ObdUserService{
    override fun getUserInfo(userId: String): ObdUserVo? {
        return userRepository.getUserInfo(userId)
    }
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/VehicleServiceImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,28 @@
package com.flightfeather.uav.lightshare.service.impl
import com.flightfeather.uav.lightshare.bean.VehicleInfoVo
import com.flightfeather.uav.lightshare.service.VehicleService
import com.flightfeather.uav.repository.VehicleRepository
import org.springframework.beans.BeanUtils
import org.springframework.stereotype.Service
/**
 * @author riku
 * Date: 2019/10/25
 */
@Service
class VehicleServiceImpl(val vehicleRepository: VehicleRepository) : VehicleService {
    override fun getVehicleInfo(pageNum: Int?, pageSize: Int?): List<VehicleInfoVo> {
        val dbResult = vehicleRepository.getVehicleInfo(pageNum, pageSize)
        val resultList = mutableListOf<VehicleInfoVo>()
        dbResult.forEach {
            val vo = VehicleInfoVo()
            BeanUtils.copyProperties(it, vo)
            resultList.add(vo)
        }
        return resultList
    }
}
src/main/kotlin/com/flightfeather/uav/lightshare/web/ObdAlarmController.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
package com.flightfeather.uav.lightshare.web
import com.flightfeather.uav.lightshare.service.ObdAlarmService
import org.springframework.web.bind.annotation.*
/**
 * @author riku
 * Date: 2019/9/5
 */
@RestController
@RequestMapping("uav/alarm")
class ObdAlarmController(val obdAlarmService: ObdAlarmService) {
    @GetMapping("/{vinCode}")
    fun getAlarmByVinCode(
            @PathVariable("vinCode") vinCode: String,
            @RequestParam("page", required = false) pageNum: Int?,
            @RequestParam("per_page", required = false) pageSize: Int?
    ) = obdAlarmService.getAlarmByVinCode(vinCode, pageNum, pageSize)
}
src/main/kotlin/com/flightfeather/uav/lightshare/web/ObdDataController.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,79 @@
package com.flightfeather.uav.lightshare.web
import com.flightfeather.uav.lightshare.service.ObdDataService
import org.springframework.web.bind.annotation.*
/**
 * @author riku
 * Date: 2019/8/27
 */
@RestController
@RequestMapping("uav/data")
class ObdDataController(val obdDataService: ObdDataService) {
    @GetMapping("/data")
    fun getById(
            @RequestParam("vinCode", required = false) vinCode: String?,
            @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/")
    fun getObdInfo(
            @RequestParam("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("/dataStream/count")
    fun getDataStreamCount(
            @RequestParam("deviceCode") deviceCode: String = "",
            @RequestParam("startTime", required = false) startTime: String?,
            @RequestParam("endTime", required = false) endTime: String?
    ) = obdDataService.getDataStreamCount(deviceCode, startTime, endTime)
    @GetMapping("/coordinate/{deviceCode}")
    fun getCoordinate(
            @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?,
            @RequestParam("per_page", required = false) pageSize: Int?
    ) = obdDataService.getLatestCoordinate(pageNum, pageSize)
}
src/main/kotlin/com/flightfeather/uav/lightshare/web/ObdThresholdController.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,32 @@
package com.flightfeather.uav.lightshare.web
import com.flightfeather.uav.lightshare.bean.ThresholdValueVo
import com.flightfeather.uav.lightshare.service.ObdThresholdValueService
import org.springframework.web.bind.annotation.*
/**
 * @author riku
 * Date: 2019/9/5
 */
@RestController
@RequestMapping("uav/threshold")
class ObdThresholdController(val obdThresholdValueService: ObdThresholdValueService) {
    @GetMapping("/{vinCode}")
    fun getDataByVinCode(
            @PathVariable("vinCode") vinCode: String
    ) = obdThresholdValueService.getDataByVinCode(vinCode)
    @PostMapping("/update")
    fun update(
            @RequestParam("userId") userId: String,
            @RequestBody thresholdValueVo: ThresholdValueVo
    ) = obdThresholdValueService.update(userId, thresholdValueVo)
    @PutMapping("/save")
    fun save(
            @RequestParam("userId") userId: String,
            @RequestBody thresholdValueVo: ThresholdValueVo
    ) = obdThresholdValueService.save(userId, thresholdValueVo)
}
src/main/kotlin/com/flightfeather/uav/lightshare/web/ObdUserController.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
package com.flightfeather.uav.lightshare.web
import com.flightfeather.uav.lightshare.service.ObdUserService
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
/**
 * @author riku
 * Date: 2019/9/6
 */
@RestController
@RequestMapping("uav/user")
class ObdUserController(val obdUserService: ObdUserService) {
    @GetMapping("/info/{userId}")
    fun getUserInfo(
            @PathVariable("userId") userId: String
    ) = obdUserService.getUserInfo(userId)
}
src/main/kotlin/com/flightfeather/uav/lightshare/web/VehicleInfoController.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
package com.flightfeather.uav.lightshare.web
import com.flightfeather.uav.lightshare.service.VehicleService
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
/**
 * @author riku
 * Date: 2019/10/25
 */
@RestController
@RequestMapping("uav/vehicle")
class VehicleInfoController(val vehicleService: VehicleService) {
    @GetMapping("/info")
    fun getVehicleInfo(
            @RequestParam("page", required = false) pageNum: Int?,
            @RequestParam("per_page", required = false) pageSize: Int?
    ) = vehicleService.getVehicleInfo(pageNum, pageSize)
}
src/main/kotlin/com/flightfeather/uav/repository/CarLoginRepository.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
package com.flightfeather.uav.repository
import com.flightfeather.uav.lightshare.bean.CarLoginVo
import com.flightfeather.uav.socket.bean.ObdPackageData
/**
 * @author riku
 * Date: 2019/9/17
 */
interface CarLoginRepository {
    /**
     * ä¿å­˜è½¦è¾†ç™»å…¥ä¿¡æ¯
     */
    fun saveCarLogin(packageData: ObdPackageData): Boolean
    /**
     * æ ¹æ®ç»ˆç«¯è®¾å¤‡ç èŽ·å–ç™»å½•æ•°æ®
     */
    fun getLoginData(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<CarLoginVo>
}
src/main/kotlin/com/flightfeather/uav/repository/CarLogoutRepository.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,21 @@
package com.flightfeather.uav.repository
import com.flightfeather.uav.lightshare.bean.CarLogoutVo
import com.flightfeather.uav.socket.bean.ObdPackageData
/**
 * @author riku
 * Date: 2019/9/17
 */
interface CarLogoutRepository {
    /**
     * ä¿å­˜ è½¦è¾†ç™»å‡ºå…¥ä¿¡æ¯
     */
    fun saveCarLogout(packageData: ObdPackageData): Boolean
    /**
     * æ ¹æ®ç»ˆç«¯è®¾å¤‡ç èŽ·å–ç™»å‡ºæ•°æ®
     */
    fun getLogoutData(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<CarLogoutVo>
}
src/main/kotlin/com/flightfeather/uav/repository/DataStreamRepository.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,32 @@
package com.flightfeather.uav.repository
import com.flightfeather.uav.domain.entity.DataStream
import com.flightfeather.uav.lightshare.bean.DataStreamVo
import com.flightfeather.uav.socket.bean.ObdPackageData
/**
 * @author riku
 * Date: 2019/9/17
 */
interface DataStreamRepository {
    /**
     * ä¿å­˜ å®žæ—¶ä¿¡æ¯æˆ–补传信息 ä¸­çš„ æ•°æ®æµä¿¡æ¯ å’Œ è¡¥å……数据流
     */
    fun saveDataStream(packageData: ObdPackageData): Boolean
    /**
     * æ ¹æ®ç»ˆç«¯è®¾å¤‡ç èŽ·å–æ•°æ®æµæ•°æ®
     */
    fun getDataStream(deviceCode: String, pageNum: Int?, pageSize: Int?, startTime: String?, endTime: String?): List<DataStreamVo>
    /**
     * æ ¹æ®ç»ˆç«¯è®¾å¤‡ç èŽ·å–æ•°æ®æµæ•°æ®è®¡æ•°
     */
    fun getDataStreamCount(deviceCode: String, startTime: String?, endTime: String?): Int
    /**
     * èŽ·å–ä¸€è¾†è½¦æœ€æ–°çš„ä¸€æ¡çŠ¶æ€ä¿¡æ¯
     */
    fun getLatestDataStream(deviceCode: String): DataStream?
}
src/main/kotlin/com/flightfeather/uav/repository/ObdAlarmRepository.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
package com.flightfeather.uav.repository
import com.flightfeather.uav.lightshare.bean.AlarmDataVo
/**
 * obd警报相关数据库操作接口
 * @author riku
 * Date: 2019/9/5
 */
interface ObdAlarmRepository {
    /**
     * å­˜å‚¨è­¦æŠ¥æ•°æ®
     */
    fun saveObdAlarm(alarmDataVo: AlarmDataVo): Boolean
    /**
     * é€šè¿‡æ±½è½¦vin码获取警报数据
     */
    fun getAlarmByVinCode(vinCode: String, pageNum: Int?, pageSize: Int?): MutableList<AlarmDataVo>
}
src/main/kotlin/com/flightfeather/uav/repository/ObdDataRepository.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,25 @@
package com.flightfeather.uav.repository
import com.flightfeather.uav.lightshare.bean.ObdDataVo
import com.flightfeather.uav.socket.bean.ObdPackageData
/**
 * obd数据相关数据库操作接口
 * @author riku
 * Date: 2019/8/27
 */
interface ObdDataRepository {
    /**
     * å­˜å‚¨obd数据
     */
    fun saveObdData(data: ObdDataVo): Boolean
    /**
     * é€šè¿‡æ±½è½¦vin码获取最新数据
     */
    fun getDataByVinCode(vinCode: String?, pageNum: Int?, pageSize: Int?): MutableList<ObdDataVo>
    fun saveObdData(packageData: ObdPackageData):Boolean
}
src/main/kotlin/com/flightfeather/uav/repository/ObdInfoRepository.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,25 @@
package com.flightfeather.uav.repository
import com.flightfeather.uav.socket.bean.ObdInfo
import com.flightfeather.uav.socket.bean.ObdPackageData
import com.flightfeather.uav.socket.bean.RealTimeData
import com.flightfeather.uav.socket.bean.ReplacementData
/**
 * @author riku
 * Date: 2019/9/17
 */
interface ObdInfoRepository {
    /**
     * ä¿å­˜ å®žæ—¶ä¿¡æ¯ @see [RealTimeData] æˆ–补传信息 @see [ReplacementData]  ä¸­çš„ uav æ•°æ® @see [ObdInfo]
     */
    fun saveObdInfo(packageData: ObdPackageData): Boolean
    /**
     * æ ¹æ®ç»ˆç«¯è®¾å¤‡ç èŽ·å–obd数据
     */
    fun getObdInfo(deviceCode: String, pageNum: Int?, pageSize: Int?): List<com.flightfeather.uav.domain.entity.ObdInfo>
}
src/main/kotlin/com/flightfeather/uav/repository/ObdThresholdValueRepository.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,27 @@
package com.flightfeather.uav.repository
import com.flightfeather.uav.lightshare.bean.ThresholdValueVo
/**
 * obd警报阈值相关数据库操作接口
 * @author riku
 * Date: 2019/9/5
 */
interface ObdThresholdValueRepository {
    /**
     * å­˜å‚¨é˜ˆå€¼
     */
    fun save(userId: String, thresholdValueVo: ThresholdValueVo): Boolean
    /**
     * æ›´æ–°é˜ˆå€¼
     */
    fun update(userId: String, thresholdValueVo: ThresholdValueVo): Boolean
    /**
     * é€šè¿‡æ±½è½¦vin码获取阈值数据
     */
    fun getByVinCode(vinCode: String): ThresholdValueVo?
}
src/main/kotlin/com/flightfeather/uav/repository/ObdUserRepository.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,13 @@
package com.flightfeather.uav.repository
import com.flightfeather.uav.lightshare.bean.ObdUserVo
/**
 * @author riku
 * Date: 2019/9/6
 */
interface ObdUserRepository {
    fun getUserInfo(userId: String): ObdUserVo?
}
src/main/kotlin/com/flightfeather/uav/repository/OriginDataRepository.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
package com.flightfeather.uav.repository
import com.flightfeather.uav.socket.bean.ObdPackageData
/**
 * @author riku
 * Date: 2019/9/17
 */
interface OriginDataRepository {
    /**
     * ä¿å­˜å‰ç«¯ä¼ è¾“的原始数据 @see [ObdPackageData]
     */
    fun saveOriginData(packageData: ObdPackageData, msg: String): Boolean
}
src/main/kotlin/com/flightfeather/uav/repository/VehicleRepository.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,15 @@
package com.flightfeather.uav.repository
import com.flightfeather.uav.domain.entity.VehicleInfo
/**
 * @author riku
 * Date: 2019/10/25
 */
interface VehicleRepository {
    /**
     * èŽ·å–è½¦è¾†ä¿¡æ¯
     */
    fun getVehicleInfo(pageNum: Int?, pageSize: Int?): List<VehicleInfo>
}
src/main/kotlin/com/flightfeather/uav/repository/impl/CarLoginDaoImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,68 @@
package com.flightfeather.uav.repository.impl
import com.flightfeather.uav.domain.entity.CarLogin
import com.flightfeather.uav.domain.mapper.CarLoginMapper
import com.flightfeather.uav.lightshare.bean.CarLoginVo
import com.flightfeather.uav.repository.CarLoginRepository
import com.flightfeather.uav.socket.bean.CarRegisterData
import com.flightfeather.uav.socket.bean.ObdPackageData
import com.flightfeather.uav.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
 * Date: 2019/9/17
 */
@Repository
class CarLoginDaoImpl(val carLoginMapper: CarLoginMapper) : CarLoginRepository {
    override fun saveCarLogin(packageData: ObdPackageData): Boolean {
        return if (packageData.commandUnit == ObdCommandUnit.CarRegister.value) {
            val carLogin = CarLogin().apply {
                obdDeviceCode = packageData.deviceCode
            }
            packageData.dataUnit.forEach {
                when (it) {
                    is CarRegisterData -> carLogin.apply {
                        loginDataTime = it.time
                        loginSerialNum = it.serialNum
                        loginSimCode = it.SIMCode
                    }
                }
            }
            carLoginMapper.insert(carLogin) == 1
        } else {
            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
    }
}
src/main/kotlin/com/flightfeather/uav/repository/impl/CarLogoutDaoImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,65 @@
package com.flightfeather.uav.repository.impl
import com.flightfeather.uav.domain.entity.CarLogout
import com.flightfeather.uav.domain.mapper.CarLogoutMapper
import com.flightfeather.uav.lightshare.bean.CarLogoutVo
import com.flightfeather.uav.repository.CarLogoutRepository
import com.flightfeather.uav.socket.bean.CarLogOutData
import com.flightfeather.uav.socket.bean.ObdPackageData
import com.flightfeather.uav.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
 * Date: 2019/9/17
 */
@Repository
class CarLogoutDaoImpl(val carLogoutMapper: CarLogoutMapper): CarLogoutRepository {
    override fun saveCarLogout(packageData: ObdPackageData): Boolean {
        return if (packageData.commandUnit == ObdCommandUnit.CarLogOut.value) {
            val carLogout = CarLogout().apply {
                obdDeviceCode = packageData.deviceCode
            }
            packageData.dataUnit.forEach {
                when (it) {
                    is CarLogOutData -> carLogout.apply {
                        logoutDataTime = it.time
                        logoutSerialNum = it.serialNum
                    }
                }
            }
            carLogoutMapper.insert(carLogout) == 1
        } else {
            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
    }
}
src/main/kotlin/com/flightfeather/uav/repository/impl/DataStreamDaoImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,157 @@
package com.flightfeather.uav.repository.impl
import com.flightfeather.uav.domain.entity.DataStream
import com.flightfeather.uav.domain.mapper.DataStreamMapper
import com.flightfeather.uav.domain.mapper.VehicleInfoMapper
import com.flightfeather.uav.lightshare.bean.DataStreamVo
import com.flightfeather.uav.repository.DataStreamRepository
import com.flightfeather.uav.socket.bean.EngineDataStream
import com.flightfeather.uav.socket.bean.ObdPackageData
import com.flightfeather.uav.socket.bean.SupplementDataStream
import com.flightfeather.uav.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
import java.util.*
/**
 * @author riku
 * Date: 2019/9/17
 */
@Repository
class DataStreamDaoImpl(val dataStreamMapper: DataStreamMapper, val vehicleInfoMapper: VehicleInfoMapper): DataStreamRepository {
    override fun saveDataStream(packageData: ObdPackageData): Boolean {
        return if (packageData.commandUnit == ObdCommandUnit.RealTimeData.value
                || packageData.commandUnit == ObdCommandUnit.ReplacementData.value) {
            val dataStream = DataStream().apply {
                obdDeviceCode = packageData.deviceCode
                obdStatus = packageData.commandUnit == ObdCommandUnit.ReplacementData.value
            }
            packageData.dataUnit.forEach {
                dataStream.apply {
                    obdDataTime = it.time
                    obdSerialNum = it.serialNum
                }
                when (it) {
                    is EngineDataStream -> dataStream.apply {
                        //fixme æ­¤å¤„相同属性可用 [BeanUtil] å·¥å…·æ¥å¿«é€Ÿèµ‹å€¼ï¼Œä½†å› ä¸ºå¹¶ä¸æ˜¯å…¨éƒ¨å±žæ€§éƒ½ç›¸åŒï¼Œå¯èƒ½å®¹æ˜“产生误解
                        obdSpeed = it.obdSpeed
                        obdAirPressure = it.obdAirPressure
                        obdEngineTorque = it.obdEngineTorque
                        obdFrictionTorque = it.obdFrictionTorque
                        obdEngineRpm = it.obdEngineRpm
                        obdEngineFuelFlow = it.obdEngineFuelFlow
                        obdScrUpstreamNox = it.obdScrUpstreamNox
                        obdScrDownstreamNox = it.obdScrDownstreamNox
                        obdRemainReactant = it.obdRemainReactant
                        obdAirInput = it.obdAirInput
                        obdScrInputTemp = it.obdScrInputTemp
                        obdScrOutputTemp = it.obdScrOutputTemp
                        obdDpf = it.obdDpf
                        obdEngineCoolantTemp = it.obdEngineCoolantTemp
                        obdFuelLevel = it.obdFuelLevel
                        obdLocationStatus = it.obdLocationStatus?.toString(2)
                        obdLong = it.obdLong
                        obdLat = it.obdLat
                        obdTotalMileage = it.obdTotalMileage
                    }
                    is SupplementDataStream -> dataStream.apply {
                        obdEngineTorqueMode = it.obdEngineTorqueMode
                        obdAcceleratorPedal = it.obdAcceleratorPedal
                        obdTotalOilConsumption = it.obdTotalOilConsumption
                        obdUreaBoxTemp = it.obdUreaBoxTemp
                        obdUreaVolume = it.obdUreaVolume
                        obdTotalUreaConsume = it.obdTotalUreaConsume
                        obdDpfTemp = it.obdDpfTemp
                    }
                }
            }
            dataStreamMapper.insert(dataStream) == 1
        } else {
            false
        }
    }
    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 {
                    try {
                        val st = sf.parse(startTime)
                        andGreaterThanOrEqualTo("obdDataTime", st)
                    } catch (e: Throwable) {
                        e.printStackTrace()
                    }
                }
                endTime?.let {
                    try {
                        val et = sf.parse(endTime)
                        andLessThanOrEqualTo("obdDataTime", et)
                    } catch (e: Throwable) {
                        e.printStackTrace()
                    }
                }
                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 getDataStreamCount(deviceCode: String, startTime: String?, endTime: String?): Int {
        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 {
                    try {
                        val st = sf.parse(startTime)
                        andGreaterThanOrEqualTo("obdDataTime", st)
                    } catch (e: Throwable) {
                        e.printStackTrace()
                    }
                }
                endTime?.let {
                    try {
                        val et = sf.parse(endTime)
                        andLessThanOrEqualTo("obdDataTime", et)
                    } catch (e: Throwable) {
                        e.printStackTrace()
                    }
                }
                orderBy("obdDataTime").desc()
            }
        }
        return dataStreamMapper.selectCountByExample(example)
    }
    override fun getLatestDataStream(deviceCode: String): DataStream? {
        val example = Example(DataStream::class.java).apply {
            createCriteria().andEqualTo("obdDeviceCode", deviceCode)
            orderBy("obdDataTime").desc()
        }
        //获取最新的一个
        PageHelper.offsetPage<DataStream>(0, 1)
        return dataStreamMapper.selectByExample(example).takeIf { it.isNotEmpty() }?.get(0)
    }
}
src/main/kotlin/com/flightfeather/uav/repository/impl/ObdAlarmDaoImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,46 @@
package com.flightfeather.uav.repository.impl
import com.flightfeather.uav.domain.entity.AlarmData
import com.flightfeather.uav.domain.mapper.AlarmDataMapper
import com.flightfeather.uav.lightshare.bean.AlarmDataVo
import com.flightfeather.uav.repository.ObdAlarmRepository
import com.github.pagehelper.PageHelper
import org.springframework.beans.BeanUtils
import org.springframework.stereotype.Repository
import tk.mybatis.mapper.entity.Example
/**
 * @author riku
 * Date: 2019/9/5
 */
@Repository
class ObdAlarmDaoImpl(val alarmDataMapper: AlarmDataMapper) : ObdAlarmRepository {
    override fun saveObdAlarm(alarmDataVo: AlarmDataVo): Boolean {
        val alarmData = AlarmData()
        BeanUtils.copyProperties(alarmDataVo, alarmData)
        return alarmDataMapper.insert(alarmData) == 1
    }
    override fun getAlarmByVinCode(vinCode: String, pageNum: Int?, pageSize: Int?): MutableList<AlarmDataVo> {
        val example = Example(AlarmData::class.java).apply {
            createCriteria().andEqualTo("obdVin", vinCode)
            orderBy("alarmTime").desc()
        }
        //分页
        val offset = (pageSize?.times(pageNum?.minus(1) ?: 0)) ?: 0
        PageHelper.offsetPage<AlarmData>(offset, pageSize ?: 10)
        val result = alarmDataMapper.selectByExample(example)
        val resultList = mutableListOf<AlarmDataVo>()
        result.forEach {
            val vo = AlarmDataVo()
            BeanUtils.copyProperties(it, vo)
            resultList.add(vo)
        }
        return resultList
    }
}
src/main/kotlin/com/flightfeather/uav/repository/impl/ObdDataDaoImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,147 @@
package com.flightfeather.uav.repository.impl
import com.flightfeather.uav.domain.entity.ObdData
import com.flightfeather.uav.domain.mapper.ObdDataMapper
import com.flightfeather.uav.lightshare.bean.ObdDataVo
import com.flightfeather.uav.repository.ObdDataRepository
import com.flightfeather.uav.socket.bean.*
import com.flightfeather.uav.socket.eunm.ObdCommandUnit
import com.github.pagehelper.PageHelper
import org.springframework.beans.BeanUtils
import org.springframework.stereotype.Repository
import tk.mybatis.mapper.entity.Example
/**
 * obd数据相关数据库操作实现
 * @author riku
 * Date: 2019/8/27
 */
@Repository
class ObdDataDaoImpl(val obdDataMapper: ObdDataMapper) : ObdDataRepository {
    override fun saveObdData(data: ObdDataVo): Boolean {
        val obdData = ObdData()
        BeanUtils.copyProperties(data, obdData)
        return obdDataMapper.insert(obdData) == 1
    }
    override fun getDataByVinCode(vinCode: String?, pageNum: Int?, pageSize: Int?): MutableList<ObdDataVo> {
        val example = Example(ObdData::class.java).apply {
            createCriteria().andEqualTo("obdVin", vinCode)
            orderBy("obdTime").desc()
        }
        //分页
        val offset = (pageSize?.times(pageNum?.minus(1) ?: 0)) ?: 0
        PageHelper.offsetPage<ObdData>(offset, pageSize ?: 10)
        val result = obdDataMapper.selectByExample(example)
        val resultList = mutableListOf<ObdDataVo>()
        result.forEach {
            val vo = ObdDataVo()
            BeanUtils.copyProperties(it, vo)
            resultList.add(vo)
        }
        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.uav.socket.bean.ObdInfo -> {
                            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.obdScrUpstreamNox
                                obdScrDownstreamNo = it.obdScrDownstreamNox
                                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
    }
}
src/main/kotlin/com/flightfeather/uav/repository/impl/ObdInfoDaoImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,68 @@
package com.flightfeather.uav.repository.impl
import com.flightfeather.uav.domain.entity.ObdInfo
import com.flightfeather.uav.domain.mapper.ObdInfoMapper
import com.flightfeather.uav.repository.ObdInfoRepository
import com.flightfeather.uav.socket.bean.ObdPackageData
import com.flightfeather.uav.socket.eunm.ObdCommandUnit
import com.github.pagehelper.PageHelper
import org.springframework.stereotype.Repository
import tk.mybatis.mapper.entity.Example
/**
 * @author riku
 * Date: 2019/9/17
 */
@Repository
class ObdInfoDaoImpl(val obdInfoMapper: ObdInfoMapper) : ObdInfoRepository {
    override fun saveObdInfo(packageData: ObdPackageData): Boolean {
        return if (packageData.commandUnit == ObdCommandUnit.RealTimeData.value
                || packageData.commandUnit == ObdCommandUnit.ReplacementData.value) {
            val obdInfo = ObdInfo().apply {
                obdDeviceCode = packageData.deviceCode
                obdStatus = packageData.commandUnit == ObdCommandUnit.ReplacementData.value
            }
            packageData.dataUnit.forEach {
                when (it) {
                    is com.flightfeather.uav.socket.bean.ObdInfo -> {
                        obdInfo.apply {
                            obdDataTime = it.time
                            obdSerialNum = it.serialNum
                            obdProtocol = it.obdProtocol
                            obdMil = it.obdMil
                            obdDiagnosisSupportStatus = it.diagnosisSupportStatus
                            obdDiagnosisReadyStatus = it.diagnosisReadyStatus
                            obdVin = it.obdVin
                            obdCrn = it.obdCrn
                            obdCvn = it.obdCvn
                            obdIupr = it.iupr
                            obdFaultCodeNum = it.obdFaultCodeNum
                            obdFaultCode = it.obdFaultCode
                        }
                    }
                }
            }
            obdInfoMapper.insert(obdInfo) == 1
        } else {
            false
        }
    }
    override fun getObdInfo(deviceCode: String, pageNum: Int?, pageSize: Int?): List<ObdInfo> {
        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)
        return obdInfoMapper.selectByExample(example)
    }
}
src/main/kotlin/com/flightfeather/uav/repository/impl/ObdThresholdValueDaoImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,56 @@
package com.flightfeather.uav.repository.impl
import com.flightfeather.uav.domain.entity.ThresholdValue
import com.flightfeather.uav.domain.mapper.ThresholdValueMapper
import com.flightfeather.uav.lightshare.bean.ThresholdValueVo
import com.flightfeather.uav.repository.ObdThresholdValueRepository
import org.springframework.beans.BeanUtils
import org.springframework.stereotype.Repository
import tk.mybatis.mapper.entity.Example
/**
 * @author riku
 * Date: 2019/9/5
 */
@Repository
class ObdThresholdValueDaoImpl(val obdThresholdValueMapper: ThresholdValueMapper) : ObdThresholdValueRepository {
    override fun save(userId: String, thresholdValueVo: ThresholdValueVo): Boolean {
        val thresholdValue = ThresholdValue()
        BeanUtils.copyProperties(thresholdValueVo, thresholdValue)
        val example = Example(ThresholdValue::class.java).apply {
            createCriteria().andEqualTo("obdVin", thresholdValueVo.obdVin)
        }
        val tempResult = obdThresholdValueMapper.selectByExample(example)
        return if (tempResult.isNotEmpty())
            false
        else
            obdThresholdValueMapper.insert(thresholdValue) == 1
    }
    override fun update(userId: String, thresholdValueVo: ThresholdValueVo): Boolean {
        val thresholdValue = ThresholdValue()
        BeanUtils.copyProperties(thresholdValueVo, thresholdValue)
        val example = Example(ThresholdValue::class.java).apply {
            createCriteria().andEqualTo("obdVin", thresholdValue.obdVin)
        }
        return obdThresholdValueMapper.updateByExample(thresholdValue, example) == 1
    }
    override fun getByVinCode(vinCode: String): ThresholdValueVo? {
        val example = Example(ThresholdValue::class.java).apply {
            createCriteria().andEqualTo("obdVin", vinCode)
        }
        val result = obdThresholdValueMapper.selectByExample(example)
        if (result.isNotEmpty()) {
            val vo = ThresholdValueVo()
            BeanUtils.copyProperties(result[0], vo)
            return vo
        }
        return null
    }
}
src/main/kotlin/com/flightfeather/uav/repository/impl/ObdUserDaoImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,34 @@
package com.flightfeather.uav.repository.impl
import com.flightfeather.uav.domain.entity.ObdUser
import com.flightfeather.uav.domain.mapper.ObdUserMapper
import com.flightfeather.uav.lightshare.bean.ObdUserVo
import com.flightfeather.uav.repository.ObdUserRepository
import org.springframework.beans.BeanUtils
import org.springframework.stereotype.Repository
import tk.mybatis.mapper.entity.Example
/**
 * @author riku
 * Date: 2019/9/6
 */
@Repository
class ObdUserDaoImpl(val obdUserMapper: ObdUserMapper): ObdUserRepository {
    override fun getUserInfo(userId: String): ObdUserVo? {
        val example = Example(ObdUser::class.java).apply {
            createCriteria().andEqualTo("obdUserId", userId)
        }
        val result = obdUserMapper.selectByExample(example)
        if (result.isNotEmpty()) {
            val vo = ObdUserVo()
            BeanUtils.copyProperties(result[0], vo)
            return vo
        }
        return null
    }
}
src/main/kotlin/com/flightfeather/uav/repository/impl/OriginDataDaoImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,29 @@
package com.flightfeather.uav.repository.impl
import com.flightfeather.uav.domain.entity.OriginData
import com.flightfeather.uav.domain.mapper.OriginDataMapper
import com.flightfeather.uav.repository.OriginDataRepository
import com.flightfeather.uav.socket.bean.ObdPackageData
import org.springframework.stereotype.Repository
/**
 * @author riku
 * Date: 2019/9/17
 */
@Repository
class OriginDataDaoImpl (val originDataMapper: OriginDataMapper): OriginDataRepository {
    override fun saveOriginData(packageData: ObdPackageData, msg: String): Boolean {
        val originData = OriginData().apply {
            obdDeviceCode = packageData.deviceCode
            obdTerminalSoftwareVersion = packageData.softwareVersion
            obdEncryptionWay = packageData.encryptionWay
            obdCommandUnit = packageData.commandUnit
            obdContent = msg
        }
        return originDataMapper.insert(originData) == 1
    }
}
src/main/kotlin/com/flightfeather/uav/repository/impl/VehicleRepositoryImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,24 @@
package com.flightfeather.uav.repository.impl
import com.flightfeather.uav.domain.entity.DataStream
import com.flightfeather.uav.domain.entity.VehicleInfo
import com.flightfeather.uav.domain.mapper.VehicleInfoMapper
import com.flightfeather.uav.repository.VehicleRepository
import com.github.pagehelper.PageHelper
import org.springframework.stereotype.Repository
/**
 * @author riku
 * Date: 2019/10/25
 */
@Repository
class VehicleRepositoryImpl(val vehicleInfoMapper: VehicleInfoMapper):VehicleRepository {
    override fun getVehicleInfo(pageNum: Int?, pageSize: Int?): List<VehicleInfo> {
        //分页
        val offset = (pageSize?.times(pageNum?.minus(1) ?: 0)) ?: 0
        PageHelper.offsetPage<DataStream>(offset, pageSize ?: 10)
        return vehicleInfoMapper.selectAll()
    }
}
src/main/kotlin/com/flightfeather/uav/socket/DeviceSession.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,29 @@
package com.flightfeather.uav.socket
import io.netty.channel.ChannelHandlerContext
import java.util.concurrent.ConcurrentHashMap
/**
 * ç”¨äºŽä¿å­˜è¿žæŽ¥çš„设备及对应的session通道
 * Date: 2019.8.27
 * @author riku
 */
class DeviceSession {
    companion object{
        private val deviceMap = ConcurrentHashMap<String, ChannelHandlerContext?>()
        fun saveDevice(deviceCode: String?, channel: ChannelHandlerContext?) {
            deviceCode?.let {
                deviceMap.put(deviceCode, channel)
            }
        }
        fun getDevice(deviceCode: String?): ChannelHandlerContext? {
            return if (deviceMap.containsKey(deviceCode))
                deviceMap[deviceCode]
            else
                null
        }
    }
}
src/main/kotlin/com/flightfeather/uav/socket/MessageManager.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,205 @@
package com.flightfeather.uav.socket
import com.flightfeather.uav.common.utils.FileUtil
import com.flightfeather.uav.repository.*
import com.flightfeather.uav.socket.bean.EngineDataStream
import com.flightfeather.uav.socket.bean.ObdInfo
import com.flightfeather.uav.socket.bean.ObdPackageData
import com.flightfeather.uav.socket.bean.SupplementDataStream
import com.flightfeather.uav.socket.decoder.VehicleDataDecoder
import com.flightfeather.uav.socket.decoder.impl.DataPackageDecoderImpl
import com.flightfeather.uav.socket.eunm.ObdCommandUnit
import io.netty.buffer.Unpooled
import io.netty.channel.ChannelHandlerContext
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component
import java.text.SimpleDateFormat
import java.util.*
import javax.annotation.PostConstruct
/**
 * å¤„理socket接收的消息
 * Date: 2019.8.27
 * @author riku
 */
@Component
class MessageManager{
    companion object{
        private lateinit var instance: MessageManager
    }
    @Autowired
    lateinit var obdDataRepository: ObdDataRepository
    @Autowired
    lateinit var originDataRepository: OriginDataRepository
    @Autowired
    lateinit var obdInfoRepository: ObdInfoRepository
    @Autowired
    lateinit var dataStreamRepository: DataStreamRepository
    @Autowired
    lateinit var carLogoutRepository: CarLogoutRepository
    @Autowired
    lateinit var carLoginRepository: CarLoginRepository
    val vehicleDataDecoder = VehicleDataDecoder()
    val dataPackageDecoder = DataPackageDecoderImpl()
    @PostConstruct
    fun init() {
        instance = this
        instance.obdDataRepository = this.obdDataRepository
        instance.originDataRepository = this.originDataRepository
        instance.obdInfoRepository = this.obdInfoRepository
        instance.dataStreamRepository = this.dataStreamRepository
        instance.carLogoutRepository = this.carLogoutRepository
        instance.carLoginRepository = this.carLoginRepository
    }
    fun dealStringMsg(msg: String, ctx: ChannelHandlerContext?) {
        //解包
        val packageData = vehicleDataDecoder.decode(msg)
        saveToTxt(msg)
        val isCommand = command(packageData, ctx)
        if (isCommand) {
            println("------远程控制指令 [${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}]")
        } else {
            if (bccCheck(msg)) {
                //保存
                DeviceSession.saveDevice(packageData.deviceCode, ctx)
                saveToDataBase(packageData, msg)
            } else {
                println("------数据BCC校验失败,舍弃 [${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}]")
            }
        }
    }
    /**
     * ä¿å­˜è‡³txt文本
     */
    fun saveToTxt(msg: String) {
        val data = "[${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}]data=> $msg"
        FileUtil.instance?.saveObdData(data)
    }
    /**
     * ä¿å­˜è‡³æ•°æ®åº“
     */
    fun saveToDataBase(packageData: ObdPackageData, msg: String) {
//        instance.obdDataRepository.saveObdData(packageData)
        instance.originDataRepository.saveOriginData(packageData, msg)
        when (packageData.commandUnit) {
            ObdCommandUnit.CarRegister.value -> instance.carLoginRepository.saveCarLogin(packageData)
            ObdCommandUnit.RealTimeData.value,
            ObdCommandUnit.ReplacementData.value -> {
                var done = false
                for (i in 0 until packageData.dataUnit.size) {
                    when (packageData.dataUnit[i]) {
                        is ObdInfo -> instance.obdInfoRepository.saveObdInfo(packageData)
                        is EngineDataStream,
                        is SupplementDataStream -> {
                            instance.dataStreamRepository.saveDataStream(packageData)
                            done = true
                        }
                    }
                    if (done) break
                }
            }
            ObdCommandUnit.CarLogOut.value-> instance.carLogoutRepository.saveCarLogout(packageData)
        }
    }
    /**
     * BCC(异或校验)
     */
    fun bccCheck(msg: String):Boolean {
        val list = mutableListOf<String>().apply {
            addAll(dataPackageDecoder.toStringList(msg))
            //去除2 ä½èµ·å§‹ç¬¦
            removeAt(0)
            removeAt(0)
        }
        //取得数据包中的bcc校验结果
        val oldBcc = list[list.size - 1].toInt(16)
        //去除校验结果
        list.removeAt(list.size-1)
        //计算bcc校验结果
        var newBcc = 0x00
        list.forEach {
            newBcc = newBcc.xor(it.toInt(16))
        }
        //返回校验结果是否正确
        return oldBcc == newBcc
    }
    /**
     * è¿œç¨‹æŒ‡ä»¤
     */
    fun command(packageData: ObdPackageData, ctx: ChannelHandlerContext?): Boolean {
        if (packageData.commandUnit == ObdCommandUnit.Update.value) {
            val channel = DeviceSession.getDevice(packageData.deviceCode)
            if (channel != null) {
                val s = getDataPackage(packageData.deviceCode)
                if (s == null) {
                    ctx?.writeAndFlush("[${packageData.deviceCode}] è®¾å¤‡ç¼–号为空")
                } else {
                    val bytes = encodeToBytes(s)
                    channel.writeAndFlush(Unpooled.copiedBuffer(bytes))
                    ctx?.writeAndFlush("[${packageData.deviceCode}] æŒ‡ä»¤å‘送成功")
                }
            } else {
                ctx?.writeAndFlush("[${packageData.deviceCode}] è®¾å¤‡æœªè¿žæŽ¥æˆ–不存在")
            }
            return true
        } else if (packageData.commandUnit != ObdCommandUnit.CarRegister.value
                && packageData.commandUnit != ObdCommandUnit.RealTimeData.value
                && packageData.commandUnit != ObdCommandUnit.ReplacementData.value
                && packageData.commandUnit != ObdCommandUnit.CarLogOut.value
                && packageData.commandUnit != ObdCommandUnit.TimeCalibration.value) {
            ctx?.writeAndFlush("[${packageData.deviceCode}] å‘½ä»¤ä¸å­˜åœ¨")
            return true
        } else {
            return false
        }
    }
    fun encodeToBytes(msg:String): ByteArray {
        val list = msg.split(" ")
        val bytes = ByteArray(list.size)
        for (i in 0 until list.size) {
            bytes[i]=list[i].toInt(16).toByte()
        }
        return bytes
    }
    fun getDataPackage(deviceCode: String?): String? {
        if (deviceCode == null) return null
        //23 23 7f 31 37 36 39 31 35 33 31 39 30 39 31 32 30 30 31 31 01 01 00 00 39
        val sb = StringBuilder("23 23 10 ")
        deviceCode.forEach {
            sb.append(it.toInt().toString(16)).append(" ")
        }
        sb.append("01 01 00 00 00 0A 41 54 2B 56 45 52 53 49 4F 4E")
        val list = sb.split(" ")
        //计算bcc校验结果
        var bcc = 0x00
        list.forEach {
            bcc = bcc.xor(it.toInt(16))
        }
        sb.append(" ").append(bcc.toString(16))
        return sb.toString()
    }
}
src/main/kotlin/com/flightfeather/uav/socket/ObdByteDataDecoder.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,112 @@
package com.flightfeather.uav.socket
import io.netty.buffer.ByteBuf
import io.netty.channel.ChannelHandlerContext
import io.netty.handler.codec.ByteToMessageDecoder
import java.lang.StringBuilder
/**
 * @author riku
 * Date: 2019/9/16
 * æ•°æ®ç²˜åŒ…分包解码器
 */
class ObdByteDataDecoder : ByteToMessageDecoder() {
    companion object {
        const val BASE_LENGTH = 2 + 1 + 17 + 1 + 1 + 2 + 0 + 1
        const val HEAD = 0x23.toByte()
    }
    override fun decode(p0: ChannelHandlerContext?, p1: ByteBuf?, p2: MutableList<Any>?) {
        val dataList = mutableListOf<Byte>()
        p1?.let {
            // å¯è¯»é•¿åº¦å¿…须大于基本长度
            if (it.readableBytes() >= BASE_LENGTH) {
                // é˜²æ­¢socket字节流攻击
                // é˜²æ­¢ï¼Œå®¢æˆ·ç«¯ä¼ æ¥çš„æ•°æ®è¿‡å¤§
                if (it.readableBytes() > 2048) {
                    it.skipBytes(it.readableBytes())
                }
                // è®°å½•包头开始的index
                var beginReader = 0
                while (true) {
                    // èŽ·å–åŒ…å¤´å¼€å§‹çš„index
                    beginReader = it.readerIndex()
                    // æ ‡è®°åŒ…头开始的index
                    it.markReaderIndex()
                    // è¯»åˆ°äº†åè®®çš„开始标志,结束while循环
                    val b = ByteArray(2)
                    it.readBytes(b)
                    if (b[0] == HEAD && b[1] == HEAD) {
                        dataList.add(b[0])
                        dataList.add(b[1])
                        break
                    }
                    // æœªè¯»åˆ°åŒ…头,重置到之前记录的包头开始位置
                    // ç•¥è¿‡1个字节后,再循环开始读取
                    it.resetReaderIndex()
                    it.readByte()
                    //当数据包长度不足时,立刻结束,等待后续数据到达
                    if (it.readableBytes() < BASE_LENGTH) {
                        return
                    }
                }
                ByteArray(1 + 17 + 1 + 1).apply {
                    it.readBytes(this)
                }.forEach {b ->
                    dataList.add(b)
                }
                //数据单元的长度
                val length = getDataUnitLength(it, dataList)
                // åˆ¤æ–­è¯·æ±‚数据单元数据及1个字节的校验码是否到齐
                if (it.readableBytes() < length + 1) {
                    // è¿˜åŽŸè¯»æŒ‡é’ˆ
                    it.readerIndex(beginReader)
                    return
                }
                //读取数据单元和校验码数据
                ByteArray(length + 1).apply {
                    it.readBytes(this)
                }.forEach {b ->
                    dataList.add(b)
                }
                p2?.add(dataList.toByteArray())
            }
        }
    }
    /**
     * èŽ·å–æ•°æ®å•å…ƒé•¿åº¦å¹¶å°†å…¶æ·»åŠ è‡³ç»“æžœåˆ—è¡¨ä¸­
     */
    private fun getDataUnitLength(p1: ByteBuf, dataList: MutableList<Byte>): Int {
        val sb = StringBuilder()
        ByteArray(2).apply {
            p1.readBytes(this)
        }.forEach { b ->
            var a = 0
            a = if (b < 0) {
                b + 256
            } else {
                b.toInt()
            }
            sb.append(a.toString(16))
            dataList.add(b)
        }
        return sb.toString().toInt(16)
    }
}
src/main/kotlin/com/flightfeather/uav/socket/ServerHandler.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,70 @@
package com.flightfeather.uav.socket
import io.netty.channel.ChannelHandlerContext
import io.netty.channel.ChannelInboundHandlerAdapter
import io.netty.util.AttributeKey
import java.lang.StringBuilder
import java.text.SimpleDateFormat
import java.util.*
class ServerHandler : ChannelInboundHandlerAdapter() {
    val attributeKey = AttributeKey.valueOf<String>("deviceCode")
    override fun channelRegistered(ctx: ChannelHandlerContext?) {
        super.channelRegistered(ctx)
        println("------端口有IP连接:[ip:${ctx?.channel()?.remoteAddress()}] ${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}")
//        ctx?.fireChannelActive()
    }
    override fun channelActive(ctx: ChannelHandlerContext?) {
        println("------端口有IP激活:[ip:${ctx?.channel()?.remoteAddress()}] ${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}")
        super.channelActive(ctx)
    }
    override fun channelRead(ctx: ChannelHandlerContext?, msg: Any?) {
        super.channelRead(ctx, msg)
        val sb = StringBuilder()
        if (msg is ByteArray) {
            println("------收到的原始数据:[ip:${ctx?.channel()?.remoteAddress()}] ${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}")
            msg.forEach {
                var a = 0
                a = if (it < 0) {
                    it + 256
                } else {
                    it.toInt()
                }
                val s = if (a < 16) {
                    "0${a.toString(16)}"
                } else {
                    a.toString(16)
                }
                print("$s ")
                sb.append(s).append(" ")
            }
            sb.deleteCharAt(sb.length - 1)
        }
        val str = sb.toString()
        if (str.isNotEmpty()) {
            MessageManager().dealStringMsg(str, ctx)
        }
    }
    override fun channelReadComplete(ctx: ChannelHandlerContext?) {
        super.channelReadComplete(ctx)
    }
    override fun channelInactive(ctx: ChannelHandlerContext?) {
        println("------端口有IP不活动:[ip:${ctx?.channel()?.remoteAddress()}] ${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}")
        super.channelInactive(ctx)
    }
    override fun exceptionCaught(ctx: ChannelHandlerContext?, cause: Throwable?) {
        cause?.printStackTrace()
        ctx?.close()
    }
}
src/main/kotlin/com/flightfeather/uav/socket/SocketServerClient.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,55 @@
package com.flightfeather.uav.socket
import io.netty.bootstrap.ServerBootstrap
import io.netty.channel.ChannelInitializer
import io.netty.channel.ChannelOption
import io.netty.channel.nio.NioEventLoopGroup
import io.netty.channel.socket.nio.NioServerSocketChannel
import io.netty.channel.socket.nio.NioSocketChannel
import io.netty.handler.codec.string.StringEncoder
import java.nio.charset.Charset
/**
 * socket长连接服务端
 * 2019.8.26
 * @author riku
 */
class SocketServerClient {
    private val bossGroup = NioEventLoopGroup()
    private val workerGroup = NioEventLoopGroup()
    fun startServer(port: Int) {
        initialize()?.bind(port)?.sync()
    }
    fun stopServer() {
        bossGroup.shutdownGracefully()
        workerGroup.shutdownGracefully()
    }
    private fun initialize(): ServerBootstrap? {
        try {
            return ServerBootstrap()
                    .group(bossGroup, workerGroup)
                    .channel(NioServerSocketChannel::class.java)
                    .option(ChannelOption.SO_BACKLOG, 128)
                    .childOption(ChannelOption.SO_KEEPALIVE, true)
                    .childOption(ChannelOption.TCP_NODELAY, true)
                    .childHandler(object : ChannelInitializer<NioSocketChannel>() {
                        override fun initChannel(p0: NioSocketChannel?) {
                            p0?.pipeline()
//                                    ?.addLast("decoder", StringDecoder())
                                    ?.addLast(ObdByteDataDecoder())
                                    ?.addLast("encoder", StringEncoder(Charset.forName("UTF-8")))
                                    ?.addLast(ServerHandler())
                        }
                    })
        } catch (e: Throwable) {
            e.printStackTrace()
        }
        return null
    }
}
src/main/kotlin/com/flightfeather/uav/socket/bean/CarLogOutData.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,19 @@
package com.flightfeather.uav.socket.bean
import com.flightfeather.uav.socket.eunm.ObdCommandUnit
import java.util.*
/**
 * @author riku
 * Date: 2019/9/12
 * è½¦è¾†ç™»å‡ºä¿¡æ¯
 * æ•°æ®ç±»åž‹ @see [ObdCommandUnit.CarLogOut]
 *
 * æ•°æ®è¡¨ç¤ºå†…容                   é•¿åº¦ï¼ˆå­—节)                  æ•°æ®ç±»åž‹                    æè¿°åŠè¦æ±‚
 * ç™»å‡ºæ—¶é—´                             6                                   BYTE[6]                   æ—¶é—´å‡åº”采用 GMT+8 æ—¶é—´ï¼Œæ—¶é—´å®šä¹‰ç¬¦åˆ GB/T32960.3-2016 ç¬¬ 6.4 æ¡çš„要求
 * ç™»å‡ºæµæ°´å·                          2                                  WORD                      ç™»å‡ºæµæ°´å·ä¸Žå½“次登入流水号一致。@see [CarRegisterData]
 */
class CarLogOutData(
        time: Date?,
        serialNum: Int?
): DataUnit(time, serialNum)
src/main/kotlin/com/flightfeather/uav/socket/bean/CarRegisterData.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
package com.flightfeather.uav.socket.bean
import com.flightfeather.uav.socket.eunm.ObdCommandUnit
import java.util.*
/**
 * @author riku
 * Date: 2019/9/12
 *
 * è½¦è¾†ç™»å…¥æ•°æ®æ ¼å¼
 * æ•°æ®ç±»åž‹ @see [ObdCommandUnit.CarRegister]
 *
 * èµ·å§‹å­—节        å†…容                               æè¿°
 * 0                    æ•°æ®é‡‡é›†æ—¶é—´                 æ—¶é—´å‡åº”采用 GMT+8 æ—¶é—´ï¼Œæ—¶é—´å®šä¹‰ç¬¦åˆ GB/T32960.3-2016 ç¬¬ 6.4 æ¡çš„要求
 * 6                    ç™»å…¥æµæ°´å·                   è½¦è½½ç»ˆç«¯æ¯ç™»å…¥ä¸€æ¬¡ï¼Œç™»å…¥æµæ°´å·è‡ªåŠ¨åŠ  1,从 1开始循环累加,最大值为 65531,循环周期为天。
 * 10                  SIM å¡å·                       SIM å¡ ICCID å·ï¼ˆICCID åº”为终端从 SIM å¡èŽ·å–çš„å€¼ï¼Œä¸åº”äººä¸ºå¡«å†™æˆ–ä¿®æ”¹ï¼‰ã€‚
 */
class CarRegisterData(
        time: Date?,
        serialNum: Int?,
        var SIMCode: String? = null
): DataUnit(time, serialNum)
src/main/kotlin/com/flightfeather/uav/socket/bean/DataUnit.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
package com.flightfeather.uav.socket.bean
import com.flightfeather.uav.socket.eunm.ObdCommandUnit
import java.util.*
/**
 * @author riku
 * Date: 2019/9/12
 *
 * æ•°æ®å•å…ƒ
 * æ ¹æ®å‘½ä»¤å•å…ƒ @see [ObdCommandUnit] çš„分类,不同类型的结构不同,见各子类
 */
open class DataUnit(
        var time: Date?,
        var serialNum: Int?
)
src/main/kotlin/com/flightfeather/uav/socket/bean/EngineDataStream.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,35 @@
package com.flightfeather.uav.socket.bean
import com.flightfeather.uav.socket.eunm.ObdDataType
import java.util.*
/**
 * @author riku
 * Date: 2019/9/15
 * å®žæ—¶ä¿¡æ¯[RealTimeData] ä¸­çš„发动机数据流
 * æ•°æ®ç±»åž‹ @see [ObdDataType.EngineDataFlow]
 */
class EngineDataStream(
        time: Date?,
        serialNum: Int?
) : RealTimeData(time, serialNum) {
    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: Int? = null
    var obdLong: Double? = null
    var obdLat: Double? = null
    var obdTotalMileage: Double? = null
}
src/main/kotlin/com/flightfeather/uav/socket/bean/ObdInfo.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,26 @@
package com.flightfeather.uav.socket.bean
import com.flightfeather.uav.socket.eunm.ObdDataType
import java.util.*
/**
 * @author riku
 * Date: 2019/9/15
 * å®žæ—¶ä¿¡æ¯[RealTimeData] ä¸­çš„obd数据
 * æ•°æ®ç±»åž‹ @see [ObdDataType.ObdData]
 */
class ObdInfo(
        time: Date?,
        serialNum: Int?
) : RealTimeData(time, serialNum) {
    var obdProtocol: Int? = null
    var obdMil: Int? = null
    var diagnosisSupportStatus: String? = null//诊断支持状态
    var diagnosisReadyStatus: String? = null//诊断就绪状态
    var obdVin: String? = null
    var obdCrn: String? = null//软件标定识别号
    var obdCvn: String? = null//标定验证码
    var iupr:String?=null//定义参考 SAE J 1979-DA è¡¨ G11
    var obdFaultCodeNum: Int? = null//故障码总数: æœ‰æ•ˆå€¼èŒƒå›´ï¼š0~253,“0xFE”表示无效。
    var obdFaultCode: String? = null//故障码信息列表: æ¯ä¸ªæ•…障码为四字节,可按故障实际顺序进行排序
}
src/main/kotlin/com/flightfeather/uav/socket/bean/ObdPackageData.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,40 @@
package com.flightfeather.uav.socket.bean
import com.flightfeather.uav.socket.eunm.ObdCommandUnit
/**
 * @author riku
 * Date: 2019/9/12
 * æ•°æ®åŒ…结构
 *
 * èµ·å§‹å­—节                     å®šä¹‰                  æ•°æ®ç±»åž‹                        æè¿°åŠè¦æ±‚
 * 0                               èµ·å§‹ç¬¦                STRING                       å›ºå®šä¸º ASCII å­—符’##’,用“0x23,0x23”表示
 * 2                               å‘½ä»¤å•å…ƒ             BYTE                            å‘½ä»¤å•元定义 @see [ObdCommandUnit]
 * 3                            è½¦è¾†è¯†åˆ«å·           STRING                        è½¦è¾†è¯†åˆ«ç æ˜¯è¯†åˆ«çš„唯一标识,由 17 ä½å­—码组成,字码应符合 GB16735 ä¸­ 4.5 çš„规定
 * 20                         ç»ˆç«¯è½¯ä»¶ç‰ˆæœ¬å·       BYTE                           ç»ˆç«¯è½¯ä»¶ç‰ˆæœ¬å·æœ‰æ•ˆå€¼èŒƒå›´ 0~255
 * 21                           æ•°æ®åŠ å¯†æ–¹å¼         BYTE                           0x01:数据不加密;
 *                                                                                                  0x02:数据经过 RSA ç®—法加密;
 *                                                                                                  0x03:数据经过国密 SM2 ç®—法加密;
 *                                                                                                  â€œ0xFE”标识异常,“0xFF”表示无效,其他预留
 * 22                           æ•°æ®å•元长度          WORD                        æ•°æ®å•元长度是数据单元的总字节数,有效范围:0~65531
 * 24                           æ•°æ®å•å…ƒ                                                    è§æ•°æ®å•元格式和定义 @see [DataUnit]
 * å€’数第 1                   æ ¡éªŒç  BYTE                                             é‡‡ç”¨ BCC(异或校验)法,校验范围聪明星单元的第一个字节开始,同后一个字节异或,直到校验码前一字节为止,校验码占用一个字节
 */
data class ObdPackageData constructor(
        //起始符
        var head: String? = null,
        //命令单元
        var commandUnit: Int? = null,
        //车辆识别号(指obd数据采集设备的编号)
        var deviceCode: String? = null,
        //终端软件版本号
        var softwareVersion: Int? = null,
        //数据加密方式
        var encryptionWay: Int? = null,
        //数据单元长度
        var dataLength: Int? = null,
        //数据单元
        var dataUnit: List<DataUnit>,
        //校验码
        var checkCode: Int? = null
)
src/main/kotlin/com/flightfeather/uav/socket/bean/RealTimeData.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,26 @@
package com.flightfeather.uav.socket.bean
import java.util.*
import com.flightfeather.uav.socket.eunm.ObdDataType
import com.flightfeather.uav.socket.eunm.ObdCommandUnit
/**
 * @author riku
 * Date: 2019/9/12
 *
 * å®žæ—¶ä¿¡æ¯
 * æ•°æ®ç±»åž‹ @see[ObdCommandUnit.RealTimeData]
 *
 * æ•°æ®è¡¨ç¤ºå†…容                          é•¿åº¦ï¼ˆå­—节)             æ•°æ®ç±»åž‹                    æè¿°åŠè¦æ±‚
 * æ•°æ®é‡‡é›†æ—¶é—´                               6                           BYTE[6]                    æ—¶é—´å‡åº”采用 GMT+8 æ—¶é—´ï¼Œæ—¶é—´å®šä¹‰ç¬¦åˆ GB/T32960.3-2016 ç¬¬ 6.4 æ¡çš„要求
 * ä¿¡æ¯æµæ°´å·                                   2                           WORD                       ä»¥å¤©ä¸ºå•位,每包实时信息流水号唯一,从 1 å¼€å§‹ç´¯åŠ 
 * ä¿¡æ¯ç±»åž‹æ ‡å¿—(n)                       1                           BYTE                         ä¿¡æ¯ç±»åž‹æ ‡å¿— @see [ObdDataType]
 * ä¿¡æ¯ä½“(n)                                                                                                æ ¹æ®ä¿¡æ¯ç±»åž‹ä¸åŒï¼Œé•¿åº¦å’Œæ•°æ®ç±»åž‹ä¸åŒ
 * â€¦â€¦                                                                                                               â€¦â€¦
 * ä¿¡æ¯ç±»åž‹æ ‡å¿—(m)                      1                            BYTE[6]                   ä¿¡æ¯ç±»åž‹æ ‡å¿—
 * ä¿¡æ¯ä½“(m)                                                                                               æ ¹æ®ä¿¡æ¯ç±»åž‹ä¸åŒï¼Œé•¿åº¦å’Œæ•°æ®ç±»åž‹ä¸åŒ
 */
open class RealTimeData(
        time: Date?,
        serialNum: Int?
) : ReplacementData(time, serialNum)
src/main/kotlin/com/flightfeather/uav/socket/bean/ReplacementData.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,15 @@
package com.flightfeather.uav.socket.bean
import java.util.*
import com.flightfeather.uav.socket.eunm.ObdCommandUnit
/**
 * @author riku
 * Date: 2019/9/12
 * è¡¥å‘信息与实时信息内容一致 @see [RealTimeData]
 * æ•°æ®ç±»åž‹ @see [ObdCommandUnit.ReplacementData]
 */
open class ReplacementData (
        time: Date?,
        serialNum: Int?
): DataUnit(time, serialNum)
src/main/kotlin/com/flightfeather/uav/socket/bean/SupplementDataStream.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,59 @@
package com.flightfeather.uav.socket.bean
import java.util.*
import com.flightfeather.uav.socket.eunm.ObdDataType
/**
 * @author riku
 * Date: 2019/9/15
 * è¡¥å……数据流
 * æ•°æ®ç±»åž‹ @see [ObdDataType.SupplementDataFlow]
 *
 * èµ·å§‹å­—节      æ•°æ®é¡¹                            æ•°æ®ç±»åž‹        å•位          æè¿°åŠè¦æ±‚
 * 0                 å‘动机扭矩模式                BYTE                            0:超速失效
 *                                                                                                  1:转速控制
 *                                                                                                  2:扭矩控制
 *                                                                                                  3:转速/扭矩控制
 * 1                  æ²¹é—¨è¸æ¿                          BYTE               %           æ•°æ®é•¿åº¦ï¼š1bytes
 *                                                                                                  ç²¾åº¦ï¼š0.4%/bit
 *                                                                                                  åç§»é‡ï¼š0
 *                                                                                                  æ•°æ®èŒƒå›´ï¼š0~100%
 *                                                                                                  â€œ0xFF”表示无效
 * 2                ç´¯è®¡æ²¹è€—(总油耗)          DWORD           L           æ•°æ®é•¿åº¦ï¼š4bytes
 *                                                                                                  ç²¾åº¦ï¼š0.5L per bit
 *                                                                                                  åç§»é‡ï¼š0
 *                                                                                                  æ•°æ®èŒƒå›´ï¼š0~2,105,540,607.5L
 *                                                                                                  â€œ0xFF,0xFF,0xFF,0xFF”表示无效
 * 6                  å°¿ç´ ç®±æ¸©åº¦                      BYTE               â„ƒ          æ•°æ®é•¿åº¦ï¼š1bytes
 *                                                                                                  ç²¾åº¦ï¼š1 â„ƒ/bit
 *                                                                                                  åç§»é‡ï¼š-40
 *                                                                                                  æ•°æ®èŒƒå›´ï¼š-40~210℃
 *                                                                                                  â€œ0xFF”表示无效
 * 7                   å®žé™…尿素喷射量              DWORD         ml/h       æ•°æ®é•¿åº¦ï¼š4bytes
 *                                                                                                  ç²¾åº¦ï¼š0.01 ml/h per bit
 *                                                                                                  åç§»é‡ï¼š0
 *                                                                                                  æ•°æ®èŒƒå›´ï¼š0
 *                                                                                                  â€œ0xFF,0xFF,0xFF,0xFF”表示无效
 * 11                   ç´¯è®¡å°¿ç´ æ¶ˆè€—(总尿素消耗)DWORD      g        æ•°æ®é•¿åº¦ï¼š4bytes
 *                                                                                                  ç²¾åº¦ï¼š1 g per bit
 *                                                                                                  åç§»é‡ï¼š0
 *                                                                                                  æ•°æ®èŒƒå›´ï¼š0
 *                                                                                                  â€œ0xFF,0xFF,0xFF,0xFF”表示无效
 * 15                   DPF æŽ’气温度                  WORD             â„ƒ        æ•°æ®é•¿åº¦ï¼š2bytes
 *                                                                                                   ç²¾åº¦ï¼š0.03125 â„ƒ per bit
 *                                                                                                   åç§»é‡ï¼š-273
 *                                                                                                   æ•°æ®èŒƒå›´ï¼š-273~1734.96875℃
 *                                                                                                   â€œ0xFF,0xFF”表示无效
 */
class SupplementDataStream(
        time: Date?,
        serialNum: Int?
) : RealTimeData(time, serialNum) {
    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
}
src/main/kotlin/com/flightfeather/uav/socket/bean/TimeCalibrationData.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
package com.flightfeather.uav.socket.bean
import java.util.*
import com.flightfeather.uav.socket.eunm.ObdCommandUnit
/**
 * @author riku
 * Date: 2019/9/12
 *
 * è½¦è½½ç»ˆç«¯æ ¡æ—¶çš„æ•°æ®å•元为空。
 * æ•°æ®ç±»åž‹ @see [ObdCommandUnit.TimeCalibration]
 *
 */
class TimeCalibrationData(
        time: Date? = null,
        serialNum: Int? = null
) : DataUnit(time, serialNum)
src/main/kotlin/com/flightfeather/uav/socket/decoder/DataPackageDecoder.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,42 @@
package com.flightfeather.uav.socket.decoder
import com.flightfeather.uav.socket.bean.DataUnit
import com.flightfeather.uav.socket.eunm.ObdCommandUnit
/**
 * uav ç¬¬ä¸€å±‚数据包解码器
 * @author riku
 * Date: 2019/9/12
 *
 * æ•°æ®ç¬¬ä¸€å±‚结构定义如下:
 * èµ·å§‹å­—节         å®šä¹‰
 * 0                    èµ·å§‹ç¬¦
 * 2                    å‘½ä»¤å•å…ƒ  ç±»åž‹@see [ObdCommandUnit]
 * 3                    è½¦è¾†è¯†åˆ«å·
 * 4                    ç»ˆç«¯è½¯ä»¶ç‰ˆæœ¬å·
 * 21                   æ•°æ®åŠ å¯†æ–¹å¼
 * 22                   æ•°æ®å•元长度
 * 24                   æ•°æ®å•å…ƒ  è§£ç å™¨@see [DataUnitDecoder]
 * å€’数第1           æ ¡éªŒç 
 */
interface DataPackageDecoder {
    fun getHead(b: List<String>): String?
    fun getCommandUnit(b: List<String>): Int?
    fun getVinCode(b: List<String>): String?
    fun getSoftwareVersion(b: List<String>): Int?
    fun getEncryptionWay(b: List<String>): Int?
    fun getDataLength(b: List<String>): Int
    fun getDataUnit(b: List<String>): List<DataUnit>
    fun getCheckCode(b: List<String>): Int?
    fun toStringList(msg: String): List<String>
}
src/main/kotlin/com/flightfeather/uav/socket/decoder/DataUnitDecoder.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,36 @@
package com.flightfeather.uav.socket.decoder
import com.flightfeather.uav.socket.bean.*
import com.flightfeather.uav.socket.eunm.ObdCommandUnit
import java.util.*
/**
 * uav ç¬¬äºŒå±‚数据单元解码器
 * @author riku
 * Date: 2019/9/12
 *
 * æ•°æ®å•元按照命令单元的类型共有以下几种类型:
 * å‘½ä»¤å•å…ƒ @see [ObdCommandUnit]
 * ç¼–码(byte)        å®šä¹‰
 * 0x01                 è½¦è¾†ç™»å…¥
 * 0x02                 å®žæ—¶ä¿¡æ¯ä¸ŠæŠ¥
 * 0x03                 è¡¥å‘信息上报
 * 0x04                 è½¦è¾†ç™»å‡º
 * 0x05                 ç»ˆç«¯æ ¡æ—¶
 * 0x06~0x7f       ä¸Šè¡Œæ•°æ®ç³»ç»Ÿé¢„ç•™
 */
interface DataUnitDecoder {
    fun getCarRegisterData(b: List<String>): List<CarRegisterData>
    fun getRealTimeData(b: List<String>): List<RealTimeData>
    fun getReplacementData(b: List<String>): List<ReplacementData>
    fun getCarLogOutData(b: List<String>): List<CarLogOutData>
    fun getTimeCalibrationData(b: List<String>): List<TimeCalibrationData>
    fun decodeDataTime(b: List<String>): Date?
}
src/main/kotlin/com/flightfeather/uav/socket/decoder/RealTimeDataDecoder.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,26 @@
package com.flightfeather.uav.socket.decoder
import com.flightfeather.uav.socket.bean.*
import com.flightfeather.uav.socket.eunm.ObdDataType
import java.util.*
/**
 * @author riku
 * Date: 2019/9/15
 * æ•°æ®å•å…ƒ[DataUnit]中,类型为实时信息[RealTimeData]的解码器
 * å…¶åˆ†ç±» @see [ObdDataType]
 */
interface RealTimeDataDecoder {
    fun getObdData(time: Date?, serialNum: Int, b: List<String>): ObdInfo?
    fun getEngineDataStream(time: Date?, serialNum: Int, b: List<String>): EngineDataStream?
    fun getSupplementDataStream(time: Date?, serialNum: Int, b: List<String>): SupplementDataStream?
    /**
     * æ ¹æ®ä¼ å…¥çš„列表,默认第一位为 [ObdDataType],返回对应的数据列表
     */
    fun getDataListByDataType(list: List<String>): MutableList<String>
}
src/main/kotlin/com/flightfeather/uav/socket/decoder/VehicleDataDecoder.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,32 @@
package com.flightfeather.uav.socket.decoder
import com.flightfeather.uav.socket.bean.ObdPackageData
import com.flightfeather.uav.socket.decoder.impl.DataPackageDecoderImpl
/**
 * è½¦è¾† uav æ•°æ®è§£ç å™¨
 * @author riku
 * Date: 2019/9/12
 */
class VehicleDataDecoder {
    private val dataPackageDecoder: DataPackageDecoder = DataPackageDecoderImpl()
    fun decode(msg: String): ObdPackageData {
        val list = dataPackageDecoder.toStringList(msg)
        dataPackageDecoder.run {
            return ObdPackageData(
                    getHead(list),
                    getCommandUnit(list),
                    getVinCode(list),
                    getSoftwareVersion(list),
                    getEncryptionWay(list),
                    getDataLength(list),
                    getDataUnit(list),
                    getCheckCode(list)
            )
        }
    }
}
src/main/kotlin/com/flightfeather/uav/socket/decoder/impl/DataPackageDecoderImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,98 @@
package com.flightfeather.uav.socket.decoder.impl
import com.flightfeather.uav.socket.bean.DataUnit
import com.flightfeather.uav.socket.decoder.DataPackageDecoder
import com.flightfeather.uav.socket.decoder.DataUnitDecoder
import com.flightfeather.uav.socket.eunm.ObdCommandUnit
/**
 * @author riku
 * Date: 2019/9/12
 */
class DataPackageDecoderImpl : DataPackageDecoder {
    private val dataUnitDecoder: DataUnitDecoder = DataUnitDecoderImpl()
    // æŽ¥æ”¶åˆ°çš„字符串是byte转码前的,其就表示字符的ASCII码;
    override fun getHead(b: List<String>): String? {
        return if (b.size >= 2) {
            "${b[0]}${b[1]}"
        } else {
            null
        }
    }
    override fun getCommandUnit(b: List<String>): Int? = if (b.size >= 3) {
        b[2].toIntOrNull(16)
    } else {
        null
    }
    override fun getVinCode(b: List<String>): String? {
        if (b.size < 20) return null
        //fixme åº”该是需要将b当作ASCII码,再获取转换后的字符串
        val s = StringBuilder()
        for (i in 3..19) {
            s.append(b[i].toIntOrNull(16)?.toChar())
        }
        return s.toString()
    }
    override fun getSoftwareVersion(b: List<String>): Int? = if (b.size >= 21) {
        b[20].toIntOrNull(16)
    } else {
        null
    }
    override fun getEncryptionWay(b: List<String>): Int? = if (b.size >= 21) {
        b[21].toIntOrNull(16)
    } else {
        null
    }
    override fun getDataLength(b: List<String>): Int {
        if (b.size < 24) return 0
        val hexNum = "${b[22]}${b[23]}"
        return hexNum.toIntOrNull(16) ?: 0
    }
    override fun getDataUnit(b: List<String>): List<DataUnit> {
        if (getDataLength(b) == 0 || b.size < 26) {
            return emptyList()
        }
        val unit = mutableListOf<String>()
        for (i in 24..b.size - 2) {
            unit.add(b[i])
        }
        dataUnitDecoder.run {
            return when (getCommandUnit(b)) {
                ObdCommandUnit.CarRegister.value -> getCarRegisterData(unit)
                ObdCommandUnit.RealTimeData.value -> getRealTimeData(unit)
                ObdCommandUnit.ReplacementData.value -> getReplacementData(unit)
                ObdCommandUnit.CarLogOut.value -> getCarLogOutData(unit)
                ObdCommandUnit.TimeCalibration.value -> getTimeCalibrationData(unit)
                else -> emptyList()
            }
        }
    }
    override fun getCheckCode(b: List<String>): Int? {
        return if (b.isNotEmpty()) {
            b[b.size - 1].toIntOrNull(16)
        } else {
            null
        }
    }
    override fun toStringList(msg: String): List<String> {
        return msg.split(" ")
    }
}
src/main/kotlin/com/flightfeather/uav/socket/decoder/impl/DataUnitDecoderImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,127 @@
package com.flightfeather.uav.socket.decoder.impl
import com.flightfeather.uav.socket.bean.*
import com.flightfeather.uav.socket.decoder.DataUnitDecoder
import com.flightfeather.uav.socket.decoder.RealTimeDataDecoder
import com.flightfeather.uav.socket.eunm.ObdDataType
import org.slf4j.LoggerFactory
import java.lang.StringBuilder
import java.util.*
/**
 * @author riku
 * Date: 2019/9/15
 */
class DataUnitDecoderImpl : DataUnitDecoder {
    private val logger = LoggerFactory.getLogger(javaClass.name)
    private var realTimeDataDecoder: RealTimeDataDecoder = RealTimeDataDecoderImpl()
    override fun getCarRegisterData(b: List<String>): List<CarRegisterData> {
        val time = decodeDataTime(b)
        val serialNum = "${b[6]}${b[7]}".toInt(16)
        val simCode = StringBuilder()
        for (i in 10 until b.size) {
            simCode.append(b[i].toInt(16).toChar())
        }
        return mutableListOf(CarRegisterData(time, serialNum, simCode.toString()))
    }
    override fun getRealTimeData(b: List<String>): List<RealTimeData> {
        val time = decodeDataTime(b)
        //国标法: èµ·å§‹å­—节为7 å¼€å§‹çš„2个字节表示 æµæ°´å·
//        val serialNum = "${b[7]}${b[8]}".toInt(16)
        //上海法: èµ·å§‹å­—节为6 å¼€å§‹çš„2个字节表示 æµæ°´å·
        val serialNum = "${b[6]}${b[7]}".toInt(16)
        val dataList = mutableListOf<String>().apply { addAll(b) }
        //删去前6位时间
        for (i in 0..5) {
            if (dataList.isNotEmpty()) dataList.removeAt(0)
        }
        //fixme 2019.9.15 ç›®å‰ä¸¤ç§è§„则有冲突,并且只从数据内容无法区分。暂时使用 å›½æ ‡æ³•
        /*
        * åˆ åŽ»æµæ°´å·ï¼Œå¾—åˆ°ä¿¡æ¯æ ‡å¿—ä¸Žä¿¡æ¯ä½“çš„ç»„åˆ
        * (国标法:去除前6位时间后,起始字节为1 å¼€å§‹çš„2个字节表示 æµæ°´å·)
        */
//        if (dataList.size >= 2) dataList.removeAt(1)
//        if (dataList.size >= 2) dataList.removeAt(1)
        /*
        * åˆ åŽ»æµæ°´å·ï¼Œå¾—åˆ°ä¿¡æ¯æ ‡å¿—ä¸Žä¿¡æ¯ä½“çš„ç»„åˆ
        * (上海法:去除前6位时间后,起始字节为0 å¼€å§‹çš„2个字节表示 æµæ°´å·)
        */
        if (dataList.isNotEmpty()) dataList.removeAt(0)
        if (dataList.isNotEmpty()) dataList.removeAt(0)
        val resultList = mutableListOf<RealTimeData>()
        /*
         * æœ€ç»ˆå¾—到的数据结构为 [ ä¿¡æ¯ç±»åž‹æ ‡å¿—, ä¿¡æ¯ä½“, ...... , ä¿¡æ¯ç±»åž‹æ ‡å¿—, ä¿¡æ¯ä½“ ]
         */
        while (dataList.isNotEmpty()) {
            //得到最前面的一组信息类型+信息体列表
            val data = realTimeDataDecoder.getDataListByDataType(dataList)
            if (data.isNotEmpty()) {
                val r = when (data[0].toInt(16)) {
                    ObdDataType.ObdData.value -> realTimeDataDecoder.getObdData(time, serialNum, data)
                    ObdDataType.EngineDataFlow.value -> realTimeDataDecoder.getEngineDataStream(time, serialNum, data)
                    ObdDataType.SupplementDataFlow.value -> realTimeDataDecoder.getSupplementDataStream(time, serialNum, data)
                    else -> null
                }
                if (r != null) {
                    resultList.add(r)
                }
                for (i in 0 until data.size) {
                    if (dataList.isNotEmpty()) dataList.removeAt(0)
                }
            }else if (dataList.isNotEmpty()) {
                //按照规则没有取到信息体,并且原数据不为空,表示原数据格式错误,退出循环
                logger.error("-------数据信息流或补充数据流格式错误")
                break
            }
        }
        return resultList
    }
    override fun getReplacementData(b: List<String>): List<ReplacementData> = getRealTimeData(b)
    override fun getCarLogOutData(b: List<String>): List<CarLogOutData> {
        val time = decodeDataTime(b)
        val serialNum = "${b[6]}${b[7]}".toInt(16)
        return mutableListOf(CarLogOutData(time, serialNum))
    }
    override fun getTimeCalibrationData(b: List<String>): List<TimeCalibrationData> = emptyList()
    override fun decodeDataTime(b: List<String>): Date? {
        if (b.size < 6) {
            return null
        }
        val year = b[0].toInt(16) + 2000
        if (year < 2000 || year > 2099) return 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)
            set(Calendar.MILLISECOND, 0)
        }
        return cal.time
    }
}
src/main/kotlin/com/flightfeather/uav/socket/decoder/impl/RealTimeDataDecoderImpl.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,185 @@
package com.flightfeather.uav.socket.decoder.impl
import com.flightfeather.uav.common.INVALID_DATA_4_BYTE
import com.flightfeather.uav.socket.bean.EngineDataStream
import com.flightfeather.uav.socket.bean.ObdInfo
import com.flightfeather.uav.socket.bean.SupplementDataStream
import com.flightfeather.uav.socket.decoder.RealTimeDataDecoder
import com.flightfeather.uav.socket.eunm.ObdDataType
import java.util.*
/**
 * @author riku
 * Date: 2019/9/15
 */
class RealTimeDataDecoderImpl : RealTimeDataDecoder {
    override fun getObdData(time: Date?, serialNum: Int, b: List<String>): ObdInfo? {
        val dataList = mutableListOf<String>().apply { addAll(b) }
        if (b.isNotEmpty()) {
            //去除 ä¿¡æ¯ç±»åž‹æ ‡å¿—
            dataList.removeAt(0)
        }
        if (dataList.size >= 96) {
            val vin = StringBuilder()
            for (i in 6..22) {
                vin.append(dataList[i].toIntOrNull(16)?.toChar())
            }
            val softwareCode = StringBuilder()
            for (i in 23..40) {
                softwareCode.append(dataList[i].toIntOrNull(16)?.toChar())
            }
            val cvn = StringBuilder()
            for (i in 41..58) {
                cvn.append(dataList[i].toIntOrNull(16)?.toChar())
            }
            val IUPR = StringBuilder()
            for (i in 59..94) {
                //todo 2019.9.15 å› æš‚不清楚格式与含义,直接保存
                IUPR.append(dataList[i])
            }
            var faultCodeNum = dataList[95].toIntOrNull() ?: 0
            val faultCode = StringBuilder()
            if (faultCodeNum < 0 || faultCodeNum > 253) {
                faultCodeNum = 254//代表无效
            } else {
                for (i in 96..(95 + 4 * faultCodeNum)) {
                    faultCode.append(dataList[i])
                }
            }
            return ObdInfo(time, serialNum).apply {
                obdProtocol = dataList[0].toIntOrNull(16)
                obdMil = dataList[1].toIntOrNull(16)
                diagnosisSupportStatus = "${dataList[2]}${dataList[3]}".toIntOrNull(16)?.toString(2)
                diagnosisReadyStatus = "${dataList[4]}${dataList[5]}".toIntOrNull(16)?.toString(2)
                obdVin = vin.toString()
                obdCrn = softwareCode.toString()
                obdCvn = cvn.toString()
                this.iupr = IUPR.toString()
                obdFaultCodeNum = faultCodeNum
                obdFaultCode = faultCode.toString()
            }
        } else {
            return null
        }
    }
    override fun getEngineDataStream(time: Date?, serialNum: Int, b: List<String>): EngineDataStream? {
        val dataList = mutableListOf<String>().apply { addAll(b) }
        if (b.isNotEmpty()) {
            //去除 ä¿¡æ¯ç±»åž‹æ ‡å¿—
            dataList.removeAt(0)
        }
        return if (dataList.size >= 37) {
             EngineDataStream(time, serialNum).apply {
                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)?.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)?.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)
                 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
        }
    }
    override fun getSupplementDataStream(time: Date?, serialNum: Int, b: List<String>): SupplementDataStream? {
        val dataList = mutableListOf<String>().apply { addAll(b) }
        if (b.isNotEmpty()) {
            //去除 ä¿¡æ¯ç±»åž‹æ ‡å¿—
            dataList.removeAt(0)
        }
        return if (dataList.size >= 17) {
            SupplementDataStream(time, serialNum).apply {
                obdEngineTorqueMode = dataList[0].toIntOrNull(16)
                obdAcceleratorPedal = dataList[1].toIntOrNull(16)?.toDouble()?.times(0.4)?.div(100)
                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)
                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
        }
    }
    override fun getDataListByDataType(list: List<String>): MutableList<String> {
        if (list.isEmpty()) return mutableListOf()
        //fixme 2019.9.16 ä¸ç®¡ç¬¬ä¸€ä½çš„信息类型标志是否正确,至少返回一个值,此方法在信息体结构没有严格按照标准,
        //fixme  å³åœ¨åŽä¸€ä¸ªä¿¡æ¯ç±»åž‹æ ‡å¿—和前一个信息体之间有无效字符时,能够将其忽略,但不确定这种处理方式是否正确和必要
        val resultList = mutableListOf<String>().apply {
            add(list[0])
        }
        when (list[0].toIntOrNull(16)) {
            ObdDataType.ObdData.value -> {
                if (list.size >= 97) {
                    //从起始字节 1 å¼€å§‹ï¼Œå›ºå®šæœ‰96个字节的数据
                    for (i in 1..96) {
                        resultList.add(list[i])
                    }
                    val faultCodeNum = list[96].toIntOrNull() ?: 0//故障码总数
                    //根据故障码总数,每个故障码4个字节,得到故障码总字节数
                    if (faultCodeNum in 0..253) {
                        for (i in 97..(96 + faultCodeNum * 4)) {
                            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
    }
}
src/main/kotlin/com/flightfeather/uav/socket/eunm/ObdCommandUnit.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,27 @@
package com.flightfeather.uav.socket.eunm
import com.flightfeather.uav.socket.bean.*
/**
 * @author riku
 * Date: 2019/9/12
 *
 * uav å‘½ä»¤å•å…ƒ
 *
 * ç¼–码                   å®šä¹‰                     æ–¹å‘
 * 0x01             è½¦è¾†ç™»å…¥                    ä¸Šè¡Œ @see [CarRegisterData]
 * 0x02            å®žæ—¶ä¿¡æ¯ä¸ŠæŠ¥             ä¸Šè¡Œ @see [com.flightfeather.uav.socket.bean.RealTimeData]
 * 0x03            è¡¥å‘信息上报             ä¸Šè¡Œ @see [com.flightfeather.uav.socket.bean.ReplacementData]
 * 0x04            è½¦è¾†ç™»å‡º                    ä¸Šè¡Œ @see [CarLogOutData]
 * 0x05            ç»ˆç«¯æ ¡æ—¶                    ä¸Šè¡Œ @see [TimeCalibrationData]
 * 0x06~0x7F ä¸Šè¡Œæ•°æ®ç³»ç»Ÿé¢„ç•™      ä¸Šè¡Œ
 * 0x7F            å›ºä»¶è¿œç¨‹æ›´æ–°
 */
enum class ObdCommandUnit constructor(val value: Int) {
    CarRegister(1),
    RealTimeData(2),
    ReplacementData(3),
    CarLogOut(4),
    TimeCalibration(5),
    Update(127)
}
src/main/kotlin/com/flightfeather/uav/socket/eunm/ObdDataType.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,20 @@
package com.flightfeather.uav.socket.eunm
import com.flightfeather.uav.socket.bean.*
/**
 * @author riku
 * Date: 2019/9/15
 *
 * å®žæ—¶ä¿¡æ¯[RealTimeData]和补发信息[ReplacementData] ä¸­çš„æ•°æ®ç±»åž‹
 * ç±»åž‹ç¼–码                     è¯´æ˜Ž
 * 0x01                           OBD ä¿¡æ¯    @see [com.flightfeather.uav.socket.bean.ObdInfo]
 * 0x02                          æ•°æ®æµä¿¡æ¯  @see[com.flightfeather.uav.socket.bean.EngineDataStream]
 * 0x03-0x7F                é¢„ç•™
 * 0x80                          è¡¥å……数据流   @see[com.flightfeather.uav.socket.bean.SupplementDataStream]
 * 0x81~0xFE                ç”¨æˆ·è‡ªå®šä¹‰
 */
enum class ObdDataType constructor(val value: Int){
    ObdData(1),
    EngineDataFlow(2),
    SupplementDataFlow(128)
}
src/test/kotlin/com/flightfeather/uav/Test.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,150 @@
package com.flightfeather.uav
import org.junit.Test
import java.text.SimpleDateFormat
import java.util.*
/**
 * @author riku
 * Date: 2019/9/12
 */
class Test {
    @Test
    fun foo1() {
        val b = ByteArray(20) {8}
        val a = 1
        println(a.toString(2))
    }
    @Test
    fun foo2() {
        val b = ByteArray(2)
        b[0] = 0x01
        b[1] = 0x80.toByte()
        println("${b[0].toString(16)}${b[1].toInt()}")
        println("${b[0]}${b[1]}".toInt(16))
    }
    @Test
    fun foo3() {
        val hexNum = "ff"
        val length = hexNum.toInt(16)
        println(length)
    }
    @Test
    fun foo4() {
        val h = "0101"
        val byte = 0xff
        val b = h.toInt(16)
        println(b)
    }
    @Test
    fun foo5() {
        val s = "23 23 30 30 30 30 30 35 33 31 36 30 38 30 31 30 35 33 36"
        val sb = StringBuilder()
        val ascii = s.split(" ")
        ascii.forEach {
            sb.append(it.toIntOrNull(16)?.toChar())
        }
        println(sb.toString())
    }
    @Test
    fun foo6() {
        val cal  = Calendar.getInstance().apply {
            set(2019, 9, 15, 23, 16, 59)
        }
        println(SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(cal.time))
    }
    @Test
    fun foo7() {
        val a = "0AAF".toIntOrNull(16)?.toString(2)
        println(a)
    }
    @Test
    fun foo8() {
        val byte = ByteArray(2)
        byte[0] = 0x23
        byte[1] = 0x23
        byte[0].toString(16)
    }
    @Test
    fun foo9() {
        val b = 128.toByte()
        var a = 0
        if (b < 0) {
            a = b + 256
        } else {
            a = b.toInt()
        }
        println(b.toString(16))
    }
    @Test
    fun foo10() {
        val s = "2 31 37 36 39 31 35 33 31 39 30 39 31 32 30 30 30 36 1 1 0 42 13 9 f 12 33 3b 2 0 8a 1b 0 36 2e 0 23 60 11 b4 0 c8 0 b4 0 0 66 0 0 0 0 0 0 73 0 0 0 b9 4 75 0 2e d8 ed 0 0 0 0 80 0 bc 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"
        val ascii = s.split(" ")
        var bcc = 0x00
        ascii.forEach {
            bcc = bcc.xor(it.toInt(16))
        }
        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))
    }
    @Test
    fun f0012() {
        val sb = java.lang.StringBuilder()
        val byte = ByteArray(2)
        byte[0] = 0x00
        byte[1] = 0xBD.toByte()
        byte.forEach { b ->
            var a = 0
            a = if (b < 0) {
                b + 256
            } else {
                b.toInt()
            }
            sb.append(a.toString(16))
        }
        println(sb.toString().toInt(16))
    }
}
src/test/kotlin/com/flightfeather/uav/UAVApplicationTests.kt
ÎļþÃû´Ó src/test/kotlin/com/flightfeather/obd/ObdApplicationTests.kt ÐÞ¸Ä
@@ -1,8 +1,7 @@
package com.flightfeather.obd
package com.flightfeather.uav
import com.flightfeather.obd.domain.mapper.ObdDataMapper
import com.flightfeather.obd.lightshare.bean.BaseJson
import com.flightfeather.obd.lightshare.bean.ObdDataVo
import com.flightfeather.uav.domain.mapper.ObdDataMapper
import com.flightfeather.uav.lightshare.bean.ObdDataVo
import com.google.gson.Gson
import org.junit.Test
import org.junit.runner.RunWith
@@ -13,7 +12,7 @@
@RunWith(SpringRunner::class)
@SpringBootTest
class ObdApplicationTests {
class UAVApplicationTests {
    @Autowired
    lateinit var obdDataMapper: ObdDataMapper
src/test/kotlin/com/flightfeather/uav/socket/MessageManagerTest.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,18 @@
package com.flightfeather.uav.socket
import org.junit.Test
/**
 * @author riku
 * Date: 2019/9/16
 */
class MessageManagerTest {
    private val messageManager = MessageManager()
    @Test
    fun bccCheck() {
        val s = "23 23 2 31 37 36 39 31 35 33 31 39 30 39 31 32 30 30 30 36 1 1 0 42 13 9 f 12 34 8 2 0 8b 1c 0 d8 0 0 12 d8 9 6c 0 c8 0 b4 0 0 66 0 0 0 0 0 0 73 0 0 0 b9 4 32 0 2e d8 c4 0 0 0 0 80 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 f6"
        println(messageManager.bccCheck(s))
    }
}
src/test/kotlin/com/flightfeather/uav/socket/decoder/VehicleDataDecoderTest.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,102 @@
package com.flightfeather.uav.socket.decoder
import com.flightfeather.uav.domain.entity.ObdData
import com.flightfeather.uav.socket.bean.*
import com.flightfeather.uav.socket.eunm.ObdCommandUnit
import org.junit.Test
/**
 * @author riku
 * Date: 2019/9/17
 */
class VehicleDataDecoderTest {
    private val vehicleDataDecoder = VehicleDataDecoder()
    @Test
    fun decode() {
        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)
        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 {
                    obdData.apply {
                        obdTime = it.time
                    }
                    when (it) {
                        is com.flightfeather.uav.socket.bean.ObdInfo -> {
                            obdData.apply {
                                obdProtocol = it.obdProtocol
                                obdMil = it.obdMil
                                obdIdCode = it.obdCrn
                                obdVerificationCode = it.obdCvn
                                obdFaultCodeNum = it.obdFaultCodeNum
                                obdFaultCode = it.obdFaultCode
                            }
                        }
                        is EngineDataStream -> {
                            obdData.apply {
                                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.obdScrUpstreamNox
                                obdScrDownstreamNo = it.obdScrDownstreamNox
                                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 {
                                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 -> {
            }
            ObdCommandUnit.TimeCalibration.value -> {
            }
        }
    }
}