feiyu02
2025-05-29 4d065a305b997bfb66f41b33a31d59de63b1958d
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
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 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>()
 
    fun mainList(): List<FactorType> {
        return selectedList.map { it.main }
    }
}