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
| package com.flightfeather.uav.biz
|
| import com.flightfeather.uav.socket.eunm.FactorType
|
| /**
| * 所选主要分析因子,以及关联因子
| * 在做数据异常分析以及数据统计时,用于决定是否需要进行处理该因子。
| * @date 2024/6/27
| * @author feiyu02
| */
| class FactorFilter private constructor(){
|
| data class SelectedFactor(
| val main:FactorType,
| var subs:List<FactorType> = emptyList()
| )
|
| inner class Builder{
| fun withMain(factorType: FactorType): Builder {
| selectedList.add(SelectedFactor(factorType))
| return this
| }
|
| fun withSubs(subs: List<FactorType>): Builder {
| if (selectedList.isNotEmpty()) {
| selectedList.last().subs = subs
| }
| return this
| }
|
| fun withCombination(com: List<List<FactorType>>):Builder{
| combination.addAll(com)
| return this
| }
|
| fun create(): FactorFilter {
| return this@FactorFilter
| }
| }
|
| companion object{
| fun builder() = FactorFilter().Builder()
| fun default() = builder()
| .withMain(FactorType.VOC)
| .withSubs(listOf(
| // FactorType.H2S,
| FactorType.O3,
| FactorType.PM25,
| FactorType.PM10,
| ))
| // .withMain(FactorType.H2S)
| // .withSubs(listOf(
| // FactorType.VOC,
| // FactorType.O3,
| // FactorType.PM25,
| // ))
| .withMain(FactorType.O3)
| .withSubs(listOf(
| FactorType.VOC,
| // FactorType.H2S,
| FactorType.PM25,
| FactorType.PM10,
| ))
| .withMain(FactorType.PM25)
| .withSubs(listOf(
| FactorType.VOC,
| // FactorType.H2S,
| FactorType.O3,
| FactorType.PM10,
| ))
| .withMain(FactorType.PM10)
| .withSubs(listOf(
| FactorType.VOC,
| // FactorType.H2S,
| FactorType.O3,
| FactorType.PM25,
| ))
| // .withSubs(listOf(
| // FactorType.NO2,
| // FactorType.CO,
| // FactorType.SO2,
| // FactorType.O3,
| // FactorType.PM25,
| // FactorType.PM10,
| // FactorType.VOC
| // ))
| .create()
| }
|
| // 所选因子集合
| val selectedList = mutableListOf<SelectedFactor>()
|
| // 因子的关联关系
| val combination = mutableListOf<List<FactorType>>()
|
| fun mainList(): List<FactorType> {
| return selectedList.map { it.main }
| }
| }
|
|