From 2e024c986c14943a41f7bfe913cfef0cede64198 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期二, 29 七月 2025 17:37:54 +0800 Subject: [PATCH] 2025.7.29 1. 动态溯源模块添加记录删除等debug功能 --- src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt | 9 +++ src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt | 14 +++- src/test/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceControllerTest.kt | 79 +++++++++++++++++++------- src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt | 19 ++++-- src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt | 2 src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/config/RTExcWindLevelConfig.kt | 31 ++++++++-- 6 files changed, 115 insertions(+), 39 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt index 81aef67..7a910ee 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceController.kt @@ -28,7 +28,12 @@ * 姣忎竴鍒婚挓瀵瑰巻鍙茬嚎绱㈣繘琛岀粺璁★紝鎻愬嚭浼氬晢寤鸿锛堢姹℃煋婧愯緝杩溿�佹薄鏌撴簮鏁伴噺銆佸嚭鐜版鏁帮級銆佽蛋鑸矾绾胯皟鏁村缓璁紙绂绘薄鏌撴簮杈冭繎銆佽蛋鑸建杩规湭鎺ヨ繎婧簮鍦烘櫙锛� */ - constructor(sceneInfoRep: SceneInfoRep, sourceTraceRep: SourceTraceRep, factorFilter: FactorFilter?) { + constructor( + sceneInfoRep: SceneInfoRep, + sourceTraceRep: SourceTraceRep, + factorFilter: FactorFilter?, + isSearchAddress: Boolean, + ) { this.sceneInfoRep = sceneInfoRep this.sourceTraceRep = sourceTraceRep this.config = if (factorFilter != null) { @@ -43,7 +48,7 @@ .withMain(FactorType.O3) .withMain(FactorType.PM25) .withMain(FactorType.PM10) -// .withMain(FactorType.VOC) + .withMain(FactorType.VOC) .withCombination( listOf( listOf(FactorType.PM25, FactorType.PM10), @@ -53,11 +58,14 @@ .create() ) } + this.config.isSearchAddress = isSearchAddress + pollutedSummary = PollutedSummary(config) { summaryCallback(it) } newTask() } - constructor(sceneInfoRep: SceneInfoRep, sourceTraceRep: SourceTraceRep) : this(sceneInfoRep, sourceTraceRep, null) + constructor(sceneInfoRep: SceneInfoRep, sourceTraceRep: SourceTraceRep, isSearchAddress: Boolean = true) + : this(sceneInfoRep, sourceTraceRep, null, isSearchAddress) private val pollutedSummary: PollutedSummary private val sceneInfoRep: SceneInfoRep diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/config/RTExcWindLevelConfig.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/config/RTExcWindLevelConfig.kt index 81d3ef6..042bcf2 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/config/RTExcWindLevelConfig.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/config/RTExcWindLevelConfig.kt @@ -19,7 +19,8 @@ val countLimit: Int, ){ } - + // 鏄惁鑱旂綉鏌ユ壘瀵瑰簲璺鍦板潃淇℃伅 + var isSearchAddress = true // 闄愬畾璺濈鍐咃紙鍗曚綅锛氱背锛� var distanceLimit = 3000 // 闄愬畾鏃堕棿鍐咃紙鍗曚綅锛氬垎閽燂級 @@ -66,20 +67,25 @@ ) /****鏁版嵁蹇�熶笂鍗�*****************************************************************************/ - // 鐩戞祴鍥犲瓙鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級鍐呮甯稿彉鍖栫殑閲忕骇鑼冨洿 + // 鍦ㄩ閫熷浜�0 - 1.5 m/s 涔嬮棿鏃� var changeRateUp1 = mutableMapOf( + // PM2.5鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級涓婂崌閲忕骇澶т簬绛変簬4渭g/m鲁锛岃繛缁彂鐢�2娆� FactorType.PM25 to WindLevelCondition( .0 to 1.5, 4.0 to Double.MAX_VALUE, DistanceType.TYPE1, - 3 +// fixme: 2025.7.24 鍥犱负浣庨閫熶笅鏁版嵁鍙樺寲娆℃暟璁剧疆杩囧锛屽鑷撮仐婕忚瘑鍒� +// 3 + 2 ), + // PM10鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級涓婂崌閲忕骇澶т簬绛変簬4渭g/m鲁锛岃繛缁彂鐢�2娆� FactorType.PM10 to WindLevelCondition( .0 to 1.5, 4.0 to Double.MAX_VALUE, DistanceType.TYPE1, - 3 + 2 ), + // VOC鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級涓婂崌閲忕骇澶т簬绛変簬6渭g/m鲁锛岃繛缁彂鐢�1娆� FactorType.VOC to WindLevelCondition( .0 to 1.5, 6.0 to Double.MAX_VALUE, @@ -87,19 +93,23 @@ 1 ), ) + // 鍦ㄩ閫熷浜�1.6 - 7.9 m/s 涔嬮棿鏃� var changeRateUp2 = mutableMapOf( + // PM2.5鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級涓婂崌閲忕骇澶т簬绛変簬4渭g/m鲁锛岃繛缁彂鐢�3娆� FactorType.PM25 to WindLevelCondition( 1.6 to 7.9, 4.0 to Double.MAX_VALUE, DistanceType.TYPE3, 3 ), + // PM10鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級涓婂崌閲忕骇澶т簬绛変簬4渭g/m鲁锛岃繛缁彂鐢�3娆� FactorType.PM10 to WindLevelCondition( 1.6 to 7.9, 4.0 to Double.MAX_VALUE, DistanceType.TYPE3, 3 ), + // VOC鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級涓婂崌閲忕骇澶т簬绛変簬6渭g/m鲁锛岃繛缁彂鐢�1娆� FactorType.VOC to WindLevelCondition( 1.6 to 7.9, 6.0 to Double.MAX_VALUE, @@ -107,19 +117,23 @@ 1 ), ) + // 鍦ㄩ閫熷浜�8.0 - 13.8 m/s 涔嬮棿鏃� var changeRateUp3 = mutableMapOf( + // PM2.5鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級涓婂崌閲忕骇澶т簬绛変簬4渭g/m鲁锛岃繛缁彂鐢�3娆� FactorType.PM25 to WindLevelCondition( 8.0 to 13.8, 4.0 to Double.MAX_VALUE, DistanceType.TYPE4, 3 ), + // PM10鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級涓婂崌閲忕骇澶т簬绛変簬4渭g/m鲁锛岃繛缁彂鐢�3娆� FactorType.PM10 to WindLevelCondition( 8.0 to 13.8, 4.0 to Double.MAX_VALUE, DistanceType.TYPE4, 3 ), + // VOC鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級涓婂崌閲忕骇澶т簬绛変簬6渭g/m鲁锛岃繛缁彂鐢�1娆� FactorType.VOC to WindLevelCondition( 8.0 to 13.8, 6.0 to Double.MAX_VALUE, @@ -129,20 +143,22 @@ ) /****鏁版嵁蹇�熶笅闄嶆彁閱�*****************************************************************************/ - // 鐩戞祴鍥犲瓙鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級鍐呮甯稿彉鍖栫殑閲忕骇鑼冨洿 var changeRateWarnDown = mutableMapOf( + // PM2.5鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級鍐呬笅闄嶉噺绾уぇ浜庣瓑浜�2渭g/m鲁锛岃繛缁彂鐢�3娆� FactorType.PM25 to WindLevelCondition( .0 to Double.MAX_VALUE, -Double.MAX_VALUE to -2.0, DistanceType.TYPE1, 3 ), + // PM10鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級鍐呬笅闄嶉噺绾уぇ浜庣瓑浜�2渭g/m鲁锛岃繛缁彂鐢�3娆� FactorType.PM10 to WindLevelCondition( .0 to Double.MAX_VALUE, -Double.MAX_VALUE to -2.0, DistanceType.TYPE1, 3 ), + // VOC鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級鍐呬笅闄嶉噺绾уぇ浜庣瓑浜�3渭g/m鲁锛岃繛缁彂鐢�3娆� FactorType.VOC to WindLevelCondition( .0 to Double.MAX_VALUE, -Double.MAX_VALUE to -3.0, @@ -153,23 +169,26 @@ /****鏁版嵁鏈変笂鍗囪秼鍔挎彁閱�*****************************************************************************/ var changeRateWarnUp = mutableMapOf( + // PM2.5鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級涓婂崌閲忕骇鍦�2 - 4渭g/m鲁涔嬮棿锛岃繛缁彂鐢�3娆� FactorType.PM25 to WindLevelCondition( .0 to Double.MAX_VALUE, 2.0 to 4.0, DistanceType.TYPE1, 3 ), + // PM10鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級涓婂崌閲忕骇鍦�2 - 4渭g/m鲁涔嬮棿锛岃繛缁彂鐢�3娆� FactorType.PM10 to WindLevelCondition( .0 to Double.MAX_VALUE, 2.0 to 4.0, DistanceType.TYPE1, 3 ), + // VOC鍦ㄤ竴涓洃娴嬪懆鏈燂紙4绉掞級涓婂崌閲忕骇鍦�3 - 6渭g/m鲁涔嬮棿锛岃繛缁彂鐢�2娆� FactorType.VOC to WindLevelCondition( .0 to Double.MAX_VALUE, 3.0 to 6.0, DistanceType.TYPE1, - 1 + 2 ), ) } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt index fe2e325..e9092d6 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt @@ -72,14 +72,19 @@ MapUtil.wgs84ToGcj02(it) } - closePolygon = closeSourceTrace(historyData, pair) + closePolygon = closeSourceTrace(historyData, pair).map { + // 灏嗗潗鏍囪浆鎹负gcj02锛堢伀鏄熷潗鏍囩郴锛夛紝鍥犱负姹℃煋婧愬満鏅俊鎭兘涓烘鍧愭爣绯� + MapUtil.wgs84ToGcj02(it) + } - try { - val address = AMapService.reGeo(pair) - this.address = address.district + address.township + address.street - Thread.sleep(100) - } catch (e: Exception) { - e.printStackTrace() + if (config.isSearchAddress) { + try { + val address = AMapService.reGeo(MapUtil.wgs84ToGcj02(pair)) + this.address = address.district + address.township + address.street +// Thread.sleep(100) + } catch (e: Exception) { + e.printStackTrace() + } } } diff --git a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt index 188bb7f..7baf746 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedSummary.kt @@ -182,7 +182,7 @@ // 寤鸿鐨勮蛋鑸矾绾� result.direction = AMapService.directionDriving(origin, destination) - Thread.sleep(200) +// Thread.sleep(200) } // 绾跨储鍒嗘瀽瀹屾垚鍚庯紝绉诲姩鑷冲巻鍙茬嚎绱㈠垪琛� historyClueList.addAll(clueList) diff --git a/src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt b/src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt index b4f945a..17a9a7e 100644 --- a/src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt +++ b/src/main/kotlin/com/flightfeather/uav/domain/repository/SourceTraceRep.kt @@ -6,6 +6,7 @@ import com.flightfeather.uav.biz.sourcetrace.model.PollutedClue import com.flightfeather.uav.biz.sourcetrace.model.PollutedSummary import com.flightfeather.uav.common.utils.GsonUtils +import com.flightfeather.uav.domain.entity.Mission import com.flightfeather.uav.domain.entity.SourceTraceMsg import com.flightfeather.uav.domain.mapper.SourceTraceMsgMapper import com.flightfeather.uav.socket.sender.MsgType @@ -103,4 +104,12 @@ } } } + + fun delete(mission: Mission): Int { + return sourceTraceMsgMapper.deleteByExample(Example(SourceTraceMsg::class.java).apply { + createCriteria().andEqualTo("deviceCode", mission.deviceCode) + .andGreaterThanOrEqualTo("startTime", mission.startTime) + .andLessThanOrEqualTo("endTime", mission.endTime) + }) + } } \ 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 3ae933c..0961852 100644 --- a/src/test/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceControllerTest.kt +++ b/src/test/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceControllerTest.kt @@ -29,38 +29,62 @@ lateinit var missionMapper: MissionMapper @Autowired + lateinit var missionRep: MissionRep + + @Autowired lateinit var realTimeDataService: RealTimeDataService @Test fun autoSourceTrace() { - val sourceTraceController = SourceTraceController(sceneInfoRep, sourceTraceRep) - val missions = missionMapper.selectByExample(Example(Mission::class.java).apply { - createCriteria().andEqualTo("deviceType", "0a") - .andLessThanOrEqualTo("startTime", "2024-11-07 15:00:00") - orderBy("startTime").desc() - }) - missions.forEach { m -> - val rtData = realTimeDataService.getSecondData( - m?.deviceType, - m?.deviceCode, - DateUtil.instance.dateToString(m?.startTime, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS), - DateUtil.instance.dateToString(m?.endTime, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS), - null, - 1, - 10000 - ) - rtData.data?.forEach { d -> - val rtdVehicle = d.toBaseRealTimeData(RealTimeDataVehicle::class.java) + val sourceTraceController = SourceTraceController(sceneInfoRep, sourceTraceRep, false) + val mCode = listOf("SH-CN-20241227", "SH-CN-20241127", "SH-CN-20240906", "SH-CN-20240830(05)", + "SH-CN-20240830(04)", "SH-CN-20240823", "SH-CN-20240723(02)", "SH-CN-20250723(01)") + mCode.forEach { c-> + missionRep.findOne(c)?.let {m -> + val rtData = realTimeDataService.getSecondData( + m?.deviceType, + m?.deviceCode, + DateUtil.instance.dateToString(m?.startTime, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS), + DateUtil.instance.dateToString(m?.endTime, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS), + null, + 1, + 10000 + ) + rtData.data?.forEach { d -> + val rtdVehicle = d.toBaseRealTimeData(RealTimeDataVehicle::class.java) // Thread.sleep(500) - sourceTraceController.addOneData(rtdVehicle) + sourceTraceController.addOneData(rtdVehicle) + } + sourceTraceController.initTask() } - sourceTraceController.initTask() } +// val missions = missionMapper.selectByExample(Example(Mission::class.java).apply { +// createCriteria().andEqualTo("deviceType", "0a") +// .andLessThanOrEqualTo("startTime", "2024-11-07 15:00:00") +// orderBy("startTime").desc() +// }) +// missions.forEach { m -> +// val rtData = realTimeDataService.getSecondData( +// m?.deviceType, +// m?.deviceCode, +// DateUtil.instance.dateToString(m?.startTime, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS), +// DateUtil.instance.dateToString(m?.endTime, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS), +// null, +// 1, +// 10000 +// ) +// rtData.data?.forEach { d -> +// val rtdVehicle = d.toBaseRealTimeData(RealTimeDataVehicle::class.java) +//// Thread.sleep(500) +// sourceTraceController.addOneData(rtdVehicle) +// } +// sourceTraceController.initTask() +// } // val rtData = realTimeDataService.getSecondData( // "0a", // "0a0000000001", -// "2025-01-06 13:32:00", -// "2025-01-06 15:52:36", +// "2024-08-23 12:30:23", +// "2024-08-23 15:12:56", // null, // 1, // 10000 @@ -73,4 +97,15 @@ } + @Test + fun deleteSourceTrace() { + val mCode = listOf("SH-CN-20241227", "SH-CN-20241127", "SH-CN-20240906", "SH-CN-20240830(05)", + "SH-CN-20240830(04)", "SH-CN-20240823", "SH-CN-20240723(02)", "SH-CN-20250723(01)") + mCode.forEach {c -> + missionRep.findOne(c)?.let { + sourceTraceRep.delete(it) + } + } + } + } \ No newline at end of file -- Gitblit v1.9.3