feiyu02
7 小时以前 4a976d3763be8a7bed743faf24abf2718ae18e31
2025.10.15
1. 走航季度报告相关数据计算逻辑调整
已修改10个文件
已添加1个文件
153 ■■■■ 文件已修改
src/main/kotlin/com/flightfeather/uav/biz/report/MissionGridFusion.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/common/net/AMapService.kt 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/AnalysisOption.kt 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/DataAnalysisService.kt 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImpl.kt 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/web/DataAnalysisController.kt 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-test.yml 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/Test.kt 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceControllerTest.kt 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImplTest.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImplTest.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
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()
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,
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
}
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>
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) ->
            // ç­›é€‰å‡ºæœ‰ç½‘格融合数据的走航任务(同时获取对应的融合数据id列表)
            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
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
        )
    }
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:
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))
    }
}
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)
        })
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)
    }
}
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)