parent
acb0028dd3
commit
f47cf01cb0
|
|
@ -129,7 +129,6 @@ public class MqttController {
|
||||||
* 便于排查连接问题
|
* 便于排查连接问题
|
||||||
*/
|
*/
|
||||||
@GetMapping("/status")
|
@GetMapping("/status")
|
||||||
@Log(title = "手动触发MQTT重连", businessType = BusinessType.SELECT)
|
|
||||||
public AjaxResult getMqttStatus() {
|
public AjaxResult getMqttStatus() {
|
||||||
try {
|
try {
|
||||||
return AjaxResult.success(mqttClientManager.getMqttStatus());
|
return AjaxResult.success(mqttClientManager.getMqttStatus());
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,9 @@ public class DeviceStatusHandler {
|
||||||
* 处理设备状态:转发给订阅的前端、处理回执、触发自动关
|
* 处理设备状态:转发给订阅的前端、处理回执、触发自动关
|
||||||
*/
|
*/
|
||||||
public void handle(String topic, String payload) throws MqttException {
|
public void handle(String topic, String payload) throws MqttException {
|
||||||
|
if (!payload.trim().startsWith("{")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 第一步:解析JSON,非有效JSON直接return
|
// 第一步:解析JSON,非有效JSON直接return
|
||||||
JSONObject payloadObj;
|
JSONObject payloadObj;
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -306,9 +306,11 @@ public class MqttSubscriptionManager {
|
||||||
private List<String> queryImeiByUserId(Long userId) {
|
private List<String> queryImeiByUserId(Long userId) {
|
||||||
// 示例:替换为你项目中查询用户设备的实际代码
|
// 示例:替换为你项目中查询用户设备的实际代码
|
||||||
// 比如:return deviceService.listDeviceIdsByUserId(userId);
|
// 比如:return deviceService.listDeviceIdsByUserId(userId);
|
||||||
List<SysAgriInfo> agriInfos = agriInfoService.lambdaQuery()
|
SysAgriInfo sysAgriInfo = new SysAgriInfo();
|
||||||
.eq(SysAgriInfo::getUserId, userId)
|
if (!SecurityUtils.isAdmin()) {
|
||||||
.list();
|
sysAgriInfo.setUserId(SecurityUtils.getUserId());
|
||||||
|
}
|
||||||
|
List<SysAgriInfo> agriInfos = agriInfoService.findAgriByUser(sysAgriInfo);
|
||||||
if (CollectionUtils.isEmpty(agriInfos)) {
|
if (CollectionUtils.isEmpty(agriInfos)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue