riku
2021-11-15 1fa0e57df26dcbf9f7c936806b5f4f0744e1d543
1. 网格化数据查询添加秒级值和分钟值的选择
已修改11个文件
413 ■■■■■ 文件已修改
src/main/kotlin/com/flightfeather/uav/domain/entity/RealTimeDataGridMin.java 367 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/domain/mapper/RealTimeDataGridMinMapper.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/RealTimeDataService.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/CompanyServiceImpl.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/service/impl/RealTimeDataServiceImpl.kt 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/kotlin/com/flightfeather/uav/lightshare/web/RealTimeDataController.kt 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/UAVApplicationTests.kt 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/kotlin/com/flightfeather/uav/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/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;
    }
}
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?>
interface RealTimeDataGridMinMapper : MyMapper<RealTimeDataGridMin>
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>>
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, page, 5000).apply {
            realTimeDataService.getSecondData(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
@@ -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,6 +68,8 @@
                pages = pageInfo.pages
            }
            UWDeviceType.GRID -> {
                // 网格化监测秒级值
                if (type == null || type == 0) {
                val pageInfo = PageHelper.startPage<RealTimeDataGrid>(_page, _perPage)
                realTimeDataGridMapper.selectByExample(Example(RealTimeDataGrid::class.java).apply {
                    getSecondDataExample(this, deviceCode, sTime, eTime)
@@ -75,6 +77,16 @@
                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 -> {
                // 从原始数据表中获取数据
                val pageInfo = PageHelper.startPage<RealTimeData>(_page, _perPage)
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(
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
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)
    }
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)
            }
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, page, 50000).apply {
                realTimeDataService.getSecondData(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, 1, 30000).data
            val data = realTimeDataService.getSecondData(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, 10000).apply {
                realTimeDataService.getSecondData(deviceCode, it.first, it.second, page, 0, 10000).apply {
                    if (totalPage == -1) {
                        totalPage = head?.totalPage ?: 0
                    }