| | |
| | | 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 |
| | | |
| | |
| | | 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) |
| | | }) |
| | |
| | | // 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 { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | 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) |
| | | } |
| | | } |