From d978297ae85b2d7453054e616bbbe87bfabe9cbe Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期一, 12 七月 2021 17:38:09 +0800
Subject: [PATCH] 1. 新增用电量数据查询接口 2. 调整污染权重算法

---
 src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt b/src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt
index ed0a404..3f23d11 100644
--- a/src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt
+++ b/src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt
@@ -21,6 +21,8 @@
 //        emptyList<String>()
         WeightType.prep
 
+    private val lastData = mutableListOf<DataVo>()
+
     override fun mDataPrep(mDataList: List<DataVo>): List<DataVo> {
         mDataList.forEach {
             it.values?.forEach v@{a ->
@@ -40,6 +42,9 @@
 //        }
 
         var i = ncal
+        if (lastData.isNotEmpty()) {
+            i = 0
+        }
         while (i < mDataList.size) {
             for (y in mDataList[i].values?.indices ?: 0..0) {
                 val it = mDataList[i].values?.get(y) ?: continue
@@ -49,7 +54,14 @@
                 it.factorData ?: continue
 
                 if (it.factorData!! > vMax) {
-                    val list = mDataList.subList(i - ncal, i)
+                    val lastDataIndex = i
+                    val thisIndex = if (i-ncal<0) 0 else i - ncal
+                    val list = mutableListOf<DataVo>()
+                    if (lastDataIndex < lastData.size) {
+                        list.addAll(lastData.subList(lastDataIndex, lastData.lastIndex + 1))
+                    }
+                    list.addAll(mDataList.subList(thisIndex, i))
+
                     // 鍘婚櫎鏃犳晥鍊肩殑骞冲潎
                     val avg = average(list, it.factorName)
                     // 鍘婚櫎鏃犳晥鍊肩殑鏍囧噯宸�
@@ -73,6 +85,11 @@
             i++
         }
 
+        lastData.clear()
+        mDataList.subList(mDataList.lastIndex - ncal + 1, mDataList.lastIndex + 1).forEach {
+            lastData.add(it.copy())
+        }
+
         return mDataList
     }
 

--
Gitblit v1.9.3