feiyu02
2025-06-03 0bfd1f3b422677ddfed45f13fc034f17f049b9d5
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)
    }
}