feiyu02
2025-09-04 707b00a0ca6604c249a110b376ac1e44e408e624
src/main/kotlin/com/flightfeather/uav/lightshare/web/RealTimeDataController.kt
@@ -1,19 +1,58 @@
package com.flightfeather.uav.lightshare.web
import com.flightfeather.uav.lightshare.service.RealTimeDataService
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.springframework.web.bind.annotation.*
import org.springframework.web.multipart.MultipartFile
import springfox.documentation.annotations.ApiIgnore
import javax.servlet.http.HttpServletResponse
@Api(tags = ["走航监测数据API接口"])
@RestController
@RequestMapping("air/realtime")
class RealTimeDataController(val realTimeDataService: RealTimeDataService) {
    @GetMapping("/sec")
    fun getSecondData(
            @RequestParam(value = "deviceCode", required = false) deviceCode: String?,
            @RequestParam(value = "page", required = false) page: Int?,
            @RequestParam(value = "perPage", required = false) perPage: Int?
    ) = realTimeDataService.getSecondData(deviceCode,page, perPage)
        @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?,
        @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(deviceType, deviceCode, startTime, endTime, type, page, perPage)
    @GetMapping("/sec/next")
    fun getNextData(
        @RequestParam(value = "deviceCode") deviceCode: String,
        @RequestParam(value = "updateTime") updateTime: String,
        @RequestParam(value = "page", required = false) page: Int?,
        @RequestParam(value = "perPage", required = false) perPage: Int?,
    ) = realTimeDataService.getNextData(deviceCode, updateTime, page, perPage)
    @PostMapping("/import")
    fun importData(
        @RequestPart("excel") file: MultipartFile,
    ) = realTimeDataService.importData(file)
    @ApiOperation(value = "导入静安区生态环境监测站的走航数据")
    @PostMapping("/import/jinan")
    fun importJinanData(
        @ApiParam("设备id") @RequestParam("code") code: String,
        @RequestPart("excel") file: MultipartFile,
    ) = resPack { realTimeDataService.importJinanData(code, file) }
    @ApiOperation(value = "下载静安区生态环境监测站走行数据导入模板")
    @PostMapping("/import/jinan/download/template")
    fun downloadTemplate(@ApiIgnore response: HttpServletResponse) = realTimeDataService.downloadTemplate(response)
    @ApiOperation(value = "获取按照路段分割的走航数据")
    @GetMapping("/sec/segment")
    fun getSegmentData(
        @ApiParam("任务id") @RequestParam("missionCode") missionCode: String,
    ) = resPack { realTimeDataService.getSegmentData(missionCode) }
}