feiyu02
2024-01-10 30a53b41f09d2eefd33513a409d472c2166ba1ea
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package cn.flightfeather.supervision.domain.ds2.repository
 
import cn.flightfeather.supervision.domain.ds1.entity.Scense
import cn.flightfeather.supervision.domain.ds1.mapper.ScenseMapper
import cn.flightfeather.supervision.domain.ds1.mapper.UserinfoMapper
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 org.springframework.stereotype.Repository
import tk.mybatis.mapper.entity.Example
 
@Repository
class UserMapRep(
    private val userMapMapper: UserMapMapper,
    private val scenseMapper: ScenseMapper,
    private val userinfoMapper: UserinfoMapper
) {
 
    /**
     * 从飞羽监管系统中查找基本信息
     * @param userinfoTZ 飞羽环境中的用户信息
     * @return
     */
    fun findFromSupervision(userinfoTZ: UserinfoTZ?): Scense? {
        val userMap = UserMap().apply {
            tzUserId = userinfoTZ?.guid
        }
        // 找到两个系统用户的对应关系
        val uMap = userMapMapper.selectOne(userMap)
        if (uMap == null) {
            println("${userinfoTZ?.guid}, ${userinfoTZ?.realname}")
            return null
        }
        // 找到飞羽监管中的用户信息
        val userInfoSp = userinfoMapper.selectByPrimaryKey(uMap.svUserId)
        // 找到飞羽监管中的场景信息
        return scenseMapper.selectByPrimaryKey(userInfoSp.dGuid)
    }
 
    /**
     * 通过飞羽监管用户id查询飞羽环境用户id
     */
    fun findBySVUserId(idList: List<String?>): List<UserMap?> {
        return userMapMapper.selectByExample(Example(UserMap::class.java).apply {
            createCriteria().andIn("svUserId", idList)
        })
    }
}