From eb3dd00b0b7fcda477229d518d250f9c842b790b Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 21 十月 2025 17:45:44 +0800
Subject: [PATCH] 2025.10.21 1. 走航季度报告相关数据计算逻辑调整
---
src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt | 154 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 148 insertions(+), 6 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..9233bcb 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,16 @@
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 com.github.pagehelper.PageHelper
import org.springframework.stereotype.Repository
+import org.springframework.transaction.annotation.Transactional
import tk.mybatis.mapper.entity.Example
import java.time.LocalDateTime
@@ -24,17 +25,52 @@
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?> {
+ 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)
})
}
+
+ fun fetchGridGroup(id: Int): GridGroup? {
+ return gridGroupMapper.selectByPrimaryKey(id)
+ }
+
+ fun fetchGridGroup(gridGroup: GridGroup): List<GridGroup?> {
+ return gridGroupMapper.select(gridGroup)
+ }
+
+ fun insertGridGroup(gridGroup: GridGroup): Int {
+ return gridGroupMapper.insert(gridGroup)
+ }
+
+ @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 {
@@ -42,6 +78,12 @@
orderBy("id")
})
}
+
+ 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 {
@@ -51,7 +93,31 @@
})
}
- fun fetchGridDataDetail(dataId: Int, groupId: Int?, cellId: Int?): List<GridDataDetail?> {
+ fun fetchGridData(gridData: GridData): List<GridData?> {
+ return gridDataMapper.select(gridData)
+ }
+
+ fun fetchGridData(id: Int): GridData? {
+ return gridDataMapper.selectByPrimaryKey(id)
+ }
+
+ fun insertGridData(gridData: GridData): Int {
+ return gridDataMapper.insert(gridData)
+ }
+
+ fun insertGridDataDetail(gridDataDetails: List<GridDataDetail?>): Int {
+ return gridDataDetailMapper.insertList(gridDataDetails)
+ }
+
+ 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)
@@ -59,4 +125,80 @@
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)
+ }
+
+ @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?> {
+ 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)
+ })
+ }
+ }
+
+ @Transactional
+ fun updateGridCellBatch(gridCellList: List<GridCell?>) {
+ gridCellList.forEach { gridCellMapper.updateByPrimaryKey(it) }
+ }
+
}
\ No newline at end of file
--
Gitblit v1.9.3