| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; |
| | | import com.ruoyi.unattended.telemetry.service.DeviceAlarmPushService; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | |
| | | @Resource |
| | | private DeviceTelemetryService deviceTelemetryService; |
| | | |
| | | @Resource |
| | | private DeviceAlarmPushService alarmPushService; |
| | | |
| | | @GetMapping("/list") |
| | | @ApiOperation("实时监控列表") |
| | | public AjaxResult list() { |
| | |
| | | @ApiOperation("触发一次采集") |
| | | public AjaxResult collect() { |
| | | return AjaxResult.success(deviceTelemetryService.collectOnce()); |
| | | } |
| | | |
| | | @PostMapping("/report") |
| | | @ApiOperation("PLC/边缘网关上报遥测数据") |
| | | public AjaxResult report(@RequestBody DeviceTelemetry telemetry) { |
| | | try { |
| | | return AjaxResult.success(deviceTelemetryService.report(telemetry)); |
| | | } catch (IllegalArgumentException e) { |
| | | return AjaxResult.error(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/history") |
| | |
| | | return AjaxResult.success(deviceTelemetryService.alarms()); |
| | | } |
| | | |
| | | @GetMapping(value = "/alarm-stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE) |
| | | @ApiOperation("订阅实时报警推送") |
| | | public SseEmitter alarmStream() { |
| | | return alarmPushService.subscribe(); |
| | | } |
| | | |
| | | @PostMapping("/control") |
| | | @ApiOperation("远程启停") |
| | | public AjaxResult control(@RequestBody ControlRequest request) { |