feiyu02
2024-08-29 e6cc379fbef57277568ee667ec07a508b3dcc479
1. 新增NO监测因子
2. 新增第三方数据接口数据获取相关模块
已修改14个文件
99 ■■■■■ 文件已修改
src/main/kotlin/com/flightfeather/uav/domain/entity/BaseRealTimeData.kt 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/entity/Mission.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/RealTimeDataService.kt 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/EPWModelServiceImpl.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/web/RealTimeDataController.kt 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/socket/eunm/FactorType.kt 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/generator/generatorConfig.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/MissionMapper.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/UAVApplicationTests.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/biz/dataprocess/DataProcessTest.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/model/epw/EPWDataPrepTest.kt 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/model/epw/EPWModelTest.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/entity/BaseRealTimeData.kt
@@ -111,20 +111,7 @@
            add(AirData().apply { setData(FactorType.WIND_SPEED, windSpeed) })
            add(AirData().apply { setData(FactorType.WIND_DIRECTION, windDirection) })
            add(AirData().apply { setData(FactorType.HEIGHT, height) })
        }
    }
    fun getByFactorIndex(i: Int): Float? {
        return when (i) {
            0 -> no2
            1 -> co
            2 -> h2s
            3 -> so2
            4 -> o3
            5 -> pm25
            6 -> pm10
            7 -> voc
            else -> null
            add(AirData().apply { setData(FactorType.NO, no) })
        }
    }
@@ -144,10 +131,11 @@
            FactorType.LNG -> longitude?.toFloat()
            FactorType.LAT -> latitude?.toFloat()
            FactorType.VELOCITY -> velocity
//            FactorType.TIME -> noi
//            FactorType.TIME -> dataTime?.time?.toFloat()
            FactorType.WIND_SPEED -> windSpeed
            FactorType.WIND_DIRECTION -> windDirection
            FactorType.HEIGHT -> height
            FactorType.NO -> no
            else -> null
        }
    }
