From 94fee0b511279679b43e210878d3d36e5a14384b Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期二, 30 九月 2025 09:14:10 +0800 Subject: [PATCH] 2025.9.30 1. 新增走航任务统计功能 --- src/main/kotlin/com/flightfeather/uav/domain/entity/Mission.java | 79 ++++++++++++++- src/main/resources/generator/generatorConfig.xml | 16 +- src/main/kotlin/com/flightfeather/uav/domain/repository/RealTimeDataRep.kt | 4 src/main/kotlin/com/flightfeather/uav/biz/mission/MissionUtil.kt | 33 ++++++ src/main/kotlin/com/flightfeather/uav/lightshare/service/DataAnalysisService.kt | 12 ++ src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/DataAnalysisServiceImpl.kt | 34 ++++++ src/main/resources/mapper/MissionMapper.xml | 4 src/main/kotlin/com/flightfeather/uav/domain/repository/RealTimeDataRepDelegate.kt | 26 +++++ src/test/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceControllerTest.kt | 9 + src/main/kotlin/com/flightfeather/uav/lightshare/web/DataAnalysisController.kt | 18 +++ src/test/kotlin/com/flightfeather/uav/biz/mission/MissionUtilTest.kt | 32 ++++-- src/main/kotlin/com/flightfeather/uav/biz/report/MissionInventory.kt | 6 12 files changed, 237 insertions(+), 36 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/biz/mission/MissionUtil.kt b/src/main/kotlin/com/flightfeather/uav/biz/mission/MissionUtil.kt index be6523c..2b49150 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/mission/MissionUtil.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/mission/MissionUtil.kt @@ -56,4 +56,37 @@ // 杩斿洖涔¢晣鍜岃閬撳悕绉扮粍鍚� return address.township } + + /** + * 鏁版嵁娓呮礂 + * 1. 淇鐢变簬纭欢璁惧鍗¢】瀵艰嚧鐨勬暟鎹噰鏍锋椂闂翠笉鍙橀棶棰橈紝閲囩敤鑷姩绱姞鏁版嵁鍛ㄦ湡鐨勬柟寮忎慨鏀归噰鏍锋椂闂� + * @param data 鍘熷鏁版嵁鍒楄〃 + * @param period 鏁版嵁鍛ㄦ湡锛屽崟浣嶏細绉� + * @return 娓呮礂鍚庨渶瑕佷慨鏀圭殑鏁版嵁鍒楄〃 + */ + fun dataClean(dataList: List<BaseRealTimeData>, period: Long): List<BaseRealTimeData> { + val cleanedData = mutableListOf<BaseRealTimeData>() + var errorData: BaseRealTimeData? = null + dataList.forEachIndexed { index, data -> + if (index == 0) { + return@forEachIndexed + } + val lastOne = dataList[index - 1] + if (errorData == null) { + if (data.dataTime!!.time == lastOne.dataTime!!.time) { + data.dataTime?.time = lastOne.dataTime?.time!!.plus(period * 1000) + cleanedData.add(data) + errorData = lastOne + } + } else { + if (data.dataTime!!.time == errorData!!.dataTime!!.time) { + data.dataTime?.time = lastOne.dataTime?.time!!.plus(period * 1000) + cleanedData.add(data) + } else { + errorData = null + } + } + } + return cleanedData + } } diff --git a/src/main/kotlin/com/flightfeather/uav/biz/report/MissionInventory.kt b/src/main/kotlin/com/flightfeather/uav/biz/report/MissionInventory.kt index f6700d7..7f0fb2e 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/report/MissionInventory.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/report/MissionInventory.kt @@ -19,7 +19,7 @@ // 璧拌埅娓呭崟淇℃伅 class MissionInfo : Mission() { // 棣栬姹℃煋鐗� - var mainFactor: String? = null +// var mainFactor: String? = null // 鐩戞祴寮傚父鍥犲瓙 var abnormalFactors: List<FactorType>? = null @@ -74,7 +74,7 @@ val missionInfo = MissionInfo() BeanUtils.copyProperties(mission, missionInfo) missionInfo.apply { - mainFactor = factorMap.maxByOrNull { it.value }?.key?.name +// mainFactor = factorMap.maxByOrNull { it.value }?.key?.name this.abnormalFactors = abnormalFactors this.sceneCount = sceneCount } @@ -152,7 +152,7 @@ val missionInfo = MissionInfo() BeanUtils.copyProperties(mission, missionInfo) missionInfo.apply { - mainFactor = factorMap.maxByOrNull { it.value }?.key?.name +// mainFactor = factorMap.maxByOrNull { it.value }?.key?.name this.abnormalFactors = abnormalFactors this.sceneCount = sceneCount this.scenes = scenes diff --git a/src/main/kotlin/com/flightfeather/uav/domain/entity/Mission.java b/src/main/kotlin/com/flightfeather/uav/domain/entity/Mission.java index e4367b9..9d045ab 100644 --- a/src/main/kotlin/com/flightfeather/uav/domain/entity/Mission.java +++ b/src/main/kotlin/com/flightfeather/uav/domain/entity/Mission.java @@ -20,6 +20,9 @@ @Column(name = "end_time") private Date endTime; + /** + * 鏁版嵁鏄惁宸茬粡鎷夊彇鍏ュ簱 + */ @Column(name = "data_pulled") private Boolean dataPulled; @@ -53,9 +56,14 @@ private Float kilometres; /** - * 鎵�灞炲尯鍩� + * 璧拌埅鍥寸粫涓昏鍖哄煙 */ private String region; + + /** + * 璧拌埅鍥寸粫涓績鍖哄煙鍗婂緞锛屽叕閲� + */ + private Float radius; /** * 绌烘皵璐ㄩ噺绛夌骇 @@ -63,7 +71,16 @@ @Column(name = "pollution_degree") private String pollutionDegree; + /** + * 绌烘皵璐ㄩ噺绛夌骇鎸囨暟AQI + */ private Integer aqi; + + /** + * 棣栬姹℃煋鍥犲瓙 + */ + @Column(name = "main_factor") + private String mainFactor; /** * @return mission_code @@ -136,14 +153,18 @@ } /** - * @return data_pulled + * 鑾峰彇鏁版嵁鏄惁宸茬粡鎷夊彇鍏ュ簱 + * + * @return data_pulled - 鏁版嵁鏄惁宸茬粡鎷夊彇鍏ュ簱 */ public Boolean getDataPulled() { return dataPulled; } /** - * @param dataPulled + * 璁剧疆鏁版嵁鏄惁宸茬粡鎷夊彇鍏ュ簱 + * + * @param dataPulled 鏁版嵁鏄惁宸茬粡鎷夊彇鍏ュ簱 */ public void setDataPulled(Boolean dataPulled) { this.dataPulled = dataPulled; @@ -280,21 +301,39 @@ } /** - * 鑾峰彇鎵�灞炲尯鍩� + * 鑾峰彇璧拌埅鍥寸粫涓昏鍖哄煙 * - * @return region - 鎵�灞炲尯鍩� + * @return region - 璧拌埅鍥寸粫涓昏鍖哄煙 */ public String getRegion() { return region; } /** - * 璁剧疆鎵�灞炲尯鍩� + * 璁剧疆璧拌埅鍥寸粫涓昏鍖哄煙 * - * @param region 鎵�灞炲尯鍩� + * @param region 璧拌埅鍥寸粫涓昏鍖哄煙 */ public void setRegion(String region) { this.region = region == null ? null : region.trim(); + } + + /** + * 鑾峰彇璧拌埅鍥寸粫涓績鍖哄煙鍗婂緞锛屽叕閲� + * + * @return radius - 璧拌埅鍥寸粫涓績鍖哄煙鍗婂緞锛屽叕閲� + */ + public Float getRadius() { + return radius; + } + + /** + * 璁剧疆璧拌埅鍥寸粫涓績鍖哄煙鍗婂緞锛屽叕閲� + * + * @param radius 璧拌埅鍥寸粫涓績鍖哄煙鍗婂緞锛屽叕閲� + */ + public void setRadius(Float radius) { + this.radius = radius; } /** @@ -316,16 +355,38 @@ } /** - * @return aqi + * 鑾峰彇绌烘皵璐ㄩ噺绛夌骇鎸囨暟AQI + * + * @return aqi - 绌烘皵璐ㄩ噺绛夌骇鎸囨暟AQI */ public Integer getAqi() { return aqi; } /** - * @param aqi + * 璁剧疆绌烘皵璐ㄩ噺绛夌骇鎸囨暟AQI + * + * @param aqi 绌烘皵璐ㄩ噺绛夌骇鎸囨暟AQI */ public void setAqi(Integer aqi) { this.aqi = aqi; } + + /** + * 鑾峰彇棣栬姹℃煋鍥犲瓙 + * + * @return main_factor - 棣栬姹℃煋鍥犲瓙 + */ + public String getMainFactor() { + return mainFactor; + } + + /** + * 璁剧疆棣栬姹℃煋鍥犲瓙 + * + * @param mainFactor 棣栬姹℃煋鍥犲瓙 + */ + public void setMainFactor(String mainFactor) { + this.mainFactor = mainFactor == null ? null : mainFactor.trim(); + } } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/domain/repository/RealTimeDataRep.kt b/src/main/kotlin/com/flightfeather/uav/domain/repository/RealTimeDataRep.kt index b7163b7..1c21daf 100644 --- a/src/main/kotlin/com/flightfeather/uav/domain/repository/RealTimeDataRep.kt +++ b/src/main/kotlin/com/flightfeather/uav/domain/repository/RealTimeDataRep.kt @@ -58,6 +58,10 @@ return delegate.insertByDeviceType(deviceType, type, data) } + fun updateData(deviceType: UWDeviceType?, data: List<BaseRealTimeData>, type: Int? = 0): Int { + return delegate.updateByDeviceType(deviceType, type, data) + } + fun deleteData(mission: Mission, type: Int? = 0): Int { if (mission.deviceCode == null || mission.startTime == null || mission.endTime == null) { throw BizException("瑕佸垹闄ょ殑璧拌埅浠诲姟缂哄け璁惧缂栧彿鎴栭噰鏍锋椂闂磋寖鍥达紝鏃犳硶鍒犻櫎瀵瑰簲鐩戞祴鏁版嵁") diff --git a/src/main/kotlin/com/flightfeather/uav/domain/repository/RealTimeDataRepDelegate.kt b/src/main/kotlin/com/flightfeather/uav/domain/repository/RealTimeDataRepDelegate.kt index 8ce8813..3628b1b 100644 --- a/src/main/kotlin/com/flightfeather/uav/domain/repository/RealTimeDataRepDelegate.kt +++ b/src/main/kotlin/com/flightfeather/uav/domain/repository/RealTimeDataRepDelegate.kt @@ -89,6 +89,32 @@ } /** + * 缁熶竴鐨剈pdate鏂规硶 + * @param deviceType 璁惧绫诲瀷 + * @param type 鏁版嵁缁熻鍛ㄦ湡锛�0锛氱绾у�硷紱1锛氬垎閽熷�� + * @param data 鏁版嵁 + */ + fun updateByDeviceType(deviceType: UWDeviceType?, type: Int? = 0, data: List<BaseRealTimeData>): Int { + return byDeviceType(deviceType, type, { + var count = 0 + data.forEach { count += realTimeDataVehicleMapper.updateByPrimaryKeySelective(it as RealTimeDataVehicle) } + count + }, { + var count = 0 + data.forEach { count += realTimeDataUavMapper.updateByPrimaryKeySelective(it as RealTimeDataUav) } + count + }, { + var count = 0 + data.forEach { count += realTimeDataGridMapper.updateByPrimaryKeySelective(it as RealTimeDataGrid) } + count + }, { + var count = 0 + data.forEach { count += realTimeDataGridMinMapper.updateByPrimaryKeySelective(it as RealTimeDataGridMin) } + count + }) ?: 0 + } + + /** * 缁熶竴鐨刣elete鏂规硶 * @param deviceType 璁惧绫诲瀷 * @param type 鏁版嵁缁熻鍛ㄦ湡锛�0锛氱绾у�硷紱1锛氬垎閽熷�� 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 2fa37ca..2c5081e 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/DataAnalysisService.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/DataAnalysisService.kt @@ -52,6 +52,8 @@ */ fun generateMissionSummary(startTime: Date, endTime: Date, areaVo: AreaVo): MissionSummary.Summary + fun generateMissionSummary(missionCode: String): MissionSummary.Summary + /** * 鐢熸垚璧拌埅浠诲姟娓呭崟锛堟寜鏃堕棿鍜屽尯鍩熺瓫閫夛級 * 鏍规嵁鏃堕棿鑼冨洿鍜屽湴鐞嗗尯鍩熸煡璇㈣蛋鑸换鍔★紝骞剁敓鎴愬寘鍚粺璁′俊鎭殑浠诲姟鍒楄〃 @@ -86,6 +88,14 @@ fun generateMissionDetail(startTime: Date, endTime: Date, areaVo: AreaVo): List<MissionDetail> /** + * 鐢熸垚璧拌埅浠诲姟璇︽儏锛堟寜浠诲姟缂栧彿绛涢�夛級 + * 鏍规嵁浠诲姟缂栧彿鏌ヨ骞剁敓鎴愯缁嗙殑浠诲姟鎶ュ憡锛屽寘鍚换鍔″畬鏁翠俊鎭�佸満鏅暟鎹拰缁熻缁撴灉 + * @param missionCode 浠诲姟缂栧彿锛岀敤浜庡敮涓�鏍囪瘑鐗瑰畾鐨勮蛋鑸换鍔� + * @return 浠诲姟璇︽儏瀵硅薄锛屽寘鍚换鍔″畬鏁翠俊鎭�佸満鏅暟鎹拰缁熻缁撴灉 + */ + fun generateMissionDetail(missionCode: String): MissionDetail + + /** * 鑾峰彇璧拌埅浠诲姟璇︽儏锛堢洿鎺ュ鐞嗕换鍔℃暟鎹級 * 澶勭悊宸叉湁鐨勪换鍔°�佹薄鏌撶嚎绱㈠拰瀹炴椂鏁版嵁锛岀敓鎴愯缁嗕换鍔℃姤鍛� * @param keyScenes 鍏抽敭鍦烘櫙鍒楄〃锛岀敤浜庡垎鏋愯蛋鑸槸鍚︾粡杩囪鍖哄煙 @@ -96,6 +106,8 @@ fun generateClueByRiskArea(startTime: Date, endTime: Date, areaVo: AreaVo): List<MissionRiskArea.ClueByArea> + fun generateClueByRiskArea(missionCode: String): List<MissionRiskArea.ClueByArea> + fun generateClueByRiskArea(keyScenes: List<SceneInfo?>, pollutedClues: List<PollutedClue?>): List<MissionRiskArea.ClueByArea> fun generateGridFusion(factorTypes: List<FactorType>, startTime: Date, endTime: Date, areaVo: AreaVo): 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 3e20de7..abdba09 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 @@ -108,6 +108,13 @@ 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 + } + /** * 鐢熸垚璧拌埅浠诲姟娓呭崟锛堟寜鏃堕棿鍜屽尯鍩熺瓫閫夛級 * 鏍规嵁鏃堕棿鑼冨洿鍜岃鏀垮尯鍒掓煡璇㈣蛋鑸换鍔★紝骞跺叧鑱旀薄鏌撶嚎绱㈡暟鎹敓鎴愪换鍔″垪琛� @@ -188,6 +195,20 @@ return generateMissionDetail(keyScenes, missionCluesData) } + override fun generateMissionDetail(missionCode: 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) + } + /** * 鐢熸垚璧拌埅浠诲姟璇︽儏锛堢洿鎺ュ鐞嗕换鍔℃暟鎹級 * 鎺ユ敹宸插叧鑱旂殑浠诲姟-姹℃煋绾跨储-瀹炴椂鏁版嵁涓夊厓缁勶紝鐢熸垚璇︾粏浠诲姟鎶ュ憡 @@ -226,6 +247,19 @@ return generateClueByRiskArea(keyScenes, 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.TYPE20.value, + SceneType.TYPE21.value + ) + ) + return generateClueByRiskArea(keyScenes, pollutedClues) + } + override fun generateClueByRiskArea( keyScenes: List<SceneInfo?>, pollutedClues: List<PollutedClue?>, 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 d6057bb..5bd3414 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/web/DataAnalysisController.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/web/DataAnalysisController.kt @@ -57,6 +57,12 @@ ) } + @ApiOperation(value = "鐢熸垚璧拌埅浠诲姟姹囨�荤粺璁�") + @GetMapping("/report/missionSummary/one") + fun generateOneMissionSummary( + @ApiParam("浠诲姟缂栧彿") @RequestParam missionCode: String, + ) = resPack { dataAnalysisService.generateMissionSummary(missionCode) } + @ApiOperation(value = "鐢熸垚璧拌埅浠诲姟娓呭崟") @PostMapping("/report/missionList") fun generateMissionList( @@ -97,6 +103,12 @@ ) } + @ApiOperation(value = "鐢熸垚璧拌埅浠诲姟璇︽儏") + @GetMapping("/report/missionDetail/one") + fun generateOneMissionDetail( + @ApiParam("浠诲姟缂栧彿") @RequestParam missionCode: String, + ) = resPack { dataAnalysisService.generateMissionDetail(missionCode) } + @ApiOperation(value = "璧拌埅鍏稿瀷闅愭偅鍖哄煙缁熻") @PostMapping("/report/clueByRiskArea") fun generateClueByRiskArea( @@ -117,6 +129,12 @@ ) } + @ApiOperation(value = "璧拌埅鍏稿瀷闅愭偅鍖哄煙缁熻") + @GetMapping("/report/clueByRiskArea/one") + fun generateOneClueByRiskArea( + @ApiParam("浠诲姟缂栧彿") @RequestParam missionCode: String, + ) = resPack { dataAnalysisService.generateClueByRiskArea(missionCode) } + @ApiOperation(value = "鍙犲姞铻嶅悎鍒嗘瀽") @PostMapping("/report/gridFusion") fun generateGridFusion( diff --git a/src/main/resources/generator/generatorConfig.xml b/src/main/resources/generator/generatorConfig.xml index df72831..1520d14 100644 --- a/src/main/resources/generator/generatorConfig.xml +++ b/src/main/resources/generator/generatorConfig.xml @@ -25,15 +25,15 @@ <property name="suppressAllComments" value="true"/> </commentGenerator> <!--鏁版嵁搴撻摼鎺RL锛岀敤鎴峰悕銆佸瘑鐮� --> -<!-- <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://47.100.191.150:3306/dronemonitor?serverTimezone=Asia/Shanghai"--> -<!-- userId="remoteU1"--> -<!-- password="eSoF8DnzfGTlhAjE">--> -<!-- </jdbcConnection>--> - <jdbcConnection driverClass="com.mysql.jdbc.Driver" - connectionURL="jdbc:mysql://localhost:3306/dronemonitor?serverTimezone=Asia/Shanghai" - userId="root" - password="123456"> + <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://47.100.191.150:3306/dronemonitor?serverTimezone=Asia/Shanghai" + userId="remoteU1" + password="eSoF8DnzfGTlhAjE"> </jdbcConnection> +<!-- <jdbcConnection driverClass="com.mysql.jdbc.Driver"--> +<!-- connectionURL="jdbc:mysql://localhost:3306/dronemonitor?serverTimezone=Asia/Shanghai"--> +<!-- userId="root"--> +<!-- password="123456">--> +<!-- </jdbcConnection>--> <javaTypeResolver> <property name="forceBigDecimals" value="false"/> </javaTypeResolver> diff --git a/src/main/resources/mapper/MissionMapper.xml b/src/main/resources/mapper/MissionMapper.xml index 0a10c92..d7f4f69 100644 --- a/src/main/resources/mapper/MissionMapper.xml +++ b/src/main/resources/mapper/MissionMapper.xml @@ -21,8 +21,10 @@ <result column="town_name" jdbcType="VARCHAR" property="townName" /> <result column="kilometres" jdbcType="REAL" property="kilometres" /> <result column="region" jdbcType="VARCHAR" property="region" /> + <result column="radius" jdbcType="REAL" property="radius" /> <result column="pollution_degree" jdbcType="VARCHAR" property="pollutionDegree" /> <result column="aqi" jdbcType="INTEGER" property="aqi" /> + <result column="main_factor" jdbcType="VARCHAR" property="mainFactor" /> </resultMap> <sql id="Base_Column_List"> <!-- @@ -30,6 +32,6 @@ --> mission_code, device_type, device_code, start_time, end_time, data_pulled, province_code, province_name, city_code, city_name, district_code, district_name, town_code, town_name, - kilometres, region, pollution_degree, aqi + kilometres, region, radius, pollution_degree, aqi, main_factor </sql> </mapper> \ No newline at end of file diff --git a/src/test/kotlin/com/flightfeather/uav/biz/mission/MissionUtilTest.kt b/src/test/kotlin/com/flightfeather/uav/biz/mission/MissionUtilTest.kt index f7264a7..ce27a1a 100644 --- a/src/test/kotlin/com/flightfeather/uav/biz/mission/MissionUtilTest.kt +++ b/src/test/kotlin/com/flightfeather/uav/biz/mission/MissionUtilTest.kt @@ -3,30 +3,40 @@ import com.flightfeather.uav.common.utils.MapUtil import com.flightfeather.uav.domain.repository.MissionRep import com.flightfeather.uav.domain.repository.RealTimeDataRep +import com.flightfeather.uav.socket.eunm.UWDeviceType 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 -//@RunWith(SpringRunner::class) -//@SpringBootTest +@RunWith(SpringRunner::class) +@SpringBootTest class MissionUtilTest { -// @Autowired + @Autowired lateinit var missionRep: MissionRep -// @Autowired + @Autowired lateinit var realTimeDataRep: RealTimeDataRep @Test fun calKilometres() { -// val m = missionRep.findOne("20250819") ?: return -// val data = realTimeDataRep.fetchData(m) -// MissionUtil.calKilometres(data) - val d = MapUtil.getDistance(121.425187, 31.225907, 121.425196, 31.225892) - println(d) - val d1 = MapUtil.getDistance(121.425196, 31.225892, 121.425187, 31.225907) - println(d1) + val m = missionRep.findOne("20250819") ?: return + val data = realTimeDataRep.fetchData(m) + MissionUtil.calKilometres(data) +// val d = MapUtil.getDistance(121.425187, 31.225907, 121.425196, 31.225892) +// println(d) +// val d1 = MapUtil.getDistance(121.425196, 31.225892, 121.425187, 31.225907) +// println(d1) + } + + @Test + fun dataClean() { + val m = missionRep.findOne("SH-CN-20250411") ?: return + val data = realTimeDataRep.fetchData(m) + val cleanedData = MissionUtil.dataClean(data, 4) + realTimeDataRep.updateData(UWDeviceType.fromValue(m.deviceType), cleanedData) + println(cleanedData.size) } } \ 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 8210d7f..51db22d 100644 --- a/src/test/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceControllerTest.kt +++ b/src/test/kotlin/com/flightfeather/uav/biz/sourcetrace/SourceTraceControllerTest.kt @@ -45,8 +45,9 @@ // "SH-CN-20240723(02)", //// "SH-CN-20250723(01)" // ) - 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 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 missions = missionMapper.selectByExample(Example(Mission::class.java).apply { createCriteria().andBetween("startTime", startTime, endTime) }) @@ -114,8 +115,8 @@ // "SH-CN-20240723(02)", //// "SH-CN-20250723(01)" // ) - 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 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 missions = missionMapper.selectByExample(Example(Mission::class.java).apply { createCriteria().andBetween("startTime", startTime, endTime) }) -- Gitblit v1.9.3