From 538ba7a3bbc682f4537f1dd34f93feb2cf56b08e Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 14 十月 2025 17:32:04 +0800
Subject: [PATCH] 2025.10.14 1. 新增数据统计颗粒度选项,可选秒级数据、分钟数据进行数据统计 2. 典型隐患区域统计新增按照污染溯源区域进行分类统计的功能

---
 src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImpl.kt |   52 ++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImpl.kt
index 3e20de7..52efc03 100644
--- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImpl.kt
+++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImpl.kt
@@ -23,7 +23,6 @@
 import com.flightfeather.uav.socket.eunm.FactorType
 import com.flightfeather.uav.socket.sender.MsgType
 import org.springframework.stereotype.Service
-import tk.mybatis.mapper.entity.Example
 import java.util.*
 
 /**
@@ -108,6 +107,13 @@
         return summary
     }
 
+    override fun generateMissionSummary(missionCode: String): MissionSummary.Summary {
+        val mission = missionRep.findOne(missionCode) ?: throw BizException("璧拌埅浠诲姟涓嶅瓨鍦�")
+        val clues = sourceTraceRep.fetchList(mission.deviceCode, mission.startTime, mission.endTime, MsgType.PolClue) as List<PollutedClue?>
+        val summary = MissionSummary().execute(mission.startTime, mission.endTime, listOf(mission), clues)
+        return summary
+    }
+
     /**
      * 鐢熸垚璧拌埅浠诲姟娓呭崟锛堟寜鏃堕棿鍜屽尯鍩熺瓫閫夛級
      * 鏍规嵁鏃堕棿鑼冨洿鍜岃鏀垮尯鍒掓煡璇㈣蛋鑸换鍔★紝骞跺叧鑱旀薄鏌撶嚎绱㈡暟鎹敓鎴愪换鍔″垪琛�
@@ -166,11 +172,17 @@
      * @param startTime 鏌ヨ璧峰鏃堕棿锛堝寘鍚級
      * @param endTime 鏌ヨ缁撴潫鏃堕棿锛堝寘鍚級
      * @param areaVo 鍖哄煙鍙傛暟锛屽寘鍚渷銆佸競銆佸尯缂栫爜
+     * @param granularity 鏁版嵁棰楃矑搴︼紝鍙�夊�间负SECOND, MINUTE, HOUR, 榛樿MINUTE
      * @return 浠诲姟璇︽儏鍒楄〃锛屾瘡涓厓绱犲寘鍚换鍔″畬鏁翠俊鎭�佹薄鏌撶嚎绱㈠強瀹炴椂鐩戞祴鏁版嵁
      * @see MissionRep.findByAreaAndTime 鍖哄煙鏃堕棿绛涢�夋暟鎹簮
      * @see realTimeDataRep.fetchData 瀹炴椂鏁版嵁鑾峰彇鎺ュ彛
      */
-    override fun generateMissionDetail(startTime: Date, endTime: Date, areaVo: AreaVo): List<MissionInventory.MissionDetail> {
+    override fun generateMissionDetail(
+        startTime: Date,
+        endTime: Date,
+        areaVo: AreaVo,
+        granularity: String?,
+    ): List<MissionInventory.MissionDetail> {
         val missionCluesData = missionRep.findByAreaAndTime(areaVo, startTime, endTime).filterNotNull().map {
             Triple(
                 it,
@@ -185,7 +197,21 @@
                 SceneType.TYPE21.value
             )
         )
-        return generateMissionDetail(keyScenes, missionCluesData)
+        return generateMissionDetail(keyScenes, missionCluesData, granularity ?: "MINUTE")
+    }
+
+    override fun generateMissionDetail(missionCode: String, granularity: String?): MissionInventory.MissionDetail {
+        val mission = missionRep.findOne(missionCode) ?: throw BizException("浠诲姟涓嶅瓨鍦�")
+        val missionClues = sourceTraceRep.fetchList(mission.deviceCode, mission.startTime, mission.endTime, MsgType.PolClue) as List<PollutedClue?>
+        val realTimeData = realTimeDataRep.fetchData(mission)
+        val keyScenes = sceneInfoRep.findBySceneTypes(
+            listOf(
+                SceneType.TYPE19.value,
+                SceneType.TYPE20.value,
+                SceneType.TYPE21.value
+            )
+        )
+        return MissionInventory().generateMissionDetail(keyScenes, mission, missionClues, realTimeData, granularity ?: "MINUTE")
     }
 
     /**
@@ -199,9 +225,10 @@
     override fun generateMissionDetail(
         keyScenes: List<SceneInfo?>,
         missionCluesData: List<Triple<Mission, List<PollutedClue?>, List<BaseRealTimeData>>>,
+        granularity: String,
     ): List<MissionInventory.MissionDetail> {
         return missionCluesData.map {
-            MissionInventory().generateMissionDetail(keyScenes, it.first, it.second, it.third)
+            MissionInventory().generateMissionDetail(keyScenes, it.first, it.second, it.third, granularity)
         }
     }
 
@@ -216,6 +243,19 @@
             val clue = sourceTraceRep.fetchList(it.deviceCode, it.startTime, it.endTime, MsgType.PolClue) as List<PollutedClue?>
             clues.addAll(clue)
         }
+//        val keyScenes = sceneInfoRep.findBySceneTypes(
+//            listOf(
+//                SceneType.TYPE19.value,
+//                SceneType.TYPE20.value,
+//                SceneType.TYPE21.value
+//            )
+//        )
+        return MissionRiskArea().generateClueByRiskArea(clues)
+    }
+
+    override fun generateClueByRiskArea(missionCode: String): List<MissionRiskArea.ClueByArea> {
+        val mission = missionRep.findOne(missionCode) ?: throw BizException("浠诲姟涓嶅瓨鍦�")
+        val pollutedClues = sourceTraceRep.fetchList(mission.deviceCode, mission.startTime, mission.endTime, MsgType.PolClue) as List<PollutedClue?>
         val keyScenes = sceneInfoRep.findBySceneTypes(
             listOf(
                 SceneType.TYPE19.value,
@@ -223,14 +263,14 @@
                 SceneType.TYPE21.value
             )
         )
-        return generateClueByRiskArea(keyScenes, clues)
+        return generateClueByRiskArea(keyScenes, pollutedClues)
     }
 
     override fun generateClueByRiskArea(
         keyScenes: List<SceneInfo?>,
         pollutedClues: List<PollutedClue?>,
     ): List<MissionRiskArea.ClueByArea> {
-        return MissionRiskArea().generateClueByRiskArea(keyScenes, pollutedClues)
+        return MissionRiskArea().generateClueByKeyRiskScene(keyScenes, pollutedClues)
     }
 
     override fun generateGridFusion(

--
Gitblit v1.9.3