| | |
| | | import com.flightfeather.uav.biz.FactorFilter |
| | | import com.flightfeather.uav.biz.dataanalysis.model.ExceptionTag |
| | | import com.flightfeather.uav.biz.dataanalysis.model.ExceptionType |
| | | import com.flightfeather.uav.biz.sourcetrace.config.RTExcWindLevelConfig |
| | | import com.flightfeather.uav.common.utils.DateUtil |
| | | import com.flightfeather.uav.domain.entity.BaseRealTimeData |
| | | import com.flightfeather.uav.domain.entity.avg |
| | |
| | | constructor(dataIndexList: List<Int>, factorType: FactorType){ |
| | | this.dataIndexList = dataIndexList |
| | | this.factorType = factorType |
| | | val first = getFirstDataValue()?.toDouble() |
| | | val last = getLastDataValue()?.toDouble() |
| | | val first = firstDataValue()?.toDouble() |
| | | val last = lastDataValue()?.toDouble() |
| | | if (first != null && last != null) { |
| | | per = round((last - first) / first * 100) / 100 |
| | | rate = round((last - first) / DEFAULT_PERIOD * 100) / 100 |
| | |
| | | * 获取异常数据的第一个数据 |
| | | * !!!!第一个数据其实是首个异常数据的前一个数据值!!!! |
| | | */ |
| | | fun getFirstData(): BaseRealTimeData? { |
| | | fun firstData(): BaseRealTimeData? { |
| | | return dataIndexList?.firstOrNull()?.let { |
| | | val i = if (it > 0) it - 1 else it |
| | | historyDataList[i].toBaseRealTimeData(BaseRealTimeData::class.java) |
| | | } |
| | | } |
| | | fun getFirstDataValue(): Float? { |
| | | return getFirstData()?.getByFactorType(factorType) |
| | | fun firstDataValue(): Float? { |
| | | return firstData()?.getByFactorType(factorType) |
| | | } |
| | | |
| | | /** |
| | | * 获取异常数据的最后一个数据 |
| | | */ |
| | | fun getLastData(): BaseRealTimeData? { |
| | | fun lastData(): BaseRealTimeData? { |
| | | return dataIndexList?.lastOrNull()?.let { |
| | | historyDataList[it].toBaseRealTimeData(BaseRealTimeData::class.java) |
| | | } |
| | | } |
| | | fun getLastDataValue(): Float? { |
| | | return getLastData()?.getByFactorType(factorType) |
| | | fun lastDataValue(): Float? { |
| | | return lastData()?.getByFactorType(factorType) |
| | | } |
| | | } |
| | | |
| | |
| | | /** |
| | | * 获取异常数据 |
| | | */ |
| | | fun getExceptionData(): List<BaseRealTimeData>? { |
| | | fun exceptionData(): List<BaseRealTimeData>? { |
| | | return dataIndexList?.map { historyDataList[it].toBaseRealTimeData(BaseRealTimeData::class.java) } |
| | | } |
| | | |
| | |
| | | * 获取异常数据分段情况 |
| | | * 将连续的异常数据分为一组 |
| | | */ |
| | | fun getExceptionDataGroup(): List<List<Int>> { |
| | | fun exceptionDataGroup(): List<List<Int>> { |
| | | val res = mutableListOf<MutableList<Int>>() |
| | | var curGroup = mutableListOf<Int>() |
| | | var lastIndex = -2 |
| | |
| | | min = s.second |
| | | max = s.third |
| | | |
| | | excGroup = getExceptionDataGroup().map { ExcGroup(it, e.first.main) } |
| | | excGroup = exceptionDataGroup().map { ExcGroup(it, e.first.main) } |
| | | avgPer = excGroup?.mapNotNull { it.per }?.average() |
| | | if (avgPer?.isNaN() == true) avgPer = .0 |
| | | avgRate = excGroup?.mapNotNull { it.rate }?.average() |
| | | if (avgRate?.isNaN() == true) avgRate = .0 |
| | | } |
| | | } |
| | | } |
| | |
| | | return factors |
| | | } |
| | | |
| | | fun getExceptionAvgData(): BaseRealTimeData { |
| | | val exceptionDataList = statisticMap.flatMap { it.value.getExceptionData() ?: emptyList() } |
| | | fun exceptionAvgData(): BaseRealTimeData { |
| | | val exceptionDataList = statisticMap.flatMap { it.value.exceptionData() ?: emptyList() } |
| | | val avgData = exceptionDataList.avg() |
| | | return avgData |
| | | } |
| | | /** |
| | | * 获取异常数据中心坐标(异常数据中经度纬度的平均值) |
| | | */ |
| | | fun getExceptionCenter(): Pair<Double, Double>? { |
| | | val avgData = getExceptionAvgData() |
| | | fun exceptionCenter(): Pair<Double, Double>? { |
| | | val avgData = exceptionAvgData() |
| | | val wgs84Lng = avgData.longitude?.toDouble() |
| | | val wgs84Lat = avgData.latitude?.toDouble() |
| | | return if (wgs84Lng == null || wgs84Lat == null) null else Pair(wgs84Lng, wgs84Lat) |