feiyu02
2025-09-30 6904763f0e74d9a9fa4dbc39f635d2aee39416c6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package cn.flightfeather.supervision.lightshare.web
 
import cn.flightfeather.supervision.domain.entity.VocPurifyDevice
import cn.flightfeather.supervision.lightshare.service.DeviceService
import cn.flightfeather.supervision.lightshare.vo.DateVo
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.springframework.web.bind.annotation.*
 
@Api(tags = ["设备相关API接口"])
@RestController
@RequestMapping("/device")
class DeviceController(val deviceService: DeviceService) {
 
    @ApiOperation(value = "获取净化设备信息")
    @GetMapping("/purify/info")
    fun getPurifyDeviceInfo(
        @ApiParam(value = "用户id") @RequestParam("userId") userId: String
    ) = deviceService.getPurifyDeviceInfo(userId)
 
    @ApiOperation(value = "获取监测设备信息")
    @GetMapping("/monitor/info")
    fun getMonitorDeviceInfo(
        @ApiParam(value = "用户id") @RequestParam("userId") userId: String
    ) = deviceService.getMonitorDeviceInfo(userId)
 
    @ApiOperation(value = "获取用户监测设备的分钟数据", notes = "目前默认返回最新的15条数据,按时间升序排列")
    @GetMapping("/min/value")
    fun getLatestMinuteValue(
        @ApiParam(value = "用户id") @RequestParam("userId") userId: String
    ) = deviceService.getLatestMinuteValue(userId)
 
    @ApiOperation(value = "获取用户监测设备的小时数据", notes = "默认返回最新的15小时数据, 按时间升序排列")
    @GetMapping("/hour/value")
    fun getLatestHourValue(
        @ApiParam(value = "用户id") @RequestParam("userId") userId: String
    ) = deviceService.getLatestHourValue(userId)
 
    @ApiOperation(value = "获取月度均值数据")
    @PostMapping("/avg/mon/value")
    fun getMonAvgData(
        @ApiParam(value = "用户id") @RequestParam("userId") userId: String,
        @ApiParam(value = "时间") @RequestBody timeList: List<DateVo>
    ) = deviceService.getMonAvgData(userId, timeList)
 
    @ApiOperation(value = "获取用户监测设备的历史数据", notes = "")
    @GetMapping("/history/value")
    fun getHistoryValue(
        @ApiParam(value = "用户id") @RequestParam("userId") userId: String,
        @ApiParam(value = "开始时间", example = "yyyy-MM-dd HH:mm") @RequestParam("startTime") startTime: String,
        @ApiParam(value = "结束时间", example = "yyyy-MM-dd HH:mm") @RequestParam("endTime") endTime: String,
        @ApiParam(value = "采样周期", example = "0:分钟均值;1:小时均值;(目前只支持分钟均值)") @RequestParam("period") period: Byte
    ) = deviceService.getHistoryValue(userId, startTime, endTime, period)
 
    @ApiOperation(value = "获取每个监测设备的最新分钟数据", notes = "")
    @GetMapping("/min/value/real_time")
    fun getRealTimeData(
        @ApiParam(value = "页数") @RequestParam("page") page: Int,
        @ApiParam(value = "每页数据量") @RequestParam("per_page") perPage: Int
    ) = deviceService.getRealTimeData(page, perPage)
 
    @ApiOperation(value = "获取静安工地扬尘小时数据")
    @GetMapping("/dust/jingan/value")
    fun getJingAnDustHourValue(
        @ApiParam(value = "用户id") @RequestParam("userId") userId: String,
        @ApiParam(value = "开始时间", example = "yyyy-MM-dd HH:mm") @RequestParam("startTime") startTime: String?,
        @ApiParam(value = "结束时间", example = "yyyy-MM-dd HH:mm") @RequestParam("endTime") endTime: String?,
    ) = deviceService.getJingAnDustHourValue(userId, startTime, endTime)
 
    @ApiOperation(value = "获取静安餐饮数据")
    @GetMapping("/fume/jingan/value")
    fun getJingAnFumeValue(
        @ApiParam(value = "用户id") @RequestParam("userId") userId: String,
        @ApiParam(value = "开始时间", example = "yyyy-MM-dd HH:mm") @RequestParam("startTime") startTime: String?,
        @ApiParam(value = "结束时间", example = "yyyy-MM-dd HH:mm") @RequestParam("endTime") endTime: String?,
    ) = deviceService.getJingAnFumeValue(userId, startTime, endTime)
 
    @ApiOperation(value = "获取设备信息")
    @GetMapping("/monitor/deviceInfo")
    fun getDeviceInfo(
        @ApiParam(value = "用户id") @RequestParam("userId") userId: String,
    ) = deviceService.getDeviceInfo(userId)
 
    @ApiOperation(value = "上传voc处理设备信息")
    @PostMapping("/voc/upload")
    fun saveVOCPurifyDevice(
        @ApiParam(value = "用户id") @RequestParam("userId") userId: String,
        @ApiParam(value = "时间") @RequestBody infoList: List<VocPurifyDevice>,
    ) = deviceService.saveVOCPurifyDevice(userId, infoList)
 
    @ApiOperation(value = "获取VOC净化设备信息")
    @GetMapping("/voc/purify/info")
    fun getVOCPurifyDevice(
        @ApiParam(value = "用户id") @RequestParam("userId") userId: String
    ) = deviceService.getVOCPurifyDevice(userId)
}