| | |
| | | import com.flightfeather.uav.socket.eunm.FactorType |
| | | import com.flightfeather.uav.socket.sender.MsgType |
| | | import org.springframework.stereotype.Service |
| | | import tk.mybatis.mapper.entity.Example |
| | | import java.util.* |
| | | |
| | | /** |
| | |
| | | private val sourceTraceRep: SourceTraceRep, |
| | | private val sceneInfoRep: SceneInfoRep, |
| | | private val satelliteGridRep: SatelliteGridRep, |
| | | private val satelliteDataCalculateService: SatelliteDataCalculateService |
| | | private val satelliteDataCalculateService: SatelliteDataCalculateService, |
| | | ) : DataAnalysisService { |
| | | |
| | | /** |
| | |
| | | return summary |
| | | } |
| | | |
| | | 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 summary = MissionSummary().execute(mission.startTime, mission.endTime, listOf(mission), clues) |
| | | return summary |
| | | } |
| | | |
| | | /** |
| | | * 生成走航任务清单(按时间和区域筛选) |
| | | * 根据时间范围和行政区划查询走航任务,并关联污染线索数据生成任务列表 |
| | |
| | | * @param startTime 查询起始时间(包含) |
| | | * @param endTime 查询结束时间(包含) |
| | | * @param areaVo 区域参数,包含省、市、区编码 |
| | | * @param granularity 数据颗粒度,可选值为SECOND, MINUTE, HOUR, 默认MINUTE |
| | | * @return 任务详情列表,每个元素包含任务完整信息、污染线索及实时监测数据 |
| | | * @see MissionRep.findByAreaAndTime 区域时间筛选数据源 |
| | | * @see realTimeDataRep.fetchData 实时数据获取接口 |
| | | */ |
| | | override fun generateMissionDetail(startTime: Date, endTime: Date, areaVo: AreaVo): List<MissionInventory.MissionDetail> { |
| | | override fun generateMissionDetail( |
| | | startTime: Date, |
| | | endTime: Date, |
| | | areaVo: AreaVo, |
| | | granularity: String?, |
| | | ): List<MissionInventory.MissionDetail> { |
| | | val missionCluesData = missionRep.findByAreaAndTime(areaVo, startTime, endTime).filterNotNull().map { |
| | | Triple( |
| | | it, |
| | |
| | | SceneType.TYPE21.value |
| | | ) |
| | | ) |
| | | return generateMissionDetail(keyScenes, missionCluesData) |
| | | return generateMissionDetail(keyScenes, missionCluesData, granularity ?: "MINUTE") |
| | | } |
| | | |
| | | 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 realTimeData = realTimeDataRep.fetchData(mission) |
| | | val keyScenes = sceneInfoRep.findBySceneTypes( |
| | | listOf( |
| | | SceneType.TYPE19.value, |
| | | SceneType.TYPE20.value, |
| | | SceneType.TYPE21.value |
| | | ) |
| | | ) |
| | | return MissionInventory().generateMissionDetail(keyScenes, mission, missionClues, realTimeData, granularity ?: "MINUTE") |
| | | } |
| | | |
| | | /** |
| | |
| | | override fun generateMissionDetail( |
| | | keyScenes: List<SceneInfo?>, |
| | | missionCluesData: List<Triple<Mission, List<PollutedClue?>, List<BaseRealTimeData>>>, |
| | | granularity: String, |
| | | ): List<MissionInventory.MissionDetail> { |
| | | return missionCluesData.map { |
| | | MissionInventory().generateMissionDetail(keyScenes, it.first, it.second, it.third) |
| | | MissionInventory().generateMissionDetail(keyScenes, it.first, it.second, it.third, granularity) |
| | | } |
| | | } |
| | | |
| | |
| | | startTime: Date, |
| | | endTime: Date, |
| | | areaVo: AreaVo, |
| | | removeOtherDistrict: Boolean, |
| | | removeNoPollutedSource: Boolean, |
| | | ): List<MissionRiskArea.ClueByArea> { |
| | | val clues = mutableListOf<PollutedClue?>() |
| | | missionRep.findByAreaAndTime(areaVo, startTime, endTime).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( |
| | | // SceneType.TYPE19.value, |
| | | // SceneType.TYPE20.value, |
| | | // SceneType.TYPE21.value |
| | | // ) |
| | | // ) |
| | | return MissionRiskArea().generateClueByRiskArea(clues) |
| | | } |
| | | |
| | | 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 keyScenes = sceneInfoRep.findBySceneTypes( |
| | | listOf( |
| | | SceneType.TYPE19.value, |
| | |
| | | SceneType.TYPE21.value |
| | | ) |
| | | ) |
| | | return generateClueByRiskArea(keyScenes, clues) |
| | | return generateClueByRiskArea(keyScenes, pollutedClues) |
| | | } |
| | | |
| | | override fun generateClueByRiskArea( |
| | | keyScenes: List<SceneInfo?>, |
| | | pollutedClues: List<PollutedClue?>, |
| | | ): List<MissionRiskArea.ClueByArea> { |
| | | return MissionRiskArea().generateClueByRiskArea(keyScenes, pollutedClues) |
| | | return MissionRiskArea().generateClueByKeyRiskScene(keyScenes, pollutedClues) |
| | | } |
| | | |
| | | override fun generateGridFusion( |
| | |
| | | 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 |