riku
2021-12-02 a5d3f60ae4aa27744b47fcc3107be8005c3da910
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
103
104
105
106
107
package com.flightfeather.uav.lightshare.bean
 
import com.flightfeather.uav.domain.entity.CompanyDevice
import com.flightfeather.uav.lightshare.eunm.ElectricityType
import java.util.*
 
/**
 * 用电量日分析结果
 * Date 2021/12/1 15:23
 * Created by feiyu
 */
class ElectricDailyInfo {
    var day: String = ""
 
    /***********产线设备ProductionLine, pl************/
    private var plDCode: String? = null  // 设备编号
    private var plSTime: Date? = null    // 开启时间
    private var plRTime: Date? = null    // 正式运行时间
    private var plETime: Date? = null    // 关闭时间
    // FIXME: 2021/12/1 (状态为运行、高负荷的时长)
    private var plRunTime: Int = 0    // 运行时长(分钟)
    private var plRunPeriod = mutableListOf<Int>()// 运行时段(小时)
    /***********净化设备Purify, pf********************/
    private var pfDCode: String? = null
    private var pfSTime: Date? = null
    private var pfRTime: Date? = null
    private var pfETime: Date? = null
    private var pfRunTime: Int = 0
    private var pfRunPeriod = mutableListOf<Int>()
 
    // TODO: 2021/12/1 正式运行时间差
    // TODO: 2021/12/1 关闭时间差
    private var dailyResult: String = ""// 当日分析结果描述
 
    // 当前设备类型,用于插入数据时决定赋值字段
    private var deviceType: ElectricityType = ElectricityType.ProductionLine
 
    fun changeType(d: CompanyDevice?) {
        deviceType = when (d?.cdType) {
            ElectricityType.ProductionLine.value -> {
                plDCode = d.cdDeviceCode
                ElectricityType.ProductionLine
            }
            ElectricityType.Purify.value -> {
                pfDCode = d.cdDeviceCode
                ElectricityType.Purify
            }
            else -> ElectricityType.UnKnow
        }
    }
 
    fun setStartTime(date: Date) {
        when (deviceType) {
            ElectricityType.ProductionLine -> plSTime = date
            ElectricityType.Purify -> pfSTime = date
            else -> Unit
        }
    }
 
    fun setEndTime(date: Date) {
        when (deviceType) {
            ElectricityType.ProductionLine -> plETime = date
            ElectricityType.Purify -> pfETime = date
            else -> Unit
        }
    }
 
    fun setRunningTime(date: Date) {
 
    }
 
    /**
     * 增加运行时长
     */
    fun addRunTime(min: Int) {
        when (deviceType) {
            ElectricityType.ProductionLine -> plRunTime += min
            ElectricityType.Purify -> pfRunTime += min
            else -> Unit
        }
    }
 
    /**
     * 添加运行时段(小时)
     */
    fun addRunPeriod(hour: Int) {
        when (deviceType) {
            ElectricityType.ProductionLine -> if (!plRunPeriod.contains(hour)) plRunPeriod += hour
            ElectricityType.Purify -> if (!pfRunPeriod.contains(hour)) pfRunPeriod += hour
            else -> Unit
        }
    }
 
    /**
     * 统计得出当日分析结果
     */
    fun getResult() {
        // 1. 设备开启关闭是否合规
 
        // TODO: 2021/12/1 1. 设备正式运行时间差 =》开启是否合规
        // TODO: 2021/12/1 2,设备关闭时间差 =》关闭是否合规
        // TODO: 2021/12/1 3. 运行时长差 =》运行过程是否合规
        // TODO: 2021/12/1 4. 综合判断结果
 
        // TODO: 2021/12/1 5. 多日摘要统计,运行天数、合规天数等
    }
}