BJQ6075 设备控制类

This commit is contained in:
2025-11-06 10:39:12 +08:00
parent 1dc3386284
commit c7ff118bfe
12 changed files with 421 additions and 145 deletions

View File

@ -28,6 +28,7 @@ public class TestController extends BaseController {
private final DeviceBJQBizService appDeviceService; private final DeviceBJQBizService appDeviceService;
/** /**
* 上传设备logo图片 * 上传设备logo图片
*/ */

View File

@ -0,0 +1,120 @@
package com.fuyuanshen.app.controller.device.bjq;
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo;
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
import com.fuyuanshen.web.service.device.DeviceBJQBizService;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
* BJQ6075 设备控制类
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/app/bjq6075/device")
public class AppDeviceBJQ6075Controller extends BaseController {
private final DeviceBJQBizService appDeviceService;
/**
* 获取设备详细信息
*
* @param id 主键
*/
@GetMapping("/{id}")
public R<AppDeviceDetailVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(appDeviceService.getInfo(id));
}
/**
* 人员信息登记
*/
@PostMapping(value = "/registerPersonInfo")
// @FunctionAccessAnnotation("registerPersonInfo")
public R<Void> registerPersonInfo(@Validated(AddGroup.class) @RequestBody AppPersonnelInfoBo bo) {
return toAjax(appDeviceService.registerPersonInfo(bo));
}
/**
* 发送信息
*/
@PostMapping(value = "/sendMessage")
@FunctionAccessBatcAnnotation(value = "sendMessage", timeOut = 30, batchMaxTimeOut = 40)
public R<Void> sendMessage(@RequestBody AppDeviceSendMsgBo bo) {
return toAjax(appDeviceService.sendMessage(bo));
}
/**
* 发送报警信息
*/
@PostMapping(value = "/sendAlarmMessage")
@FunctionAccessBatcAnnotation(value = "sendAlarmMessage", timeOut = 5, batchMaxTimeOut = 10)
public R<Void> sendAlarmMessage(@RequestBody AppDeviceSendMsgBo bo) {
return toAjax(appDeviceService.sendAlarmMessage(bo));
}
/**
* 上传设备logo图片
*/
@PostMapping("/uploadLogo")
@FunctionAccessAnnotation("uploadLogo")
public R<Void> upload(@Validated @ModelAttribute AppDeviceLogoUploadDto bo) {
MultipartFile file = bo.getFile();
if (file.getSize() > 1024 * 1024 * 2) {
return R.warn("图片不能大于2M");
}
appDeviceService.uploadDeviceLogo(bo);
return R.ok();
}
/**
* 灯光模式
* 0关灯1强光模式2弱光模式, 3爆闪模式, 4泛光模式
*/
// @FunctionAccessAnnotation("lightModeSettings")
@PostMapping("/lightModeSettings")
public R<Void> lightModeSettings(@RequestBody DeviceInstructDto params) {
// params 转 JSONObject
appDeviceService.lightModeSettings(params);
return R.ok();
}
/**
* 灯光亮度设置
*/
// @FunctionAccessAnnotation("lightBrightnessSettings")
@PostMapping("/lightBrightnessSettings")
public R<Void> lightBrightnessSettings(@RequestBody DeviceInstructDto params) {
appDeviceService.lightBrightnessSettings(params);
return R.ok();
}
/**
* 激光模式设置
*/
@PostMapping("/laserModeSettings")
// @FunctionAccessAnnotation("laserModeSettings")
public R<Void> laserModeSettings(@RequestBody DeviceInstructDto params) {
appDeviceService.laserModeSettings(params);
return R.ok();
}
}

View File

@ -11,6 +11,7 @@ public class AppDeviceLogoUploadDto {
private Long deviceId; private Long deviceId;
private String deviceImei; private String deviceImei;
/** /**
* 文件 * 文件
*/ */
@ -25,4 +26,5 @@ public class AppDeviceLogoUploadDto {
private List<Long> deviceIds; private List<Long> deviceIds;
private Integer chunkSize; private Integer chunkSize;
} }

