From b7b520bfe8b35683112284861f0dca8e645cbd56 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 31 十二月 2024 10:22:40 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/hc-satellite-data-import-1227_2'

---
 src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt |   61 ++++++++++++++++++++++++++++--
 1 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt b/src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt
index 2c0db63..b88bc35 100644
--- a/src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt
+++ b/src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt
@@ -1,9 +1,8 @@
 package com.flightfeather.uav.domain.repository
 
-import com.flightfeather.uav.domain.entity.GridCell
-import com.flightfeather.uav.domain.entity.GridData
-import com.flightfeather.uav.domain.entity.GridDataDetail
-import com.flightfeather.uav.domain.entity.GridGroup
+import com.flightfeather.uav.domain.entity.*
+import com.flightfeather.uav.domain.mapper.GridAodDetailMapper
+import com.flightfeather.uav.domain.mapper.GridAodMapper
 import com.flightfeather.uav.domain.mapper.GridCellMapper
 import com.flightfeather.uav.domain.mapper.GridDataDetailMapper
 import com.flightfeather.uav.domain.mapper.GridDataMapper
@@ -24,6 +23,8 @@
     private val gridCellMapper: GridCellMapper,
     private val gridDataMapper: GridDataMapper,
     private val gridDataDetailMapper: GridDataDetailMapper,
+    private val gridAodMapper: GridAodMapper,
+    private val gridAodDetailMapper: GridAodDetailMapper,
 ) {
 
     fun fetchGridGroup(areaVo: AreaVo): List<GridGroup?> {
@@ -59,4 +60,56 @@
             orderBy("cellId")
         })
     }
+
+    fun insertGridDataAndDetail(data: GridData, gridDataDetails: List<GridDataDetail>) {
+        gridDataMapper.insert(data)
+        gridDataDetails.forEach {
+            it.dataId = data.id
+            it.groupId = data.groupId
+        }
+        gridDataDetailMapper.insertList(gridDataDetails)
+    }
+
+    fun updatePM25Batch(gridDataDetails: List<GridDataDetail>) {
+        gridDataDetailMapper.updatePM25Batch(gridDataDetails)
+    }
+
+
+    //    aod 鐩稿叧鎿嶄綔
+    fun fetchGridAod(groupId: Int, dataTime: LocalDateTime?): List<GridAod?> {
+        return gridAodMapper.selectByExample(Example(GridAod::class.java).apply {
+            createCriteria().andEqualTo("groupId", groupId)
+                .andEqualTo("dataTime", dataTime)
+        })
+    }
+
+    fun fetchGridAodDetail(aodId: Int, groupId: Int?, cellId: Int?): List<GridAodDetail?> {
+        return gridAodDetailMapper.selectByExample(Example(GridAodDetail::class.java).apply {
+            createCriteria().andEqualTo("aodId", aodId)
+                .andEqualTo("groupId", groupId)
+                .andEqualTo("cellId", cellId)
+            orderBy("cellId")
+        })
+    }
+
+    fun insertGridAodAndDetail(aod: GridAod, gridAodDetails: List<GridAodDetail>) {
+        gridAodMapper.insert(aod)
+        gridAodDetails.forEach {
+            it.aodId = aod.id
+            it.groupId = aod.groupId
+        }
+        gridAodDetailMapper.insertList(gridAodDetails)
+    }
+
+    fun updateGridAodBatch(gridDataDetails: List<GridAodDetail>) {
+        gridDataDetails.forEach {
+            gridAodDetailMapper.updateByExample(it, Example(GridAodDetail::class.java).apply {
+                createCriteria().andEqualTo("aodId", it.aodId)
+                    .andEqualTo("groupId", it.groupId)
+                    .andEqualTo("cellId", it.cellId)
+            })
+        }
+
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.9.3