From b10c22af595bd995e56946bff63b8f2f984b13e8 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期四, 14 八月 2025 17:25:05 +0800 Subject: [PATCH] 2025.8.14 1. 动态溯源模块添加滑动平均异常计算(调试中) --- src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionTag.kt | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionTag.kt b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionTag.kt index 0bb8a4a..474881b 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionTag.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionTag.kt @@ -2,13 +2,20 @@ import com.flightfeather.uav.biz.dataanalysis.BaseExceptionResult import com.flightfeather.uav.domain.entity.BaseRealTimeData +import org.apache.commons.lang3.SerializationUtils +import org.springframework.beans.BeanUtils +import java.io.Serializable /** * 寮傚父鏁版嵁鏍囩 * @date 2025/5/13 * @author feiyu02 */ -open class ExceptionTag { +open class ExceptionTag : Serializable { + companion object { + const val MAX_HISTORY = 10 + } + // 璧峰鏁版嵁涓嬫爣 var sIndex = 0 @@ -24,6 +31,9 @@ // 寮傚父鏁版嵁娈� var exceptionData = mutableListOf<BaseRealTimeData>() + // 杩戞鏃堕棿鍐呯殑鍘嗗彶鏁版嵁 + var historyData = mutableListOf<BaseRealTimeData>() + // 鏄惁瀛樺湪寮傚父 var exceptionExisted = false @@ -32,16 +42,53 @@ var exceptionResult = mutableListOf<BaseExceptionResult>() - fun addExceptionData(data: BaseRealTimeData){ + fun addHistoryData(data: BaseRealTimeData) { + historyData.add(data) + if (exceptionData.isNotEmpty()) { + // 淇濊瘉鍘嗗彶鏁版嵁鍖呭惈鎵�鏈夊紓甯告暟鎹紙寮傚父鏁版嵁鍙兘涓嶈繛缁級锛屽苟涓斿湪棣栦釜寮傚父鏁版嵁涔嬪墠鏈�澶氬啀淇濆瓨10涓暟鎹� + val i = historyData.indexOf(exceptionData.first()) + if (i > MAX_HISTORY) { + historyData = historyData.subList(i - MAX_HISTORY, historyData.size).toMutableList() + } + } else { + if (historyData.size > MAX_HISTORY) { + historyData = historyData.subList(historyData.size - MAX_HISTORY, historyData.size).toMutableList() + } + } + } + + fun addExceptionData(data: BaseRealTimeData) { exceptionExisted = true exceptionData.add(data) } - fun refreshWithNextException(data: BaseRealTimeData) { + fun refreshWithNoException(data: BaseRealTimeData) { sIndex = eIndex startData = data + } + + fun refreshWithNextException(data: BaseRealTimeData) { + refreshWithNoException(data) exceptionData.clear() exceptionExisted = false exceptionCreated = false } + + fun clone(): ExceptionTag { + val exceptionTag = SerializationUtils.clone(this) +// val exceptionTag = ExceptionTag() +// BeanUtils.copyProperties(this, exceptionTag) +// exceptionTag.apply { +// this.sIndex = this@ExceptionTag.sIndex +// this.startData = this@ExceptionTag.startData +// this.eIndex = this@ExceptionTag.eIndex +// this.endData = this@ExceptionTag.endData +// this.exceptionData = this@ExceptionTag.exceptionData +// this.historyData = this@ExceptionTag.historyData +// this.exceptionExisted = this@ExceptionTag.exceptionExisted +// this.exceptionCreated = this@ExceptionTag.exceptionCreated +// this.exceptionResult = this@ExceptionTag.exceptionResult +// } + return exceptionTag + } } \ No newline at end of file -- Gitblit v1.9.3