View File

@ -21,6 +21,8 @@ public class MqttRuleEngine {
private ThreadPoolTaskExecutor threadPoolTaskExecutor; private ThreadPoolTaskExecutor threadPoolTaskExecutor;
private final LinkedHashMap<String, MqttMessageRule> rulesMap = new LinkedHashMap<>(); private final LinkedHashMap<String, MqttMessageRule> rulesMap = new LinkedHashMap<>();
public MqttRuleEngine(List<MqttMessageRule> rules) { public MqttRuleEngine(List<MqttMessageRule> rules) {
// 按优先级排序 // 按优先级排序
rules.sort(Comparator.comparing(MqttMessageRule::getPriority)); rules.sort(Comparator.comparing(MqttMessageRule::getPriority));
@ -28,8 +30,10 @@ public class MqttRuleEngine {
); );
} }
/** /**
* 执行匹配 * 执行匹配
*
* @param context 处理上下文 * @param context 处理上下文
* @return * @return
*/ */
@ -43,4 +47,5 @@ public class MqttRuleEngine {
return false; return false;
} }
} }

View File

@ -3,7 +3,6 @@ package com.fuyuanshen.global.mqtt.constants;
public interface MqttConstants { public interface MqttConstants {
/** /**
* 全局发布消息的key * 全局发布消息的key
*/ */
@ -13,4 +12,5 @@ public interface MqttConstants {
* 全局订阅消息的key * 全局订阅消息的key
*/ */
String GLOBAL_SUB_KEY = "A/"; String GLOBAL_SUB_KEY = "A/";
} }

View File

@ -25,6 +25,8 @@ import java.util.Objects;
import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX; import static com.fuyuanshen.global.mqtt.constants.DeviceRedisKeyConstants.DEVICE_KEY_PREFIX;
/** /**
* 6075
*
* @author: 默苍璃 * @author: 默苍璃
* @date: 2025-11-05 17:41 * @date: 2025-11-05 17:41
*/ */

View File

@ -28,6 +28,7 @@ public class DeviceBJQController extends BaseController {
private final DeviceBJQBizService appDeviceService; private final DeviceBJQBizService appDeviceService;
/** /**
* 获取设备详细信息 * 获取设备详细信息
* *
@ -39,6 +40,7 @@ public class DeviceBJQController extends BaseController {
return R.ok(appDeviceService.getInfo(id)); return R.ok(appDeviceService.getInfo(id));
} }
/** /**
* 人员信息登记 * 人员信息登记
*/ */
@ -112,7 +114,6 @@ public class DeviceBJQController extends BaseController {
/** /**
* 灯光亮度设置 * 灯光亮度设置
*
*/ */
// @FunctionAccessAnnotation("lightBrightnessSettings") // @FunctionAccessAnnotation("lightBrightnessSettings")
@PostMapping("/lightBrightnessSettings") @PostMapping("/lightBrightnessSettings")
@ -123,7 +124,6 @@ public class DeviceBJQController extends BaseController {
/** /**
* 激光模式设置 * 激光模式设置
*
*/ */
@PostMapping("/laserModeSettings") @PostMapping("/laserModeSettings")
// @FunctionAccessAnnotation("laserModeSettings") // @FunctionAccessAnnotation("laserModeSettings")

View File

@ -42,6 +42,7 @@ public class DeviceControlCenterController extends BaseController {
return appDeviceService.queryWebDeviceList(bo, pageQuery); return appDeviceService.queryWebDeviceList(bo, pageQuery);
} }
/** /**
* 绑定设备 * 绑定设备
*/ */
@ -59,6 +60,7 @@ public class DeviceControlCenterController extends BaseController {
return toAjax(appDeviceService.unBindDevice(id)); return toAjax(appDeviceService.unBindDevice(id));
} }
/** /**
* 查询设备类型列表 * 查询设备类型列表
*/ */
@ -68,6 +70,7 @@ public class DeviceControlCenterController extends BaseController {
return R.ok(typeList); return R.ok(typeList);
} }
/** /**
* 重命名设备 * 重命名设备
* *
@ -147,4 +150,5 @@ public class DeviceControlCenterController extends BaseController {
public R<List<LocationHistoryDetailVo>> getLocationHistoryDetail(Long id) { public R<List<LocationHistoryDetailVo>> getLocationHistoryDetail(Long id) {
return R.ok(appDeviceService.getLocationHistoryDetail(id)); return R.ok(appDeviceService.getLocationHistoryDetail(id));
} }
} }

View File

@ -0,0 +1,140 @@
package com.fuyuanshen.web.controller.device.bjq;
import com.fuyuanshen.app.domain.bo.AppPersonnelInfoBo;
import com.fuyuanshen.app.domain.dto.AppDeviceLogoUploadDto;
import com.fuyuanshen.app.domain.dto.DeviceInstructDto;
import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo;
import com.fuyuanshen.common.core.domain.R;
import com.fuyuanshen.common.core.validate.AddGroup;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation;
import com.fuyuanshen.common.web.core.BaseController;
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
import com.fuyuanshen.web.service.device.DeviceBJQBizService;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
* web后台:设备控制类
* 6075
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/bjq6075/device")
public class DeviceBJQ6075Controller extends BaseController {
private final DeviceBJQBizService appDeviceService;
/**
* 获取设备详细信息
*
* @param id 主键
*/
@GetMapping("/{id}")
public R<AppDeviceDetailVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Long id) {
return R.ok(appDeviceService.getInfo(id));
}
/**
* 人员信息登记
*/
@PostMapping(value = "/registerPersonInfo")
// @FunctionAccessAnnotation("registerPersonInfo")
public R<Void> registerPersonInfo(@Validated(AddGroup.class) @RequestBody AppPersonnelInfoBo bo) {
return toAjax(appDeviceService.registerPersonInfo(bo));
}
/**
* 发送信息
*/
@PostMapping(value = "/sendMessage")
@FunctionAccessBatcAnnotation(value = "sendMessage", timeOut = 30, batchMaxTimeOut = 40)
public R<Void> sendMessage(@RequestBody AppDeviceSendMsgBo bo) {
return toAjax(appDeviceService.sendMessage(bo));
}
/**
* 发送报警信息
*/
@PostMapping(value = "/sendAlarmMessage")
@FunctionAccessBatcAnnotation(value = "sendAlarmMessage", timeOut = 5, batchMaxTimeOut = 10)
public R<Void> sendAlarmMessage(@RequestBody AppDeviceSendMsgBo bo) {
return toAjax(appDeviceService.sendAlarmMessage(bo));
}
/**
* 上传设备logo图片
*/
@PostMapping("/uploadLogo")
@FunctionAccessAnnotation("uploadLogo")
public R<Void> upload(@Validated @ModelAttribute AppDeviceLogoUploadDto bo) {
MultipartFile file = bo.getFile();
if (file.getSize() > 1024 * 1024 * 2) {
return R.warn("图片不能大于2M");
}
appDeviceService.uploadDeviceLogo(bo);
return R.ok();
}
/**
* 批量上传设备logo图片
*/
@PostMapping("/batchUploadLogo")
@FunctionAccessAnnotation("batchUploadLogo")
public R<Void> batchUploadLogo(@Validated @ModelAttribute AppDeviceLogoUploadDto bo) {
MultipartFile file = bo.getFile();
if (file.getSize() > 1024 * 1024 * 2) {
return R.warn("图片不能大于2M");
}
appDeviceService.batchUploadLogo(bo);
return R.ok();
}
/**
* 灯光模式
* 0关灯1强光模式2弱光模式, 3爆闪模式, 4泛光模式
*/
// @FunctionAccessAnnotation("lightModeSettings")
@PostMapping("/lightModeSettings")
public R<Void> lightModeSettings(@RequestBody DeviceInstructDto params) {
// params 转 JSONObject
appDeviceService.lightModeSettings(params);
return R.ok();
}
/**
* 灯光亮度设置
*/
// @FunctionAccessAnnotation("lightBrightnessSettings")
@PostMapping("/lightBrightnessSettings")
public R<Void> lightBrightnessSettings(@RequestBody DeviceInstructDto params) {
appDeviceService.lightBrightnessSettings(params);
return R.ok();
}
/**
* 激光模式设置
*/
@PostMapping("/laserModeSettings")
// @FunctionAccessAnnotation("laserModeSettings")
public R<Void> laserModeSettings(@RequestBody DeviceInstructDto params) {
appDeviceService.laserModeSettings(params);
return R.ok();
}
}

