From dc4f12f66685260ac357997680e5f3fe723c3c4a Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期五, 12 九月 2025 17:22:40 +0800
Subject: [PATCH] 2025.9.12 1. 新增监测设备和巡查场景信息的匹配功能

---
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/UserMapServiceImpl.kt |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/UserMapServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/UserMapServiceImpl.kt
index 234838d..5f4a5fb 100644
--- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/UserMapServiceImpl.kt
+++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/UserMapServiceImpl.kt
@@ -17,7 +17,9 @@
 import cn.flightfeather.supervision.domain.ds2.repository.UserMapRep
 import cn.flightfeather.supervision.lightshare.service.UserMapService
 import cn.flightfeather.supervision.lightshare.vo.AreaVo
+import cn.flightfeather.supervision.lightshare.vo.DataHead
 import cn.flightfeather.supervision.lightshare.vo.DeviceMapVo
+import cn.flightfeather.supervision.lightshare.vo.DeviceSiteVo
 import org.springframework.stereotype.Service
 import tk.mybatis.mapper.entity.Example
 import java.util.*
@@ -102,18 +104,64 @@
             //浠ラ缇界幆澧冪郴缁熶腑鐨勭敤鎴蜂负涓讳綋
             1 -> {
                 val u = userInfoTZRep.findEnterpriseUser(areaVo.districtname, areaVo.scensetypeid?.toInt())
-                u.map { it?.guid }
+                u.map { it?.guid to it?.realname }
             }
             //浠ラ缇界洃绠$郴缁熶腑鐨勭敤鎴蜂负涓讳綋
             2 -> {
                 val task = taskRep.findOneTask(areaVo) ?: throw BizException("褰撳墠鏌ヨ鏉′欢涓嬫湭鎵惧埌瀵瑰簲椤跺眰浠诲姟")
                 val scenes = sceneRep.findSceneList(task.tguid!!, areaVo.scensetypeid?.toInt(), areaVo.towncode)
                     .map { it?.guid }
-                userInfoSVRep.findUser(scenes).map { it?.guid }
+                userInfoSVRep.findUser(scenes).map { it?.guid to it?.realname }
             }
             else -> emptyList()
         }
         // 2.閫氳繃鍖哄煙鏉′欢鍐冲畾鍖归厤鐨勬暟鎹潵婧�
-        return aopDataDeviceMap.findMapSet(areaVo, userIdList)
+        val mapSet = aopDataDeviceMap.findMapSet(areaVo, userIdList.map { it.first })
+        val result = mutableListOf<DeviceMapVo>()
+        // 灏嗕笉鍦╩apSet涓殑鐢ㄦ埛锛屾坊鍔犲埌缁撴灉闆嗕腑
+        userIdList.forEach {u ->
+            val ddm = mapSet.find { m->
+                when (areaVo.sourceType) {
+                    //浠ラ缇界幆澧冪郴缁熶腑鐨勭敤鎴蜂负涓讳綋
+                    1 -> m.tzUserId == u.first
+                    //浠ラ缇界洃绠$郴缁熶腑鐨勭敤鎴蜂负涓讳綋
+                    2 -> m.svUserId == u.first
+                    else -> false
+                }
+            }
+            if (ddm == null) {
+                result.add(DeviceMapVo().apply {
+                    when (areaVo.sourceType) {
+                        //浠ラ缇界幆澧冪郴缁熶腑鐨勭敤鎴蜂负涓讳綋
+                        1 -> {
+                            tzUserId = u.first
+                            tzUserName = u.second
+                        }
+                        //浠ラ缇界洃绠$郴缁熶腑鐨勭敤鎴蜂负涓讳綋
+                        2 -> {
+                            svUserId = u.first
+                            svUserName = u.second
+
+                        }
+                    }
+                })
+            }
+        }
+        // 灏唌apSet涓殑鏁版嵁娣诲姞鍒扮粨鏋滈泦涓�
+        result.addAll(mapSet)
+        return result.sortedBy { it.svUserId }
+    }
+
+    override fun insertOrUpdate(param: Pair<AreaVo, DeviceMapVo>): Int {
+        return aopDataDeviceMap.insertOrUpdate(param.first, listOf(param.second))
+    }
+
+    override fun searchThirdPartyDevice(
+        areaVo: AreaVo,
+        keyword: String,
+        page: Int?,
+        perPage: Int?,
+    ): Pair<DataHead, List<DeviceSiteVo>> {
+        return aopDataDeviceMap.searchDevice(areaVo, keyword, page ?: 1, perPage ?: 30)
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3