feiyu02
2024-06-27 e8f935a01d75c89ac591a80b9318eac2480e2dcd
src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/exceptiontype/ExceptionValueMutation.kt
@@ -4,6 +4,7 @@
import com.flightfeather.uav.biz.dataanalysis.model.DataAnalysisConfig
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
/**
@@ -19,21 +20,34 @@
    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 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)
        }
//        repeat(config.factorCount) { i->
//            if (p?.getByFactorIndex(i) == null || n.getByFactorIndex(i) == null) {
//                res.add(false)
//                return@repeat
//            }
//            val pValue = p.getByFactorIndex(i)!!
//            val nValue = n.getByFactorIndex(i)!!
//            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)
//        }
        return res
    }