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/lightshare/service/impl/DeviceServiceImpl.kt | 34 ++++++++++++++++++++++++++--------
1 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DeviceServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DeviceServiceImpl.kt
index f8708f9..499f724 100644
--- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DeviceServiceImpl.kt
+++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DeviceServiceImpl.kt
@@ -1,18 +1,36 @@
package com.flightfeather.uav.lightshare.service.impl
+import com.flightfeather.uav.common.exception.BizException
import com.flightfeather.uav.domain.entity.DeviceInfo
-import com.flightfeather.uav.domain.mapper.DeviceInfoMapper
-import com.flightfeather.uav.lightshare.bean.BaseResponse
+import com.flightfeather.uav.domain.repository.DeviceRep
import com.flightfeather.uav.lightshare.service.DeviceService
+import com.flightfeather.uav.socket.eunm.UWDeviceType
import org.springframework.stereotype.Service
+import java.util.*
@Service
-class DeviceServiceImpl(
- private val deviceInfoMapper: DeviceInfoMapper
-) : DeviceService {
+class DeviceServiceImpl(private val deviceRep: DeviceRep) : DeviceService {
- override fun getDeviceInfo(): BaseResponse<List<DeviceInfo>> {
- val r = deviceInfoMapper.selectAll()
- return BaseResponse(true, data = r)
+ override fun getDeviceInfo(type: String?): List<DeviceInfo> {
+ return deviceRep.find(UWDeviceType.fromValue(type))
+ }
+
+ override fun createDevice(deviceInfo: DeviceInfo): Int {
+ if (deviceRep.find(DeviceInfo().apply { deviceCode = deviceInfo.deviceCode }).isNotEmpty()) {
+ throw BizException("璁惧缂栧彿宸插瓨鍦�")
+ }
+ val deviceType = UWDeviceType.fromValue(deviceInfo.deviceType) ?: throw BizException("璁惧绫诲瀷涓嶅瓨鍦�")
+ val dList = deviceRep.find(deviceType, false)
+ val index = if (dList.isEmpty()) 1 else ++dList[0].displayIndex
+ deviceInfo.apply {
+ deviceName = "${deviceType.des}${index}鍙�"
+ displayIndex = index
+ createTime = Date()
+ }
+ return deviceRep.insert(deviceInfo)
+ }
+
+ override fun deleteDevice(deviceCode: String): Int {
+ return deviceRep.delete(deviceCode)
}
}
\ No newline at end of file
--
Gitblit v1.9.3