| | |
| | | package com.flightfeather.uav.lightshare.service.impl |
| | | |
| | | import com.flightfeather.uav.biz.satellite.GridGroupOption |
| | | import com.flightfeather.uav.biz.satellite.SatelliteGridManage |
| | | import com.flightfeather.uav.biz.satellite.SatelliteGridUtil |
| | | import com.flightfeather.uav.common.exception.BizException |
| | | import com.flightfeather.uav.domain.entity.GridCell |
| | | import com.flightfeather.uav.domain.entity.GridData |
| | | import com.flightfeather.uav.domain.entity.GridDataDetail |
| | | import com.flightfeather.uav.domain.entity.GridGroup |
| | | import com.flightfeather.uav.common.utils.TimeUtil |
| | | import com.flightfeather.uav.domain.entity.* |
| | | import com.flightfeather.uav.domain.repository.MissionRep |
| | | import com.flightfeather.uav.domain.repository.RealTimeDataRep |
| | | import com.flightfeather.uav.domain.repository.SatelliteGridRep |
| | |
| | | val mission = missionRep.findOne(missionCode) ?: throw BizException("任务不存在") |
| | | val data = realTimeDataRep.fetchData(mission) |
| | | |
| | | // 查找是否已有走航融合记录 |
| | | val oldGridDataList = satelliteGridRep.fetchGridData(GridData().apply { |
| | | this.groupId = groupId |
| | | mixDataId = missionCode |
| | | this.type = SatelliteDataType.Monitor.value.toByte() |
| | | }) |
| | | |
| | | if (oldGridDataList.isEmpty()) { |
| | |
| | | this.groupId = groupId |
| | | dataTime = mission.startTime |
| | | type = SatelliteDataType.Monitor.value.toByte() |
| | | mixDataId = mission.missionCode |
| | | this.missionCode = mission.missionCode |
| | | // Fixme 2025.3.27: 行政区划在走航任务添加对应字段后进行赋值 |
| | | provinceCode |
| | | provinceName |
| | | cityCode |
| | | cityName |
| | | districtCode |
| | | districtName = mission.districtName |
| | | // Fixme 2025.3.27: 所属监测点区域目前需要通过用户选择确定 |
| | | zone |
| | | pollutionDegreeIndex |
| | | pollutionDegree |
| | | |
| | | val period = TimeUtil.getDayTimeTag(mission.startTime, mission.endTime) |
| | | dayTimePeriod = period?.first |
| | | dayTimePeriodStart = period?.second |
| | | dayTimePeriodEnd = period?.third |
| | | } |
| | | satelliteGridRep.insertGridData(newGridData) |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | override fun buildHeatmap(groupId: Int, gridDataDetail: List<GridDataDetail>): List<GridDataDetail> { |
| | | override fun buildHeatmap(groupId: Int, gridDataDetailList: List<GridDataDetail>, searchLength:Int): List<GridDataDetail> { |
| | | val gridCellList = satelliteGridRep.fetchGridCell(groupId) |
| | | val originCellIdList = gridDataDetailList.map { it.cellId } |
| | | // Fixme 2025.3.24: 此处根据现有的网格信息设计方式,使用临时的参数,后续将网格通过二维坐标形式表示,此处参数去除 |
| | | val option = GridGroupOption(120, 90, 10, 10) |
| | | |
| | | val resMap = mutableMapOf<Int, MutableList<GridDataDetail>>() |
| | | |
| | | // 循环计算每个网格的周边扩散网格结果 |
| | | gridDataDetailList.forEach {gdd -> |
| | | SatelliteGridManage.heatMap(gdd, gridCellList, option, searchLength).forEach {r -> |
| | | if (!originCellIdList.contains(r.cellId)) { |
| | | if (!resMap.containsKey(r.cellId)) { |
| | | resMap[r.cellId] = mutableListOf() |
| | | } |
| | | resMap[r.cellId]?.add(r) |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 将所有结果格式化,同时重叠网格进行监测数据均值计算 |
| | | val result = mutableListOf<GridDataDetail>() |
| | | resMap.forEach { (_, v) -> |
| | | result.add(v.avg().apply { |
| | | this.dataId = v.first().dataId |
| | | this.groupId = v.first().groupId |
| | | this.cellId = v.first().cellId |
| | | }) |
| | | } |
| | | result.addAll(gridDataDetailList) |
| | | |
| | | return result |
| | | } |
| | | } |