diff --git a/app/src/main/java/com/yinuo/safetywatcher/watcher/ui/QueryDataActivity.kt b/app/src/main/java/com/yinuo/safetywatcher/watcher/ui/QueryDataActivity.kt index e3ac3ef..6f64037 100644 --- a/app/src/main/java/com/yinuo/safetywatcher/watcher/ui/QueryDataActivity.kt +++ b/app/src/main/java/com/yinuo/safetywatcher/watcher/ui/QueryDataActivity.kt @@ -142,18 +142,29 @@ class QueryDataActivity : BaseActivity() { val newMapList = gasNewMap[type] var startGas: Gas? = null var gasValue = 0.0 + var tempTime = 0L var count = 0 list.forEachIndexed { index, gas -> if (startGas == null) { startGas = gas + tempTime = gas.time - ((gas.time - startTime) % intervalMs) gasValue = 0.0 count = 0 } - if (gas.time - startGas!!.time > intervalMs) { - if (gasValue != 0.0) { + if (gas.time - tempTime > intervalMs) { + val offsetTime = gas.time - tempTime + val num = offsetTime / intervalMs + if (num > 0) { + for (i in num downTo 1) { + tempTime += intervalMs + newMapList?.add(gas.copy(time = tempTime, gasValue = -1.0)) + } + } + if (gasValue >= 0.0) { startGas!!.gasValue = gasValue / count newMapList?.add(startGas!!) } + tempTime += intervalMs startGas = gas gasValue = gas.gasValue count = 1 @@ -164,7 +175,7 @@ class QueryDataActivity : BaseActivity() { // 最后一个特殊处理 if (list.size - 1 == index) { - if (gasValue != 0.0) { + if (gasValue >= 0.0) { startGas!!.gasValue = gasValue / count newMapList?.add(startGas!!) }