| | |
| | | import com.flightfeather.uav.domain.entity.RealTimeData |
| | | import com.flightfeather.uav.domain.mapper.RealTimeDataMapper |
| | | import com.flightfeather.uav.repository.AirDataRepository |
| | | import com.flightfeather.uav.socket.bean.AirPackageData |
| | | import com.flightfeather.uav.socket.bean.AirData |
| | | import com.flightfeather.uav.socket.bean.AirDataPackage |
| | | import com.flightfeather.uav.socket.eunm.FactorType |
| | | import com.google.gson.Gson |
| | | import org.springframework.stereotype.Repository |
| | | import java.util.* |
| | | |
| | | /** |
| | | * @author riku |
| | |
| | | @Repository |
| | | class AirDataRepositoryImpl(private val realTimeDataMapper: RealTimeDataMapper): AirDataRepository { |
| | | |
| | | override fun saveAirData(packageData: AirPackageData): Int { |
| | | |
| | | override fun saveAirData(dataPackage: AirDataPackage): Int { |
| | | val data = RealTimeData().apply { |
| | | deviceCode = packageData.deviceCode |
| | | deviceCode = dataPackage.deviceCode |
| | | latitude |
| | | longitude |
| | | altitude |
| | | height |
| | | factors = Gson().toJson(packageData.dataUnit) |
| | | dataTime = packageData.dataTime |
| | | factors = Gson().toJson(dataPackage.dataUnit) |
| | | dataTime = dataPackage.dataTime |
| | | } |
| | | dataPackage.dataUnit.forEach { |
| | | if (it is AirData) { |
| | | when (it.factorId?.toInt()) { |
| | | FactorType.LAT.value -> { |
| | | data.latitude = it.factorData?.toBigDecimal() |
| | | } |
| | | FactorType.LNG.value -> { |
| | | data.longitude = it.factorData?.toBigDecimal() |
| | | } |
| | | FactorType.TIME.value -> { |
| | | it.factorData?.let { f-> Date(f)}?.let {d -> |
| | | data.dataTime = d |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | realTimeDataMapper.insert(data) |
| | | |
| | | return 0 |