@@ -162,7 +150,7 @@
    //除风向外的其他因子采用算术平均法求取均值
    val tmpList = mutableListOf<AvgPair>()
    repeat(17) {
    repeat(18) {
        tmpList.add(AvgPair(0f, 0))
    }
@@ -277,6 +265,12 @@
                this.c++
            }
        }
        tmpList[17].apply {
            it.no?.let {
                t += it
                this.c++
            }
        }
    }
    return RealTimeDataGridMin().apply {
@@ -301,6 +295,7 @@
        velocity = tmpList[14].avg()
        windSpeed = tmpList[15].avg()
        height = tmpList[16].avg()
        no = tmpList[17].avg()
        if (c != 0) {
            val avgU = u / c
src/main/kotlin/com/flightfeather/uav/domain/entity/Mission.java
@@ -24,6 +24,12 @@
    private String districtName;
    /**
     * 数据是否已经拉取入库
     */
    @Column(name = "data_pulled")
    private Boolean dataPulled;
    /**
     * @return mission_code
     */
    public String getMissionCode() {
@@ -106,4 +112,22 @@
    public void setDistrictName(String districtName) {
        this.districtName = districtName == null ? null : districtName.trim();
    }
    /**
     * 获取数据是否已经拉取入库
     *
     * @return data_pulled - 数据是否已经拉取入库
     */
    public Boolean getDataPulled() {
        return dataPulled;
    }
    /**
     * 设置数据是否已经拉取入库
     *
     * @param dataPulled 数据是否已经拉取入库
     */
    public void setDataPulled(Boolean dataPulled) {
        this.dataPulled = dataPulled;
    }
}
src/main/kotlin/com/flightfeather/uav/lightshare/service/RealTimeDataService.kt
@@ -10,7 +10,10 @@
interface RealTimeDataService {
    fun getSecondData(deviceCode: String?, startTime: String?, endTime: String?, type: Int?, page: Int?, perPage: Int?): BaseResponse<List<DataVo>>
    fun getSecondData(
        deviceType: String?, deviceCode: String?, startTime: String?, endTime: String?, type: Int?,
        page: Int?, perPage: Int?,
    ): BaseResponse<List<DataVo>>
    fun getNextData(deviceCode: String, updateTime: String, page: Int?, perPage: Int?): BaseResponse<List<DataVo>>
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt
@@ -64,7 +64,7 @@
        var page = 1
        var totalPage = -1
        while (totalPage == -1 || page <= totalPage) {
            realTimeDataService.getSecondData(deviceCode, startTime, endTime, 0, page, 5000).apply {
            realTimeDataService.getSecondData(null, deviceCode, startTime, endTime, 0, page, 5000).apply {
                if (totalPage == -1) {
                    totalPage = head?.totalPage ?: 0
                }
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/EPWModelServiceImpl.kt
@@ -47,7 +47,7 @@
        var c = 0//风向数据计数
        var windDirection = .0 // 平均风向角度
        while (totalPage == -1 || page <= totalPage) {
            realTimeDataService.getSecondData(deviceCode, startTime, endTime, 0, page, 5000).apply {
            realTimeDataService.getSecondData(null, deviceCode, startTime, endTime, 0, page, 5000).apply {
                if (totalPage == -1) {
                    totalPage = head?.totalPage ?: 0
                }
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt
@@ -57,6 +57,7 @@
    private val fileExchange = FileExchange()
    override fun getSecondData(
        deviceType: String?,
        deviceCode: String?,
        startTime: String?,
        endTime: String?,
@@ -73,7 +74,12 @@
        var pages = 0
        val result = mutableListOf<DataVo>()
        when (UWDeviceType.getType(deviceCode)) {
        val _deviceType = if (deviceType != null) {
            UWDeviceType.fromValue(deviceType)
        } else {
            UWDeviceType.getType(deviceCode)
        }
        when (_deviceType) {
            UWDeviceType.VEHICLE -> {
                val pageInfo = PageHelper.startPage<RealTimeDataVehicle>(_page, _perPage)
                realTimeDataVehicleMapper.selectByExample(Example(RealTimeDataVehicle::class.java).apply {
src/main/kotlin/com/flightfeather/uav/lightshare/web/RealTimeDataController.kt
@@ -16,6 +16,7 @@
    @GetMapping("/sec")
    fun getSecondData(
        @RequestParam(value = "deviceType", required = false) deviceType: String?,
        @RequestParam(value = "deviceCode", required = false) deviceCode: String?,
        @RequestParam(value = "startTime", required = false) startTime: String?,
        @RequestParam(value = "endTime", required = false) endTime: String?,
@@ -23,7 +24,7 @@
            required = false) type: Int?,
        @RequestParam(value = "page", required = false) page: Int?,
        @RequestParam(value = "perPage", required = false) perPage: Int?,
    ) = realTimeDataService.getSecondData(deviceCode, startTime, endTime, type, page, perPage)
    ) = realTimeDataService.getSecondData(deviceType, deviceCode, startTime, endTime, type, page, perPage)
    @GetMapping("/sec/next")
    fun getNextData(
src/main/kotlin/com/flightfeather/uav/socket/eunm/FactorType.kt
@@ -24,7 +24,8 @@
    TIME(15, "TIME", 6),//时间
    WIND_SPEED(16, "WIND_SPEED", 3),
    WIND_DIRECTION(17, "WIND_DIRECTION", 2),
    HEIGHT(18, "HEIGHT", 3);
    HEIGHT(18, "HEIGHT", 3),
    NO(19, "NO", 6);
    companion object {
@@ -41,6 +42,7 @@
            5 -> PM25
            6 -> PM10
            7 -> VOC
            19 -> NO
            else -> null
        }
@@ -63,6 +65,7 @@
            WIND_SPEED.value -> WIND_SPEED
            WIND_DIRECTION.value -> WIND_DIRECTION
            HEIGHT.value -> HEIGHT
            NO.value -> NO
            else -> null
        }
@@ -85,6 +88,7 @@
            WIND_SPEED.des -> WIND_SPEED
            WIND_DIRECTION.des -> WIND_DIRECTION
            HEIGHT.des -> HEIGHT
            NO.des -> NO
            else -> null
        }
@@ -99,6 +103,7 @@
         * 获取监测因子的合理范围
         */
        fun getRange(type: FactorType): Pair<Double, Double>? = when (type) {
            NO -> Pair(0.1, 1000.0)
            NO2 -> Pair(0.1, 1000.0)
            CO -> Pair(1.0, 5000.0)
            H2S -> Pair(0.1, 1000.0)
@@ -131,6 +136,7 @@
         * 不处理低于此值的值
         */
        fun getVMax(type: FactorType): Double? = when (type) {
            NO -> 1.0
            NO2 -> 10.0
            CO -> 100.0
            H2S -> 10.0
@@ -152,6 +158,9 @@
            else -> null
        }
        /**
         * 因子连续数据上升合理幅度(倍数)
         */
        fun getMultiplier(name: String?): Double {
            getByName(name)?.let {
                return getMultiplier(it)
src/main/resources/generator/generatorConfig.xml
@@ -47,14 +47,14 @@
        </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"/>-->
<!--        <table tableName="co_assessment" domainObjectName="Assessment" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!--        <table tableName="real_time_data_grid" domainObjectName="RealTimeDataGrid" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!--        <table tableName="real_time_data_uav" domainObjectName="RealTimeDataUav" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
        <table tableName="real_time_data_vehicle" domainObjectName="RealTimeDataVehicle" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
<!--        <table tableName="real_time_data_vehicle" domainObjectName="RealTimeDataVehicle" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!--        <table tableName="device_info" domainObjectName="DeviceInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!--        <table tableName="factor_calibration" domainObjectName="FactorCalibration" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
<!--        <table tableName="real_time_data_grid_min" domainObjectName="RealTimeDataGridMin" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>-->
src/main/resources/mapper/MissionMapper.xml
@@ -11,11 +11,12 @@
    <result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
    <result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
    <result column="district_name" jdbcType="VARCHAR" property="districtName" />
    <result column="data_pulled" jdbcType="BIT" property="dataPulled" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
    -->
    mission_code, device_type, device_code, start_time, end_time, district_name
    mission_code, device_type, device_code, start_time, end_time, district_name, data_pulled
  </sql>
</mapper>
src/test/kotlin/com/flightfeather/uav/UAVApplicationTests.kt
@@ -36,7 +36,7 @@
    @Test
    fun foo2() {
        val r = realTimeDataService.getSecondData(null, "2021-01-13 14:30:00", "2021-01-13 14:45:00", 0, null, 10)
        val r = realTimeDataService.getSecondData(null, null, "2021-01-13 14:30:00", "2021-01-13 14:45:00", 0, null, 10)
        println(r)
    }
src/test/kotlin/com/flightfeather/uav/biz/dataprocess/DataProcessTest.kt
@@ -45,7 +45,7 @@
            val dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
            val s = sTime.format(dateFormatter)
            val e = eTime.format(dateFormatter)
            val data = realTimeDataService.getSecondData(deviceCode, s, e, 0, 1, 30000).data
            val data = realTimeDataService.getSecondData(null, deviceCode, s, e, 0, 1, 30000).data
            data?.let {
                process.process(it)
            }
src/test/kotlin/com/flightfeather/uav/model/epw/EPWDataPrepTest.kt
@@ -70,7 +70,7 @@
            var totalPage = -1
            val dataList = mutableListOf<DataVo>()
            while (totalPage == -1 || page <= totalPage) {
                realTimeDataService.getSecondData(deviceCode, it.first, it.second, 0, page, 50000).apply {
                realTimeDataService.getSecondData(null, deviceCode, it.first, it.second, 0, page, 50000).apply {
                    if (totalPage == -1) {
                        totalPage = head?.totalPage ?: 0
                    }
@@ -128,7 +128,7 @@
            val dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
            val s = sTime.format(dateFormatter)
            val e = eTime.format(dateFormatter)
            val data = realTimeDataService.getSecondData(deviceCode, s, e, 0, 1, 30000).data
            val data = realTimeDataService.getSecondData(null, deviceCode, s, e, 0, 1, 30000).data
            data?.let {
                val dataList = ePWDataPrep.mDataPrep(it)
src/test/kotlin/com/flightfeather/uav/model/epw/EPWModelTest.kt
@@ -96,7 +96,7 @@
            var page = 1
            var totalPage = -1
            while (totalPage == -1 || page <= totalPage) {
                realTimeDataService.getSecondData(deviceCode, it.first, it.second, page, 0, 10000).apply {
                realTimeDataService.getSecondData(null, deviceCode, it.first, it.second, page, 0, 10000).apply {
                    if (totalPage == -1) {
                        totalPage = head?.totalPage ?: 0
                    }