View File

@ -119,6 +119,7 @@ public class DeviceBJQBizService {
/** /**
* 记录设备操作日志 * 记录设备操作日志
*
* @param deviceId 设备ID * @param deviceId 设备ID
* @param content 日志内容 * @param content 日志内容
* @param operator 操作人 * @param operator 操作人
@ -234,7 +235,6 @@ public class DeviceBJQBizService {
} }
public boolean registerPersonInfo(AppPersonnelInfoBo bo) { public boolean registerPersonInfo(AppPersonnelInfoBo bo) {
Long deviceId = bo.getDeviceId(); Long deviceId = bo.getDeviceId();
Device deviceObj = deviceMapper.selectById(deviceId); Device deviceObj = deviceMapper.selectById(deviceId);
@ -297,6 +297,7 @@ public class DeviceBJQBizService {
} }
return true; return true;
} }
public void uploadDeviceLogo2(AppDeviceLogoUploadDto bo) { public void uploadDeviceLogo2(AppDeviceLogoUploadDto bo) {
try { try {
Device device = deviceMapper.selectById(bo.getDeviceId()); Device device = deviceMapper.selectById(bo.getDeviceId());
@ -331,6 +332,7 @@ public class DeviceBJQBizService {
throw new ServiceException("发送指令失败"); throw new ServiceException("发送指令失败");
} }
} }
public void uploadDeviceLogo(AppDeviceLogoUploadDto bo) { public void uploadDeviceLogo(AppDeviceLogoUploadDto bo) {
try { try {
Device device = deviceMapper.selectById(bo.getDeviceId()); Device device = deviceMapper.selectById(bo.getDeviceId());

View File

@ -59,8 +59,8 @@ public class DeviceBizService {
private final RealTimeStatusEngine realTimeStatusEngine; private final RealTimeStatusEngine realTimeStatusEngine;
private final DeviceLogMapper deviceLogMapper; private final DeviceLogMapper deviceLogMapper;
private final AppDeviceShareMapper appDeviceShareMapper; private final AppDeviceShareMapper appDeviceShareMapper;
private final AppUserMapper appUserMapper;; private final AppUserMapper appUserMapper;
;
public List<APPDeviceTypeVo> getTypeList() { public List<APPDeviceTypeVo> getTypeList() {
@ -165,6 +165,7 @@ public class DeviceBizService {
return TableDataInfo.build(result); return TableDataInfo.build(result);
} }
public int bindDevice(AppDeviceBo bo) { public int bindDevice(AppDeviceBo bo) {
Integer mode = bo.getCommunicationMode(); Integer mode = bo.getCommunicationMode();
Long userId = AppLoginHelper.getUserId(); Long userId = AppLoginHelper.getUserId();

View File

@ -58,7 +58,6 @@ public class WebDeviceVo implements Serializable {
*/ */
private Integer deviceStatus; private Integer deviceStatus;
/**绑定状态 /**绑定状态
* 0 未绑定 * 0 未绑定
* 1 已绑定 * 1 已绑定