riku
2025-08-25 2de612e9b260df2e76d4dd620ca739aa3b6e8c57
2025.8.25
1. 添加走航季度报告相关统计功能(待完成)
已修改7个文件
已添加3个文件
253 ■■■■ 文件已修改
src/main/kotlin/com/flightfeather/uav/biz/report/MissionClue.kt 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/biz/report/MissionInventory.kt 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/biz/report/MissionSummary.kt 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/entity/Mission.java 81 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/bean/FactorStatistics.kt 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/MissionService.kt 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/MissionServiceImpl.kt 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/web/MissionController.kt 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/generator/generatorConfig.xml 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/MissionMapper.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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
    }
}
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
    }
}
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() {
    }
}
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();
    }
}
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
)
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
}
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)
    }
}
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(
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:这个模型与hierarchical模型相似,除了如果一个实体类只包含一个字段,则不会单独生成此实体类。因此,如果一个表的主键只有一个字段,那么不会为该字段生成单独的实体类,会将该字段合并到基本实体类中。
    flat:该模型为每一张表只生成一个实体类。这个实体类包含表中的所有字段。
@@ -25,15 +25,15 @@
            <property name="suppressAllComments" value="true"/>
        </commentGenerator>
        <!--数据库链接URL,用户名、密码 -->
        <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>
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>