From 2de612e9b260df2e76d4dd620ca739aa3b6e8c57 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期一, 25 八月 2025 16:07:16 +0800 Subject: [PATCH] 2025.8.25 1. 添加走航季度报告相关统计功能(待完成) --- src/main/kotlin/com/flightfeather/uav/domain/entity/Mission.java | 81 ++++++++++++++- src/main/resources/generator/generatorConfig.xml | 26 ++-- src/main/kotlin/com/flightfeather/uav/lightshare/service/MissionService.kt | 14 ++ src/main/kotlin/com/flightfeather/uav/biz/report/MissionClue.kt | 15 +++ src/main/kotlin/com/flightfeather/uav/lightshare/bean/FactorStatistics.kt | 19 +++ src/main/resources/mapper/MissionMapper.xml | 6 + src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImpl.kt | 32 ++++- src/main/kotlin/com/flightfeather/uav/lightshare/web/MissionController.kt | 8 src/main/kotlin/com/flightfeather/uav/biz/report/MissionInventory.kt | 34 ++++++ src/main/kotlin/com/flightfeather/uav/biz/report/MissionSummary.kt | 18 +++ 10 files changed, 210 insertions(+), 43 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/biz/report/MissionClue.kt b/src/main/kotlin/com/flightfeather/uav/biz/report/MissionClue.kt new file mode 100644 index 0000000..73855b5 --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/biz/report/MissionClue.kt @@ -0,0 +1,15 @@ +package com.flightfeather.uav.biz.report + +import com.flightfeather.uav.socket.eunm.FactorType + +/** + * @date 2025/8/25 14:18 + * @author feiyu + */ +class MissionClue { + + inner class Clue{ + var factor:FactorType?=null + var riskRegion:String?=null + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/biz/report/MissionInventory.kt b/src/main/kotlin/com/flightfeather/uav/biz/report/MissionInventory.kt new file mode 100644 index 0000000..701526e --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/biz/report/MissionInventory.kt @@ -0,0 +1,34 @@ +package com.flightfeather.uav.biz.report + +import com.flightfeather.uav.domain.entity.Mission +import com.flightfeather.uav.domain.entity.SceneInfo +import com.flightfeather.uav.lightshare.bean.FactorStatistics +import com.flightfeather.uav.socket.eunm.FactorType + +/** + * 璧拌埅婧簮娓呭崟 + * 鍖呭惈鏃舵鍐呯殑璧拌埅浠诲姟姹囨�绘竻鍗曚互鍙婃瘡娆¤蛋鑸殑鏁版嵁姹囨�绘竻鍗� + * @date 2025/8/25 11:02 + * @author feiyu + */ +class MissionInventory { + + // 璧拌埅娓呭崟淇℃伅 + inner class MissionInfo : Mission() { + // 棣栬姹℃煋鐗� + var mainFactor: String? = null + + // 鐩戞祴寮傚父鍥犲瓙 + var abnormalFactors: List<FactorType>? = null + + // 婧簮闂鍦烘櫙鏁� + var sceneCount: Int = 0 + } + + // 璧拌埅璇︽儏淇℃伅 + inner class MissionDetail : Mission() { + var keyScene: List<SceneInfo>? = null + var dataStatistics: List<FactorStatistics>? = null + + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/biz/report/MissionSummary.kt b/src/main/kotlin/com/flightfeather/uav/biz/report/MissionSummary.kt index a3926fd..beb76d5 100644 --- a/src/main/kotlin/com/flightfeather/uav/biz/report/MissionSummary.kt +++ b/src/main/kotlin/com/flightfeather/uav/biz/report/MissionSummary.kt @@ -1,10 +1,13 @@ package com.flightfeather.uav.biz.report +import org.springframework.stereotype.Component + /** * 璧拌埅浠诲姟姹囨�� * @date 2025/8/22 * @author feiyu02 */ +@Component class MissionSummary { inner class Summary( @@ -14,8 +17,17 @@ val kilometres: Double, // 娑夊強鍖哄煙 val regionList: List<String>, - // 鍚勭瓑绾х┖姘旇川閲忚儗鏅蛋鑸鏁� - val countByDegree: MutableMap<String, Int>, - + // 鍚勭瓑绾х┖姘旇川閲忚儗鏅蛋鑸鏁�,<绌烘皵璐ㄩ噺绛夌骇锛屾鏁帮紝鍗犳瘮> + val countByDegree: List<Triple<String, Int, Double>>, + // 闂鎬绘暟 + val probCount:Int, + // 楂橀闄╁満鏅�绘暟 + val highRiskSceneCount:Int, + // 闂鎸夌洃娴嬪洜瀛愮被鍨嬪垎甯冩儏鍐�, <鍥犲瓙绫诲瀷锛屾鏁帮紝鍗犳瘮> + val probByFactor:List<Triple<String, Int, Double>> ) + + fun execute() { + + } } \ No newline at end of file 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 d98aadf..68280ab 100644 --- a/src/main/kotlin/com/flightfeather/uav/domain/entity/Mission.java +++ b/src/main/kotlin/com/flightfeather/uav/domain/entity/Mission.java @@ -20,9 +20,6 @@ @Column(name = "end_time") private Date endTime; - /** - * 鏁版嵁鏄惁宸茬粡鎷夊彇鍏ュ簱 - */ @Column(name = "data_pulled") private Boolean dataPulled; @@ -49,6 +46,22 @@ @Column(name = "town_name") private String townName; + + /** + * 閲岀▼鏁帮紝鍏噷 + */ + private Float kilometres; + + /** + * 鎵�灞炲尯鍩� + */ + private String region; + + /** + * 绌烘皵璐ㄩ噺绛夌骇 + */ + @Column(name = "pollution_degree") + private String pollutionDegree; /** * @return mission_code @@ -121,18 +134,14 @@ } /** - * 鑾峰彇鏁版嵁鏄惁宸茬粡鎷夊彇鍏ュ簱 - * - * @return data_pulled - 鏁版嵁鏄惁宸茬粡鎷夊彇鍏ュ簱 + * @return data_pulled */ public Boolean getDataPulled() { return dataPulled; } /** - * 璁剧疆鏁版嵁鏄惁宸茬粡鎷夊彇鍏ュ簱 - * - * @param dataPulled 鏁版嵁鏄惁宸茬粡鎷夊彇鍏ュ簱 + * @param dataPulled */ public void setDataPulled(Boolean dataPulled) { this.dataPulled = dataPulled; @@ -249,4 +258,58 @@ public void setTownName(String townName) { this.townName = townName == null ? null : townName.trim(); } + + /** + * 鑾峰彇閲岀▼鏁帮紝鍏噷 + * + * @return kilometres - 閲岀▼鏁帮紝鍏噷 + */ + public Float getKilometres() { + return kilometres; + } + + /** + * 璁剧疆閲岀▼鏁帮紝鍏噷 + * + * @param kilometres 閲岀▼鏁帮紝鍏噷 + */ + public void setKilometres(Float kilometres) { + this.kilometres = kilometres; + } + + /** + * 鑾峰彇鎵�灞炲尯鍩� + * + * @return region - 鎵�灞炲尯鍩� + */ + public String getRegion() { + return region; + } + + /** + * 璁剧疆鎵�灞炲尯鍩� + * + * @param region 鎵�灞炲尯鍩� + */ + public void setRegion(String region) { + this.region = region == null ? null : region.trim(); + } + + /** + * 鑾峰彇绌烘皵璐ㄩ噺绛夌骇 + * + * @return pollution_degree - 绌烘皵璐ㄩ噺绛夌骇 + */ + public String getPollutionDegree() { + return pollutionDegree; + } + + /** + * 璁剧疆绌烘皵璐ㄩ噺绛夌骇 + * + * @param pollutionDegree 绌烘皵璐ㄩ噺绛夌骇 + */ + public void setPollutionDegree(String pollutionDegree) { + this.pollutionDegree = pollutionDegree == null ? null : pollutionDegree.trim(); + } } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/bean/FactorStatistics.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/bean/FactorStatistics.kt new file mode 100644 index 0000000..f81e97f --- /dev/null +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/bean/FactorStatistics.kt @@ -0,0 +1,19 @@ +package com.flightfeather.uav.lightshare.bean + +import com.flightfeather.uav.socket.eunm.FactorType + +/** + * 鐩戞祴鍥犲瓙鏁版嵁缁熻 + * @date 2025/8/25 11:26 + * @author feiyu + */ +data class FactorStatistics( + // 鐩戞祴鍥犲瓙绫诲瀷 + val factor: FactorType, + // 鏈�灏忓�� + val minValue: Double, + // 鏈�澶у�� + val maxValue: Double, + // 鍧囧�� + val avgValue: Double +) \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/MissionService.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/MissionService.kt index bd49475..5c6f6a9 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/MissionService.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/MissionService.kt @@ -2,19 +2,25 @@ import com.flightfeather.uav.domain.entity.Mission import com.flightfeather.uav.lightshare.bean.BaseResponse +import com.flightfeather.uav.lightshare.bean.DataHead import javax.servlet.http.HttpServletResponse interface MissionService { - fun getMission(type: String?, page: Int?, perPage: Int?): BaseResponse<List<Mission>> + fun getMission(type: String?, page: Int?, perPage: Int?): Pair<DataHead, List<Mission>> - fun createMission(mission: Mission): BaseResponse<Boolean> + fun createMission(mission: Mission): Boolean - fun updateMission(mission: Mission): BaseResponse<Boolean> + fun updateMission(mission: Mission): Boolean - fun deleteMission(missionCode: String): BaseResponse<Boolean> + fun deleteMission(missionCode: String): Boolean fun deleteMissionAndData(missionCode: String): Boolean fun getReport(missionCode: String, response: HttpServletResponse) + + /** + * 璁$畻浠诲姟淇℃伅锛屽寘鎷�婚噷绋嬫暟銆佹墍灞炲尯鍩熴�佸綋鏃ョ殑绌烘皵璐ㄩ噺鑳屾櫙绛� + */ + fun calMissionInfo(missionCode: String): Boolean } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImpl.kt index e0f0d8a..d00408f 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImpl.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImpl.kt @@ -1,12 +1,15 @@ package com.flightfeather.uav.lightshare.service.impl import com.flightfeather.uav.biz.FactorFilter +import com.flightfeather.uav.biz.mission.MissionUtil import com.flightfeather.uav.biz.report.MissionReport import com.flightfeather.uav.common.exception.BizException import com.flightfeather.uav.domain.entity.Mission import com.flightfeather.uav.domain.entity.RealTimeDataVehicle import com.flightfeather.uav.domain.mapper.MissionMapper import com.flightfeather.uav.domain.mapper.RealTimeDataVehicleMapper +import com.flightfeather.uav.domain.repository.MissionRep +import com.flightfeather.uav.domain.repository.RealTimeDataRep import com.flightfeather.uav.lightshare.bean.BaseResponse import com.flightfeather.uav.lightshare.bean.DataHead import com.flightfeather.uav.lightshare.service.MissionService @@ -22,8 +25,10 @@ private val missionMapper: MissionMapper, private val realTimeDataVehicleMapper: RealTimeDataVehicleMapper, private val missionReport: MissionReport, + private val missionRep: MissionRep, + private val realTimeDataRep: RealTimeDataRep ) : MissionService { - override fun getMission(type: String?, page: Int?, perPage: Int?): BaseResponse<List<Mission>> { + override fun getMission(type: String?, page: Int?, perPage: Int?): Pair<DataHead, List<Mission>> { val _perPage = perPage ?: 60 val _page = page ?: 1 val pageInfo = PageHelper.startPage<Mission>(_page, _perPage) @@ -34,28 +39,30 @@ } orderBy("startTime").desc() }).forEach { it?.let { result.add(it) } } - return BaseResponse(true, head = DataHead(pageInfo.pageNum, pageInfo.pages),data = result) +// return BaseResponse(true, head = DataHead(pageInfo.pageNum, pageInfo.pages),data = result) + return DataHead(pageInfo.pageNum, pageInfo.pages) to result } @Synchronized - override fun createMission(mission: Mission): BaseResponse<Boolean> { + override fun createMission(mission: Mission): Boolean { missionMapper.selectByPrimaryKey(mission.missionCode)?.run { - return BaseResponse(false, "浠诲姟缂栧彿宸插瓨鍦�") +// return BaseResponse(false, "浠诲姟缂栧彿宸插瓨鍦�") + throw BizException("浠诲姟缂栧彿宸插瓨鍦�") } missionMapper.insert(mission).let { - return BaseResponse(it == 1) + return it == 1 } } - override fun updateMission(mission: Mission): BaseResponse<Boolean> { + override fun updateMission(mission: Mission): Boolean { missionMapper.updateByPrimaryKey(mission).let { - return BaseResponse(it == 1) + return it == 1 } } - override fun deleteMission(missionCode: String): BaseResponse<Boolean> { + override fun deleteMission(missionCode: String): Boolean { missionMapper.deleteByPrimaryKey(missionCode).let { - return BaseResponse(it == 1) + return it == 1 } } @@ -81,4 +88,11 @@ } return } + + override fun calMissionInfo(missionCode: String): Boolean { + val mission = missionRep.findOne(missionCode) ?: throw BizException("璧拌埅浠诲姟涓嶅瓨鍦�") + val data = realTimeDataRep.fetchData(mission) + mission.kilometres = MissionUtil.calKilometres(data).toFloat() + return updateMission(mission) + } } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/web/MissionController.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/web/MissionController.kt index d220000..eeb0fc7 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/web/MissionController.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/web/MissionController.kt @@ -16,22 +16,22 @@ @RequestParam(value = "type", required = false) type: String?, @RequestParam(value = "page", required = false) page: Int?, @RequestParam(value = "perPage", required = false) perPage: Int? - ) = missionService.getMission(type, page, perPage) + ) = resPack { missionService.getMission(type, page, perPage) } @PostMapping("/create") fun createMission( @RequestBody mission: Mission - ) = missionService.createMission(mission) + ) = resPack { missionService.createMission(mission) } @PostMapping("/update") fun updateMission( @RequestBody mission: Mission - ) = missionService.updateMission(mission) + ) = resPack { missionService.updateMission(mission) } @PostMapping("/delete") fun deleteMission( @RequestParam("missionCode") missionCode: String - ) = missionService.deleteMission(missionCode) + ) = resPack { missionService.deleteMission(missionCode) } @PostMapping("/delete/data/vehicle") fun deleteMissionAndData( diff --git a/src/main/resources/generator/generatorConfig.xml b/src/main/resources/generator/generatorConfig.xml index fdf25e1..50c00e3 100644 --- a/src/main/resources/generator/generatorConfig.xml +++ b/src/main/resources/generator/generatorConfig.xml @@ -4,8 +4,8 @@ "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> <generatorConfiguration> <!-- 鏁版嵁搴撻┍鍔�:閫夋嫨浣犵殑鏈湴纭洏涓婇潰鐨勬暟鎹簱椹卞姩鍖�--> -<!-- <classPathEntry location="C:\Users\feiyu\.m2\repository\mysql\mysql-connector-java\5.1.46\mysql-connector-java-5.1.46.jar"/>--> - <classPathEntry location="C:\Users\feiyu02\.m2\repository\mysql\mysql-connector-java\8.0.21\mysql-connector-java-8.0.21.jar"/> + <classPathEntry location="C:\Users\feiyu\.m2\repository\mysql\mysql-connector-java\5.1.46\mysql-connector-java-5.1.46.jar"/> +<!-- <classPathEntry location="C:\Users\feiyu02\.m2\repository\mysql\mysql-connector-java\8.0.21\mysql-connector-java-8.0.21.jar"/>--> <!--defaultModelType{ conditional:杩欎釜妯″瀷涓巋ierarchical妯″瀷鐩镐技,闄や簡濡傛灉涓�涓疄浣撶被鍙寘鍚竴涓瓧娈�,鍒欎笉浼氬崟鐙敓鎴愭瀹炰綋绫汇�傚洜姝�,濡傛灉涓�涓〃鐨勪富閿彧鏈変竴涓瓧娈�,閭d箞涓嶄細涓鸿瀛楁鐢熸垚鍗曠嫭鐨勫疄浣撶被,浼氬皢璇ュ瓧娈靛悎骞跺埌鍩烘湰瀹炰綋绫讳腑銆� flat:璇ユā鍨嬩负姣忎竴寮犺〃鍙敓鎴愪竴涓疄浣撶被銆傝繖涓疄浣撶被鍖呭惈琛ㄤ腑鐨勬墍鏈夊瓧娈点�� @@ -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> @@ -52,7 +52,7 @@ </javaClientGenerator> <!-- 瑕佺敓鎴愮殑琛� tableName鏄暟鎹簱涓殑琛ㄥ悕鎴栬鍥惧悕 domainObjectName鏄疄浣撶被鍚�--> <!-- <table tableName="air_real_time_data" domainObjectName="RealTimeData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> -<!-- <table tableName="mission" domainObjectName="Mission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> + <table tableName="mission" domainObjectName="Mission" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> <!-- <table tableName="el_minutevalue" domainObjectName="ElectricMinuteValue" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> <!-- <table tableName="el_company_device" domainObjectName="CompanyDevice" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> <!-- <table tableName="co_complaint" domainObjectName="Complaint" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> @@ -70,7 +70,7 @@ <!-- <table tableName="grid_cell" domainObjectName="GridCell" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> <!-- <table tableName="grid_data" domainObjectName="GridData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> <!-- <table tableName="grid_data_detail" domainObjectName="GridDataDetail" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> - <table tableName="source_trace_msg" domainObjectName="SourceTraceMsg" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> - <table tableName="source_trace_msg_blob" domainObjectName="SourceTraceMsgBlob" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> +<!-- <table tableName="source_trace_msg" domainObjectName="SourceTraceMsg" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> +<!-- <table tableName="source_trace_msg_blob" domainObjectName="SourceTraceMsgBlob" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> </context> </generatorConfiguration> \ No newline at end of file diff --git a/src/main/resources/mapper/MissionMapper.xml b/src/main/resources/mapper/MissionMapper.xml index e6dbcb6..3a44488 100644 --- a/src/main/resources/mapper/MissionMapper.xml +++ b/src/main/resources/mapper/MissionMapper.xml @@ -19,12 +19,16 @@ <result column="district_name" jdbcType="VARCHAR" property="districtName" /> <result column="town_code" jdbcType="VARCHAR" property="townCode" /> <result column="town_name" jdbcType="VARCHAR" property="townName" /> + <result column="kilometres" jdbcType="REAL" property="kilometres" /> + <result column="region" jdbcType="VARCHAR" property="region" /> + <result column="pollution_degree" jdbcType="VARCHAR" property="pollutionDegree" /> </resultMap> <sql id="Base_Column_List"> <!-- WARNING - @mbg.generated --> 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 + province_name, city_code, city_name, district_code, district_name, town_code, town_name, + kilometres, region, pollution_degree </sql> </mapper> \ No newline at end of file -- Gitblit v1.9.3