From baf2cc2ce3dfd1235c012a3750132769fcd9ad2f Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期四, 18 九月 2025 17:02:05 +0800 Subject: [PATCH] 2025.9.18 1. 联合前端调试数据产品接口(待完成) --- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/impl/UserMapServiceImpl.kt | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 102 insertions(+), 12 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..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 @@ -1,41 +1,62 @@ package cn.flightfeather.supervision.lightshare.service.impl +import cn.flightfeather.supervision.business.autooutput.dataanalysis.AopDataDeviceMap +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 +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.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.* @Service 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 userMapRep: UserMapRep, + private val aopDataDeviceMap: AopDataDeviceMap, +) : UserMapService { override fun getTZIdBySceneId(sceneId: String): UserMap { - val list = userinfoMapper.selectByExample(Example(Userinfo::class.java).apply { - createCriteria().andEqualTo("dGuid", 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 autoCreateMap() { + override fun getSceneByTZId(tzUserId: String): Scense? { + return userMapRep.findFromSupervision(tzUserId) + } + + override fun autoCreateMap(userList: List<Userinfo?>) { // 閫夋嫨闇�瑕佸鐞嗙殑璐︽埛 - val userList = userinfoMapper.selectByExample(Example(Userinfo::class.java).apply { - createCriteria().andEqualTo("remark", "闈欏畨鍖�") - }) +// val userList = userinfoMapper.selectByExample(Example(Userinfo::class.java).apply { +// createCriteria().andEqualTo("remark", "寰愭眹鍖�") +// }) userList.forEach { + it ?: return@forEach // 鏌ユ壘鏄惁宸茬粡鏈夎处鎴峰尮閰嶈褰� val records = userMapMapper.selectByExample(Example(UserMap::class.java).apply { createCriteria().andEqualTo("svUserId", it.guid) @@ -54,13 +75,14 @@ tzUserName = tzU.realname svUserId = it.guid svUserName = it.realname + umCreateTime = Date() }) } } // 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 { @@ -68,10 +90,78 @@ tzUserName = id svUserId = it.guid svUserName = it.realname + umCreateTime = Date() }) } } } } } + + override fun fetchDeviceMap(page: Int?, perPage: Int?, areaVo: AreaVo): List<DeviceMapVo?> { + // 1.閫氳繃鍖哄煙鏉′欢鑾峰彇涓讳綋鐢ㄦ埛 + val userIdList = when (areaVo.sourceType) { + //浠ラ缇界幆澧冪郴缁熶腑鐨勭敤鎴蜂负涓讳綋 + 1 -> { + val u = userInfoTZRep.findEnterpriseUser(areaVo.districtname, areaVo.scensetypeid?.toInt()) + 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 to it?.realname } + } + else -> emptyList() + } + // 2.閫氳繃鍖哄煙鏉′欢鍐冲畾鍖归厤鐨勬暟鎹潵婧� + 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