feiyu02
2025-03-28 8cf331411ea79c0d83e00657ed1374b29b09f4d7
1. 新增走航卫星网格数据之间的融合功能
已修改5个文件
已添加1个文件
122 ■■■■ 文件已修改
src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/GridDataDetailMixVo.kt 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteDataCalculateService.kt 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteTelemetryService.kt 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImpl.kt 66 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/web/SatelliteTelemetryController.kt 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt
@@ -114,7 +114,7 @@
        return res
    }
    fun fetchGridDataDetail(dataId: Int?, groupId: Int?, cellId: Int?): List<GridDataDetail?> {
    fun fetchGridDataDetail(dataId: Int? = null, groupId: Int? = null, cellId: Int? = null): List<GridDataDetail?> {
        return gridDataDetailMapper.selectByExample(Example(GridDataDetail::class.java).apply {
            createCriteria().andEqualTo("dataId", dataId)
                .andEqualTo("groupId", groupId)
src/main/kotlin/com/flightfeather/uav/lightshare/bean/GridDataDetailMixVo.kt
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,14 @@
package com.flightfeather.uav.lightshare.bean
import com.flightfeather.uav.domain.entity.GridDataDetail
/**
 * ç½‘格数据融合结果
 * @date 2025/3/28
 * @author feiyu02
 */
class GridDataDetailMixVo : GridDataDetail() {
    // æ˜¯å¦æ˜¯èžåˆåŽçš„网格监测数据
    var mixData: Boolean = false
    var originDataList: MutableList<GridDataDetail> = mutableListOf()
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteDataCalculateService.kt
@@ -2,6 +2,7 @@
import com.flightfeather.uav.domain.entity.GridCell
import com.flightfeather.uav.domain.entity.GridDataDetail
import com.flightfeather.uav.lightshare.bean.GridDataDetailMixVo
/**
 *
@@ -38,6 +39,14 @@
    fun dataFusion(missionCode: String, groupId: Int): List<GridDataDetail?>
    /**
     * èµ°èˆªæ•°æ®èžåˆ
     * @param groupId ä½¿ç”¨çš„网格组id
     * @param dataIdList èžåˆçš„æ•°æ®id索引数组
     */
    // Fixme 2025.3.28: éœ€è¦å’Œ[SatelliteTelemetryService.mixGridData]函数合并
    fun mixGridData(groupId: Int, dataIdList: List<Int>): List<GridDataDetailMixVo>
    /**
     * å°†èµ°èˆªç½‘格数据生成对应的热力网格图
     * @param groupId ä½¿ç”¨çš„网格组id
     * @param gridDataDetailList ä½¿ç”¨çš„走航网格数据
src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteTelemetryService.kt
@@ -40,6 +40,7 @@
    /**
     * æ•°æ®èžåˆ
     */
    // Fixme 2025.3.28: éœ€è¦å’Œ[SatelliteDataCalculateService.mixGridData]函数合并
    fun mixGridData(dataIdList: List<Int>): List<GridData?>
    @Throws(BizException::class)
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImpl.kt
@@ -2,13 +2,13 @@
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.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
import com.flightfeather.uav.lightshare.bean.GridDataDetailMixVo
import com.flightfeather.uav.lightshare.eunm.GridType
import com.flightfeather.uav.lightshare.eunm.SatelliteDataType
import com.flightfeather.uav.lightshare.service.SatelliteDataCalculateService
@@ -108,14 +108,15 @@
    }
    @Transactional
    override fun splitData(groupId: Int, dataId:Int): List<GridDataDetail?> {
    override fun splitData(groupId: Int, dataId: Int): List<GridDataDetail?> {
        // æ£€æŸ¥æ˜¯å¦æ˜¯ç»†åˆ†ç½‘格类型
        val gridGroup = satelliteGridRep.fetchGridGroup(groupId) ?: throw BizException("该网格组不存在,无法进行细分网格数据映射")
        val gridGroup =
            satelliteGridRep.fetchGridGroup(groupId) ?: throw BizException("该网格组不存在,无法进行细分网格数据映射")
        if (gridGroup.type != GridType.Sub.name.lowercase()) throw BizException("该网格组不是细分网格类型存在,无法进行细分网格数据映射")
        val subGridCellList = satelliteGridRep.fetchGridCell(groupId)
        val originGridData = satelliteGridRep.fetchGridData(dataId)
        val originGridDataDetailList = satelliteGridRep.fetchGridDataDetail(dataId, null, null)
        val originGridDataDetailList = satelliteGridRep.fetchGridDataDetail(dataId)
        val subGridData = GridData().apply {
            this.groupId = groupId
@@ -181,8 +182,7 @@
            return gridDataDetailList
        } else {
            val oldGridData = oldGridDataList.first()
            val oldGridDataDetailList = satelliteGridRep.fetchGridDataDetail(oldGridData?.id, oldGridData?.groupId,
                null)
            val oldGridDataDetailList = satelliteGridRep.fetchGridDataDetail(oldGridData?.id, oldGridData?.groupId)
            // æŸ¥è¯¢ç½‘格单元格信息
            val gridCellList = satelliteGridRep.fetchGridCell(groupId)
            // å°†èµ°èˆªæ•°æ®å’Œå«æ˜Ÿç½‘格进行融合计算
@@ -199,7 +199,55 @@
        }
    }
    override fun buildHeatmap(groupId: Int, gridDataDetailList: List<GridDataDetail>, searchLength:Int): List<GridDataDetail> {
    override fun mixGridData(groupId: Int, dataIdList: List<Int>): List<GridDataDetailMixVo> {
        // èŽ·å–æ‰€ä½¿ç”¨çš„ç½‘æ ¼ç»„ç½‘æ ¼ä¿¡æ¯
        val gridCellList = satelliteGridRep.fetchGridCell(groupId)
        val gridDataDetailMap = mutableMapOf<Int?, MutableList<GridDataDetail>>()
        // å½’集所有相同单元网格的数据
        dataIdList.forEach { id ->
            satelliteGridRep.fetchGridDataDetail(id, groupId).forEach gdd@{ gdd ->
                if (gdd == null) return@gdd
                if (!gridDataDetailMap.containsKey(gdd.cellId)) {
                    gridDataDetailMap[gdd.cellId] = mutableListOf()
                }
                gridDataDetailMap[gdd.cellId]?.add(gdd)
            }
        }
        // å°†æ‰€æœ‰ç»“果格式化,同时重叠网格进行监测数据均值计算
        val result = mutableListOf<GridDataDetailMixVo>()
        gridDataDetailMap.forEach { (_, v) ->
            val target = GridDataDetailMixVo()
            if (v.size == 1) {
                BeanUtils.copyProperties(v[0], target)
            } else {
                BeanUtils.copyProperties(v.avg(), target)
                target.mixData = true
                target.originDataList = v
            }
            target.apply {
                this.dataId = v.first().dataId
                this.groupId = v.first().groupId
                this.cellId = v.first().cellId
            }
            result.add(target)
        }
        result.sortBy { it.pm25 }
        result.forEachIndexed { index, d ->
            d.rank = index + 1
        }
        result.sortBy { it.cellId }
        return result
    }
    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: æ­¤å¤„根据现有的网格信息设计方式,使用临时的参数,后续将网格通过二维坐标形式表示,此处参数去除
@@ -208,8 +256,8 @@
        val resMap = mutableMapOf<Int, MutableList<GridDataDetail>>()
        // å¾ªçŽ¯è®¡ç®—æ¯ä¸ªç½‘æ ¼çš„å‘¨è¾¹æ‰©æ•£ç½‘æ ¼ç»“æžœ
        gridDataDetailList.forEach {gdd ->
            SatelliteGridManage.heatMap(gdd, gridCellList, option, searchLength).forEach {r ->
        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()
src/main/kotlin/com/flightfeather/uav/lightshare/web/SatelliteTelemetryController.kt
@@ -24,7 +24,7 @@
@RequestMapping("air/satellite")
class SatelliteTelemetryController(
    private val satelliteTelemetryService: SatelliteTelemetryService,
    private val satelliteDataCalculateService: SatelliteDataCalculateService
    private val satelliteDataCalculateService: SatelliteDataCalculateService,
) {
    @ApiOperation(value = "获取网格组信息")
@@ -33,7 +33,7 @@
        @RequestBody areaVo: AreaVo,
        @RequestParam(required = false) type: String?,
        @RequestParam("page", required = false) page: Int?,
        @RequestParam("per_page", required = false) perPage: Int?
        @RequestParam("per_page", required = false) perPage: Int?,
    ) = resPack { satelliteTelemetryService.fetchGridGroup(areaVo, type, page, perPage) }
    @ApiOperation(value = "获取网格组内具体网格信息")
@@ -48,7 +48,10 @@
        @ApiParam("网格组id") @RequestParam groupId: Int,
        @ApiParam("遥测数据时间")
        @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") dataTime: LocalDateTime?,
        @ApiParam("遥测数据类型", allowableValues = "0:原始卫星遥测数据;1:融合数据") @RequestParam(required = false) type: Int?,
        @ApiParam(
            "遥测数据类型",
            allowableValues = "0:原始卫星遥测数据;1:融合数据"
        ) @RequestParam(required = false) type: Int?,
    ) = resPack { satelliteTelemetryService.fetchGridData(groupId, dataTime, type) }
    @ApiOperation(value = "获取网格组下的卫星遥测具体数据")
@@ -65,7 +68,7 @@
        @ApiParam("网格组id") @RequestParam groupId: Int,
        @ApiParam("遥测数据时间")
        @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") dateTime: LocalDateTime,
        @RequestBody gridDataDetail: List<GridDataDetail>
        @RequestBody gridDataDetail: List<GridDataDetail>,
    ) = resPack {
        satelliteTelemetryService.createGridDataAndDataDetail(groupId, dateTime, gridDataDetail)
    }
@@ -74,7 +77,7 @@
    @ApiOperation(value = "多次走航数据进行融合计算")
    @PostMapping("/grid/data/mix")
    fun mixGridData(
        @ApiParam("原始数据id数组") @RequestBody dataIdList: List<Int>
        @ApiParam("原始数据id数组") @RequestBody dataIdList: List<Int>,
    ) = resPack { satelliteTelemetryService.mixGridData(dataIdList) }
@@ -92,7 +95,8 @@
    @ApiOperation(value = "下载卫星遥测PM2.5结果数据导入模板")
    @GetMapping("/import/grid/data/download/template")
    fun downloadTemplate(@ApiIgnore response: HttpServletResponse) = satelliteTelemetryService.downloadTemplate(response)
    fun downloadTemplate(@ApiIgnore response: HttpServletResponse) =
        satelliteTelemetryService.downloadTemplate(response)
    @ApiOperation(value = "导入卫星遥测Aod结果数据")
    @PostMapping("/import/grid/aod")
@@ -108,7 +112,8 @@
    @ApiOperation(value = "下载卫星遥测Aod结果数据导入模板")
    @GetMapping("/import/grid/aod/download/template")
    fun downloadAODTemplate(@ApiIgnore response: HttpServletResponse) = satelliteTelemetryService.downloadAODTemplate(response)
    fun downloadAODTemplate(@ApiIgnore response: HttpServletResponse) =
        satelliteTelemetryService.downloadAODTemplate(response)
    /**AOD数据相关**************************************************************/
@@ -145,11 +150,18 @@
        @ApiParam("网格组id") @RequestParam groupId: Int,
    ) = resPack { satelliteDataCalculateService.dataFusion(missionCode, groupId) }
    @ApiOperation(value = "进行走航融合产品的融合分析")
    @PostMapping("/product/underway/mix")
    fun mixGridData(
        @ApiParam("网格组id") @RequestParam groupId: Int,
        @ApiParam("需要融合的数据id") @RequestBody dataIdList: List<Int>,
    ) = resPack { satelliteDataCalculateService.mixGridData(groupId, dataIdList) }
    @ApiOperation(value = "生成走航热力图")
    @PostMapping("/product/underway/heatmap/build")
    fun buildUnderwayHeatmap(
        @ApiParam("使用的网格组id") @RequestParam groupId: Int,
        @ApiParam("搜索网格距离") @RequestParam searchLength:Int,
        @ApiParam("使用的走航网格数据") @RequestBody gridDataDetailList: List<GridDataDetail>
        @ApiParam("搜索网格距离") @RequestParam searchLength: Int,
        @ApiParam("使用的走航网格数据") @RequestBody gridDataDetailList: List<GridDataDetail>,
    ) = resPack { satelliteDataCalculateService.buildHeatmap(groupId, gridDataDetailList, searchLength) }
}