From 38d72198bfcced01ed9513b978163e5cd1d84625 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期一, 21 七月 2025 15:31:41 +0800
Subject: [PATCH] 2025.7.21 1. 修改动态溯源异常判断逻辑

---
 src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/exceptiontype/ExceptionValueMutation.kt |   33 +++++++++++++++++++++------------
 1 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/exceptiontype/ExceptionValueMutation.kt b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/exceptiontype/ExceptionValueMutation.kt
index f9da13a..5633645 100644
--- a/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/exceptiontype/ExceptionValueMutation.kt
+++ b/src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/exceptiontype/ExceptionValueMutation.kt
@@ -1,15 +1,16 @@
 package com.flightfeather.uav.biz.dataanalysis.exceptiontype
 
-import com.flightfeather.uav.biz.dataanalysis.BaseExceptionContinuous
 import com.flightfeather.uav.biz.dataanalysis.model.DataAnalysisConfig
+import com.flightfeather.uav.biz.dataanalysis.model.ExceptionTag
 import com.flightfeather.uav.biz.dataanalysis.model.ExceptionType
 import com.flightfeather.uav.domain.entity.BaseRealTimeData
+import com.flightfeather.uav.socket.eunm.FactorType
 import kotlin.math.abs
 
 /**
  * 閲忕骇绐佸彉寮傚父鍒嗘瀽
  */
-class ExceptionValueMutation(config: DataAnalysisConfig) : BaseExceptionContinuous(config) {
+class ExceptionValueMutation(config: DataAnalysisConfig) : ExceptionContinuous(config) {
 
     /**
      * 鏈紓甯哥殑杩炵画鍙戠敓娆℃暟浼氭牴鎹紓甯哥殑绋嬪害鍙樺寲
@@ -19,29 +20,37 @@
 
     override fun getExceptionType(): ExceptionType = ExceptionType.TYPE4
 
-    override fun judgeException(p: BaseRealTimeData?, n: BaseRealTimeData): List<Boolean> {
-        val res = mutableListOf<Boolean>()
-        repeat(config.factorCount) { i->
-            if (p?.getByFactorIndex(i) == null || n.getByFactorIndex(i) == null) {
-                res.add(false)
-                return@repeat
+    override var judgeMethod: JudgeMethod = JudgeMethod.M2
+
+    override fun judgeException(p: BaseRealTimeData?, n: BaseRealTimeData): MutableMap<FactorType, Boolean> {
+        val res = mutableMapOf<FactorType, Boolean>()
+        config.factorFilter.mainList().forEach { f ->
+            if (p?.getByFactorType(f) == null || n.getByFactorType(f) == null) {
+                res[f] = (false)
+                return@forEach
             }
-            val pValue = p.getByFactorIndex(i)!!
-            val nValue = n.getByFactorIndex(i)!!
+            val pValue = p.getByFactorType(f)!!
+            val nValue = n.getByFactorType(f)!!
             val r = abs((pValue - nValue) / pValue)
             val b1 = r >= (2 * config.mutationRate)
             val b2 = r >= config.mutationRate
             if (b1) special = true
-            res.add(b1 || b2)
+            res[f] = (b1 || b2)
+//            if (res[f] == true) println("p: $pValue --- n: $nValue --- r: $r")
         }
 
         return res
     }
 
-    override fun judgeDuration(sIndex: Int, eIndex: Int): Boolean {
+    override fun judgeExceptionCount(tag: ExceptionTag, factorType: FactorType?): Boolean {
+        // 棣栦釜鏁版嵁娌℃湁鍓嶄竴涓暟鎹弬鐓э紝涓嶇畻寮傚父鍊硷紝鏈�鍚庝竴涓暟鎹槸鍒ゆ柇缁撴潫鐨勬甯稿�硷紝鍥犳寮傚父鏁版嵁涓暟鐨勮绠椾笅鏍囦负sIndex鍜宔Index
+        val sIndex = tag.sIndex
+        val eIndex = tag.eIndex - 1
+
         val b1 = special && (eIndex - sIndex) >= (config.mutationNum / 2)
         val b2 = (eIndex - sIndex) >= config.mutationNum
         special = false
+//        println("sIndex: $sIndex --- eIndex: $eIndex --- special: $special")
         return b1 || b2
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3