You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Water_Machine_Management_Sy.../src/manage-web/MonitorController.java

43 lines
1.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.campus.water.web.controller;
import com.campus.water.web.entity.SensorDataWebVO;
import com.campus.water.web.service.RealTimeService;
import com.campus.water.web.service.HistoryDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 监控数据接口供Web前端Vue调用适配管理员“监控设备数据”需求
*/
@RestController
@RequestMapping("/api/admin/monitor")
public class MonitorController {
@Autowired
private RealTimeService realTimeService;
@Autowired
private HistoryDataService historyDataService;
// 1. 获取单设备实时数据(适配前端设备详情页)
@GetMapping("/realTime/{deviceId}")
public SensorDataWebVO getRealTimeData(@PathVariable String deviceId) {
return realTimeService.getRealTimeData(deviceId);
}
// 2. 获取全量设备实时状态(适配前端监控总览页)
@GetMapping("/realTime/all")
public List<SensorDataWebVO> getAllRealTimeData() {
return realTimeService.getAllRealTimeData();
}
// 3. 获取设备历史数据(适配前端历史曲线,需求中“查看历史水质”)
@GetMapping("/history/{deviceId}")
public List<SensorDataWebVO> getHistoryData(
@PathVariable String deviceId,
@RequestParam String startTime, // 开始时间如2024-05-20 00:00:00
@RequestParam String endTime // 结束时间
) {
return historyDataService.getHistoryData(deviceId, startTime, endTime);
}
}