diff --git a/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceControlCenterController.java b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceControlCenterController.java new file mode 100644 index 00000000..0f4079c5 --- /dev/null +++ b/fys-admin/src/main/java/com/fuyuanshen/web/controller/device/DeviceControlCenterController.java @@ -0,0 +1,210 @@ +package com.fuyuanshen.web.controller.device; + +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author: 默苍璃 + * @date: 2025-08-0810:40 + */ +@Slf4j +@Tag(name = "web后台:设备控制中心", description = "web后台:设备控制中心") +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/device") +public class DeviceControlCenterController { + + /** + * 获取设备基本信息 + * @param deviceId 设备ID + * @return 设备基本信息 + */ + @GetMapping("/info/{deviceId}") + public ResponseEntity> getDeviceInfo(@PathVariable String deviceId) { + // 实际应用中这里会从数据库查询设备信息 + Map 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); + } + + /** + * 设置灯光模式 + * @param lightModeRequest 灯光模式请求 + * @return 操作结果 + */ + @PostMapping("/light-mode") + public ResponseEntity> setLightMode(@RequestBody LightModeRequest lightModeRequest) { + // 实际应用中这里会控制设备灯光 + Map response = new HashMap<>(); + response.put("code", 200); + // response.put("message", "灯光模式已设置为: " + lightModeRequest.getMode()); + // response.put("deviceId", lightModeRequest.getDeviceId()); + // response.put("mode", lightModeRequest.getMode()); + + return ResponseEntity.ok(response); + } + + /** + * 更新人员信息 + * @param personInfo 人员信息 + * @return 操作结果 + */ + @PostMapping("/person-info") + public ResponseEntity> updatePersonInfo(@RequestBody PersonInfo personInfo) { + // 实际应用中这里会更新数据库 + Map response = new HashMap<>(); + response.put("code", 200); + response.put("message", "人员信息已更新"); + // response.put("unit", personInfo.getUnit()); + // response.put("position", personInfo.getPosition()); + + return ResponseEntity.ok(response); + } + + /** + * 管理开机画面内容 + * @param bootScreenRequest 开机画面请求 + * @return 操作结果 + */ + @PostMapping("/boot-screen") + public ResponseEntity> manageBootScreen(@RequestBody BootScreenRequest bootScreenRequest) { + // 实际应用中这里会更新设备开机画面 + Map response = new HashMap<>(); + response.put("code", 200); + response.put("message", "开机画面内容已更新"); + // response.put("deviceId", bootScreenRequest.getDeviceId()); + // response.put("screens", bootScreenRequest.getScreens()); + + return ResponseEntity.ok(response); + } + + /** + * 设置灯光亮度 + * @param brightnessRequest 亮度请求 + * @return 操作结果 + */ + @PostMapping("/brightness") + public ResponseEntity> setBrightness(@RequestBody BrightnessRequest brightnessRequest) { + // 实际应用中这里会控制设备亮度 + Map 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> getLocation(@PathVariable String deviceId) { + // 实际应用中这里会从设备获取实时位置 + Map 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> sendMessage(@RequestBody MessageRequest messageRequest) { + // 实际应用中这里会向设备发送消息 + Map 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> manageOperationVideo(@RequestBody VideoRequest videoRequest) { + // 实际应用中这里会更新设备操作视频 + Map 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 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 + } + +}