From e6cc379fbef57277568ee667ec07a508b3dcc479 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期四, 29 八月 2024 17:35:35 +0800
Subject: [PATCH] 1. 新增NO监测因子 2. 新增第三方数据接口数据获取相关模块

---
 src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt      |    2 
 src/test/kotlin/com/flightfeather/uav/biz/dataprocess/DataProcessTest.kt                 |    2 
 src/main/kotlin/com/flightfeather/uav/lightshare/web/RealTimeDataController.kt           |    3 +
 src/main/resources/mapper/MissionMapper.xml                                              |    3 +
 src/test/kotlin/com/flightfeather/uav/UAVApplicationTests.kt                             |    2 
 src/main/kotlin/com/flightfeather/uav/lightshare/service/RealTimeDataService.kt          |    5 ++
 src/test/kotlin/com/flightfeather/uav/model/epw/EPWModelTest.kt                          |    2 
 src/main/kotlin/com/flightfeather/uav/domain/entity/Mission.java                         |   24 ++++++++++++
 src/test/kotlin/com/flightfeather/uav/model/epw/EPWDataPrepTest.kt                       |    4 +-
 src/main/resources/generator/generatorConfig.xml                                         |    4 +-
 src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/EPWModelServiceImpl.kt     |    2 
 src/main/kotlin/com/flightfeather/uav/domain/entity/BaseRealTimeData.kt                  |   27 +++++--------
 src/main/kotlin/com/flightfeather/uav/socket/eunm/FactorType.kt                          |   11 +++++
 src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt |    8 +++
 14 files changed, 69 insertions(+), 30 deletions(-)

diff --git a/src/main/kotlin/com/flightfeather/uav/domain/entity/BaseRealTimeData.kt b/src/main/kotlin/com/flightfeather/uav/domain/entity/BaseRealTimeData.kt
index d7bd69b..d4d315c 100644
--- a/src/main/kotlin/com/flightfeather/uav/domain/entity/BaseRealTimeData.kt
+++ b/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
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 1af716d..4272c58 100644
--- a/src/main/kotlin/com/flightfeather/uav/domain/entity/Mission.java
+++ b/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;
+    }
 }
\ No newline at end of file
diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/RealTimeDataService.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/RealTimeDataService.kt
index c9e7f16..af71e21 100644
--- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/RealTimeDataService.kt
+++ b/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>>
 
diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt
index fb8ca9d..2c3e172 100644
--- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt
+++ b/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
                 }
diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/EPWModelServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/EPWModelServiceImpl.kt
index 494a8dc..0986058 100644
--- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/EPWModelServiceImpl.kt
+++ b/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
                 }
diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt
index 057472d..4bf03aa 100644
--- a/src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt
+++ b/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 {
diff --git a/src/main/kotlin/com/flightfeather/uav/lightshare/web/RealTimeDataController.kt b/src/main/kotlin/com/flightfeather/uav/lightshare/web/RealTimeDataController.kt
index bdeb3b0..cc717f7 100644
--- a/src/main/kotlin/com/flightfeather/uav/lightshare/web/RealTimeDataController.kt
+++ b/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(
diff --git a/src/main/kotlin/com/flightfeather/uav/socket/eunm/FactorType.kt b/src/main/kotlin/com/flightfeather/uav/socket/eunm/FactorType.kt
index 5ae4e9f..9874aa7 100644
--- a/src/main/kotlin/com/flightfeather/uav/socket/eunm/FactorType.kt
+++ b/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)
diff --git a/src/main/resources/generator/generatorConfig.xml b/src/main/resources/generator/generatorConfig.xml
index 4bb181c..891447b 100644
--- a/src/main/resources/generator/generatorConfig.xml
+++ b/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"/>-->
diff --git a/src/main/resources/mapper/MissionMapper.xml b/src/main/resources/mapper/MissionMapper.xml
index eb104a7..31c198e 100644
--- a/src/main/resources/mapper/MissionMapper.xml
+++ b/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>
\ No newline at end of file
diff --git a/src/test/kotlin/com/flightfeather/uav/UAVApplicationTests.kt b/src/test/kotlin/com/flightfeather/uav/UAVApplicationTests.kt
index 88b2b6b..1dd2ccf 100644
--- a/src/test/kotlin/com/flightfeather/uav/UAVApplicationTests.kt
+++ b/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)
     }
 
diff --git a/src/test/kotlin/com/flightfeather/uav/biz/dataprocess/DataProcessTest.kt b/src/test/kotlin/com/flightfeather/uav/biz/dataprocess/DataProcessTest.kt
index 43b578f..7b51ffb 100644
--- a/src/test/kotlin/com/flightfeather/uav/biz/dataprocess/DataProcessTest.kt
+++ b/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)
             }
diff --git a/src/test/kotlin/com/flightfeather/uav/model/epw/EPWDataPrepTest.kt b/src/test/kotlin/com/flightfeather/uav/model/epw/EPWDataPrepTest.kt
index 4cdb400..7e0b6f7 100644
--- a/src/test/kotlin/com/flightfeather/uav/model/epw/EPWDataPrepTest.kt
+++ b/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)
diff --git a/src/test/kotlin/com/flightfeather/uav/model/epw/EPWModelTest.kt b/src/test/kotlin/com/flightfeather/uav/model/epw/EPWModelTest.kt
index f69e430..b76ffff 100644
--- a/src/test/kotlin/com/flightfeather/uav/model/epw/EPWModelTest.kt
+++ b/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
                     }

--
Gitblit v1.9.3