feiyu02
2024-07-18 5b0d58c3f7f35f61c0a0437bac3ff708db57fe61
1. 修正实时走航数据平滑处理算法,PM2.5、PM10、VOC采用新的修正算法
已修改6个文件
71 ■■■■ 文件已修改
src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/ExceptionAnalysisController.kt 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/repository/RealTimeDataRep.kt 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/model/epw/WeightType.kt 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/repository/impl/AirDataRepositoryImpl.kt 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/eunm/FactorType.kt 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/biz/dataanalysis/ExceptionAnalysisController.kt
src/main/kotlin/com/flightfeather/uav/domain/repository/RealTimeDataRep.kt
@@ -68,6 +68,7 @@
                    })
                }
            }
            else -> Unit
        }
        return result
    }
src/main/kotlin/com/flightfeather/uav/model/epw/EPWDataPrep.kt
@@ -29,10 +29,7 @@
    // 均值倍数参数
    private val xratio = 3
    // 连续数据的合理最大增长倍率
    private val multiplier = 20
    // 需要处理的因子类型
    // 需要平滑处理的因子类型
    private var calTypes = when (deviceType) {
        UWDeviceType.VEHICLE,
        UWDeviceType.UAV,
@@ -41,6 +38,25 @@
        UWDeviceType.GRID -> WeightType.prepFixed
        else -> WeightType.prepFixed
    }
    // 只需要检查范围和变化幅度的因子类型
    private var rangeTypes = listOf(
        FactorType.PM25.des,
        FactorType.PM10.des,
        FactorType.VOC.des
    )
    // 无需修正的因子类型
    private var noCalTypes = listOf(
        FactorType.TEMPERATURE.des,
        FactorType.HUMIDITY.des,
        FactorType.LNG.des,
        FactorType.LAT.des,
        FactorType.VELOCITY.des,
        FactorType.TIME.des,
        FactorType.WIND_DIRECTION.des,
        FactorType.HEIGHT.des
    )
    private val lastData = mutableListOf<DataVo>()
@@ -151,26 +167,27 @@
                        // 去除无效值的标准差
                        val std = standardDeviation(avg.first, list, it.factorName)
                        // 合理最大值
                        val max = max(avg.first + std * nstd, avg.first + avg.first * xratio)
                        var maxValue = max(avg.first + std * nstd, avg.first + avg.first * xratio)
                        maxValue = max(maxValue, FactorType.getRange(it.factorName)?.second ?: .0)
                        // 合理最小值
                        val min = min(avg.first - std * nstd, avg.first / (1 + xratio))
                        val minValue = min(avg.first - std * nstd, avg.first / (1 + xratio))
                        // 判断监测因子是否需要进行平滑处理,
                        // 若不需要,则判断量级是否在合理范围内以及变化倍率是否在合理范围内
                        if (!calTypes.contains(it.factorName)) {
                            if (isInRange(it) != true || excessiveChange(it) == true) {
                                // 采用计算所得均值代替原始值
                                it.factorData = avg.first
                            }
                        } else {
                        if (calTypes.contains(it.factorName)) {
                            // 数据不处于合理范围并且有效个数达标时,采用计算所得均值代替原始值
                            if (avg.second > max(ncal / 5, 2)
                                && (it.factorData!! < min || it.factorData!! > max)
                                && (it.factorData!! < minValue || it.factorData!! > maxValue)
                            ) {
                                it.factorData = avg.first
                            }
                        }
                        // 判断量级是否在合理范围内以及变化倍率是否在合理范围内
                        else if (rangeTypes.contains(it.factorName)) {
                            if (isInRange(it) != true || excessiveChange(it) == true) {
                                // 采用计算所得均值代替原始值
                                it.factorData = avg.first
                            }
                        }
                    }
                }
            }
@@ -289,6 +306,6 @@
                break
            }
        }
        return m > multiplier
        return m > FactorType.getMultiplier(airData.factorName)
    }
}
src/main/kotlin/com/flightfeather/uav/model/epw/WeightType.kt
@@ -13,8 +13,8 @@
        FactorType.O3.des,
//        FactorType.PM25.des,
//        FactorType.PM10.des,
        FactorType.VOC.des,
        FactorType.WIND_SPEED.des
//        FactorType.VOC.des,
//        FactorType.WIND_SPEED.des
    )
    // 定点监测
src/main/kotlin/com/flightfeather/uav/repository/impl/AirDataRepositoryImpl.kt
@@ -97,6 +97,7 @@
                realTimeDataGridMapper.insert(d)
                count++
            }
            else -> Unit
        }
        return count
    }
@@ -123,6 +124,7 @@
                    realTimeDataGridMapper.insert(d)
                    count++
                }
                else -> Unit
            }
        }
        return count
@@ -202,6 +204,7 @@
                UWDeviceType.BOAT -> {
                }
                else -> Unit
            }
        }
        return count
src/main/kotlin/com/flightfeather/uav/socket/eunm/FactorType.kt
@@ -152,6 +152,20 @@
            else -> null
        }
        fun getMultiplier(name: String?): Double {
            getByName(name)?.let {
                return getMultiplier(it)
            }
            return 10.0
        }
        fun getMultiplier(type: FactorType): Double = when (type) {
            PM25 -> 20.0
            PM10 -> 20.0
            VOC -> 10.0
            else -> 10.0
        }
        fun outputFactor(factorName: String?): Boolean {
            return when (factorName) {
                NO2.des,