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;
|
2024-11-26 18:46:34 +08:00
|
|
|
import com.isu.gaswellwatch.entity.DeviceOptLog;
|
2024-11-25 01:04:53 +08:00
|
|
|
import com.isu.gaswellwatch.entity.Response;
|
|
|
|
import com.isu.gaswellwatch.enums.LogType;
|
2024-11-26 03:12:53 +08:00
|
|
|
import com.isu.gaswellwatch.exception.BusinessException;
|
2024-11-25 01:04:53 +08:00
|
|
|
import com.isu.gaswellwatch.service.DeviceService;
|
2024-11-26 03:12:53 +08:00
|
|
|
import com.isu.gaswellwatch.vo.DeviceHistoryVO;
|
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.*;
|
|
|
|
|
2024-11-26 03:12:53 +08:00
|
|
|
import java.text.ParseException;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2024-11-25 01:04:53 +08:00
|
|
|
/**
|
|
|
|
* 设备管理
|
|
|
|
*
|
|
|
|
* @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,
|
2024-11-28 16:38:54 +08:00
|
|
|
@RequestParam Long deviceTypeId,@RequestParam Long blockId) {
|
|
|
|
return Response.succeed(deviceService.page(currentPage, pageSize, gasWellName,gasStationName,deviceTypeId,blockId));
|
2024-11-25 01:04:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取设备基础信息
|
|
|
|
*/
|
|
|
|
@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) {
|
2024-11-28 01:30:00 +08:00
|
|
|
try {
|
|
|
|
deviceService.add(deviceCreateDTO);
|
|
|
|
}catch (NumberFormatException e){
|
|
|
|
throw new BusinessException("设备编号只能为纯数字格式");
|
|
|
|
}
|
2024-11-25 01:04:53 +08:00
|
|
|
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")
|
2024-11-26 03:12:53 +08:00
|
|
|
public Response<Map<String,String>> getDeviceControlData(@RequestParam Long deviceId) {
|
|
|
|
return Response.succeed(deviceService.getDeviceControlData(deviceId));
|
|
|
|
}
|
|
|
|
|
2024-11-25 01:04:53 +08:00
|
|
|
/**
|
|
|
|
* 获取设备历史数据
|
|
|
|
*/
|
|
|
|
@GetMapping("/getDeviceHistoryData")
|
2024-11-26 03:12:53 +08:00
|
|
|
public Response<Page<DeviceHistoryVO>> getDeviceHistoryData(@RequestParam(defaultValue = "1") Integer currentPage,
|
|
|
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
|
|
|
@RequestParam(required = false)String startTime,
|
|
|
|
@RequestParam (required = false)String endTime,
|
|
|
|
@RequestParam Long deviceId) {
|
|
|
|
try {
|
|
|
|
return Response.succeed(deviceService.getDeviceHistoryData(currentPage,pageSize,startTime,endTime,deviceId));
|
|
|
|
} catch (ParseException e) {
|
|
|
|
throw new BusinessException("日期格式错误");
|
|
|
|
}
|
2024-11-25 01:04:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取设备日志数据
|
|
|
|
*/
|
|
|
|
@GetMapping("/getDeviceLogData")
|
2024-11-26 18:46:34 +08:00
|
|
|
public Response<Page<DeviceOptLog>> getDeviceLogData(@RequestParam(defaultValue = "1") Integer currentPage,
|
|
|
|
@RequestParam(defaultValue = "10") Integer pageSize,
|
|
|
|
@RequestParam(required = false)String startTime,
|
|
|
|
@RequestParam (required = false)String endTime,
|
|
|
|
@RequestParam Long deviceId) {
|
|
|
|
try {
|
|
|
|
return Response.succeed(deviceService.getDeviceLogData(currentPage,pageSize,startTime,endTime,deviceId));
|
|
|
|
} catch (ParseException e) {
|
|
|
|
throw new BusinessException("日期格式错误");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-25 01:04:53 +08:00
|
|
|
|
|
|
|
|
|
|
|
}
|