From 275ad59f206d9bc1801b28daeb31b4207f609ce3 Mon Sep 17 00:00:00 2001
From: hcong <1050828145@qq.com>
Date: 星期四, 02 一月 2025 09:10:09 +0800
Subject: [PATCH] 1. 修改网格组数据导入接口返回值为bool 2. 修改网格组数据批量更新 使用Transactional注解

---
 src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt |  118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 113 insertions(+), 5 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..3293a6f 100644
--- a/src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt
+++ b/src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt
@@ -1,15 +1,15 @@
 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
 import com.flightfeather.uav.domain.mapper.GridGroupMapper
 import com.flightfeather.uav.lightshare.bean.AreaVo
 import org.springframework.stereotype.Repository
+import org.springframework.transaction.annotation.Transactional
 import tk.mybatis.mapper.entity.Example
 import java.time.LocalDateTime
 
@@ -24,6 +24,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 +61,110 @@
             orderBy("cellId")
         })
     }
-}
\ No newline at end of file
+
+    /**
+     * 鎻掑叆缃戞牸缁凱M2.5鏁版嵁绱㈠紩鍜岃缁嗘暟鎹��
+     *
+     * @param data 缃戞牸缁凱M2.5鏁版嵁绱㈠紩銆�
+     * @param gridDataDetails 缃戞牸缁凱M2.5璇︾粏鏁版嵁鍒楄〃銆�
+     * @author hc
+     * @date 2024-12-29
+     */
+    fun insertGridDataAndDetail(data: GridData, gridDataDetails: List<GridDataDetail>) {
+        gridDataMapper.insert(data)
+        gridDataDetails.forEach {
+            it.dataId = data.id
+            it.groupId = data.groupId
+        }
+        gridDataDetailMapper.insertList(gridDataDetails)
+    }
+
+    /**
+     * 鏇存柊缃戞牸缁勮缁嗘暟鎹��
+     *
+     * @param gridDataDetails 闇�瑕佹洿鏂扮殑缃戞牸缁勮缁嗘暟鎹垪琛ㄣ��
+     * @author hc
+     * @date 2024-12-29
+     */
+    @Transactional(rollbackFor = [Exception::class])
+    fun updatePM25Batch(gridDataDetails: List<GridDataDetail>) {
+        gridDataDetails.forEach {
+            gridDataDetailMapper.updateByExample(it, Example(GridDataDetail::class.java).apply {
+                createCriteria().andEqualTo("dataId", it.dataId)
+                    .andEqualTo("groupId", it.groupId)
+                    .andEqualTo("cellId", it.cellId)
+            })
+        }
+    }
+
+    /**
+     * 鏍规嵁缁処D鍜屾暟鎹椂闂磋幏鍙栫綉鏍肩粍aod鏁版嵁绱㈠紩銆�
+     *
+     * @param groupId 缃戞牸缁処D銆�
+     * @param dataTime 鏁版嵁鏃堕棿銆�
+     * @return 缃戞牸缁刟od鏁版嵁绱㈠紩鍒楄〃銆�
+     * @author hc
+     * @date 2024-12-29
+     */
+    fun fetchGridAod(groupId: Int, dataTime: LocalDateTime?): List<GridAod?> {
+        return gridAodMapper.selectByExample(Example(GridAod::class.java).apply {
+            createCriteria().andEqualTo("groupId", groupId)
+                .andEqualTo("dataTime", dataTime)
+        })
+    }
+
+    /**
+     * 鑾峰彇缃戞牸缁刟od鏁版嵁璇︽儏銆�
+     *
+     * @param aodId aod鏁版嵁ID銆�
+     * @param groupId 缃戞牸缁処D銆�
+     * @param cellId 鍗曞厓鏍糏D銆�
+     * @return 缃戞牸缁刟od鏁版嵁璇︽儏鍒楄〃銆�
+     * @author hc
+     * @date 2024-12-29
+     */
+    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")
+        })
+    }
+
+    /**
+     * 鎻掑叆缃戞牸缁刟od鏁版嵁绱㈠紩鍜岃缁嗘暟鎹��
+     *
+     * @param aod 缃戞牸缁刟od鏁版嵁绱㈠紩銆�
+     * @param gridAodDetails 缃戞牸缁刟od璇︾粏鏁版嵁鍒楄〃銆�
+     * @author hc
+     * @date 2024-12-29
+     */
+    fun insertGridAodAndDetail(aod: GridAod, gridAodDetails: List<GridAodDetail>) {
+        gridAodMapper.insert(aod)
+        gridAodDetails.forEach {
+            it.aodId = aod.id
+            it.groupId = aod.groupId
+        }
+        gridAodDetailMapper.insertList(gridAodDetails)
+    }
+
+    /**
+     * 鏇存柊缃戞牸缁刟od鏁版嵁璇︽儏銆�
+     *
+     * @param gridDataDetails 闇�瑕佹洿鏂扮殑缃戞牸缁刟od璇︾粏鏁版嵁鍒楄〃銆�
+     * @author hc
+     * @date 2024-12-29
+     */
+    @Transactional(rollbackFor = [Exception::class])
+    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)
+            })
+        }
+    }
+
+}

--
Gitblit v1.9.3