From 8cf331411ea79c0d83e00657ed1374b29b09f4d7 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期五, 28 三月 2025 17:46:30 +0800 Subject: [PATCH] 1. 新增走航卫星网格数据之间的融合功能 --- src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt | 2 src/main/kotlin/com/flightfeather/uav/lightshare/bean/GridDataDetailMixVo.kt | 14 ++++ src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImpl.kt | 66 +++++++++++++++++++--- src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteTelemetryService.kt | 1 src/main/kotlin/com/flightfeather/uav/lightshare/web/SatelliteTelemetryController.kt | 30 +++++++--- src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteDataCalculateService.kt | 9 +++ 6 files changed, 103 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt b/src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt index a5439b5..202983d 100644 --- a/src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt +++ b/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) diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/bean/GridDataDetailMixVo.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/bean/GridDataDetailMixVo.kt new file mode 100644 index 0000000..2181253 --- /dev/null +++ b/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() +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteDataCalculateService.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteDataCalculateService.kt index 88eb303..d858605 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteDataCalculateService.kt +++ b/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 铻嶅悎鐨勬暟鎹甶d绱㈠紩鏁扮粍 + */ + // Fixme 2025.3.28: 闇�瑕佸拰[SatelliteTelemetryService.mixGridData]鍑芥暟鍚堝苟 + fun mixGridData(groupId: Int, dataIdList: List<Int>): List<GridDataDetailMixVo> + + /** * 灏嗚蛋鑸綉鏍兼暟鎹敓鎴愬搴旂殑鐑姏缃戞牸鍥� * @param groupId 浣跨敤鐨勭綉鏍肩粍id * @param gridDataDetailList 浣跨敤鐨勮蛋鑸綉鏍兼暟鎹� diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteTelemetryService.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteTelemetryService.kt index 0be52ab..d75f91b 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteTelemetryService.kt +++ b/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) diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImpl.kt index c260d11..ece5805 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImpl.kt +++ b/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>>() // 寰幆璁$畻姣忎釜缃戞牸鐨勫懆杈规墿鏁g綉鏍肩粨鏋� - 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() diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/web/SatelliteTelemetryController.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/web/SatelliteTelemetryController.kt index c431269..20c487e 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/web/SatelliteTelemetryController.kt +++ b/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("缃戞牸缁刬d") @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("缃戞牸缁刬d") @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("缃戞牸缁刬d") @RequestParam groupId: Int, ) = resPack { satelliteDataCalculateService.dataFusion(missionCode, groupId) } + @ApiOperation(value = "杩涜璧拌埅铻嶅悎浜у搧鐨勮瀺鍚堝垎鏋�") + @PostMapping("/product/underway/mix") + fun mixGridData( + @ApiParam("缃戞牸缁刬d") @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) } } \ No newline at end of file -- Gitblit v1.9.3