feiyu02
2024-04-25 0392c333ed3d987cb2ab3dac4e1a972cff405f21
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
49
50
51
52
53
54
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
import java.util.*
 
@Repository
class UserMapRep(
    private val userMapMapper: UserMapMapper,
    private val scenseMapper: ScenseMapper,
    private val userinfoMapper: UserinfoMapper
) {
 
    /**
     * 从飞羽监管系统中查找基本信息
     * @param userinfoTZ 飞羽环境中的用户信息
     * @return
     */
    fun findFromSupervision(userinfoTZ: UserinfoTZ?): Scense? {
        return findFromSupervision(userinfoTZ?.guid)
    }
 
    fun findFromSupervision(guid: String?): Scense? {
        val userMap = UserMap().apply {
            tzUserId = guid
        }
        // 找到两个系统用户的对应关系
        val uMap = userMapMapper.selectOne(userMap) ?: 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)
        })
    }
 
    fun insert(userMap: UserMap): Int {
        if (userMap.umCreateTime == null) userMap.umCreateTime = Date()
        return userMapMapper.insert(userMap)
    }
}