feiyu02
2025-06-03 0bfd1f3b422677ddfed45f13fc034f17f049b9d5
1. 新增动态污染溯源新的判定逻辑(待完成)
已修改10个文件
110 ■■■■ 文件已修改
src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuous.kt 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/exceptiontype/ExceptionSlideAverage.kt 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionTag.kt 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/config/RTExcWindLevelConfig.kt 49 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcWindLevel.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcWindLevel1_1.kt 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RealTimeExceptionSlideAverage.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSource.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/BaseExceptionContinuous.kt
@@ -109,6 +109,11 @@
                        recordException(s, it, data)
                    }
                }
                // 3. 数据正常,无任何异常时d
                // TODO("2025.6.3:其他子类的此处刷新逻辑待完成“)
                else {
                    it.refreshWithNoException(data)
                }
            }
        }
        lastData = data
@@ -154,7 +159,7 @@
     */
    open fun onNewException(tag: T, factor: FactorFilter.SelectedFactor, exceptionStatus: ExceptionStatusType) {
        if (tag.startData == null) return
        val ex = newResult(tag.startData!!, lastData, factor, tag.exceptionData)
        val ex = newResult(tag.startData!!, tag.endData, factor, tag.exceptionData)
            .apply { status = exceptionStatus.value }
        // 异常已创建时,更新异常信息
        if (tag.exceptionCreated) {
src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/exceptiontype/ExceptionSlideAverage.kt
@@ -183,7 +183,7 @@
        if (factor != null && tag != null) {
            if (tag.exceptionExisted) {
                tag.startData?.let {
                    resultList.add(newResult(it, lastData, factor, tag.exceptionData))
                    resultList.add(newResult(it, tag.endData, factor, tag.exceptionData))
                }
                tag.exceptionExisted = false
            }
@@ -192,7 +192,7 @@
                val tag1 = tagMap[f.main] ?: return@forEach
                if (tag1.exceptionExisted) {
                    tag1.startData?.let {
                        resultList.add(newResult(it, lastData, f, tag1.exceptionData))
                        resultList.add(newResult(it, tag1.endData, f, tag1.exceptionData))
                    }
                    tag1.exceptionExisted = false
                }
src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/model/ExceptionTag.kt
@@ -37,9 +37,13 @@
        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
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/config/RTExcWindLevelConfig.kt
@@ -13,7 +13,8 @@
    inner class WindLevelCondition(
        val windSpeed: Pair<Double, Double>,
        val mutationRate: Pair<Double, DistanceType>,
        val mutationRate: Pair<Double, Double>,
        val distanceType: DistanceType,
        val countLimit: Int,
    )
@@ -25,28 +26,33 @@
    // 0 - 1级风
    var windLevelCondition1 = WindLevelCondition(
        .0 to 1.5,
        0.5 to DistanceType.TYPE1,
        0.5 to Double.MAX_VALUE,
        DistanceType.TYPE1,
        1
    )
    // 0 - 1级风
    var windLevelCondition1_1 = WindLevelCondition(
        .0 to 1.5,
        0.2 to DistanceType.TYPE2,
        0.2 to 0.5,
        DistanceType.TYPE2,
        1
    )
    // 2 - 4级风
    var windLevelCondition2 = WindLevelCondition(
        1.6 to 7.9,
        0.2 to DistanceType.TYPE3,
        3
        0.2 to Double.MAX_VALUE,
        DistanceType.TYPE3,
//        3
        1
    )
    // 5 - 6级风
    var windLevelCondition3 = WindLevelCondition(
        8.0 to 13.8,
        0.1 to DistanceType.TYPE4,
        0.1 to Double.MAX_VALUE,
        DistanceType.TYPE4,
        3
    )
@@ -57,4 +63,35 @@
    var analysisPeriod = 15
    // 定时分析间隔中,立即进行线索分析的最小线索量(单位:个)
    var analysisCount = 3
//    // 0 - 1级风
//    var windLevelCondition1 = WindLevelCondition(
//        .0 to 1.5,
//        listOf(0.5 to DistanceType.TYPE1, 0.2 to DistanceType.TYPE2,),
//        listOf(1, 1)
//    )
//
//    // 0 - 1级风
//    var windLevelCondition1_1 = WindLevelCondition(
//        .0 to 1.5,
//        0.2 to DistanceType.TYPE2,
//        1
//    )
//
//    // 2 - 4级风
//    var windLevelCondition2 = WindLevelCondition(
//        1.6 to 7.9,
//        listOf(0.2 to DistanceType.TYPE3),
////        listOf(3)
//        listOf(1)
//    )
//
//    // 5 - 6级风
//    var windLevelCondition3 = WindLevelCondition(
//        8.0 to 13.8,
//        listOf(0.1 to DistanceType.TYPE4),
//        listOf(3)
//    )
}
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/BaseRTExcWindLevel.kt
@@ -54,7 +54,7 @@
                val nValue = n.getByFactorType(f)!!
                // 计算后一个数据相比于前一个数据的变化率
                val r = (nValue - pValue) / pValue
                val b1 = r >= con.mutationRate.first
                val b1 = r >= con.mutationRate.first && r < con.mutationRate.second
                println("因子:${f.des},幅度:${r},限定:${con.mutationRate.first},${b1}")
                res[f] = b1
            } else {
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcWindLevel1_1.kt
@@ -7,6 +7,7 @@
 * @date 2025/5/29
 * @author feiyu02
 */
class RTExcWindLevel1_1 : BaseRTExcWindLevel {
    constructor(config: RTExcWindLevelConfig) : super(config)
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RealTimeExceptionSlideAverage.kt
@@ -121,7 +121,7 @@
     */
    open fun onNewException(tag: ExceptionSlideAverageTag, factor: FactorFilter.SelectedFactor, exceptionStatus: ExceptionStatusType) {
        if (tag.startData == null) return
        val ex = newResult(tag.startData!!, lastData, factor, tag.exceptionData)
        val ex = newResult(tag.startData!!, tag.endData, factor, tag.exceptionData)
            .apply { status = exceptionStatus.value }
        // 异常已创建时,更新异常信息
        if (tag.exceptionCreated) {
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt
@@ -24,7 +24,7 @@
        config: RTExcWindLevelConfig,
        windLevelCondition: RTExcWindLevelConfig.WindLevelCondition,
    ) : this() {
        distanceType = windLevelCondition.mutationRate.second
        distanceType = windLevelCondition.distanceType
        sourceTrace(exceptionData, config, windLevelCondition)
    }
@@ -55,13 +55,16 @@
        polygon = calSector(
            avgData.windSpeed!!.toDouble(),
            pair,
            windLevelCondition.mutationRate.second.disRange,
            windLevelCondition.distanceType.disRange,
            config.sourceTraceDegOffset
        )
        ).map {
            // 将坐标转换为gcj02(火星坐标系),因为污染源场景信息都为此坐标系
            MapUtil.wgs84ToGcj02(it)
        }
        try {
            val address = AMapService.reGeo(pair)
            this.address = address.township + address.street
            this.address = address.district + address.township + address.street
        } catch (e: Exception) {
            e.printStackTrace()
        }
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedData.kt
@@ -41,17 +41,20 @@
        startTime = DateUtil.instance.dateToString(start.dataTime, DateUtil.DateStyle.HH_MM_SS)
        endTime = DateUtil.instance.dateToString(end?.dataTime, DateUtil.DateStyle.HH_MM_SS) ?: startTime
        startData = start.getByFactorType(factor.main)
        endData = end?.getByFactorType(factor.main) ?: startData
//        startData = start.getByFactorType(factor.main)
//        endData = end?.getByFactorType(factor.main) ?: startData
        startData = start
        endData = end
        windSpeed = exceptionData.first().windSpeed?.toDouble()
        percentage = windLevelCondition.mutationRate.first
        times = windLevelCondition.countLimit
        dataList.add(start)
        exceptionData.forEach {
            dataList.add(it)
            dataVoList.add(it.toDataVo())
        }
        dataVoList.addAll(dataList.map { it.toDataVo() })
        calPer()
    }
@@ -70,8 +73,8 @@
    var startTime: String? = null
    var endTime: String? = null
    var startData: Float? = null
    var endData: Float? = null
    var startData: BaseRealTimeData? = null
    var endData: BaseRealTimeData? = null
    // 风速
    var windSpeed: Double? = null
@@ -89,12 +92,17 @@
    var dataVoList: MutableList<DataVo> = mutableListOf()
    private fun calPer() {
        if (dataList.size < 2) return
        val list = dataList
//        list.add(startData)
//        list.addAll(dataList)
        if (list.size < 2) return
        var total = .0
        for (i in 0 until dataList.size - 1) {
            total += dataList[i].getByFactorType(selectedFactor!!.main)!!
        for (i in 0 until list.size - 1) {
            val p = list[i]?.getByFactorType(selectedFactor!!.main)!!
            val n = list[i + 1]?.getByFactorType(selectedFactor!!.main)!!
            total += (n - p) / p
        }
        avgPer = total / (dataList.size - 1)
        avgPer = total / (list.size - 1)
    }
}
src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSource.kt
@@ -44,7 +44,7 @@
    fun searchScenes(pollutedArea: PollutedArea, sceneInfoRep: SceneInfoRep, factor: FactorFilter.SelectedFactor) {
        // Fixme 2025.5.14: 污染源的坐标是高德地图坐标系(火星坐标系),而走航数据是WGS84坐标系
        // 按照区域检索内部污染源信息
        // 1. 首先按照四至范围从数据库初步筛选污染源,需要先将坐标转换为gcj02(火星坐标系),因为污染源场景信息都为此坐标系
        // 1. 首先按照四至范围从数据库初步筛选污染源
//        val polygonTmp = pollutedArea.polygon!!.map {
//            MapUtil.gcj02ToWgs84(it)
//        }