From 49832a5bba94c816e83e7e74095106643f0a433e Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 16 十二月 2021 13:24:28 +0800
Subject: [PATCH] 1. 用电量日分析 2. 网格权重污染分析

---
 src/main/kotlin/com/flightfeather/uav/lightshare/bean/ElectricDailyInfo.kt |   64 ++++++++++++++++++++++++-------
 1 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/bean/ElectricDailyInfo.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/bean/ElectricDailyInfo.kt
index d7f2802..cf868ae 100644
--- a/src/main/kotlin/com/flightfeather/uav/lightshare/bean/ElectricDailyInfo.kt
+++ b/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    // 姝e紡杩愯鏃堕棿
     private var plETime: Date? = null    // 鍏抽棴鏃堕棿
-    // FIXME: 2021/12/1 锛堢姸鎬佷负杩愯銆侀珮璐熻嵎鐨勬椂闀匡級
-    private var plRunTime: Int = 0    // 杩愯鏃堕暱锛堝垎閽燂級
+    private var plRunTime: Int = 0    // 杩愯鏃堕暱锛堝垎閽燂級锛堢姸鎬佷负杩愯銆侀珮璐熻嵎鐨勬椂闀匡級
     private var plRunPeriod = mutableListOf<Int>()// 杩愯鏃舵锛堝皬鏃讹級
     /***********鍑�鍖栬澶嘝urify, pf********************/
     private var pfDCode: String? = null
@@ -28,9 +30,13 @@
     private var pfRunTime: Int = 0
     private var pfRunPeriod = mutableListOf<Int>()
 
-    // TODO: 2021/12/1 姝e紡杩愯鏃堕棿宸�
-    // TODO: 2021/12/1 鍏抽棴鏃堕棿宸�
-    private var dailyResult: String = ""// 褰撴棩鍒嗘瀽缁撴灉鎻忚堪
+    var rTimeDiff:Int = 0 //姝e紡杩愯鏃堕棿宸�
+    var sResult:Boolean = false //璁惧寮�鍚槸鍚﹀悎瑙�
+    var eTimeDiff: Int = 0 //鍏抽棴鏃堕棿宸�
+    var eResult: Boolean = false //璁惧鍏抽棴鏄惁鍚堣
+    var runningTimeDiff = 0 //杩愯鏃堕暱宸�
+    var rResult:Boolean = false //杩愯杩囩▼鏄惁鍚堣
+    var dailyResult: String = ""// 褰撴棩鍒嗘瀽缁撴灉鎻忚堪
 
     // 褰撳墠璁惧绫诲瀷锛岀敤浜庢彃鍏ユ暟鎹椂鍐冲畾璧嬪�煎瓧娈�
     private var deviceType: ElectricityType = ElectricityType.ProductionLine
@@ -65,18 +71,39 @@
         }
     }
 
-    fun setRunningTime(date: Date) {
-
+    /**
+     * 璁剧疆姝e紡杩愯鏃堕棿
+     */
+    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,12 +122,19 @@
      * 缁熻寰楀嚭褰撴棩鍒嗘瀽缁撴灉
      */
     fun getResult() {
-        // 1. 璁惧寮�鍚叧闂槸鍚﹀悎瑙�
-
         // TODO: 2021/12/1 1. 璁惧姝e紡杩愯鏃堕棿宸� =銆嬪紑鍚槸鍚﹀悎瑙�
+        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()
+            eResult = eTimeDiff > 0
+        }
         // TODO: 2021/12/1 3. 杩愯鏃堕暱宸� =銆嬭繍琛岃繃绋嬫槸鍚﹀悎瑙�
-        // TODO: 2021/12/1 4. 缁煎悎鍒ゆ柇缁撴灉
+        runningTimeDiff = pfRunTime - plRunTime
+        rResult = runningTimeDiff > 0
 
         // TODO: 2021/12/1 5. 澶氭棩鎽樿缁熻锛岃繍琛屽ぉ鏁般�佸悎瑙勫ぉ鏁扮瓑
     }

--
Gitblit v1.9.3