From b2e89ca1b11f33417f3e83223c4aa188186c8155 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期五, 05 七月 2024 17:38:18 +0800
Subject: [PATCH] 1. 新增走航报告自动道路识别模块

---
 src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt
index ee7dd04..057472d 100644
--- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt
+++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt
@@ -11,6 +11,7 @@
 import com.flightfeather.uav.domain.mapper.*
 import com.flightfeather.uav.domain.repository.MissionRep
 import com.flightfeather.uav.domain.repository.RealTimeDataRep
+import com.flightfeather.uav.domain.repository.SegmentInfoRep
 import com.flightfeather.uav.lightshare.bean.*
 import com.flightfeather.uav.lightshare.service.RealTimeDataService
 import com.flightfeather.uav.model.epw.EPWDataPrep
@@ -45,6 +46,7 @@
     private val missionMapper: MissionMapper,
     private val missionRep: MissionRep,
     private val realTimeDataRep: RealTimeDataRep,
+    private val segmentInfoRep: SegmentInfoRep,
 ) : RealTimeDataService {
 
     @Value("\${filePath}")
@@ -189,7 +191,26 @@
     override fun getSegmentData(missionCode: String): List<List<DataVo>> {
         val mission = missionRep.findOne(missionCode) ?: throw BizException("浠诲姟涓嶅瓨鍦�")
         val data = realTimeDataRep.fetchData(mission)
-        return TrackSegment.segmentWithRoad(data).map { it.map { b -> b.toDataVo() } }
+
+        val segInfo = SegmentInfo().apply { this.missionCode = missionCode }
+        val segList = segmentInfoRep.findList(segInfo)
+//        return TrackSegment.segmentWithRoad(data).map { it.map { b -> b.toDataVo() } }
+        val res = mutableListOf<MutableList<DataVo>>()
+        res.add(mutableListOf())
+        var index = 0
+        data.forEach {
+            if (it.dataTime == null) return@forEach
+            if (it.dataTime!! <= segList[index]?.endTime) {
+                res[index].add(it.toDataVo())
+                if (it.dataTime!! == segList[index]?.endTime) {
+                    index++
+                    res.add(mutableListOf())
+                }
+            }
+        }
+        // 绉婚櫎鏈�鍚庝竴涓┖闆嗗悎
+        if (res.last().isEmpty()) res.removeLast()
+        return res
     }
 
     override fun importData(file: MultipartFile): BaseResponse<DataImportResult> {

--
Gitblit v1.9.3