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/RealTimeDataRep.kt | 111 ++++++++++++++++++++++++++++++++-----------------------
1 files changed, 65 insertions(+), 46 deletions(-)
diff --git a/src/main/kotlin/com/flightfeather/uav/domain/repository/RealTimeDataRep.kt b/src/main/kotlin/com/flightfeather/uav/domain/repository/RealTimeDataRep.kt
index b41950d..1c21daf 100644
--- a/src/main/kotlin/com/flightfeather/uav/domain/repository/RealTimeDataRep.kt
+++ b/src/main/kotlin/com/flightfeather/uav/domain/repository/RealTimeDataRep.kt
@@ -1,5 +1,6 @@
package com.flightfeather.uav.domain.repository
+import com.flightfeather.uav.common.exception.BizException
import com.flightfeather.uav.domain.entity.*
import com.flightfeather.uav.domain.mapper.RealTimeDataGridMapper
import com.flightfeather.uav.domain.mapper.RealTimeDataGridMinMapper
@@ -9,6 +10,8 @@
import com.github.pagehelper.PageHelper
import org.springframework.stereotype.Repository
import tk.mybatis.mapper.entity.Example
+import java.time.LocalDateTime
+import java.time.ZoneId
import java.util.*
/**
@@ -22,56 +25,72 @@
private val realTimeDataGridMinMapper: RealTimeDataGridMinMapper,
) {
- private fun getSecondDataExample(example: Example, deviceCode: String?, sTime: Date?, eTime: Date?) {
- example.createCriteria().apply {
- deviceCode?.let { andEqualTo("deviceCode", it) }
- sTime?.let { andGreaterThanOrEqualTo("dataTime", it) }
- eTime?.let { andLessThanOrEqualTo("dataTime", it) }
- }
- example.orderBy("dataTime").apply {
- // 褰撹姹傛帴鍙d笉浼犻�掕捣濮嬫椂闂达紝榛樿鑾峰彇鏈�鏂扮殑鏁版嵁
- if (sTime == null && eTime == null) {
- desc()
- }
- }
- }
+ private val delegate = RealTimeDataRepDelegate(realTimeDataVehicleMapper, realTimeDataUavMapper,
+ realTimeDataGridMapper, realTimeDataGridMinMapper)
fun fetchData(
- deviceCode: String,
- sTime: Date?,
- eTime: Date?,
- type: Int? = 0,
+ deviceType: UWDeviceType?, deviceCode: String, sTime: Date? = null, eTime: Date? = null, type: Int? = 0,
+ page: Int? = null, perPage: Int? = null,
): List<BaseRealTimeData> {
- var result = listOf<BaseRealTimeData>()
- when (UWDeviceType.getType(deviceCode)) {
- UWDeviceType.VEHICLE -> {
- result = realTimeDataVehicleMapper.selectByExample(Example(RealTimeDataVehicle::class.java).apply {
- getSecondDataExample(this, deviceCode, sTime, eTime)
- })
- }
- UWDeviceType.UAV -> {
- result = realTimeDataUavMapper.selectByExample(Example(RealTimeDataUav::class.java).apply {
- getSecondDataExample(this, deviceCode, sTime, eTime)
- })
- }
- UWDeviceType.GRID -> {
- // 缃戞牸鍖栫洃娴嬬绾у��
- result = if (type == null || type == 0) {
- realTimeDataGridMapper.selectByExample(Example(RealTimeDataGrid::class.java).apply {
- getSecondDataExample(this, deviceCode, sTime, eTime)
- })
- }
- // 缃戞牸鍖栫洃娴嬪垎閽熷��
- else {
- realTimeDataGridMinMapper.selectByExample(Example(RealTimeDataGridMin::class.java).apply {
- getSecondDataExample(this, deviceCode, sTime, eTime)
- })
- }
- }
- else -> Unit
+ if (page != null && perPage != null) {
+ var pageInfo = PageHelper.startPage<BaseRealTimeData>(page, perPage)
}
- return result
+ return delegate.selectByDeviceType(deviceType, type) { example ->
+ example.createCriteria().apply {
+ andEqualTo("deviceCode", deviceCode)
+ sTime?.let { andGreaterThanOrEqualTo("dataTime", it) }
+ eTime?.let { andLessThanOrEqualTo("dataTime", it) }
+ }
+ example.orderBy("dataTime").apply {
+ // 褰撹姹傛帴鍙d笉浼犻�掕捣濮嬫椂闂达紝榛樿鑾峰彇鏈�鏂扮殑鏁版嵁
+ if (sTime == null && eTime == null) {
+ desc()
+ }
+ }
+ }
}
- fun fetchData(mission: Mission) = fetchData(mission.deviceCode, mission.startTime, mission.endTime)
+ fun fetchData(mission: Mission) =
+ fetchData(UWDeviceType.fromValue(mission.deviceType), mission.deviceCode, mission.startTime, mission.endTime)
+
+
+ fun saveData(deviceType: UWDeviceType?, data: List<BaseRealTimeData>, type: Int? = 0): Int {
+ return delegate.insertByDeviceType(deviceType, type, data)
+ }
+
+ fun updateData(deviceType: UWDeviceType?, data: List<BaseRealTimeData>, type: Int? = 0): Int {
+ return delegate.updateByDeviceType(deviceType, type, data)
+ }
+
+ fun deleteData(mission: Mission, type: Int? = 0): Int {
+ if (mission.deviceCode == null || mission.startTime == null || mission.endTime == null) {
+ throw BizException("瑕佸垹闄ょ殑璧拌埅浠诲姟缂哄け璁惧缂栧彿鎴栭噰鏍锋椂闂磋寖鍥达紝鏃犳硶鍒犻櫎瀵瑰簲鐩戞祴鏁版嵁")
+ }
+ return deleteData(UWDeviceType.fromValue(mission.deviceType),
+ mission.deviceCode,
+ mission.startTime,
+ mission.endTime, type)
+ }
+
+ fun deleteData(deviceType: UWDeviceType?, deviceCode: String, sTime: Date?, eTime: Date?, type: Int? = 0): Int {
+ return delegate.deleteByDeviceType(deviceType, type) {
+ it.createCriteria().apply {
+ andEqualTo("deviceCode", deviceCode)
+ andGreaterThanOrEqualTo("dataTime", sTime)
+ andLessThanOrEqualTo("dataTime", eTime)
+ }
+ }
+ }
+
+ fun deleteData(
+ deviceType: UWDeviceType?, deviceCode: String, sTime: LocalDateTime?, eTime: LocalDateTime?, type: Int? = 0,
+ ): Int = deleteData(deviceType, deviceCode,
+ Date.from(sTime?.atZone(ZoneId.systemDefault())?.toInstant()),
+ Date.from(eTime?.atZone(ZoneId.systemDefault())?.toInstant()),
+ type
+ )
+
+ fun deleteData(deviceType: UWDeviceType?, data: List<BaseRealTimeData>, type: Int? = 0) {
+ delegate.deleteByDeviceType(deviceType, type, data)
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3