From 30a53b41f09d2eefd33513a409d472c2166ba1ea Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期三, 10 一月 2024 17:35:03 +0800
Subject: [PATCH] 1. 新增自动评估相关数据源的检查接口

---
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/UserMapServiceImpl.kt |   47 ++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 40 insertions(+), 7 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 97eeab2..47e7b9e 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
@@ -1,13 +1,22 @@
 package cn.flightfeather.supervision.lightshare.service.impl
 
+import cn.flightfeather.supervision.business.autooutput.dataanalysis.AopDataDeviceMap
+import cn.flightfeather.supervision.common.utils.Constant
 import cn.flightfeather.supervision.common.utils.UUIDGenerator
 import cn.flightfeather.supervision.domain.ds1.entity.Userinfo
 import cn.flightfeather.supervision.domain.ds1.mapper.UserinfoMapper
+import cn.flightfeather.supervision.domain.ds1.repository.SceneRep
+import cn.flightfeather.supervision.domain.ds1.repository.TaskRep
+import cn.flightfeather.supervision.domain.ds1.repository.UserInfoSVRep
 import cn.flightfeather.supervision.domain.ds2.entity.UserMap
 import cn.flightfeather.supervision.domain.ds2.entity.UserinfoTZ
 import cn.flightfeather.supervision.domain.ds2.mapper.UserMapMapper
 import cn.flightfeather.supervision.domain.ds2.mapper.UserinfoTZMapper
+import cn.flightfeather.supervision.domain.ds2.repository.UserInfoTZRep
 import cn.flightfeather.supervision.lightshare.service.UserMapService
+import cn.flightfeather.supervision.lightshare.service.UserinfoService
+import cn.flightfeather.supervision.lightshare.vo.AreaVo
+import cn.flightfeather.supervision.lightshare.vo.DeviceMapVo
 import org.springframework.stereotype.Service
 import tk.mybatis.mapper.entity.Example
 
@@ -15,15 +24,18 @@
 class UserMapServiceImpl(
     private val userMapMapper: UserMapMapper,
     private val userinfoMapper: UserinfoMapper,
-    private val userinfoTZMapper: UserinfoTZMapper
-    ) : UserMapService {
+    private val userinfoTZMapper: UserinfoTZMapper,
+    private val sceneRep: SceneRep,
+    private val taskRep: TaskRep,
+    private val userInfoSVRep: UserInfoSVRep,
+    private val userInfoTZRep: UserInfoTZRep,
+    private val aopDataDeviceMap: AopDataDeviceMap,
+) : UserMapService {
 
     override fun getTZIdBySceneId(sceneId: String): UserMap {
-        val list = userinfoMapper.selectByExample(Example(Userinfo::class.java).apply {
-            createCriteria().andEqualTo("dGuid", sceneId)
-        })
+        val list = userInfoSVRep.findUser(sceneId)
         if (list.isEmpty()) return UserMap()
-        val userId = list[0].guid
+        val userId = list[0]?.guid
         val result = userMapMapper.selectByExample(Example(UserMap::class.java).apply {
             createCriteria().andEqualTo("svUserId", userId)
         })
@@ -60,7 +72,7 @@
                 // 2銆� 鏃犳硶绮剧‘鍖归厤鐨勶紝閲囩敤榛樿鐨勭紪鍙凤紝鎻掑叆璁板綍銆傚悗缁汉宸ヤ慨鏀癸紙鏆傚畾锛�
                 else {
                     if (userMapMapper.selectByExample(Example(UserMap::class.java).apply {
-                        createCriteria().andEqualTo("svUserId", it.guid)
+                            createCriteria().andEqualTo("svUserId", it.guid)
                         }).isEmpty()) {
                         val id = "temp" + UUIDGenerator.generateShortUUID()
                         userMapMapper.insert(UserMap().apply {
@@ -74,4 +86,25 @@
             }
         }
     }
+
+    override fun fetchDeviceMap(areaVo: AreaVo): List<DeviceMapVo?> {
+        // 1.閫氳繃鍖哄煙鏉′欢鑾峰彇涓讳綋鐢ㄦ埛
+        val userIdList = when (areaVo.sourceType) {
+            //浠ラ缇界幆澧冪郴缁熶腑鐨勭敤鎴蜂负涓讳綋
+            1 -> {
+                val u = userInfoTZRep.findEnterpriseUser(areaVo.districtname, areaVo.scensetypeid?.toInt())
+                u.map { it?.guid }
+            }
+            //浠ラ缇界洃绠$郴缁熶腑鐨勭敤鎴蜂负涓讳綋
+            2 -> {
+                val task = taskRep.findOneTask(areaVo) ?: throw IllegalStateException("褰撳墠鏌ヨ鏉′欢涓嬫湭鎵惧埌瀵瑰簲椤跺眰浠诲姟")
+                val scenes = sceneRep.findScene(task.tguid!!, areaVo.scensetypeid?.toInt(), areaVo.towncode)
+                    .map { it?.guid }
+                userInfoSVRep.findUser(scenes).map { it?.guid }
+            }
+            else -> emptyList()
+        }
+        // 2.閫氳繃鍖哄煙鏉′欢鍐冲畾鍖归厤鐨勬暟鎹潵婧�
+        return aopDataDeviceMap.findMapSet(areaVo, userIdList)
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3