From 1fa0e57df26dcbf9f7c936806b5f4f0744e1d543 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期一, 15 十一月 2021 17:42:01 +0800 Subject: [PATCH] 1. 网格化数据查询添加秒级值和分钟值的选择 --- src/test/kotlin/com/flightfeather/uav/model/epw/EPWDataPrepTest.kt | 6 src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt | 6 src/test/kotlin/com/flightfeather/uav/dataprocess/DataProcessTest.kt | 2 src/main/kotlin/com/flightfeather/uav/lightshare/web/RealTimeDataController.kt | 4 src/test/kotlin/com/flightfeather/uav/UAVApplicationTests.kt | 2 src/main/kotlin/com/flightfeather/uav/lightshare/service/RealTimeDataService.kt | 2 src/main/kotlin/com/flightfeather/uav/domain/entity/RealTimeDataGridMin.java | 367 --------------------------------------------- src/test/kotlin/com/flightfeather/uav/model/epw/EPWModelTest.kt | 4 src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt | 26 ++ src/main/kotlin/com/flightfeather/uav/domain/mapper/RealTimeDataGridMinMapper.kt | 2 src/main/resources/application.yml | 12 11 files changed, 41 insertions(+), 392 deletions(-) diff --git a/src/main/kotlin/com/flightfeather/uav/domain/entity/RealTimeDataGridMin.java b/src/main/kotlin/com/flightfeather/uav/domain/entity/RealTimeDataGridMin.java index b5fcd00..b42834f 100644 --- a/src/main/kotlin/com/flightfeather/uav/domain/entity/RealTimeDataGridMin.java +++ b/src/main/kotlin/com/flightfeather/uav/domain/entity/RealTimeDataGridMin.java @@ -5,371 +5,6 @@ import javax.persistence.*; @Table(name = "real_time_data_grid_min") -public class RealTimeDataGridMin { - @Id - private Integer id; - - @Column(name = "device_code") - private String deviceCode; - - private BigDecimal latitude; - - private BigDecimal longitude; - - private Float altitude; - - @Column(name = "data_time") - private Date dataTime; - - @Column(name = "create_time") - private Date createTime; - - @Column(name = "NO2") - private Float no2; - - @Column(name = "CO") - private Float co; - - @Column(name = "H2S") - private Float h2s; - - @Column(name = "SO2") - private Float so2; - - @Column(name = "O3") - private Float o3; - - @Column(name = "PM25") - private Float pm25; - - @Column(name = "PM10") - private Float pm10; - - private Float temperature; - - private Float humidity; - - @Column(name = "VOC") - private Float voc; - - @Column(name = "NOI") - private Float noi; - - private Float velocity; - - @Column(name = "wind_speed") - private Float windSpeed; - - @Column(name = "wind_direction") - private Float windDirection; - - private Float height; - - /** - * @return id - */ - public Integer getId() { - return id; - } - - /** - * @param id - */ - public void setId(Integer id) { - this.id = id; - } - - /** - * @return device_code - */ - public String getDeviceCode() { - return deviceCode; - } - - /** - * @param deviceCode - */ - public void setDeviceCode(String deviceCode) { - this.deviceCode = deviceCode == null ? null : deviceCode.trim(); - } - - /** - * @return latitude - */ - public BigDecimal getLatitude() { - return latitude; - } - - /** - * @param latitude - */ - public void setLatitude(BigDecimal latitude) { - this.latitude = latitude; - } - - /** - * @return longitude - */ - public BigDecimal getLongitude() { - return longitude; - } - - /** - * @param longitude - */ - public void setLongitude(BigDecimal longitude) { - this.longitude = longitude; - } - - /** - * @return altitude - */ - public Float getAltitude() { - return altitude; - } - - /** - * @param altitude - */ - public void setAltitude(Float altitude) { - this.altitude = altitude; - } - - /** - * @return data_time - */ - public Date getDataTime() { - return dataTime; - } - - /** - * @param dataTime - */ - public void setDataTime(Date dataTime) { - this.dataTime = dataTime; - } - - /** - * @return create_time - */ - public Date getCreateTime() { - return createTime; - } - - /** - * @param createTime - */ - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - /** - * @return NO2 - */ - public Float getNo2() { - return no2; - } - - /** - * @param no2 - */ - public void setNo2(Float no2) { - this.no2 = no2; - } - - /** - * @return CO - */ - public Float getCo() { - return co; - } - - /** - * @param co - */ - public void setCo(Float co) { - this.co = co; - } - - /** - * @return H2S - */ - public Float getH2s() { - return h2s; - } - - /** - * @param h2s - */ - public void setH2s(Float h2s) { - this.h2s = h2s; - } - - /** - * @return SO2 - */ - public Float getSo2() { - return so2; - } - - /** - * @param so2 - */ - public void setSo2(Float so2) { - this.so2 = so2; - } - - /** - * @return O3 - */ - public Float getO3() { - return o3; - } - - /** - * @param o3 - */ - public void setO3(Float o3) { - this.o3 = o3; - } - - /** - * @return PM25 - */ - public Float getPm25() { - return pm25; - } - - /** - * @param pm25 - */ - public void setPm25(Float pm25) { - this.pm25 = pm25; - } - - /** - * @return PM10 - */ - public Float getPm10() { - return pm10; - } - - /** - * @param pm10 - */ - public void setPm10(Float pm10) { - this.pm10 = pm10; - } - - /** - * @return temperature - */ - public Float getTemperature() { - return temperature; - } - - /** - * @param temperature - */ - public void setTemperature(Float temperature) { - this.temperature = temperature; - } - - /** - * @return humidity - */ - public Float getHumidity() { - return humidity; - } - - /** - * @param humidity - */ - public void setHumidity(Float humidity) { - this.humidity = humidity; - } - - /** - * @return VOC - */ - public Float getVoc() { - return voc; - } - - /** - * @param voc - */ - public void setVoc(Float voc) { - this.voc = voc; - } - - /** - * @return NOI - */ - public Float getNoi() { - return noi; - } - - /** - * @param noi - */ - public void setNoi(Float noi) { - this.noi = noi; - } - - /** - * @return velocity - */ - public Float getVelocity() { - return velocity; - } - - /** - * @param velocity - */ - public void setVelocity(Float velocity) { - this.velocity = velocity; - } - - /** - * @return wind_speed - */ - public Float getWindSpeed() { - return windSpeed; - } - - /** - * @param windSpeed - */ - public void setWindSpeed(Float windSpeed) { - this.windSpeed = windSpeed; - } - - /** - * @return wind_direction - */ - public Float getWindDirection() { - return windDirection; - } - - /** - * @param windDirection - */ - public void setWindDirection(Float windDirection) { - this.windDirection = windDirection; - } - - /** - * @return height - */ - public Float getHeight() { - return height; - } +public class RealTimeDataGridMin extends BaseRealTimeData { - /** - * @param height - */ - public void setHeight(Float height) { - this.height = height; - } } \ No newline at end of file diff --git a/src/main/kotlin/com/flightfeather/uav/domain/mapper/RealTimeDataGridMinMapper.kt b/src/main/kotlin/com/flightfeather/uav/domain/mapper/RealTimeDataGridMinMapper.kt index b8b4e8e..7fd5497 100644 --- a/src/main/kotlin/com/flightfeather/uav/domain/mapper/RealTimeDataGridMinMapper.kt +++ b/src/main/kotlin/com/flightfeather/uav/domain/mapper/RealTimeDataGridMinMapper.kt @@ -5,4 +5,4 @@ import org.apache.ibatis.annotations.Mapper @Mapper -interface RealTimeDataGridMinMapper : MyMapper<RealTimeDataGridMin?> \ No newline at end of file +interface RealTimeDataGridMinMapper : MyMapper<RealTimeDataGridMin> \ 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 0608e28..c7fb767 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,7 @@ interface RealTimeDataService { - fun getSecondData(deviceCode: String?, startTime: String?, endTime: String?, page: Int?, perPage: Int?): BaseResponse<List<DataVo>> + fun getSecondData(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 5e5da20..fb8ca9d 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,11 +64,11 @@ var page = 1 var totalPage = -1 while (totalPage == -1 || page <= totalPage) { - realTimeDataService.getSecondData(deviceCode, startTime, endTime, page, 5000).apply { + realTimeDataService.getSecondData(deviceCode, startTime, endTime, 0, page, 5000).apply { if (totalPage == -1) { totalPage = head?.totalPage ?: 0 } - val dataList = data?: emptyList() + val dataList = data ?: emptyList() // FIXME: 2021/7/13 姝ゅ涓轰簡娴嬭瘯鏆傛椂灏嗙珯鐐圭粡绾害鍐欐锛屽悗缁�氳繃鏁版嵁搴撻厤缃幏鍙� dataList.forEach { @@ -77,7 +77,7 @@ it.lat = 30.835898 } } - + epwModel.execute(dataList, companySOPList, true) page++ } 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 0336692..48aff07 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 @@ -40,7 +40,7 @@ private var dateFormatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm") private val fileExchange = FileExchange() - override fun getSecondData(deviceCode: String?, startTime: String?, endTime: String?, page: Int?, perPage: Int?): BaseResponse<List<DataVo>> { + override fun getSecondData(deviceCode: String?, startTime: String?, endTime: String?, type: Int?, page: Int?, perPage: Int?): BaseResponse<List<DataVo>> { val _perPage = perPage ?: 60 val _page = page ?: 1 val sTime = startTime?.let { dateFormatter.parse(it) } @@ -68,12 +68,24 @@ pages = pageInfo.pages } UWDeviceType.GRID -> { - val pageInfo = PageHelper.startPage<RealTimeDataGrid>(_page, _perPage) - realTimeDataGridMapper.selectByExample(Example(RealTimeDataGrid::class.java).apply { - getSecondDataExample(this, deviceCode, sTime, eTime) - }).forEach { result.add(it.toDataVo()) } - pageNum = pageInfo.pageNum - pages = pageInfo.pages + // 缃戞牸鍖栫洃娴嬬绾у�� + if (type == null || type == 0) { + val pageInfo = PageHelper.startPage<RealTimeDataGrid>(_page, _perPage) + realTimeDataGridMapper.selectByExample(Example(RealTimeDataGrid::class.java).apply { + getSecondDataExample(this, deviceCode, sTime, eTime) + }).forEach { result.add(it.toDataVo()) } + pageNum = pageInfo.pageNum + pages = pageInfo.pages + } + // 缃戞牸鍖栫洃娴嬪垎閽熷�� + else if (type == 1) { + val pageInfo = PageHelper.startPage<RealTimeDataGridMin>(_page, _perPage) + realTimeDataGridMinMapper.selectByExample(Example(RealTimeDataGridMin::class.java).apply { + getSecondDataExample(this, deviceCode, sTime, eTime) + }).forEach { result.add(it.toDataVo()) } + pageNum = pageInfo.pageNum + pages = pageInfo.pages + } } else -> { // 浠庡師濮嬫暟鎹〃涓幏鍙栨暟鎹� 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 cc05b83..def38ec 100644 --- a/src/main/kotlin/com/flightfeather/uav/lightshare/web/RealTimeDataController.kt +++ b/src/main/kotlin/com/flightfeather/uav/lightshare/web/RealTimeDataController.kt @@ -2,6 +2,7 @@ import com.flightfeather.uav.lightshare.service.RealTimeDataService import io.swagger.annotations.Api +import io.swagger.annotations.ApiParam import org.springframework.web.bind.annotation.* import org.springframework.web.multipart.MultipartFile @@ -15,9 +16,10 @@ @RequestParam(value = "deviceCode", required = false) deviceCode: String?, @RequestParam(value = "startTime", required = false) startTime: String?, @RequestParam(value = "endTime", required = false) endTime: String?, + @ApiParam(value = "0: 绉掔骇鍊�; 1:鍒嗛挓鍊�", defaultValue = "0") @RequestParam(value = "type", required = false) type: Int?, @RequestParam(value = "page", required = false) page: Int?, @RequestParam(value = "perPage", required = false) perPage: Int? - ) = realTimeDataService.getSecondData(deviceCode, startTime, endTime, page, perPage) + ) = realTimeDataService.getSecondData(deviceCode, startTime, endTime, type, page, perPage) @GetMapping("/sec/next") fun getNextData( diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 1087cd6..e03ad45 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -7,9 +7,9 @@ # password: cn.FLIGHTFEATHER # 绾夸笂鏈嶅姟鍣� -# url: jdbc:mysql://localhost:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false -# username: dronemonitor -# password: dronemonitor_hackxrnomxm + url: jdbc:mysql://localhost:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false + username: dronemonitor + password: dronemonitor_hackxrnomxm # 寮�鍙戞湰鍦版湇鍔″櫒 # url: jdbc:mysql://localhost:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false @@ -17,9 +17,9 @@ # password: 123456 # 寮�鍙戣繙绋嬫湇鍔″櫒 - url: jdbc:mysql://47.100.191.150:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false - username: remoteU1 - password: eSoF8DnzfGTlhAjE +# url: jdbc:mysql://47.100.191.150:3306/dronemonitor?serverTimezone=Asia/Shanghai&prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false +# username: remoteU1 +# password: eSoF8DnzfGTlhAjE hikari: maximum-pool-size: 500 minimum-idle: 20 diff --git a/src/test/kotlin/com/flightfeather/uav/UAVApplicationTests.kt b/src/test/kotlin/com/flightfeather/uav/UAVApplicationTests.kt index 6bc811e..88b2b6b 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", null, 10) + val r = realTimeDataService.getSecondData(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/dataprocess/DataProcessTest.kt b/src/test/kotlin/com/flightfeather/uav/dataprocess/DataProcessTest.kt index bea0d39..2fd77b6 100644 --- a/src/test/kotlin/com/flightfeather/uav/dataprocess/DataProcessTest.kt +++ b/src/test/kotlin/com/flightfeather/uav/dataprocess/DataProcessTest.kt @@ -53,7 +53,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, 1, 30000).data + val data = realTimeDataService.getSecondData(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 5b8301e..69db2a2 100644 --- a/src/test/kotlin/com/flightfeather/uav/model/epw/EPWDataPrepTest.kt +++ b/src/test/kotlin/com/flightfeather/uav/model/epw/EPWDataPrepTest.kt @@ -70,12 +70,12 @@ var totalPage = -1 val dataList = mutableListOf<DataVo>() while (totalPage == -1 || page <= totalPage) { - realTimeDataService.getSecondData(deviceCode, it.first, it.second, page, 50000).apply { + realTimeDataService.getSecondData(deviceCode, it.first, it.second, 0, page, 50000).apply { if (totalPage == -1) { totalPage = head?.totalPage ?: 0 } - val list = data?: emptyList() + val list = data ?: emptyList() val prepList = prep.mDataPrep(list) @@ -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, 1, 30000).data + val data = realTimeDataService.getSecondData(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 261b525..f69e430 100644 --- a/src/test/kotlin/com/flightfeather/uav/model/epw/EPWModelTest.kt +++ b/src/test/kotlin/com/flightfeather/uav/model/epw/EPWModelTest.kt @@ -96,12 +96,12 @@ var page = 1 var totalPage = -1 while (totalPage == -1 || page <= totalPage) { - realTimeDataService.getSecondData(deviceCode, it.first, it.second, page, 10000).apply { + realTimeDataService.getSecondData(deviceCode, it.first, it.second, page, 0, 10000).apply { if (totalPage == -1) { totalPage = head?.totalPage ?: 0 } - val dataList = data?: emptyList() + val dataList = data ?: emptyList() dataList.forEach { if (it.lng == 0.0 && it.lat == 0.0) { -- Gitblit v1.9.3