feiyu02
2024-07-08 b212ef0208cb094f63ea8a239a1361f8e859c839
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package cn.flightfeather.supervision.lightshare.vo
 
import cn.flightfeather.supervision.domain.ds2.entity.DustSiteMap
import cn.flightfeather.supervision.domain.ds3.entity.FumeSiteMap
import cn.flightfeather.supervision.domain.ds3.entity.JSDustSiteMap
import org.springframework.beans.BeanUtils
import java.util.*
 
/**
 * 监测设备和飞羽监管系统、飞羽环境系统用户的匹配关系
 */
class DeviceMapVo {
    // 监测设备id
    var deviceCode:String?=null
    // 监测设备或站点名称
    var deviceName:String?=null
    // 飞羽监管系统用户id
    var svUserId:String?=null
    // 飞羽监管系统用户名称
    var svUserName:String?=null
    // 飞羽环境系统用户id
    var tzUserId:String?=null
    // 飞羽环境系统用户名称
    var tzUserName:String?=null
 
    var createTime: Date? = null
 
    companion object {
        fun fromJADustSiteMap(list: List<DustSiteMap?>): List<DeviceMapVo> {
            val res = mutableListOf<DeviceMapVo>()
            list.forEach {
                it ?: return@forEach
                res.add(DeviceMapVo().apply {
                    deviceCode = it.jaMnCode
                    deviceName = it.jaSceneName
                    svUserId = it.svUserId
                    svUserName = it.svUserName
                    tzUserId = it.tzUserId
                    tzUserName = it.tzUserName
                })
            }
            return res
        }
 
        fun fromJSDustSiteMap(list: List<JSDustSiteMap?>): List<DeviceMapVo> {
            val res = mutableListOf<DeviceMapVo>()
            list.forEach {
                it ?: return@forEach
                res.add(DeviceMapVo().apply {
                    deviceCode = it.jsDeviceCode
                    deviceName = it.jsDeviceName
                    svUserId = it.svUserId
                    svUserName = it.svUserName
                    tzUserId = it.tzUserId
                    tzUserName = it.tzUserName
                })
            }
            return res
        }
 
        fun fromXHFumeSiteMap(list: List<FumeSiteMap?>): List<DeviceMapVo> {
            val res = mutableListOf<DeviceMapVo>()
            list.forEach {
                it ?: return@forEach
                res.add(DeviceMapVo().apply {
                    deviceCode = it.xhDeviceCode
                    deviceName = it.xhDeviceName
                    svUserId = it.svUserId
                    svUserName = it.svUserName
                    tzUserId = it.tzUserId
                    tzUserName = it.tzUserName
                })
            }
            return res
        }
    }
}
 
/**
 * 根据设备mn编码找到对应关系
 */
fun List<DeviceMapVo>.findByDeviceCode(code: String?): DeviceMapVo? {
    this.forEach {
        if (it.deviceCode == code) {
            return it
        }
    }
    return null
}
 
/**
 * 根据飞羽监管系统用户id找到对应关系
 */
fun List<DeviceMapVo>.findBySVUserId(svUserId: String?): List<DeviceMapVo> {
    val res = mutableListOf<DeviceMapVo>()
    this.forEach {
        if (it.svUserId == svUserId) {
            res.add(it)
        }
    }
    return res
}