From 7d33080998a2c5b38e8a74dbed2b0f40d39bbe47 Mon Sep 17 00:00:00 2001
From: Riku <risaku@163.com>
Date: 星期三, 04 六月 2025 23:27:26 +0800
Subject: [PATCH] 1. 新增动态污染溯源新的判定逻辑(待完成)

---
 src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt |   40 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 38 insertions(+), 2 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 3fcdb97..9233bcb 100644
--- a/src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt
+++ b/src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt
@@ -8,6 +8,7 @@
 import com.flightfeather.uav.domain.mapper.GridDataMapper
 import com.flightfeather.uav.domain.mapper.GridGroupMapper
 import com.flightfeather.uav.lightshare.bean.AreaVo
+import com.github.pagehelper.PageHelper
 import org.springframework.stereotype.Repository
 import org.springframework.transaction.annotation.Transactional
 import tk.mybatis.mapper.entity.Example
@@ -28,13 +29,14 @@
     private val gridAodDetailMapper: GridAodDetailMapper,
 ) {
 
-    fun fetchGridGroup(areaVo: AreaVo): List<GridGroup?> {
+    fun fetchGridGroup(areaVo: AreaVo, type: String?): List<GridGroup?> {
         return gridGroupMapper.selectByExample(Example(GridGroup::class.java).apply {
             createCriteria()
                 .andEqualTo("provinceCode", areaVo.provinceCode).andEqualTo("provinceName", areaVo.provinceName)
                 .andEqualTo("cityCode", areaVo.cityCode).andEqualTo("cityName", areaVo.cityName)
                 .andEqualTo("districtCode", areaVo.districtCode).andEqualTo("districtName", areaVo.districtName)
                 .andEqualTo("townCode", areaVo.townCode).andEqualTo("townName", areaVo.townName)
+                .andEqualTo("type", type)
         })
     }
 
@@ -53,18 +55,22 @@
     @Transactional
     fun deleteGridGroup(groupId: Int) {
         gridCellMapper.delete(GridCell().apply { this.groupId = groupId })
+        PageHelper.startPage<GridCell>(1, 1)
         gridCellMapper.selectByExample(
             Example(GridCell::class.java).apply { orderBy("id").desc() }
         ).takeIf { it.isNotEmpty() }?.get(0)?.id?.let { id ->
             gridCellMapper.resetAutoIncrement(id + 1)
         }
         gridGroupMapper.deleteByPrimaryKey(groupId)
+        PageHelper.startPage<GridGroup>(1, 1)
         gridGroupMapper.selectByExample(
             Example(GridGroup::class.java).apply { orderBy("id").desc() }
         ).takeIf { it.isNotEmpty() }?.get(0)?.id?.let { id ->
             gridGroupMapper.resetAutoIncrement(id + 1)
         }
     }
+
+    /*****************************************************************/
 
     fun fetchGridCell(groupId: Int): List<GridCell?> {
         return gridCellMapper.selectByExample(Example(GridCell::class.java).apply {
@@ -76,6 +82,8 @@
     fun insertGridCell(gridCellList: List<GridCell?>): Int {
         return gridCellMapper.insertList(gridCellList)
     }
+
+    /*****************************************************************/
 
     fun fetchGridData(groupId: Int, dataTime: LocalDateTime?, type: Int?): List<GridData?> {
         return gridDataMapper.selectByExample(Example(GridData::class.java).apply {
@@ -101,7 +109,15 @@
         return gridDataDetailMapper.insertList(gridDataDetails)
     }
 
-    fun fetchGridDataDetail(dataId: Int, groupId: Int?, cellId: Int?): List<GridDataDetail?> {
+    fun updateGridDataDetail(gridDataDetails: List<GridDataDetail?>): Int {
+        var res = 0
+        gridDataDetails.forEach {
+            res += gridDataDetailMapper.updateByPrimaryKey(it)
+        }
+        return res
+    }
+
+    fun fetchGridDataDetail(dataId: Int? = null, groupId: Int? = null, cellId: Int? = null): List<GridDataDetail?> {
         return gridDataDetailMapper.selectByExample(Example(GridDataDetail::class.java).apply {
             createCriteria().andEqualTo("dataId", dataId)
                 .andEqualTo("groupId", groupId)
@@ -123,6 +139,26 @@
         gridDataDetailMapper.updatePM25Batch(gridDataDetails)
     }
 
+    @Transactional
+    @Throws
+    fun deleteGridData(dataId: Int?) {
+        gridDataDetailMapper.delete(GridDataDetail().apply { this.dataId = dataId })
+        // Fixme 2025.4.16 姝ゅ鐨勯噸缃嚜澧瀒d鍙湪鍒犻櫎鏈�鏂版暟鎹殑鎯呭喌涓嬫湁鏁堬紝鍚庣画鑰冭檻涓嶉�傜敤鑷涓婚敭锛屾敼涓烘柊鐨勪富閿敓鎴愭柟寮�
+//        PageHelper.startPage<GridDataDetail>(1, 1)
+//        gridDataDetailMapper.selectByExample(Example(GridDataDetail::class.java).apply { orderBy("id").desc() })
+//            .takeIf { it.isNotEmpty() }?.get(0)?.id?.let { id ->
+//                gridDataDetailMapper.resetAutoIncrement(id + 1)
+//            }
+        gridDataMapper.deleteByPrimaryKey(dataId)
+//        PageHelper.startPage<GridData>(1, 1)
+//        gridDataMapper.selectByExample(
+//            Example(GridData::class.java).apply { orderBy("id").desc() }
+//        ).takeIf { it.isNotEmpty() }?.get(0)?.id?.let { id ->
+//            gridDataMapper.resetAutoIncrement(id + 1)
+//        }
+    }
+
+    /*****************************************************************/
 
     //    aod 鐩稿叧鎿嶄綔
     fun fetchGridAod(groupId: Int, dataTime: LocalDateTime?): List<GridAod?> {

--
Gitblit v1.9.3