forked from dyf/fys-Multi-tenant
web端控制中心2
This commit is contained in:
@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* BJQ6170设备控制类
|
||||
* web后台:设备控制类
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
|
@ -1,9 +1,22 @@
|
||||
package com.fuyuanshen.web.controller.device;
|
||||
|
||||
import com.fuyuanshen.app.domain.dto.APPReNameDTO;
|
||||
import com.fuyuanshen.app.domain.dto.AppRealTimeStatusDto;
|
||||
import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
|
||||
import com.fuyuanshen.equipment.domain.vo.WebDeviceVo;
|
||||
import com.fuyuanshen.web.service.device.DeviceBizService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
@ -12,199 +25,74 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author: 默苍璃
|
||||
* @date: 2025-08-0810:40
|
||||
* web后台:设备控制中心
|
||||
*/
|
||||
@Slf4j
|
||||
@Tag(name = "web后台:设备控制中心", description = "web后台:设备控制中心")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/device/controlCenter")
|
||||
public class DeviceControlCenterController {
|
||||
public class DeviceControlCenterController extends BaseController {
|
||||
|
||||
private final DeviceBizService appDeviceService;
|
||||
/**
|
||||
* 获取设备基本信息
|
||||
* @param deviceId 设备ID
|
||||
* @return 设备基本信息
|
||||
* 查询设备列表
|
||||
*/
|
||||
@GetMapping("/info/{deviceId}")
|
||||
public ResponseEntity<Map<String, Object>> getDeviceInfo(@PathVariable String deviceId) {
|
||||
// 实际应用中这里会从数据库查询设备信息
|
||||
Map<String, Object> deviceInfo = new HashMap<>();
|
||||
deviceInfo.put("deviceName", "6170零零一");
|
||||
deviceInfo.put("deviceModel", "BJQ6170");
|
||||
deviceInfo.put("deviceId", deviceId);
|
||||
deviceInfo.put("status", "在线");
|
||||
deviceInfo.put("batteryLevel", 85);
|
||||
|
||||
return ResponseEntity.ok(deviceInfo);
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<WebDeviceVo> list(DeviceQueryCriteria bo, PageQuery pageQuery) {
|
||||
return appDeviceService.queryWebDeviceList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置灯光模式
|
||||
* @param lightModeRequest 灯光模式请求
|
||||
* @return 操作结果
|
||||
* 绑定设备
|
||||
*/
|
||||
@PostMapping("/light-mode")
|
||||
public ResponseEntity<Map<String, Object>> setLightMode(@RequestBody LightModeRequest lightModeRequest) {
|
||||
// 实际应用中这里会控制设备灯光
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("code", 200);
|
||||
// response.put("message", "灯光模式已设置为: " + lightModeRequest.getMode());
|
||||
// response.put("deviceId", lightModeRequest.getDeviceId());
|
||||
// response.put("mode", lightModeRequest.getMode());
|
||||
@PostMapping("/bind")
|
||||
public R<Void> bind(@RequestBody AppDeviceBo bo) {
|
||||
return toAjax(appDeviceService.bindDevice(bo));
|
||||
}
|
||||
|
||||
return ResponseEntity.ok(response);
|
||||
|
||||
/**
|
||||
* 解绑设备
|
||||
*/
|
||||
@DeleteMapping("/unBind")
|
||||
public R<Void> unBind(Long id) {
|
||||
return toAjax(appDeviceService.unBindDevice(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新人员信息
|
||||
* @param personInfo 人员信息
|
||||
* @return 操作结果
|
||||
* 查询设备类型列表
|
||||
*/
|
||||
@PostMapping("/person-info")
|
||||
public ResponseEntity<Map<String, Object>> updatePersonInfo(@RequestBody PersonInfo personInfo) {
|
||||
// 实际应用中这里会更新数据库
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("code", 200);
|
||||
response.put("message", "人员信息已更新");
|
||||
// response.put("unit", personInfo.getUnit());
|
||||
// response.put("position", personInfo.getPosition());
|
||||
|
||||
return ResponseEntity.ok(response);
|
||||
@GetMapping(value = "/typeList")
|
||||
public R<List<APPDeviceTypeVo>> getTypeList() {
|
||||
List<APPDeviceTypeVo> typeList = appDeviceService.getTypeList();
|
||||
return R.ok(typeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理开机画面内容
|
||||
* @param bootScreenRequest 开机画面请求
|
||||
* @return 操作结果
|
||||
* 重命名设备
|
||||
*
|
||||
* @param reNameDTO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/boot-screen")
|
||||
public ResponseEntity<Map<String, Object>> manageBootScreen(@RequestBody BootScreenRequest bootScreenRequest) {
|
||||
// 实际应用中这里会更新设备开机画面
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("code", 200);
|
||||
response.put("message", "开机画面内容已更新");
|
||||
// response.put("deviceId", bootScreenRequest.getDeviceId());
|
||||
// response.put("screens", bootScreenRequest.getScreens());
|
||||
@PostMapping(value = "/reName")
|
||||
public R<String> reName(@Validated @RequestBody APPReNameDTO reNameDTO) {
|
||||
appDeviceService.reName(reNameDTO);
|
||||
return R.ok("重命名成功!!!");
|
||||
}
|
||||
|
||||
return ResponseEntity.ok(response);
|
||||
|
||||
@GetMapping("/realTimeStatus")
|
||||
public R<Map<String, Object>> getRealTimeStatus(AppRealTimeStatusDto statusDto) {
|
||||
Map<String, Object> status = appDeviceService.getRealTimeStatus(statusDto);
|
||||
return R.ok(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置灯光亮度
|
||||
* @param brightnessRequest 亮度请求
|
||||
* @return 操作结果
|
||||
* 根据mac查询设备信息
|
||||
*/
|
||||
@PostMapping("/brightness")
|
||||
public ResponseEntity<Map<String, Object>> setBrightness(@RequestBody BrightnessRequest brightnessRequest) {
|
||||
// 实际应用中这里会控制设备亮度
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("code", 200);
|
||||
// response.put("message", "灯光亮度已设置为: " + brightnessRequest.getBrightness() + "%");
|
||||
// response.put("deviceId", brightnessRequest.getDeviceId());
|
||||
// response.put("brightness", brightnessRequest.getBrightness());
|
||||
// response.put("forceAlarm", brightnessRequest.isForceAlarm());
|
||||
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备位置信息
|
||||
* @param deviceId 设备ID
|
||||
* @return 位置信息
|
||||
*/
|
||||
@GetMapping("/location/{deviceId}")
|
||||
public ResponseEntity<Map<String, Object>> getLocation(@PathVariable String deviceId) {
|
||||
// 实际应用中这里会从设备获取实时位置
|
||||
Map<String, Object> locationInfo = new HashMap<>();
|
||||
locationInfo.put("deviceId", deviceId);
|
||||
locationInfo.put("longitude", "114°7'E");
|
||||
locationInfo.put("latitude", "30'28'N");
|
||||
locationInfo.put("address", "湖北省武汉市洪山区光谷大道国际企业中心");
|
||||
locationInfo.put("timestamp", new Date());
|
||||
|
||||
return ResponseEntity.ok(locationInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送紧急消息
|
||||
* @param messageRequest 消息请求
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PostMapping("/send-message")
|
||||
public ResponseEntity<Map<String, Object>> sendMessage(@RequestBody MessageRequest messageRequest) {
|
||||
// 实际应用中这里会向设备发送消息
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("code", 200);
|
||||
response.put("message", "消息已发送");
|
||||
// response.put("deviceId", messageRequest.getDeviceId());
|
||||
// response.put("content", messageRequest.getContent());
|
||||
response.put("timestamp", new Date());
|
||||
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理操作视频
|
||||
* @param videoRequest 视频请求
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PostMapping("/operation-video")
|
||||
public ResponseEntity<Map<String, Object>> manageOperationVideo(@RequestBody VideoRequest videoRequest) {
|
||||
// 实际应用中这里会更新设备操作视频
|
||||
Map<String, Object> response = new HashMap<>();
|
||||
response.put("code", 200);
|
||||
response.put("message", "操作视频已更新");
|
||||
// response.put("deviceId", videoRequest.getDeviceId());
|
||||
// response.put("videoUrl", videoRequest.getVideoUrl());
|
||||
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
|
||||
// 请求对象类定义
|
||||
public static class LightModeRequest {
|
||||
private String deviceId;
|
||||
private String mode; // 强光、弱光、爆闪、泛光、激光
|
||||
|
||||
// Getters and Setters
|
||||
}
|
||||
|
||||
public static class PersonInfo {
|
||||
private String deviceId;
|
||||
private String unit; // 单位
|
||||
private String position; // 职位
|
||||
|
||||
// Getters and Setters
|
||||
}
|
||||
|
||||
public static class BootScreenRequest {
|
||||
private String deviceId;
|
||||
private List<String> screens; // 产品参数、操作说明等
|
||||
|
||||
// Getters and Setters
|
||||
}
|
||||
|
||||
public static class BrightnessRequest {
|
||||
private String deviceId;
|
||||
private int brightness; // 0-100
|
||||
private boolean forceAlarm; // 强制报警
|
||||
|
||||
// Getters and Setters
|
||||
}
|
||||
|
||||
public static class MessageRequest {
|
||||
private String deviceId;
|
||||
private String content; // 消息内容
|
||||
|
||||
// Getters and Setters
|
||||
}
|
||||
|
||||
public static class VideoRequest {
|
||||
private String deviceId;
|
||||
private String videoUrl; // 视频链接
|
||||
|
||||
// Getters and Setters
|
||||
@GetMapping("/getDeviceInfoByDeviceMac")
|
||||
public R<AppDeviceVo> getDeviceInfo(String deviceMac) {
|
||||
return R.ok(appDeviceService.getDeviceInfo(deviceMac));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ import java.util.Map;
|
||||
public class WEBDeviceController extends BaseController {
|
||||
|
||||
private final WEBDeviceService deviceService;
|
||||
private final DeviceBizService appDeviceService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -53,66 +53,7 @@ public class WEBDeviceController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询设备列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<AppDeviceVo> list(DeviceQueryCriteria bo, PageQuery pageQuery) {
|
||||
return appDeviceService.queryAppDeviceList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定设备
|
||||
*/
|
||||
@PostMapping("/bind")
|
||||
public R<Void> bind(@RequestBody AppDeviceBo bo) {
|
||||
return toAjax(appDeviceService.bindDevice(bo));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解绑设备
|
||||
*/
|
||||
@DeleteMapping("/unBind")
|
||||
public R<Void> unBind(Long id) {
|
||||
return toAjax(appDeviceService.unBindDevice(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询设备类型列表
|
||||
*/
|
||||
@GetMapping(value = "/typeList")
|
||||
public R<List<APPDeviceTypeVo>> getTypeList() {
|
||||
List<APPDeviceTypeVo> typeList = appDeviceService.getTypeList();
|
||||
return R.ok(typeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重命名设备
|
||||
*
|
||||
* @param reNameDTO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/reName")
|
||||
public R<String> reName(@Validated @RequestBody APPReNameDTO reNameDTO) {
|
||||
appDeviceService.reName(reNameDTO);
|
||||
return R.ok("重命名成功!!!");
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/realTimeStatus")
|
||||
public R<Map<String, Object>> getRealTimeStatus(AppRealTimeStatusDto statusDto) {
|
||||
Map<String, Object> status = appDeviceService.getRealTimeStatus(statusDto);
|
||||
return R.ok(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据mac查询设备信息
|
||||
*/
|
||||
@GetMapping("/getDeviceInfoByDeviceMac")
|
||||
public R<AppDeviceVo> getDeviceInfo(String deviceMac) {
|
||||
return R.ok(appDeviceService.getDeviceInfo(deviceMac));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user