From 0392c333ed3d987cb2ab3dac4e1a972cff405f21 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 25 四月 2024 17:42:08 +0800
Subject: [PATCH] 1. 新增后台任务关联模块 2. 新增自动评分后台任务; 3. 修复部分bug

---
 src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/UserMapServiceImpl.kt |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 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 6ef1a58..764f171 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,9 +1,9 @@
 package cn.flightfeather.supervision.lightshare.service.impl
 
 import cn.flightfeather.supervision.business.autooutput.dataanalysis.AopDataDeviceMap
-import cn.flightfeather.supervision.common.exception.ResponseErrorException
-import cn.flightfeather.supervision.common.utils.Constant
+import cn.flightfeather.supervision.common.exception.BizException
 import cn.flightfeather.supervision.common.utils.UUIDGenerator
+import cn.flightfeather.supervision.domain.ds1.entity.Scense
 import cn.flightfeather.supervision.domain.ds1.entity.Userinfo
 import cn.flightfeather.supervision.domain.ds1.mapper.UserinfoMapper
 import cn.flightfeather.supervision.domain.ds1.repository.SceneRep
@@ -14,12 +14,13 @@
 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.domain.ds2.repository.UserMapRep
 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
+import java.util.*
 
 @Service
 class UserMapServiceImpl(
@@ -30,23 +31,27 @@
     private val taskRep: TaskRep,
     private val userInfoSVRep: UserInfoSVRep,
     private val userInfoTZRep: UserInfoTZRep,
+    private val userMapRep: UserMapRep,
     private val aopDataDeviceMap: AopDataDeviceMap,
 ) : UserMapService {
 
     override fun getTZIdBySceneId(sceneId: String): UserMap {
-        val list = userInfoSVRep.findUser(sceneId)
-        if (list.isEmpty()) return UserMap()
-        val userId = list[0]?.guid
+        val user = userInfoSVRep.findUser(sceneId)
+        val userId = user?.guid
         val result = userMapMapper.selectByExample(Example(UserMap::class.java).apply {
             createCriteria().andEqualTo("svUserId", userId)
         })
         return if (result.isNotEmpty()) result[0] else UserMap()
     }
 
+    override fun getSceneByTZId(tzUserId: String): Scense? {
+        return userMapRep.findFromSupervision(tzUserId)
+    }
+
     override fun autoCreateMap() {
         // 閫夋嫨闇�瑕佸鐞嗙殑璐︽埛
         val userList = userinfoMapper.selectByExample(Example(Userinfo::class.java).apply {
-            createCriteria().andEqualTo("remark", "闈欏畨鍖�")
+            createCriteria().andEqualTo("remark", "寰愭眹鍖�")
         })
         userList.forEach {
             // 鏌ユ壘鏄惁宸茬粡鏈夎处鎴峰尮閰嶈褰�
@@ -81,6 +86,7 @@
                             tzUserName = id
                             svUserId = it.guid
                             svUserName = it.realname
+                            umCreateTime = Date()
                         })
                     }
                 }
@@ -98,7 +104,7 @@
             }
             //浠ラ缇界洃绠$郴缁熶腑鐨勭敤鎴蜂负涓讳綋
             2 -> {
-                val task = taskRep.findOneTask(areaVo) ?: throw ResponseErrorException("褰撳墠鏌ヨ鏉′欢涓嬫湭鎵惧埌瀵瑰簲椤跺眰浠诲姟")
+                val task = taskRep.findOneTask(areaVo) ?: throw BizException("褰撳墠鏌ヨ鏉′欢涓嬫湭鎵惧埌瀵瑰簲椤跺眰浠诲姟")
                 val scenes = sceneRep.findScene(task.tguid!!, areaVo.scensetypeid?.toInt(), areaVo.towncode)
                     .map { it?.guid }
                 userInfoSVRep.findUser(scenes).map { it?.guid }

--
Gitblit v1.9.3