| | |
| | | package com.flightfeather.uav.socket.processor |
| | | |
| | | import com.flightfeather.uav.model.epw.EPWDataPrep |
| | | import com.flightfeather.uav.repository.AirDataRepository |
| | | import com.flightfeather.uav.socket.bean.AirDataPackage |
| | | import com.flightfeather.uav.socket.decoder.AirDataDecoder |
| | | import com.flightfeather.uav.socket.decoder.DataPackageDecoder |
| | | import com.flightfeather.uav.socket.eunm.AirCommandUnit |
| | | import com.flightfeather.uav.socket.eunm.UWDeviceType |
| | | import io.netty.channel.ChannelHandlerContext |
| | | import org.springframework.beans.factory.annotation.Autowired |
| | | import org.springframework.stereotype.Component |
| | |
| | | @Autowired |
| | | lateinit var airDataRepository: AirDataRepository |
| | | |
| | | val airDataDecoder = AirDataDecoder.instance |
| | | val dataPackageDecoder = DataPackageDecoder() |
| | | private val airDataDecoder = AirDataDecoder.instance |
| | | private val dataPackageDecoder = DataPackageDecoder() |
| | | |
| | | // 数据预处理函数 |
| | | private val dataProcessMap = mutableMapOf<String?, EPWDataPrep>() |
| | | |
| | | @PostConstruct |
| | | fun init() { |
| | |
| | | */ |
| | | fun saveToDataBase(dataPackage: AirDataPackage) { |
| | | when (dataPackage.commandUnit) { |
| | | AirCommandUnit.AirData.value -> instance.airDataRepository.saveAirData(dataPackage) |
| | | AirCommandUnit.AirData.value -> { |
| | | // 以json格式存储原始数据 |
| | | instance.airDataRepository.saveAirData(dataPackage) |
| | | // 进行预处理后,存储至对应数据表 |
| | | if (!dataProcessMap.containsKey(dataPackage.deviceCode)) { |
| | | dataProcessMap[dataPackage.deviceCode] = EPWDataPrep()// 每台设备有单独的数据预处理对象 |
| | | } |
| | | dataProcessMap[dataPackage.deviceCode]?.run { |
| | | val list = this.mDataPrep2(dataPackage)// 数据平滑处理 |
| | | instance.airDataRepository.savePrepData2(list)// 按照设备类型存储至对应数据表 |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |