feiyu02
2021-12-02 74ffc8ebf3a25d2e3cee758954ce6efc163cb864
src/main/kotlin/com/flightfeather/uav/lightshare/bean/ElectricDailyInfo.kt
@@ -1,6 +1,9 @@
package com.flightfeather.uav.lightshare.bean
import com.flightfeather.uav.dataprocess.ElectricDailyAnalysis
import com.flightfeather.uav.domain.entity.CompanyDevice
import com.flightfeather.uav.domain.entity.ElectricMinuteValue
import com.flightfeather.uav.lightshare.eunm.ElectricityStatus
import com.flightfeather.uav.lightshare.eunm.ElectricityType
import java.util.*
@@ -17,8 +20,7 @@
    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 plRunTime: Int = 0    // 运行时长(分钟)(状态为运行、高负荷的时长)
    private var plRunPeriod = mutableListOf<Int>()// 运行时段(小时)
    /***********净化设备Purify, pf********************/
    private var pfDCode: String? = null
@@ -28,8 +30,12 @@
    private var pfRunTime: Int = 0
    private var pfRunPeriod = mutableListOf<Int>()
    // TODO: 2021/12/1 正式运行时间差
    // TODO: 2021/12/1 关闭时间差
    private var rTimeDiff:Int = 0 //正式运行时间差
    private var sResult:Boolean = false //设备开启是否合规
    private var eTimeDiff: Int = 0 //关闭时间差
    private var eResult: Boolean = false //设备关闭是否合规
    private var runningTimeDiff = 0 //运行时长差
    private var rResult:Boolean = false //运行过程是否合规
    private var dailyResult: String = ""// 当日分析结果描述
    // 当前设备类型,用于插入数据时决定赋值字段
@@ -65,18 +71,39 @@
        }
    }
    fun setRunningTime(date: Date) {
    /**
     * 设置正式运行时间
     */
    fun setRunningTime(s: Triple<String, String, Double>, e:ElectricMinuteValue?) {
        when (deviceType) {
            ElectricityType.ProductionLine -> {
                if (plRTime == null) {
                    if (s.first.toInt() >= ElectricityStatus.C.value) {
                        plRTime = e?.mvDataTime
                    }
                }
            }
            ElectricityType.Purify -> {
                if (pfRTime == null) {
                    if (s.first.toInt() >= ElectricityStatus.C.value) {
                        pfRTime = e?.mvDataTime
                    }
                }
            }
            else -> Unit
        }
    }
    /**
     * 增加运行时长
     */
    fun addRunTime(min: Int) {
        when (deviceType) {
            ElectricityType.ProductionLine -> plRunTime += min
            ElectricityType.Purify -> pfRunTime += min
            else -> Unit
    fun addRunTime(s: Triple<String, String, Double>) {
        if (s.first.toInt() >= ElectricityStatus.C.value) {
            when (deviceType) {
                ElectricityType.ProductionLine -> plRunTime++
                ElectricityType.Purify -> pfRunTime++
                else -> Unit
            }
        }
    }
@@ -95,11 +122,17 @@
     * 统计得出当日分析结果
     */
    fun getResult() {
        // 1. 设备开启关闭是否合规
        // TODO: 2021/12/1 1. 设备正式运行时间差 =》开启是否合规
        if (pfRTime != null && plRTime != null) {
            rTimeDiff = ((pfRTime!!.time - plRTime!!.time) / 1000 / 60).toInt()
            sResult = rTimeDiff > 0
        }
        // TODO: 2021/12/1 2,设备关闭时间差 =》关闭是否合规
        if (pfETime != null && plETime != null) {
            eTimeDiff = ((pfETime!!.time - plETime!!.time) / 1000 / 60).toInt()
        }
        // TODO: 2021/12/1 3. 运行时长差 =》运行过程是否合规
        runningTimeDiff = pfRunTime - plRunTime
        // TODO: 2021/12/1 4. 综合判断结果
        // TODO: 2021/12/1 5. 多日摘要统计,运行天数、合规天数等