src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcChangeRate.kt
@@ -66,7 +66,7 @@ // 计算后一个数据相比于前一个数据的变化速率 val v = (nValue - pValue) val b1 = v in rate.mutationRate.first..rate.mutationRate.second println("因子:${f.des},速率:${v},${b1}") // println("因子:${f.des},速率:${v},${b1}") res[f] = b1 } else { res[f] = false src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcWindLevel.kt
@@ -66,13 +66,13 @@ val con = windLevelCondition if (n.windSpeed!! in con.windSpeed.first..con.windSpeed.second) { println("风速:${n.windSpeed},[${con.windSpeed.first} - ${con.windSpeed.second}]") // println("风速:${n.windSpeed},[${con.windSpeed.first} - ${con.windSpeed.second}]") val pValue = p.getByFactorType(f)!! val nValue = n.getByFactorType(f)!! // 计算后一个数据相比于前一个数据的变化率 val r = (nValue - pValue) / pValue val b1 = r >= con.mutationRate.first && r < con.mutationRate.second println("因子:${f.des},幅度:${r},限定:${con.mutationRate.first},${b1}") // println("因子:${f.des},幅度:${r},限定:${con.mutationRate.first},${b1}") res[f] = b1 } else { res[f] = false src/main/kotlin/com/flightfeather/uav/common/utils/FileUtil.kt
@@ -80,7 +80,7 @@ } // readyToShutDownStream(bw, fw) println("----写入完成") // println("----写入完成") } src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt
@@ -137,7 +137,14 @@ */ fun mDataPrep2(dataPackage: AirDataPackage): List<DataVo> { val vo = dataPackage.toDataVo() return mDataPrep2(listOf(vo)) return mDataPrep2(vo) } /** * 实时数据平滑处理 */ fun mDataPrep2(dataVo: DataVo): List<DataVo> { return mDataPrep2(listOf(dataVo)) } /** src/main/kotlin/com/flightfeather/uav/socket/decoder/DataUnitDecoder.kt
@@ -27,11 +27,7 @@ resultList.add(AirTypeData(f)) } } if (!types.containsKey(deviceCode)) { types[deviceCode] = mutableListOf() } types[deviceCode]?.clear() types[deviceCode]?.addAll(resultList) types[deviceCode] = resultList return resultList } src/main/kotlin/com/flightfeather/uav/socket/processor/UnderwayProcessor.kt
@@ -6,14 +6,18 @@ import com.flightfeather.uav.domain.repository.AirDataRep import com.flightfeather.uav.domain.repository.SceneInfoRep import com.flightfeather.uav.domain.repository.SourceTraceRep import com.flightfeather.uav.lightshare.bean.DataVo 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.format.annotation.DateTimeFormat import org.springframework.stereotype.Component import java.text.SimpleDateFormat import java.time.LocalDateTime import java.time.format.DateTimeFormatter import java.util.* /** @@ -52,15 +56,17 @@ //保存 deviceSession.saveDevice(packageData.deviceCode, ctx) saveToTxt(msg) saveToDataBase(packageData)?.takeIf { it.isNotEmpty() }?.get(0)?.let { val res = saveToDataBase(packageData) println("----写入完成") res?.takeIf { it.isNotEmpty() }?.get(0)?.let { // 每台设备有各自单独的异常数据处理器 if (!sourceTraceMap.containsKey(it.deviceCode)) { sourceTraceMap[it.deviceCode] = SourceTraceController(sceneInfoRep, sourceTraceRep) } // 将走航数据传入异常处理器 sourceTraceMap[it.deviceCode]?.addOneData(it) println("----动态溯源完成") } } else { println("------${TAG}数据BCC校验失败,舍弃 [${SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Date())}]") } @@ -72,8 +78,9 @@ fun saveToDataBase(dataPackage: AirDataPackage): List<BaseRealTimeData>? { when (dataPackage.commandUnit) { AirCommandUnit.AirData.value -> { val dataVo = dataPackage.toDataVo() // 存储前判断数据是否有效 if (!isValid(dataPackage)) return null if (!isValid(dataVo)) return null // 以json格式存储原始数据 airDataRep.saveAirData(dataPackage) // 进行预处理后,存储至对应数据表 @@ -82,7 +89,7 @@ dataProcessMap[dataPackage.deviceCode] = EPWDataPrep(UWDeviceType.getType(dataPackage.deviceCode)) } return dataProcessMap[dataPackage.deviceCode]?.run { val list = this.mDataPrep2(dataPackage)// 数据平滑处理 val list = this.mDataPrep2(dataVo)// 数据平滑处理 airDataRep.savePrepData2(list)// 按照设备类型存储至对应数据表 } } @@ -151,9 +158,10 @@ /** * 数据有效性判断 */ private fun isValid(dataPackage: AirDataPackage): Boolean { if (dataPackage.dataTime == null) return false val check1 = dataPackage.dataTime!!.time < Date().time private fun isValid(dataVo: DataVo): Boolean { if (dataVo.time == null) return false val check1 = LocalDateTime.parse(dataVo.time!!, DateTimeFormatter.ofPattern("yyy-MM-dd HH:mm:ss")) .isBefore(LocalDateTime.now()) return check1 } } src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImplTest.kt
@@ -34,7 +34,7 @@ @Test fun calMissionInfo() { missionMapper.selectByExample(Example(Mission::class.java).apply { createCriteria().andBetween("startTime", "2026-01-29 00:00:00", "2026-12-31 23:59:59") createCriteria().andBetween("startTime", "2026-02-02 00:00:00", "2026-12-31 23:59:59") }).forEach {mission -> mission?.let { missionService.calMissionInfo(it.missionCode) } Thread.sleep(1000) src/test/kotlin/com/flightfeather/uav/socket/UnderwayProcessorTest.kt
@@ -6,6 +6,9 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.context.junit4.SpringRunner import java.io.File import java.nio.file.Files import java.nio.file.Paths /** * @author riku @@ -20,7 +23,19 @@ @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)) listOf( "01 04 0a 00 00 00 00 01 12 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 00 0c", "01 05 0a 00 00 00 00 01 52 00 05 af 00 cb f7 03 45 84 02 a1 65 00 71 92 01 ec 04 00 b7 9b 01 6e 0f 00 aa 9c 01 6b c4 00 0c 00 00 0d 00 00 1b 10 00 34 08 05 d3 1c 05 d4 7f 00 00 00 00 00 00 56 00 00 00 00 45 00 00 00 00 4e 00 00 00 50 01 06 08 0c 29 00 00 00 00 00 00 00 00 00 64" ).forEach { messageManager.dealStringMsg(it, null) } // println(messageManager.bccCheck(s)) // val lines = Files.readAllLines(Paths.get("C:\\Users\\feiyu\\Desktop\\data-2026-04-10-10-03-14.txt")) // println("数据量:${lines.size - 1}") // lines.forEach { // val msg = it.split("data=> ")[1] // messageManager.dealStringMsg(msg, null) // Thread.sleep(4000) // } } }