From db447bb757b51f8d03e62d6ae4f183b4608723ef Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期五, 07 三月 2025 17:10:43 +0800 Subject: [PATCH] 卫星遥测系统相关接口新增及调整 --- src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt | 18 ++ src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImpl.kt | 53 ++++++-- src/main/kotlin/com/flightfeather/uav/lightshare/web/SceneController.kt | 7 + src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImplTest.kt | 26 +++ src/main/kotlin/com/flightfeather/uav/lightshare/service/SceneService.kt | 3 src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt | 10 + src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt | 56 +++++++- src/test/kotlin/com/flightfeather/uav/SatelliteDebugData.kt | 68 +++++++++++ src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteTelemetryService.kt | 17 ++ src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SceneServiceImpl.kt | 7 + src/main/kotlin/com/flightfeather/uav/lightshare/web/SatelliteTelemetryController.kt | 69 +++++++++- 11 files changed, 286 insertions(+), 48 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt b/src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt index 36c85c7..bea89eb 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/satellite/SatelliteGridManage.kt @@ -229,7 +229,7 @@ */ fun dataFusion( realTimeDataList: List<BaseRealTimeData>, - gridData: GridData, + gridData: GridData?, gridCellList: List<GridCell?>, ): List<GridDataDetail> { // 閬嶅巻璧拌埅鐩戞祴鏁版嵁锛岃绠楁瘡涓偣鎵�鍦ㄧ綉鏍� @@ -251,7 +251,7 @@ dataMap.forEach { (k, v) -> val avgData = v.avg() val dataDetail = GridDataDetail().apply { - dataId = gridData.id + dataId = gridData?.id groupId = k.groupId cellId = k.cellIndex pm25 = avgData.pm25 @@ -260,6 +260,12 @@ gridDataDetailList.add(dataDetail) } + gridDataDetailList.sortBy { it.pm25 } + gridDataDetailList.forEachIndexed { index, d -> + d.rank = index + 1 + } + gridDataDetailList.sortBy { it.cellId } + return gridDataDetailList } 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 3fcdb97..a5439b5 100644 --- a/src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt +++ b/src/main/kotlin/com/flightfeather/uav/domain/repository/SatelliteGridRep.kt @@ -28,13 +28,14 @@ private val gridAodDetailMapper: GridAodDetailMapper, ) { - fun fetchGridGroup(areaVo: AreaVo): List<GridGroup?> { + fun fetchGridGroup(areaVo: AreaVo, type: String?): List<GridGroup?> { return gridGroupMapper.selectByExample(Example(GridGroup::class.java).apply { createCriteria() .andEqualTo("provinceCode", areaVo.provinceCode).andEqualTo("provinceName", areaVo.provinceName) .andEqualTo("cityCode", areaVo.cityCode).andEqualTo("cityName", areaVo.cityName) .andEqualTo("districtCode", areaVo.districtCode).andEqualTo("districtName", areaVo.districtName) .andEqualTo("townCode", areaVo.townCode).andEqualTo("townName", areaVo.townName) + .andEqualTo("type", type) }) } @@ -66,6 +67,8 @@ } } + /*****************************************************************/ + fun fetchGridCell(groupId: Int): List<GridCell?> { return gridCellMapper.selectByExample(Example(GridCell::class.java).apply { createCriteria().andEqualTo("groupId", groupId) @@ -76,6 +79,8 @@ fun insertGridCell(gridCellList: List<GridCell?>): Int { return gridCellMapper.insertList(gridCellList) } + + /*****************************************************************/ fun fetchGridData(groupId: Int, dataTime: LocalDateTime?, type: Int?): List<GridData?> { return gridDataMapper.selectByExample(Example(GridData::class.java).apply { @@ -101,7 +106,15 @@ return gridDataDetailMapper.insertList(gridDataDetails) } - fun fetchGridDataDetail(dataId: Int, groupId: Int?, cellId: Int?): List<GridDataDetail?> { + fun updateGridDataDetail(gridDataDetails: List<GridDataDetail?>): Int { + var res = 0 + gridDataDetails.forEach { + res += gridDataDetailMapper.updateByPrimaryKey(it) + } + return res + } + + fun fetchGridDataDetail(dataId: Int?, groupId: Int?, cellId: Int?): List<GridDataDetail?> { return gridDataDetailMapper.selectByExample(Example(GridDataDetail::class.java).apply { createCriteria().andEqualTo("dataId", dataId) .andEqualTo("groupId", groupId) @@ -123,6 +136,7 @@ gridDataDetailMapper.updatePM25Batch(gridDataDetails) } + /*****************************************************************/ // aod 鐩稿叧鎿嶄綔 fun fetchGridAod(groupId: Int, dataTime: LocalDateTime?): List<GridAod?> { 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 0799ea9..0be52ab 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteTelemetryService.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/SatelliteTelemetryService.kt @@ -2,6 +2,7 @@ import com.flightfeather.uav.common.exception.BizException import com.flightfeather.uav.domain.entity.GridAod +import com.flightfeather.uav.domain.entity.GridAodDetail import com.flightfeather.uav.domain.entity.GridCell import com.flightfeather.uav.domain.entity.GridData import com.flightfeather.uav.domain.entity.GridDataDetail @@ -20,7 +21,7 @@ */ interface SatelliteTelemetryService { - fun fetchGridGroup(areaVo: AreaVo, page: Int?, perPage: Int?): Pair<DataHead, List<GridGroup?>> + fun fetchGridGroup(areaVo: AreaVo, type: String?, page: Int?, perPage: Int?): Pair<DataHead, List<GridGroup?>> fun deleteGridGroup(groupId: Int) @@ -29,6 +30,12 @@ fun fetchGridData(groupId: Int, dataTime: LocalDateTime?, type: Int?): List<GridData?> fun fetchGridDataDetail(dataId: Int, groupId: Int?, cellId: Int?): List<GridDataDetail?> + + fun createGridDataAndDataDetail( + groupId: Int, + dataTime: LocalDateTime?, + gridDataDetail: List<GridDataDetail>, + ): Boolean /** * 鏁版嵁铻嶅悎 @@ -40,8 +47,6 @@ fun downloadTemplate(response: HttpServletResponse): Boolean - fun fetchGridAod(groupId: Int, dataTime: LocalDateTime?): List<GridAod?> - @Throws(BizException::class) fun importGridAOD(groupId: Int, dataTime: LocalDateTime?, update: Boolean, file: MultipartFile): GridDataImportResult? @@ -52,4 +57,10 @@ * @param groupId 缃戞牸缁勭储寮昳d */ fun calGridVertex(groupId: Int): List<GridCell?> + + + /**AOD鏁版嵁鐩稿叧**************************************************************/ + fun fetchGridAod(groupId: Int, dataTime: LocalDateTime?): List<GridAod?> + + fun fetchGridAODDetail(aodId: Int, groupId: Int?, cellId: Int?): List<GridAodDetail?> } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/SceneService.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/SceneService.kt index 719a3ef..e7c9ef5 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/SceneService.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/SceneService.kt @@ -1,5 +1,6 @@ package com.flightfeather.uav.lightshare.service +import com.flightfeather.uav.domain.entity.GridCell import com.flightfeather.uav.domain.entity.SceneInfo import com.flightfeather.uav.lightshare.bean.AreaVo @@ -8,4 +9,6 @@ fun searchScene(areaVo: AreaVo, page: Int?, perPage: Int?): List<SceneInfo?> fun searchByCoordinate(lng: Double, lat: Double, radius: Double): List<SceneInfo?> + + fun searchByGrid(gridCell: GridCell): List<SceneInfo?> } \ No newline at end of file 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 7358603..248b091 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 @@ -138,21 +138,46 @@ val mission = missionRep.findOne(missionCode) ?: throw BizException("浠诲姟涓嶅瓨鍦�") val data = realTimeDataRep.fetchData(mission) - // 鍒涘缓铻嶅悎鏁版嵁绱㈠紩瀵硅薄 - val newGridData = GridData().apply { + val oldGridDataList = satelliteGridRep.fetchGridData(GridData().apply { this.groupId = groupId - dataTime = mission.startTime - type = SatelliteDataType.Monitor.value.toByte() + mixDataId = missionCode + }) + + if (oldGridDataList.isEmpty()) { + // 鍒涘缓铻嶅悎鏁版嵁绱㈠紩瀵硅薄 + val newGridData = GridData().apply { + this.groupId = groupId + dataTime = mission.startTime + type = SatelliteDataType.Monitor.value.toByte() + mixDataId = mission.missionCode + } + satelliteGridRep.insertGridData(newGridData) + + // 鏌ヨ缃戞牸鍗曞厓鏍间俊鎭� + val gridCellList = satelliteGridRep.fetchGridCell(groupId) + + // 灏嗚蛋鑸暟鎹拰鍗槦缃戞牸杩涜铻嶅悎璁$畻 + val gridDataDetailList = SatelliteGridManage.dataFusion(data, newGridData, gridCellList) + satelliteGridRep.insertGridDataDetail(gridDataDetailList) + + return gridDataDetailList + } else { + val oldGridData = oldGridDataList.first() + val oldGridDataDetailList = satelliteGridRep.fetchGridDataDetail(oldGridData?.id, oldGridData?.groupId, + null) + // 鏌ヨ缃戞牸鍗曞厓鏍间俊鎭� + val gridCellList = satelliteGridRep.fetchGridCell(groupId) + // 灏嗚蛋鑸暟鎹拰鍗槦缃戞牸杩涜铻嶅悎璁$畻 + val gridDataDetailList = SatelliteGridManage.dataFusion(data, oldGridData, gridCellList) + + // 灏嗗凡鏈夌殑鏁版嵁id璧嬪�肩粰鏂扮殑铻嶅悎缁撴灉锛屼袱缁勭粨鏋滃潎浠ユ牴鎹甤ellId椤哄簭鎺掑垪锛屾墍浠ョ洿鎺ュ惊鐜祴鍊� + gridDataDetailList.forEachIndexed { index, gridDataDetail -> + gridDataDetail.id = oldGridDataDetailList[index]?.id + } + + satelliteGridRep.updateGridDataDetail(gridDataDetailList) + + return gridDataDetailList } - satelliteGridRep.insertGridData(newGridData) - - // 鏌ヨ缃戞牸鍗曞厓鏍间俊鎭� - val gridCellList = satelliteGridRep.fetchGridCell(groupId) - - // 灏嗚蛋鑸暟鎹拰鍗槦缃戞牸杩涜铻嶅悎璁$畻 - val gridDataDetailList = SatelliteGridManage.dataFusion(data, newGridData, gridCellList) - satelliteGridRep.insertGridDataDetail(gridDataDetailList) - - return gridDataDetailList } } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt index 1caf954..d83ba68 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteTelemetryServiceImpl.kt @@ -4,15 +4,12 @@ import com.flightfeather.uav.biz.satellite.SatelliteGridManage import com.flightfeather.uav.common.exception.BizException import com.flightfeather.uav.common.utils.FileExchange -import com.flightfeather.uav.domain.entity.GridAod -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.domain.entity.* import com.flightfeather.uav.domain.repository.SatelliteGridRep import com.flightfeather.uav.lightshare.bean.AreaVo import com.flightfeather.uav.lightshare.bean.DataHead import com.flightfeather.uav.lightshare.bean.GridDataImportResult +import com.flightfeather.uav.lightshare.eunm.SatelliteDataType import com.flightfeather.uav.lightshare.service.SatelliteTelemetryService import com.github.pagehelper.PageHelper import org.springframework.stereotype.Service @@ -38,9 +35,10 @@ ) : SatelliteTelemetryService { private val fileExchange = FileExchange() - override fun fetchGridGroup(areaVo: AreaVo, page: Int?, perPage: Int?): Pair<DataHead, List<GridGroup?>> { + override fun fetchGridGroup(areaVo: AreaVo, type: String?, page: Int?, perPage: Int?): Pair<DataHead, + List<GridGroup?>> { val pageInfo = PageHelper.startPage<GridGroup>(page ?: 1, perPage ?: 100) - val res = satelliteGridRep.fetchGridGroup(areaVo) + val res = satelliteGridRep.fetchGridGroup(areaVo, type) return DataHead(pageInfo.pageNum, pageInfo.pages) to res } @@ -56,10 +54,6 @@ return satelliteGridRep.fetchGridData(groupId, dataTime, type) } - override fun fetchGridAod(groupId: Int, dataTime: LocalDateTime?): List<GridAod?> { - return satelliteGridRep.fetchGridAod(groupId, dataTime) - } - override fun fetchGridDataDetail(dataId: Int, groupId: Int?, cellId: Int?): List<GridDataDetail?> { val res = satelliteGridRep.fetchGridDataDetail(dataId, groupId, cellId) res.forEach { @@ -68,6 +62,38 @@ } } return res + } + + @Transactional + override fun createGridDataAndDataDetail( + groupId: Int, + dataTime: LocalDateTime?, + gridDataDetail: List<GridDataDetail>, + ): Boolean { + // 淇濆瓨鎷熷悎鐨勫崼鏄熼仴娴嬫暟鎹� type濮嬬粓涓�0 + val type = SatelliteDataType.Original.value + + // 鏌ユ壘鏄惁鏈夊巻鍙茶褰� + val gridData = satelliteGridRep.fetchGridData(groupId, dataTime, type) + // 鏃犲巻鍙茶褰曞垯鍒涘缓鏁版嵁绱㈠紩GridData锛屼箣鍚庡啀瀛樺叆鎷熷悎鐨勬暟鎹� + if (gridData.isEmpty()) { + val gridDataEntity = GridData() + gridDataEntity.groupId = groupId + gridDataEntity.dataTime = dataTime?.atZone(ZoneId.systemDefault())?.toInstant()?.toEpochMilli() + ?.let { Date(it) } + gridDataEntity.type = type.toByte() + satelliteGridRep.insertGridDataAndDetail(gridDataEntity, gridDataDetail) + } + // 鏇存柊鍘嗗彶鏁版嵁 + else { + gridDataDetail.forEach { + it.dataId = gridData[0]?.id + it.groupId = gridData[0]?.groupId + } + satelliteGridRep.updatePM25Batch(gridDataDetail) + } + + return true } @Transactional @@ -238,4 +264,12 @@ return cellList } + + override fun fetchGridAod(groupId: Int, dataTime: LocalDateTime?): List<GridAod?> { + return satelliteGridRep.fetchGridAod(groupId, dataTime) + } + + override fun fetchGridAODDetail(aodId: Int, groupId: Int?, cellId: Int?): List<GridAodDetail?> { + return satelliteGridRep.fetchGridAodDetail(aodId, groupId, cellId) + } } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SceneServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SceneServiceImpl.kt index 25e45ec..e85c4ec 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SceneServiceImpl.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/SceneServiceImpl.kt @@ -1,6 +1,7 @@ package com.flightfeather.uav.lightshare.service.impl import com.flightfeather.uav.common.location.LocationRoadNearby +import com.flightfeather.uav.domain.entity.GridCell import com.flightfeather.uav.domain.entity.SceneInfo import com.flightfeather.uav.domain.repository.SceneInfoRep import com.flightfeather.uav.lightshare.bean.AreaVo @@ -21,4 +22,10 @@ override fun searchByCoordinate(lng: Double, lat: Double, radius: Double): List<SceneInfo?> { return locationRoadNearby.searchByRadius(Pair(lng, lat), radius) } + + override fun searchByGrid(gridCell: GridCell): List<SceneInfo?> { + // 棣栧厛鐢ㄧ綉鏍间腑蹇冪偣浠ュ強缃戞牸瀵硅绾跨殑闀垮害姹傚彇鍥涜嚦鑼冨洿锛岀瓫閫夎鑼冨洿鍐呯殑鍦烘櫙鐐逛綅 + // 鍐嶉�氳繃璁$畻鍧愭爣鐐规槸鍚﹁惤鍦ㄥ杈瑰舰鍐� + TODO() + } } \ No newline at end of file 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 d0c2811..5e5c4ff 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/web/SatelliteTelemetryController.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/web/SatelliteTelemetryController.kt @@ -1,7 +1,8 @@ package com.flightfeather.uav.lightshare.web -import com.fasterxml.jackson.annotation.JsonFormat +import com.flightfeather.uav.domain.entity.GridDataDetail import com.flightfeather.uav.lightshare.bean.AreaVo +import com.flightfeather.uav.lightshare.service.SatelliteDataCalculateService import com.flightfeather.uav.lightshare.service.SatelliteTelemetryService import io.swagger.annotations.Api import io.swagger.annotations.ApiOperation @@ -21,15 +22,19 @@ @Api(tags = ["鍗槦閬ユ祴API鎺ュ彛"]) @RestController @RequestMapping("air/satellite") -class SatelliteTelemetryController(private val satelliteTelemetryService: SatelliteTelemetryService) { +class SatelliteTelemetryController( + private val satelliteTelemetryService: SatelliteTelemetryService, + private val satelliteDataCalculateService: SatelliteDataCalculateService +) { @ApiOperation(value = "鑾峰彇缃戞牸缁勪俊鎭�") @PostMapping("/grid/group") fun fetchGridGroup( @RequestBody areaVo: AreaVo, + @RequestParam(required = false) type: String?, @RequestParam("page", required = false) page: Int?, @RequestParam("per_page", required = false) perPage: Int? - ) = resPack { satelliteTelemetryService.fetchGridGroup(areaVo, page, perPage) } + ) = resPack { satelliteTelemetryService.fetchGridGroup(areaVo, type, page, perPage) } @ApiOperation(value = "鑾峰彇缃戞牸缁勫唴鍏蜂綋缃戞牸淇℃伅") @GetMapping("/grid/cell") @@ -54,11 +59,24 @@ @ApiParam("缃戞牸鍗曞厓鏍糹d") @RequestParam(required = false) cellId: Int?, ) = resPack { satelliteTelemetryService.fetchGridDataDetail(dataId, groupId, cellId) } + @ApiOperation(value = "淇濆瓨鎷熷悎鐢熸垚鐨勫崼鏄熼仴娴婸M2.5缁撴灉鏁版嵁") + @PostMapping("/grid/data/create") + fun createGridDataAndDataDetail( + @ApiParam("缃戞牸缁刬d") @RequestParam groupId: Int, + @ApiParam("閬ユ祴鏁版嵁鏃堕棿") + @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") dateTime: LocalDateTime, + @RequestBody gridDataDetail: List<GridDataDetail> + ) = resPack { + satelliteTelemetryService.createGridDataAndDataDetail(groupId, dateTime, gridDataDetail) + } + + @ApiOperation(value = "澶氭璧拌埅鏁版嵁杩涜铻嶅悎璁$畻") @PostMapping("/grid/data/mix") fun mixGridData( @ApiParam("鍘熷鏁版嵁id鏁扮粍") @RequestBody dataIdList: List<Int> ) = resPack { satelliteTelemetryService.mixGridData(dataIdList) } + @ApiOperation(value = "瀵煎叆鍗槦閬ユ祴PM2.5缁撴灉鏁版嵁") @PostMapping("/import/grid/data") @@ -76,14 +94,6 @@ @GetMapping("/import/grid/data/download/template") fun downloadTemplate(@ApiIgnore response: HttpServletResponse) = satelliteTelemetryService.downloadTemplate(response) - @ApiOperation(value = "鑾峰彇缃戞牸缁勪笅鐨勫崼鏄熼仴娴媋od鏁版嵁") - @GetMapping("/grid/aod") - fun fetchGridAod( - @ApiParam("缃戞牸缁刬d") @RequestParam groupId: Int, - @ApiParam("閬ユ祴鏁版嵁鏃堕棿") - @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") dataTime: LocalDateTime?, - ) = resPack { satelliteTelemetryService.fetchGridAod(groupId, dataTime) } - @ApiOperation(value = "瀵煎叆鍗槦閬ユ祴Aod缁撴灉鏁版嵁") @PostMapping("/import/grid/aod") fun importGridAOD( @@ -99,4 +109,41 @@ @ApiOperation(value = "涓嬭浇鍗槦閬ユ祴Aod缁撴灉鏁版嵁瀵煎叆妯℃澘") @GetMapping("/import/grid/aod/download/template") fun downloadAODTemplate(@ApiIgnore response: HttpServletResponse) = satelliteTelemetryService.downloadAODTemplate(response) + + + /**AOD鏁版嵁鐩稿叧**************************************************************/ + @ApiOperation(value = "鑾峰彇缃戞牸缁勪笅鐨勫崼鏄熼仴娴媋od鏁版嵁") + @GetMapping("/grid/aod") + fun fetchGridAod( + @ApiParam("缃戞牸缁刬d") @RequestParam groupId: Int, + @ApiParam("閬ユ祴鏁版嵁鏃堕棿") + @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") dataTime: LocalDateTime?, + ) = resPack { satelliteTelemetryService.fetchGridAod(groupId, dataTime) } + +// @ApiOperation(value = "鑾峰彇缃戞牸缁勪笅鐨勫崼鏄熼仴娴婣OD鏁版嵁") +// @GetMapping("/aod/data") +// fun fetchGridAOD( +// @ApiParam("缃戞牸缁刬d") @RequestParam groupId: Int, +// @ApiParam("AOD鏁版嵁鏃堕棿") +// @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") dataTime: LocalDateTime?, +// ) = resPack { satelliteTelemetryService.fetchGridAOD(groupId, dataTime) } + + @ApiOperation(value = "鑾峰彇缃戞牸缁勪笅鐨勫崼鏄熼仴娴婣OD鍏蜂綋鏁版嵁") + @GetMapping("/aod/data/detail") + fun fetchGridAODDetail( + @ApiParam("AOD鏁版嵁id") @RequestParam aodId: Int, + @ApiParam("缃戞牸缁刬d") @RequestParam(required = false) groupId: Int?, + @ApiParam("缃戞牸鍗曞厓鏍糹d") @RequestParam(required = false) cellId: Int?, + ) = resPack { satelliteTelemetryService.fetchGridAODDetail(aodId, groupId, cellId) } + + + /**閬ユ祴浜у搧鍒朵綔鐩稿叧**************************************************************/ + @ApiOperation(value = "鐢熸垚璧拌埅铻嶅悎浜у搧") + @GetMapping("/product/underway/build") + fun buildUnderwayProduct( + @ApiParam("璧拌埅浠诲姟缂栧彿") @RequestParam missionCode: String, + @ApiParam("缃戞牸缁刬d") @RequestParam groupId: Int, + ) = resPack { satelliteDataCalculateService.dataFusion(missionCode, groupId) } + + } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/web/SceneController.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/web/SceneController.kt index a74ebe7..d2c8baf 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/web/SceneController.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/web/SceneController.kt @@ -1,5 +1,6 @@ package com.flightfeather.uav.lightshare.web +import com.flightfeather.uav.domain.entity.GridCell import com.flightfeather.uav.lightshare.bean.AreaVo import com.flightfeather.uav.lightshare.service.SceneService import io.swagger.annotations.Api @@ -24,4 +25,10 @@ @RequestParam("lat") lat: Double, @RequestParam("radius") radius: Double, ) = resPack { sceneService.searchByCoordinate(lng, lat, radius) } + + @ApiOperation(value = "鏍规嵁鍗槦缃戞牸鎵惧埌鑼冨洿鍐呯殑鍦烘櫙") + @PostMapping("/find/grid") + fun searchByGrid( + @RequestBody gridCell: GridCell, + ) = resPack { sceneService.searchByGrid(gridCell) } } \ No newline at end of file diff --git a/src/test/kotlin/com/flightfeather/uav/SatelliteDebugData.kt b/src/test/kotlin/com/flightfeather/uav/SatelliteDebugData.kt new file mode 100644 index 0000000..b593287 --- /dev/null +++ b/src/test/kotlin/com/flightfeather/uav/SatelliteDebugData.kt @@ -0,0 +1,68 @@ +package com.flightfeather.uav + +import com.flightfeather.uav.domain.entity.GridAod +import com.flightfeather.uav.domain.entity.GridAodDetail +import com.flightfeather.uav.domain.entity.GridData +import com.flightfeather.uav.domain.entity.GridDataDetail +import com.flightfeather.uav.domain.mapper.GridAodDetailMapper +import com.flightfeather.uav.domain.mapper.GridAodMapper +import com.flightfeather.uav.domain.mapper.GridDataDetailMapper +import com.flightfeather.uav.domain.mapper.GridDataMapper +import com.flightfeather.uav.lightshare.eunm.GridType +import com.flightfeather.uav.lightshare.eunm.SatelliteDataType +import org.junit.Test +import org.junit.runner.RunWith +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.test.context.junit4.SpringRunner +import org.springframework.transaction.annotation.Transactional + +/** + * 鍗槦閬ユ祴娴嬭瘯鏁版嵁绠$悊 + * @date 2025/3/2 + * @author feiyu02 + */ +@RunWith(SpringRunner::class) +@SpringBootTest +class SatelliteDebugData { + + + @Autowired + lateinit var gridDataMapper: GridDataMapper + + @Autowired + lateinit var gridDataDetailMapper: GridDataDetailMapper + + @Autowired + lateinit var gridAodMapper: GridAodMapper + + @Autowired + lateinit var gridAodDetailMapper: GridAodDetailMapper + + /** + * 鍙嶅悜鐢熸垚AOD鏁版嵁 + */ + @Test + fun createAODData() { + gridDataMapper.select(GridData().apply { type = SatelliteDataType.Original.value.toByte() }).forEach {gridData -> + val gridAod = GridAod().apply { + groupId = gridData?.groupId + dataTime = gridData?.dataTime + } + gridAodMapper.insert(gridAod) + + gridDataDetailMapper.select(GridDataDetail().apply { + dataId = gridData?.id + }).forEach { gridDataDetail-> + val girdAodDetail = GridAodDetail().apply { + aodId = gridAod.id + groupId = gridAod.groupId + cellId = gridDataDetail?.cellId + aod = gridDataDetail?.pm25?.div(2) + } + gridAodDetailMapper.insert(girdAodDetail) + } + } + + } +} \ No newline at end of file diff --git a/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImplTest.kt b/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImplTest.kt index bbadfd9..0ad77e0 100644 --- a/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImplTest.kt +++ b/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/SatelliteDataCalculateServiceImplTest.kt @@ -26,7 +26,7 @@ */ @Test fun refreshDataRank() { - for (i in 51..51) { + for (i in 64..69) { val dataDetailList = gridDataDetailMapper.selectByExample(Example(GridDataDetail::class.java).apply { createCriteria().andEqualTo("dataId", i) orderBy("pm25").desc() @@ -47,13 +47,29 @@ @Test fun splitData() { - val res = satelliteDataCalculateService.splitData(4, 25) -// println(res) + val groupIdList = listOf(2, 4) + val dataId = listOf(34, 29, 25, 18, 8) + + groupIdList.forEach {g -> + dataId.forEach { d -> + satelliteDataCalculateService.splitData(g, d) + } + } +// val res = satelliteDataCalculateService.splitData(2, 25) } @Test fun dataFusion() { - val res = satelliteDataCalculateService.dataFusion("SH-CN-20241216", 3) -// println(res) + val missionList = + listOf("SH-CN-20241202", "SH-CN-20241127", "SH-CN-20241126-1", "SH-CN-20241126-2", "SH-CN-20241108", "SH-CN-20240823") + missionList.forEach { m -> + satelliteDataCalculateService.dataFusion(m, 3) + } +// val res = satelliteDataCalculateService.dataFusion("SH-CN-20241216", 3) + } + + @Test + fun splitDataAndDataFusion() { + } } \ No newline at end of file -- Gitblit v1.9.3