2024-11-25 01:04:53 +08:00
|
|
|
package com.isu.gaswellwatch.controller;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
import com.isu.gaswellwatch.annotation.OperationLog;
|
|
|
|
import com.isu.gaswellwatch.dto.DeviceCreateDTO;
|
|
|
|
import com.isu.gaswellwatch.dto.DeviceEditDTO;
|
|
|
|
import com.isu.gaswellwatch.entity.Device;
|
|
|
|
import com.isu.gaswellwatch.entity.Response;
|
|
|
|
import com.isu.gaswellwatch.enums.LogType;
|
|
|
|
import com.isu.gaswellwatch.service.DeviceService;
|
2024-11-25 15:48:00 +08:00
|
|
|
import com.isu.gaswellwatch.vo.DeviceVO;
|
2024-11-25 01:04:53 +08:00
|
|
|
import jakarta.validation.Valid;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 设备管理
|
|
|
|
*
|
|
|
|
* @author scwsl
|
|
|
|
* @date 2024-11-17
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
@RequestMapping("/device")
|
|
|
|
public class DeviceController {
|
|
|
|
|
|
|
|
private final DeviceService deviceService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询设备列表
|
|
|
|
*/
|
|
|
|
@GetMapping(value = "/page")
|
2024-11-25 15:48:00 +08:00
|
|
|
public Response<Page<DeviceVO>> page(@RequestParam(defaultValue = "1") Integer currentPage,
|
|
|
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
|
|
|
@RequestParam(required = false) String gasWellName,
|
|
|
|
@RequestParam(required = false) String gasStationName,
|
|
|
|
@RequestParam Long deviceTypeId) {
|
2024-11-25 01:04:53 +08:00
|
|
|
return Response.succeed(deviceService.page(currentPage, pageSize, gasWellName,gasStationName,deviceTypeId));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取设备基础信息
|
|
|
|
*/
|
|
|
|
@GetMapping(value = "/getDevice")
|
2024-11-25 15:48:00 +08:00
|
|
|
public Response<DeviceVO> getDevice(@RequestParam Long id) {
|
2024-11-25 01:04:53 +08:00
|
|
|
return Response.succeed(deviceService.getDevice(id));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*新增设备
|
|
|
|
*/
|
|
|
|
@PostMapping(value = "/add")
|
|
|
|
@OperationLog(description = "新增设备", type = LogType.ADD)
|
|
|
|
public Response<String> add(@RequestBody @Valid DeviceCreateDTO deviceCreateDTO) {
|
|
|
|
deviceService.add(deviceCreateDTO);
|
|
|
|
return Response.succeed();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 修改设备
|
|
|
|
*/
|
|
|
|
@PostMapping("/edit")
|
|
|
|
@OperationLog(description = "修改设备", type = LogType.UPDATE)
|
|
|
|
public Response<String> edit(@RequestBody @Valid DeviceEditDTO deviceEditDTO) {
|
|
|
|
deviceService.edit(deviceEditDTO);
|
|
|
|
return Response.succeed();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 删除设备
|
|
|
|
*/
|
|
|
|
@GetMapping("/delete")
|
|
|
|
@OperationLog(description = "删除设备", type = LogType.DELETE)
|
|
|
|
public Response<String> delete(@RequestParam Long id) {
|
|
|
|
deviceService.delete(id);
|
|
|
|
return Response.succeed();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取设备控制数据
|
|
|
|
*/
|
|
|
|
@GetMapping("/getDeviceControlData")
|
|
|
|
public Response<String> getDeviceControlData(@RequestParam Long id) {
|
|
|
|
deviceService.getDeviceControlData(id);
|
|
|
|
return Response.succeed();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取设备历史数据
|
|
|
|
*/
|
|
|
|
@GetMapping("/getDeviceHistoryData")
|
|
|
|
public Response<String> getDeviceHistoryData(@RequestParam Long id) {
|
|
|
|
deviceService.getDeviceHistoryData(id);
|
|
|
|
return Response.succeed();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取设备日志数据
|
|
|
|
*/
|
|
|
|
@GetMapping("/getDeviceLogData")
|
|
|
|
public Response<String> getDeviceLogData(@RequestParam Long id) {
|
|
|
|
deviceService.getDeviceLogData(id);
|
|
|
|
return Response.succeed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|