| | |
| | | |
| | | // 对äºå¼å¸¸ççæå嫿§è¡åç½®å¤æãåç«å³å¤æ |
| | | // 1. åç½®å¤æï¼å½ç¸é»æ°æ®æ¶é´ä¸è¿ç»æ¶ï¼æè
满足èªå®ä¹æ¡ä»¶æ¶ï¼å¯¹ä¹åå·²æçå¼å¸¸è¿è¡è®°å½ï¼å½¢æå¼å¸¸ç»æ |
| | | if (afterExcCheck(isContinue, it, hasException[f])) { |
| | | // æ°æ®ä¸è¿ç»æ¶æè
æ»¡è¶³ä¸»å¨æªææ¡ä»¶æ¶ï¼è®°å½å¼å¸¸æ
åµ |
| | | recordException(s, it, data) |
| | | } |
| | | // if (afterExcCheck(isContinue, it, hasException[f])) { |
| | | // // æ°æ®ä¸è¿ç»æ¶æè
æ»¡è¶³ä¸»å¨æªææ¡ä»¶æ¶ï¼è®°å½å¼å¸¸æ
åµ |
| | | // recordException(s, it, data) |
| | | // } |
| | | // 2. ç«å³å¤æï¼å½åºç°å¼å¸¸æ¶ï¼ç¼åå¼å¸¸æ°æ®çåæ¶ï¼ç«å³å¯¹å·²æå¼å¸¸è¿è¡å¤ææ¯å¦æ»¡è¶³å¼å¸¸ç»æè¦æ± |
| | | else if (hasException[f] == true) { |
| | | if (hasException[f] == true) { |
| | | // afterExcCheck(isContinue, it, hasException[f]) |
| | | needCut(it, hasException[f]) |
| | | // æå¼å¸¸åºç°æ¶ï¼è®°å½å¼å¸¸æ°æ® |
| | | it.addExceptionData(data) |
| | | // å½ç«å³å¤æéè¿æ¶ï¼å½¢æå¼å¸¸ç»æ |
| | |
| | | } |
| | | // 3. æ°æ®æ£å¸¸ï¼æ ä»»ä½å¼å¸¸æ¶d |
| | | // TODO("2025.6.3ï¼å
¶ä»åç±»çæ¤å¤å·æ°é»è¾å¾
宿â) |
| | | else { |
| | | it.refreshWithNextException(data) |
| | | } |
| | | // else { |
| | | // it.refreshWithNextException(data) |
| | | // } |
| | | } |
| | | } |
| | | lastData = data |
| | |
| | | TYPE7(7, "æ»å¨å¹³åå¼çªå"), |
| | | TYPE8(8, "ææçå¼å¸¸"), |
| | | TYPE9(9, "å¿«éä¸å"), |
| | | TYPE10(10, "å¿«éä¸é") |
| | | TYPE10(10, "å¿«éä¸é"), |
| | | TYPE11(11, "ä¸åè¶å¿") |
| | | } |
| | |
| | | |
| | | import com.flightfeather.uav.biz.FactorFilter |
| | | import com.flightfeather.uav.biz.dataanalysis.BaseExceptionAnalysis |
| | | import com.flightfeather.uav.biz.sourcetrace.RealTimeAnalysisConfig |
| | | import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig |
| | | import com.flightfeather.uav.biz.sourcetrace.exceptiontype.* |
| | | import com.flightfeather.uav.biz.sourcetrace.model.AnalysisResult |
| | | import com.flightfeather.uav.biz.sourcetrace.model.PollutedClue |
| | | import com.flightfeather.uav.biz.sourcetrace.model.PollutedSummary |
| | | import com.flightfeather.uav.common.utils.GsonUtils |
| | | import com.flightfeather.uav.domain.entity.BaseRealTimeData |
| | | import com.flightfeather.uav.domain.repository.SceneInfoRep |
| | | import com.flightfeather.uav.domain.repository.SourceTraceRep |
| | |
| | | add(RTExcWindLevel1_1(config) { exceptionCallback(it) }.also { it.init() }) |
| | | add(RTExcWindLevel4(config) { exceptionCallback(it) }.also { it.init() }) |
| | | add(RTExcWindLevel6(config) { exceptionCallback(it) }.also { it.init() }) |
| | | add(RTExcChangeRate(config) { exceptionCallback(it) }.also { it.init() }) |
| | | |
| | | add(RTExcChangeRate1(config) { exceptionCallback(it) }.also { it.init() }) |
| | | add(RTExcChangeRate4(config) { exceptionCallback(it) }.also { it.init() }) |
| | | add(RTExcChangeRate6(config) { exceptionCallback(it) }.also { it.init() }) |
| | | |
| | | add(RTWarnChangeRate(config) { dataChangeCallback(it) }.also { it.init() }) |
| | | add(RTWarnChangeRate2(config) { dataChangeCallback(it) }.also { it.init() }) |
| | | } |
| | | } |
| | | |
| | |
| | | ) |
| | | |
| | | /****æ°æ®å¿«éä¸å*****************************************************************************/ |
| | | var changeRateCondition = WindLevelCondition( |
| | | .0 to Double.MAX_VALUE, |
| | | 0.1 to Double.MAX_VALUE, |
| | | DistanceType.TYPE1, |
| | | 3 |
| | | ) |
| | | // çæµå åå¨ä¸ä¸ªçæµå¨æï¼4ç§ï¼å
æ£å¸¸ååçé级èå´ |
| | | var changeRateUp = mutableMapOf( |
| | | var changeRateUp1 = mutableMapOf( |
| | | FactorType.PM25 to WindLevelCondition( |
| | | .0 to Double.MAX_VALUE, |
| | | .0 to 1.5, |
| | | 4.0 to Double.MAX_VALUE, |
| | | DistanceType.TYPE1, |
| | | 3 |
| | | ), |
| | | FactorType.PM10 to WindLevelCondition( |
| | | .0 to Double.MAX_VALUE, |
| | | .0 to 1.5, |
| | | 4.0 to Double.MAX_VALUE, |
| | | DistanceType.TYPE1, |
| | | 3 |
| | | ), |
| | | FactorType.VOC to WindLevelCondition( |
| | | .0 to Double.MAX_VALUE, |
| | | .0 to 1.5, |
| | | 6.0 to Double.MAX_VALUE, |
| | | DistanceType.TYPE1, |
| | | 1 |
| | | ), |
| | | ) |
| | | var changeRateUp2 = mutableMapOf( |
| | | FactorType.PM25 to WindLevelCondition( |
| | | 1.6 to 7.9, |
| | | 4.0 to Double.MAX_VALUE, |
| | | DistanceType.TYPE3, |
| | | 3 |
| | | ), |
| | | FactorType.PM10 to WindLevelCondition( |
| | | 1.6 to 7.9, |
| | | 4.0 to Double.MAX_VALUE, |
| | | DistanceType.TYPE3, |
| | | 3 |
| | | ), |
| | | FactorType.VOC to WindLevelCondition( |
| | | 1.6 to 7.9, |
| | | 6.0 to Double.MAX_VALUE, |
| | | DistanceType.TYPE3, |
| | | 1 |
| | | ), |
| | | ) |
| | | var changeRateUp3 = mutableMapOf( |
| | | FactorType.PM25 to WindLevelCondition( |
| | | 8.0 to 13.8, |
| | | 4.0 to Double.MAX_VALUE, |
| | | DistanceType.TYPE4, |
| | | 3 |
| | | ), |
| | | FactorType.PM10 to WindLevelCondition( |
| | | 8.0 to 13.8, |
| | | 4.0 to Double.MAX_VALUE, |
| | | DistanceType.TYPE4, |
| | | 3 |
| | | ), |
| | | FactorType.VOC to WindLevelCondition( |
| | | 8.0 to 13.8, |
| | | 6.0 to Double.MAX_VALUE, |
| | | DistanceType.TYPE4, |
| | | 1 |
| | | ), |
| | | ) |
| | | |
| | | /****æ°æ®å¿«éä¸é*****************************************************************************/ |
| | | /****æ°æ®å¿«éä¸éæé*****************************************************************************/ |
| | | // çæµå åå¨ä¸ä¸ªçæµå¨æï¼4ç§ï¼å
æ£å¸¸ååçé级èå´ |
| | | var changeRateDown = mutableMapOf( |
| | | var changeRateWarnDown = mutableMapOf( |
| | | FactorType.PM25 to WindLevelCondition( |
| | | .0 to Double.MAX_VALUE, |
| | | -Double.MAX_VALUE to -2.0, |
| | |
| | | 3 |
| | | ), |
| | | ) |
| | | |
| | | /****æ°æ®æä¸åè¶å¿æé*****************************************************************************/ |
| | | var changeRateWarnUp = mutableMapOf( |
| | | FactorType.PM25 to WindLevelCondition( |
| | | .0 to Double.MAX_VALUE, |
| | | 2.0 to 4.0, |
| | | DistanceType.TYPE1, |
| | | 3 |
| | | ), |
| | | FactorType.PM10 to WindLevelCondition( |
| | | .0 to Double.MAX_VALUE, |
| | | 2.0 to 4.0, |
| | | DistanceType.TYPE1, |
| | | 3 |
| | | ), |
| | | FactorType.VOC to WindLevelCondition( |
| | | .0 to Double.MAX_VALUE, |
| | | 3.0 to 6.0, |
| | | DistanceType.TYPE1, |
| | | 1 |
| | | ), |
| | | ) |
| | | } |
ÎļþÃû´Ó src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/exceptiontype/RTExcChangeRate.kt ÐÞ¸Ä |
| | |
| | | * @date 2025/6/10 |
| | | * @author feiyu02 |
| | | */ |
| | | open class RTExcChangeRate(config: RTExcWindLevelConfig) : |
| | | abstract class BaseRTExcChangeRate(config: RTExcWindLevelConfig) : |
| | | BaseExceptionContinuous<ExceptionTag, RTExcWindLevelConfig, PollutedClue>(config, ExceptionTag::class.java) { |
| | | |
| | | constructor(config: RTExcWindLevelConfig, callback: NewPolluteClueCallback) : this(config){ |
| | |
| | | |
| | | private var callback: NewPolluteClueCallback? = null |
| | | |
| | | open var changeRate = this.config.changeRateUp |
| | | abstract var changeRate: MutableMap<FactorType, RTExcWindLevelConfig.WindLevelCondition> |
| | | |
| | | override fun getExceptionType(): ExceptionType { |
| | | return ExceptionType.TYPE9 |
| | |
| | | |
| | | val rate = changeRate[f] |
| | | |
| | | val pValue = p.getByFactorType(f)!! |
| | | val nValue = n.getByFactorType(f)!! |
| | | // 计ç®åä¸ä¸ªæ°æ®ç¸æ¯äºåä¸ä¸ªæ°æ®çååéç |
| | | val v = (nValue - pValue) |
| | | |
| | | val b1 = if (rate != null) { |
| | | v in rate.mutationRate.first..rate.mutationRate.second |
| | | if (rate != null && n.windSpeed!! in rate.windSpeed.first..rate.windSpeed.second) { |
| | | val pValue = p.getByFactorType(f)!! |
| | | val nValue = n.getByFactorType(f)!! |
| | | // 计ç®åä¸ä¸ªæ°æ®ç¸æ¯äºåä¸ä¸ªæ°æ®çååéç |
| | | val v = (nValue - pValue) |
| | | val b1 = v in rate.mutationRate.first..rate.mutationRate.second |
| | | println("å åï¼${f.des}ï¼éçï¼${v}ï¼${b1}") |
| | | res[f] = b1 |
| | | } else { |
| | | false |
| | | res[f] = false |
| | | } |
| | | // val r = (nValue - pValue) / pValue |
| | | // val b1 = r >= con.mutationRate.first && r < con.mutationRate.second |
| | | println("å åï¼${f.des}ï¼éçï¼${v}ï¼${b1}") |
| | | res[f] = b1 |
| | | } |
| | | return res |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.biz.sourcetrace.exceptiontype |
| | | |
| | | import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig |
| | | import com.flightfeather.uav.socket.eunm.FactorType |
| | | |
| | | /** |
| | | * æ°æ®ååéçå¼å¸¸ |
| | | * @date 2025/6/10 |
| | | * @author feiyu02 |
| | | */ |
| | | open class RTExcChangeRate1 : BaseRTExcChangeRate { |
| | | |
| | | constructor(config: RTExcWindLevelConfig):super(config) |
| | | constructor(config: RTExcWindLevelConfig, callback: NewPolluteClueCallback) : super(config, callback) |
| | | |
| | | override var changeRate: MutableMap<FactorType, RTExcWindLevelConfig.WindLevelCondition> = this.config.changeRateUp1 |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.biz.sourcetrace.exceptiontype |
| | | |
| | | import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig |
| | | import com.flightfeather.uav.socket.eunm.FactorType |
| | | |
| | | /** |
| | | * æ°æ®ååéçå¼å¸¸ |
| | | * @date 2025/6/10 |
| | | * @author feiyu02 |
| | | */ |
| | | open class RTExcChangeRate4 : BaseRTExcChangeRate { |
| | | |
| | | constructor(config: RTExcWindLevelConfig):super(config) |
| | | constructor(config: RTExcWindLevelConfig, callback: NewPolluteClueCallback) : super(config, callback) |
| | | |
| | | override var changeRate: MutableMap<FactorType, RTExcWindLevelConfig.WindLevelCondition> = this.config.changeRateUp2 |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.biz.sourcetrace.exceptiontype |
| | | |
| | | import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig |
| | | import com.flightfeather.uav.socket.eunm.FactorType |
| | | |
| | | /** |
| | | * æ°æ®ååéçå¼å¸¸ |
| | | * @date 2025/6/10 |
| | | * @author feiyu02 |
| | | */ |
| | | open class RTExcChangeRate6 : BaseRTExcChangeRate { |
| | | |
| | | constructor(config: RTExcWindLevelConfig):super(config) |
| | | constructor(config: RTExcWindLevelConfig, callback: NewPolluteClueCallback) : super(config, callback) |
| | | |
| | | override var changeRate: MutableMap<FactorType, RTExcWindLevelConfig.WindLevelCondition> = this.config.changeRateUp3 |
| | | } |
| | |
| | | * @date 2025/7/3 |
| | | * @author feiyu02 |
| | | */ |
| | | class RTWarnChangeRate : RTExcChangeRate { |
| | | class RTWarnChangeRate : BaseRTExcChangeRate { |
| | | constructor(config: RTExcWindLevelConfig):super(config) |
| | | constructor(config: RTExcWindLevelConfig, callback: NewPolluteClueCallback) : super(config, callback) |
| | | |
| | |
| | | return ExceptionType.TYPE10 |
| | | } |
| | | |
| | | override var changeRate = config.changeRateDown |
| | | override var changeRate = config.changeRateWarnDown |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.biz.sourcetrace.exceptiontype |
| | | |
| | | import com.flightfeather.uav.biz.dataanalysis.model.ExceptionType |
| | | import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig |
| | | |
| | | /** |
| | | * æ°æ®æä¸åè¶å¿æé |
| | | * @date 2025/7/3 |
| | | * @author feiyu02 |
| | | */ |
| | | class RTWarnChangeRate2 : RTExcChangeRate1 { |
| | | constructor(config: RTExcWindLevelConfig):super(config) |
| | | constructor(config: RTExcWindLevelConfig, callback: NewPolluteClueCallback) : super(config, callback) |
| | | |
| | | override fun getExceptionType(): ExceptionType { |
| | | return ExceptionType.TYPE11 |
| | | } |
| | | |
| | | override var changeRate = config.changeRateWarnUp |
| | | } |
| | |
| | | import com.flightfeather.uav.common.utils.DateUtil |
| | | import com.flightfeather.uav.domain.entity.BaseRealTimeData |
| | | import com.flightfeather.uav.lightshare.bean.DataVo |
| | | import com.flightfeather.uav.socket.eunm.FactorType |
| | | import java.util.Date |
| | | import kotlin.math.round |
| | | |
| | | /** |
| | | * æ±¡ææ°æ® |
| | |
| | | |
| | | calPer() |
| | | calRate() |
| | | |
| | | val s = dataSummary(exceptionData, factor.main) |
| | | avg = s.first |
| | | min = s.second |
| | | max = s.third |
| | | } |
| | | |
| | | var deviceCode: String? = null |
| | |
| | | var avgPer: Double? = null |
| | | // å åé级平åååéç |
| | | var avgRate: Double? = null |
| | | |
| | | var avg: Double? = null |
| | | var min: Double? = null |
| | | var max: Double? = null |
| | | |
| | | // åçæ¬¡æ° |
| | | var times: Int? = null |
| | |
| | | } |
| | | avgRate = total / (list.size - 1) |
| | | } |
| | | |
| | | private fun dataSummary(exceptionData: List<BaseRealTimeData?>, factorType: FactorType): Triple<Double, Double, |
| | | Double> { |
| | | var min = -1.0 |
| | | var max = -1.0 |
| | | var total = .0 |
| | | var count = 0 |
| | | exceptionData.forEach { |
| | | val value = it?.getByFactorType(factorType)?.toDouble() ?: return@forEach |
| | | if (min == -1.0 || min > value) { |
| | | min = round(value * 1000) / 1000 |
| | | } |
| | | if (max == -1.0 || max < value) { |
| | | max = round(value * 1000) / 1000 |
| | | } |
| | | total += value |
| | | count++ |
| | | } |
| | | val avg = if (count == 0) .0 else round(total / count * 1000) / 1000 |
| | | return Triple(avg, min, max) |
| | | } |
| | | } |
| | |
| | | package com.flightfeather.uav.biz.sourcetrace.model |
| | | |
| | | import com.flightfeather.uav.common.utils.DateUtil |
| | | import com.flightfeather.uav.common.utils.MapUtil |
| | | import com.flightfeather.uav.domain.entity.SceneInfo |
| | | import com.flightfeather.uav.domain.repository.SceneInfoRep |
| | |
| | | */ |
| | | |
| | | // 溯æºä¼ä¸ |
| | | var sceneList: List<SceneInfoVo?>? = null |
| | | var sceneList: List<SceneInfoVo>? = null |
| | | |
| | | // æº¯æºæ¨çç»è®º |
| | | var conclusion: String? = null |
| | |
| | | // æ ¹æ®æ±¡æå åçé级ï¼è®¡ç®ä¸»è¦ç污æåºæ¯ç±»åï¼çéç»æ |
| | | val mainSceneType = calSceneType(pollutedData) |
| | | if (mainSceneType != null) { |
| | | this.conclusion = mainSceneType.first |
| | | // this.conclusion = mainSceneType.first |
| | | result = result.filter { |
| | | val r = mainSceneType.second.find { s-> |
| | | s.value == it.typeId.toInt() |
| | |
| | | |
| | | this.sceneList = findClosestStation(sceneInfoRep, result) |
| | | |
| | | val txt = summaryTxt(pollutedData, this.sceneList!!) |
| | | this.conclusion = txt |
| | | } |
| | | |
| | | /** |
| | |
| | | it.pm25!! / it.pm10!! |
| | | }.average() |
| | | val str = |
| | | "PM2.5é级为${pm25Avg}μg/m³ï¼PM10é级为${pm25Avg}μg/m³ï¼PM2.5å PM10çæ¯é为${round(percentageAvg * 100)}%" |
| | | "PM2.5é级为${pm25Avg}μg/m³ï¼PM10é级为${pm10Avg}μg/m³ï¼PM2.5å PM10çæ¯é为${round(percentageAvg * 100)}%" |
| | | return if (percentageAvg > 0.666) { |
| | | "${str}ï¼æ¯éè¾å¤§ï¼æ±¡ææºä»¥é¤é¥®ä¸ºä¸»ï¼å·¥å°æ¬¡ä¹" to |
| | | listOf(SceneType.TYPE1, SceneType.TYPE2, SceneType.TYPE3, SceneType.TYPE14, SceneType.TYPE5) |
| | |
| | | return@map vo |
| | | } |
| | | } |
| | | |
| | | private fun summaryTxt(pollutedData: PollutedData, sceneList: List<SceneInfoVo>): String { |
| | | // pollutedData.exception |
| | | // pollutedData.selectedFactor?.main |
| | | val st = DateUtil.instance.getTime(pollutedData.startTime) |
| | | val et = DateUtil.instance.getTime(pollutedData.endTime) |
| | | var txt = |
| | | "${pollutedData.selectedFactor?.main?.des}å¨${st}è³${et}ä¹é´ï¼åºç°${pollutedData.exception}ï¼æä½å¼ä¸º${ |
| | | pollutedData |
| | | .min |
| | | }ï¼æé«å¼ä¸º${pollutedData.max}" |
| | | if (sceneList.isEmpty()) { |
| | | txt += ("ï¼å¯è½åå¨éèé£é©æºã") |
| | | } else { |
| | | txt += ("ï¼åç°${sceneList.size}个é£é©æºï¼å
å«") |
| | | |
| | | val sizeMap = mutableMapOf<String, Int>() |
| | | sceneList.forEach { |
| | | if (!sizeMap.containsKey(it.type)) { |
| | | sizeMap[it.type] = 0 |
| | | } |
| | | sizeMap[it.type] = sizeMap[it.type]!! + 1 |
| | | } |
| | | sizeMap.forEach { (t, u) -> |
| | | txt += ("${u}个${t}ï¼") |
| | | } |
| | | txt = txt.replaceRange(txt.length - 1, txt.length, "ã") |
| | | } |
| | | |
| | | return txt |
| | | } |
| | | } |
| | |
| | | val closetScene = result.sortedSceneList?.first() |
| | | // èµ°èªè·¯çº¿è°æ´å»ºè®® |
| | | result.advice = |
| | | "æ ¹æ®${sT}è³${eT}ç${clueList.size}æ¡æº¯æºåçï¼é£é©æºã" + |
| | | "${closetScene?.first?.name}ãè¢«å¤æ¬¡æº¯æºï¼å
·æè¾é«æ±¡æé£é©ï¼ç°æä¾æ°çèµ°èªæ¨è路线ï¼å¯ç»è¿è¯¥æ±¡ææºã" |
| | | "æ ¹æ®${sT}è³${eT}ç${clueList.size}个溯æºåçï¼é£é©æºã" + |
| | | "${closetScene?.first?.name}ãè¢«å¤æ¬¡æº¯æºï¼å
·æè¾é«æ±¡æé£é©ï¼ç°æä¾ææ°ç´è¾¾èµ°èªè·¯çº¿ã" |
| | | |
| | | val lastP = realTimeDataList.last() |
| | | // 建议对åºçæ°æ®éæ ·æ¶é´ |
| | |
| | | * @param date æ¥æ |
| | | * @return æ¶é´ |
| | | */ |
| | | fun getTime(date: Date): String? { |
| | | fun getTime(date: Date?): String? { |
| | | return dateToString(date, DateStyle.HH_MM_SS) |
| | | } |
| | | |