From 4a976d3763be8a7bed743faf24abf2718ae18e31 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期三, 15 十月 2025 17:34:14 +0800 Subject: [PATCH] 2025.10.15 1. 走航季度报告相关数据计算逻辑调整 --- src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImplTest.kt | 2 src/main/kotlin/com/flightfeather/uav/lightshare/bean/AnalysisOption.kt | 39 +++++++++++++ src/main/kotlin/com/flightfeather/uav/lightshare/service/DataAnalysisService.kt | 8 ++ src/test/kotlin/com/flightfeather/uav/Test.kt | 11 ++- src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImpl.kt | 40 +++++++++++-- src/test/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceControllerTest.kt | 8 +- src/main/kotlin/com/flightfeather/uav/common/net/AMapService.kt | 8 ++ src/main/kotlin/com/flightfeather/uav/lightshare/web/DataAnalysisController.kt | 21 +++--- src/main/kotlin/com/flightfeather/uav/biz/report/MissionGridFusion.kt | 2 src/main/resources/application-test.yml | 12 ++-- src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImplTest.kt | 2 11 files changed, 117 insertions(+), 36 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/biz/report/MissionGridFusion.kt b/src/main/kotlin/com/flightfeather/uav/biz/report/MissionGridFusion.kt index a274fae..5b928c4 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/report/MissionGridFusion.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/report/MissionGridFusion.kt @@ -89,7 +89,7 @@ if (highRiskGrid != null) { factorValue = highRiskGrid!!.data.getByFactorType(f) if (highRiskGrid!!.cell.longitude != null && highRiskGrid!!.cell.latitude != null) { - Thread.sleep(50) + Thread.sleep(100) val address = AMapService.reGeo(MapUtil.wgs84ToGcj02( highRiskGrid!!.cell.longitude.toDouble() to highRiskGrid!!.cell.latitude.toDouble() diff --git a/src/main/kotlin/com/flightfeather/uav/common/net/AMapService.kt b/src/main/kotlin/com/flightfeather/uav/common/net/AMapService.kt index 9b25bff..0baf2e8 100644 --- a/src/main/kotlin/com/flightfeather/uav/common/net/AMapService.kt +++ b/src/main/kotlin/com/flightfeather/uav/common/net/AMapService.kt @@ -88,11 +88,15 @@ fun reGeo(location:Pair<Double, Double>):AMapAddress { val res = httpMethod.get("/v3/geocode/regeo", listOf( "key" to KEY, - "location" to "${location.first},${location.second}" + "location" to "${location.first},${location.second}", + "extensions" to "all" )) val obj = handleRes(res) try { - val a = obj["regeocode"].asJsonObject["addressComponent"].asJsonObject + val regeocode = obj["regeocode"].asJsonObject + val a = regeocode["addressComponent"].asJsonObject + val roads = regeocode["roads"].asJsonArray + val roadinters = regeocode["roadinters"].asJsonArray return AMapAddress( a["country"].asString, a["province"].asString, diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/bean/AnalysisOption.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/bean/AnalysisOption.kt new file mode 100644 index 0000000..ac79900 --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/bean/AnalysisOption.kt @@ -0,0 +1,39 @@ +package com.flightfeather.uav.lightshare.bean + +import com.fasterxml.jackson.annotation.JsonFormat +import io.swagger.annotations.ApiModel +import io.swagger.annotations.ApiModelProperty +import org.springframework.format.annotation.DateTimeFormat +import java.time.LocalDateTime + +/** + * 鏁版嵁鍒嗘瀽鎺ュ彛鏌ヨ閫夐」 + * @date 2025/10/15 + * @author feiyu02 + */ +@ApiModel(value = "鏁版嵁鍒嗘瀽鎺ュ彛鏌ヨ閫夐」") +class AnalysisOption { + + /** 鍖哄煙 */ + @ApiModelProperty(value = "鍖哄煙") + var area: AreaVo? = null + + /** 鏄惁涓嶅寘鍚叾浠栧尯鍘� */ + @ApiModelProperty(value = "鏄惁涓嶅寘鍚叾浠栧尯鍘�") + var removeOtherDistrict: Boolean = false + + + /** 鏄惁涓嶅寘鍚湭婧簮鍒版薄鏌撴簮鐨勬薄鏌撶嚎绱� */ + @ApiModelProperty(value = "鏄惁涓嶅寘鍚湭婧簮鍒版薄鏌撴簮鐨勬薄鏌撶嚎绱�") + var removeNoPollutedSource:Boolean = false + + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty(value = "寮�濮嬫椂闂�") + var startTime: LocalDateTime? = null + + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @ApiModelProperty(value = "缁撴潫鏃堕棿") + var endTime: LocalDateTime? = null +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/DataAnalysisService.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/DataAnalysisService.kt index a2d5daa..161c7b7 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/DataAnalysisService.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/DataAnalysisService.kt @@ -110,7 +110,13 @@ granularity: String, ): List<MissionDetail> - fun generateClueByRiskArea(startTime: Date, endTime: Date, areaVo: AreaVo): List<MissionRiskArea.ClueByArea> + fun generateClueByRiskArea( + startTime: Date, + endTime: Date, + areaVo: AreaVo, + removeOtherDistrict: Boolean, + removeNoPollutedSource: Boolean, + ): List<MissionRiskArea.ClueByArea> fun generateClueByRiskArea(missionCode: String): List<MissionRiskArea.ClueByArea> diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImpl.kt index 52efc03..31c44cd 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImpl.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImpl.kt @@ -42,7 +42,7 @@ private val sourceTraceRep: SourceTraceRep, private val sceneInfoRep: SceneInfoRep, private val satelliteGridRep: SatelliteGridRep, - private val satelliteDataCalculateService: SatelliteDataCalculateService + private val satelliteDataCalculateService: SatelliteDataCalculateService, ) : DataAnalysisService { /** @@ -109,7 +109,12 @@ override fun generateMissionSummary(missionCode: String): MissionSummary.Summary { val mission = missionRep.findOne(missionCode) ?: throw BizException("璧拌埅浠诲姟涓嶅瓨鍦�") - val clues = sourceTraceRep.fetchList(mission.deviceCode, mission.startTime, mission.endTime, MsgType.PolClue) as List<PollutedClue?> + val clues = sourceTraceRep.fetchList( + mission.deviceCode, + mission.startTime, + mission.endTime, + MsgType.PolClue + ) as List<PollutedClue?> val summary = MissionSummary().execute(mission.startTime, mission.endTime, listOf(mission), clues) return summary } @@ -202,7 +207,12 @@ override fun generateMissionDetail(missionCode: String, granularity: String?): MissionInventory.MissionDetail { val mission = missionRep.findOne(missionCode) ?: throw BizException("浠诲姟涓嶅瓨鍦�") - val missionClues = sourceTraceRep.fetchList(mission.deviceCode, mission.startTime, mission.endTime, MsgType.PolClue) as List<PollutedClue?> + val missionClues = sourceTraceRep.fetchList( + mission.deviceCode, + mission.startTime, + mission.endTime, + MsgType.PolClue + ) as List<PollutedClue?> val realTimeData = realTimeDataRep.fetchData(mission) val keyScenes = sceneInfoRep.findBySceneTypes( listOf( @@ -236,12 +246,24 @@ startTime: Date, endTime: Date, areaVo: AreaVo, + removeOtherDistrict: Boolean, + removeNoPollutedSource: Boolean, ): List<MissionRiskArea.ClueByArea> { val clues = mutableListOf<PollutedClue?>() missionRep.findByAreaAndTime(areaVo, startTime, endTime).onEach { it ?: return@onEach val clue = sourceTraceRep.fetchList(it.deviceCode, it.startTime, it.endTime, MsgType.PolClue) as List<PollutedClue?> clues.addAll(clue) + } + if (removeOtherDistrict) { + clues.removeIf { + !areaVo.districtName.isNullOrBlank() && + (it?.pollutedArea?.address.isNullOrBlank() + || !it!!.pollutedArea!!.address!!.contains(areaVo.districtName!!)) + } + } + if (removeNoPollutedSource) { + clues.removeIf { it?.pollutedSource?.sceneList.isNullOrEmpty() } } // val keyScenes = sceneInfoRep.findBySceneTypes( // listOf( @@ -255,7 +277,12 @@ override fun generateClueByRiskArea(missionCode: String): List<MissionRiskArea.ClueByArea> { val mission = missionRep.findOne(missionCode) ?: throw BizException("浠诲姟涓嶅瓨鍦�") - val pollutedClues = sourceTraceRep.fetchList(mission.deviceCode, mission.startTime, mission.endTime, MsgType.PolClue) as List<PollutedClue?> + val pollutedClues = sourceTraceRep.fetchList( + mission.deviceCode, + mission.startTime, + mission.endTime, + MsgType.PolClue + ) as List<PollutedClue?> val keyScenes = sceneInfoRep.findBySceneTypes( listOf( SceneType.TYPE19.value, @@ -297,8 +324,9 @@ val gridDataDetailList = missionGroups.mapNotNull { (degree, missionList) -> // 绛涢�夊嚭鏈夌綉鏍艰瀺鍚堟暟鎹殑璧拌埅浠诲姟(鍚屾椂鑾峰彇瀵瑰簲鐨勮瀺鍚堟暟鎹甶d鍒楄〃) val gridDataIds = mutableListOf<Int>() - val validMissions = missionList.filter {mission -> - val gridData = satelliteGridRep.fetchGridData(GridData().apply { missionCode = mission?.missionCode }).firstOrNull() + val validMissions = missionList.filter { mission -> + val gridData = + satelliteGridRep.fetchGridData(GridData().apply { missionCode = mission?.missionCode }).firstOrNull() val res = gridData != null if (res) gridDataIds.add(gridData?.id ?: 0) res diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/web/DataAnalysisController.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/web/DataAnalysisController.kt index c6c2a83..07b27c3 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/web/DataAnalysisController.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/web/DataAnalysisController.kt @@ -1,6 +1,8 @@ package com.flightfeather.uav.lightshare.web import com.fasterxml.jackson.annotation.JsonFormat +import com.flightfeather.uav.common.exception.BizException +import com.flightfeather.uav.lightshare.bean.AnalysisOption import com.flightfeather.uav.lightshare.bean.AreaVo import com.flightfeather.uav.lightshare.service.DataAnalysisService import com.flightfeather.uav.socket.eunm.FactorType @@ -116,20 +118,19 @@ @ApiOperation(value = "璧拌埅鍏稿瀷闅愭偅鍖哄煙缁熻") @PostMapping("/report/clueByRiskArea") fun generateClueByRiskArea( - @ApiParam("寮�濮嬫椂闂�") @RequestParam - @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - startTime: LocalDateTime, - @ApiParam("缁撴潫鏃堕棿") @RequestParam - @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - endTime: LocalDateTime, - @ApiParam("鍖哄煙") @RequestBody areaVo: AreaVo, + @ApiParam("鍖哄煙") @RequestBody analysisOption: AnalysisOption, ) = resPack { + if (analysisOption.startTime == null || analysisOption.endTime == null || analysisOption.area == null) + throw BizException("鍙傛暟閿欒, startTime, endTime, areaVo涓嶈兘涓虹┖") + val startTime = analysisOption.startTime!!.atZone(ZoneId.systemDefault()).toInstant() + val endTime = analysisOption.endTime!!.atZone(ZoneId.systemDefault()).toInstant() + val areaVo = analysisOption.area!! dataAnalysisService.generateClueByRiskArea( Date.from(startTime.atZone(ZoneId.systemDefault()).toInstant()), Date.from(endTime.atZone(ZoneId.systemDefault()).toInstant()), - areaVo + areaVo, + analysisOption.removeOtherDistrict, + analysisOption.removeNoPollutedSource ) } diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 02d8369..75ca738 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -7,13 +7,13 @@ # password: cn.FLIGHTFEATHER # 杩滅▼鏈嶅姟鍣� - url: jdbc:mysql://47.100.191.150:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false - username: remoteU1 - password: eSoF8DnzfGTlhAjE - -# url: jdbc:mysql://114.215.109.124:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false +# url: jdbc:mysql://47.100.191.150:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false # username: remoteU1 -# password: feiyu2024 +# password: eSoF8DnzfGTlhAjE + + url: jdbc:mysql://114.215.109.124:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false + username: remoteU1 + password: feiyu2024 springfox: documentation: diff --git a/src/test/kotlin/com/flightfeather/uav/Test.kt b/src/test/kotlin/com/flightfeather/uav/Test.kt index 11a50e1..db6bf8b 100644 --- a/src/test/kotlin/com/flightfeather/uav/Test.kt +++ b/src/test/kotlin/com/flightfeather/uav/Test.kt @@ -1,9 +1,7 @@ package com.flightfeather.uav -import com.flightfeather.uav.common.utils.DateUtil -import com.flightfeather.uav.common.utils.FileExchange -import com.flightfeather.uav.common.utils.FileUtil -import com.flightfeather.uav.common.utils.TimeUtil +import com.flightfeather.uav.common.net.AMapService +import com.flightfeather.uav.common.utils.* import com.flightfeather.uav.domain.entity.BaseRealTimeData import com.flightfeather.uav.domain.entity.Company import com.flightfeather.uav.domain.entity.GridDataDetail @@ -201,4 +199,9 @@ println(sc.nextLine()) } } + + @Test + fun reGeo() { + AMapService.reGeo(MapUtil.wgs84ToGcj02(121.461753 to 31.252426)) + } } \ No newline at end of file diff --git a/src/test/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceControllerTest.kt b/src/test/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceControllerTest.kt index 51db22d..c54a5d3 100644 --- a/src/test/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceControllerTest.kt +++ b/src/test/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceControllerTest.kt @@ -46,8 +46,8 @@ //// "SH-CN-20250723(01)" // ) // val startTime = LocalDateTime.of(2024, 12, 31, 0, 0, 0).atZone(ZoneId.systemDefault()).toInstant() - val startTime = LocalDateTime.of(2024, 12, 4, 0, 0, 0).atZone(ZoneId.systemDefault()).toInstant() - val endTime = LocalDateTime.of(2025, 4, 11, 23, 59, 59).atZone(ZoneId.systemDefault()).toInstant() + val startTime = LocalDateTime.of(2025, 7, 1, 0, 0, 0).atZone(ZoneId.systemDefault()).toInstant() + val endTime = LocalDateTime.of(2025, 9, 30, 23, 59, 59).atZone(ZoneId.systemDefault()).toInstant() val missions = missionMapper.selectByExample(Example(Mission::class.java).apply { createCriteria().andBetween("startTime", startTime, endTime) }) @@ -115,8 +115,8 @@ // "SH-CN-20240723(02)", //// "SH-CN-20250723(01)" // ) - val startTime = LocalDateTime.of(2024, 12, 4, 0, 0, 0).atZone(ZoneId.systemDefault()).toInstant() - val endTime = LocalDateTime.of(2025, 4, 11, 23, 59, 59).atZone(ZoneId.systemDefault()).toInstant() + val startTime = LocalDateTime.of(2025, 7, 1, 0, 0, 0).atZone(ZoneId.systemDefault()).toInstant() + val endTime = LocalDateTime.of(2025, 9, 30, 23, 59, 59).atZone(ZoneId.systemDefault()).toInstant() val missions = missionMapper.selectByExample(Example(Mission::class.java).apply { createCriteria().andBetween("startTime", startTime, endTime) }) diff --git a/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImplTest.kt b/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImplTest.kt index e8ccfd2..aec4b68 100644 --- a/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImplTest.kt +++ b/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImplTest.kt @@ -51,7 +51,7 @@ @Test fun generateClueByRiskArea() { - val res = dataAnalysisService.generateClueByRiskArea(startTime, endTime, areaVo) + val res = dataAnalysisService.generateClueByRiskArea(startTime, endTime, areaVo, false, false) println(res) } } \ No newline at end of file diff --git a/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImplTest.kt b/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImplTest.kt index 3d3dba5..d66b52b 100644 --- a/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImplTest.kt +++ b/src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImplTest.kt @@ -34,7 +34,7 @@ @Test fun calMissionInfo() { missionMapper.selectByExample(Example(Mission::class.java).apply { - createCriteria().andGreaterThanOrEqualTo("startTime", "2025-08-08 08:30:00") + createCriteria().andGreaterThanOrEqualTo("startTime", "2025-07-08 08:30:00") }).forEach {mission -> mission?.let { missionService.calMissionInfo(it.missionCode) } Thread.sleep(1000) -- Gitblit v1.9.3