From b8cc591541b88dd2bb93f111f8e8075842dce7ca Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期二, 13 八月 2024 17:21:06 +0800
Subject: [PATCH] 1. 新增设备信息相关功能 2. 修正自评估中数据自动评分的部分逻辑

---
 src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/DeviceRep.kt |  109 ++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 80 insertions(+), 29 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/DeviceRep.kt b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/DeviceRep.kt
index 46fdfe1..7d7c7ac 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/DeviceRep.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/domain/ds1/repository/DeviceRep.kt
@@ -1,9 +1,11 @@
 package cn.flightfeather.supervision.domain.ds1.repository
 
-import cn.flightfeather.supervision.domain.ds1.entity.DeviceInfo
-import cn.flightfeather.supervision.domain.ds1.entity.DeviceLocation
-import cn.flightfeather.supervision.domain.ds1.mapper.DeviceInfoMapper
-import cn.flightfeather.supervision.domain.ds1.mapper.DeviceLocationMapper
+import cn.flightfeather.supervision.common.utils.Constant
+import cn.flightfeather.supervision.domain.ds1.entity.*
+import cn.flightfeather.supervision.domain.ds1.mapper.DeviceStatusMapper
+import cn.flightfeather.supervision.domain.ds1.mapper.MonitorDeviceInfoMapper
+import cn.flightfeather.supervision.domain.ds1.mapper.TreatmentDeviceInfoMapper
+import cn.flightfeather.supervision.domain.ds1.mapper.ProductionDeviceInfoMapper
 import org.springframework.stereotype.Repository
 
 /**
@@ -13,48 +15,97 @@
  */
 @Repository
 class DeviceRep(
-    private val deviceInfoMapper: DeviceInfoMapper,
-    private val deviceLocationMapper: DeviceLocationMapper,
+    private val monitorDeviceInfoMapper: MonitorDeviceInfoMapper,
+    private val treatmentDeviceInfoMapper: TreatmentDeviceInfoMapper,
+    private val productionDeviceInfoMapper: ProductionDeviceInfoMapper,
+    private val deviceStatusMapper: DeviceStatusMapper,
 ) {
     /***--DeviceInfo--***/
-    fun findDevice(sceneId: String): DeviceInfo? {
-        return deviceInfoMapper.selectByPrimaryKey(sceneId)
+
+    /**
+     * 鏌ヨ璁惧淇℃伅
+     * @param deviceId 璁惧涓婚敭id
+     * @param type 璁惧绫诲瀷
+     * @return 璁惧淇℃伅
+     */
+    fun findDevice(deviceId: Int, type: Constant.DeviceType): BaseDevice? {
+        return when (type) {
+            Constant.DeviceType.MONITOR_DEVICE -> monitorDeviceInfoMapper.selectByPrimaryKey(deviceId)
+            Constant.DeviceType.TREATMENT_DEVICE -> treatmentDeviceInfoMapper.selectByPrimaryKey(deviceId)
+            Constant.DeviceType.PRODUCTION_DEVICE -> productionDeviceInfoMapper.selectByPrimaryKey(deviceId)
+        }
     }
 
-    fun findDeviceList(sceneId: String): List<DeviceInfo> {
-        return findDeviceList(DeviceInfo().apply { diSceneGuid = sceneId })
+    /**
+     * 鏌ヨ璁惧淇℃伅
+     * @param sceneId 鍦烘櫙涓婚敭id
+     * @param type 璁惧绫诲瀷
+     * @return 璁惧淇℃伅
+     */
+    fun findDeviceList(sceneId: String, type: Constant.DeviceType): List<BaseDevice> {
+        return when (type) {
+            Constant.DeviceType.MONITOR_DEVICE -> findDeviceList(MonitorDeviceInfo().apply { diSceneGuid = sceneId })
+            Constant.DeviceType.TREATMENT_DEVICE -> findDeviceList(TreatmentDeviceInfo()
+                .apply { piSceneGuid = sceneId })
+            Constant.DeviceType.PRODUCTION_DEVICE -> findDeviceList(ProductionDeviceInfo()
+                .apply { wiSceneGuid = sceneId })
+        }
+    }
+    fun findDeviceList(monitorDeviceInfo: MonitorDeviceInfo): List<MonitorDeviceInfo> {
+        return monitorDeviceInfoMapper.select(monitorDeviceInfo)
+    }
+    fun findDeviceList(treatmentDeviceInfo: TreatmentDeviceInfo): List<TreatmentDeviceInfo> {
+        return treatmentDeviceInfoMapper.select(treatmentDeviceInfo)
+    }
+    fun findDeviceList(productionDeviceInfo: ProductionDeviceInfo): List<ProductionDeviceInfo> {
+        return productionDeviceInfoMapper.select(productionDeviceInfo)
     }
 
-    fun findDeviceList(deviceInfo: DeviceInfo): List<DeviceInfo> {
-        return deviceInfoMapper.select(deviceInfo)
+    /**
+     * 鎻掑叆璁惧淇℃伅
+     */
+    fun insertDevice(monitorDeviceInfo: MonitorDeviceInfo): Int {
+        return monitorDeviceInfoMapper.insert(monitorDeviceInfo)
+    }
+    fun insertDevice(treatmentDeviceInfo: TreatmentDeviceInfo): Int {
+        return treatmentDeviceInfoMapper.insert(treatmentDeviceInfo)
+    }
+    fun insertDevice(productionDeviceInfo: ProductionDeviceInfo): Int {
+        return productionDeviceInfoMapper.insert(productionDeviceInfo)
     }
 
-    fun insertDevice(deviceInfo: DeviceInfo): Int {
-        return deviceInfoMapper.insert(deviceInfo)
+    /**
+     * 鏇存柊璁惧淇℃伅
+     */
+    fun updateDevice(monitorDeviceInfo: MonitorDeviceInfo): Int {
+        return monitorDeviceInfoMapper.updateByPrimaryKey(monitorDeviceInfo)
+    }
+    fun updateDevice(treatmentDeviceInfo: TreatmentDeviceInfo): Int {
+        return treatmentDeviceInfoMapper.updateByPrimaryKey(treatmentDeviceInfo)
+    }
+    fun updateDevice(productionDeviceInfo: ProductionDeviceInfo): Int {
+        return productionDeviceInfoMapper.updateByPrimaryKey(productionDeviceInfo)
     }
 
-    fun updateDevice(deviceInfo: DeviceInfo): Int {
-        return deviceInfoMapper.updateByPrimaryKey(deviceInfo)
+    /***--DeviceStatus--***/
+    fun findStatus(id: Int): DeviceStatus? {
+        return deviceStatusMapper.selectByPrimaryKey(id)
     }
 
-    /***--DeviceLocation--***/
-    fun findLocation(id: Int): DeviceLocation? {
-        return deviceLocationMapper.selectByPrimaryKey(id)
+    fun findStatuses(deviceId: Int): List<DeviceStatus> {
+        return findStatuses(DeviceStatus()
+            .apply { dlDeviceId = deviceId })
     }
 
-    fun findLocations(deviceId: Int): List<DeviceLocation> {
-        return findLocations(DeviceLocation().apply { dlDeviceId = deviceId })
+    fun findStatuses(location: DeviceStatus): List<DeviceStatus> {
+        return deviceStatusMapper.select(location)
     }
 
-    fun findLocations(location: DeviceLocation): List<DeviceLocation> {
-        return deviceLocationMapper.select(location)
+    fun insertStatus(location: DeviceStatus): Int {
+        return deviceStatusMapper.insert(location)
     }
 
-    fun insertLocation(location: DeviceLocation): Int {
-        return deviceLocationMapper.insert(location)
-    }
-
-    fun updateLocation(location: DeviceLocation): Int {
-        return deviceLocationMapper.updateByPrimaryKey(location)
+    fun updateStatus(location: DeviceStatus): Int {
+        return deviceStatusMapper.updateByPrimaryKey(location)
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3