mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-17 16:36:03 +08:00
设备信号实时显示
This commit is contained in:
@@ -195,8 +195,8 @@ public class ToolController extends BaseController {
|
|||||||
if (model.getAction().equals("client_disconnected")) {
|
if (model.getAction().equals("client_disconnected")) {
|
||||||
device.setStatus(4);
|
device.setStatus(4);
|
||||||
deviceService.updateDeviceStatusAndLocation(device, "");
|
deviceService.updateDeviceStatusAndLocation(device, "");
|
||||||
// 发布设备状态
|
// 设备掉线后发布设备状态
|
||||||
emqxService.publishStatus(device.getProductId(), device.getSerialNumber(), 4, device.getIsShadow());
|
emqxService.publishStatus(device.getProductId(), device.getSerialNumber(), 4, device.getIsShadow(),device.getRssi());
|
||||||
// 清空保留消息,上线后发布新的属性功能保留消息
|
// 清空保留消息,上线后发布新的属性功能保留消息
|
||||||
emqxService.publishProperty(device.getProductId(), device.getSerialNumber(), null);
|
emqxService.publishProperty(device.getProductId(), device.getSerialNumber(), null);
|
||||||
emqxService.publishFunction(device.getProductId(), device.getSerialNumber(), null);
|
emqxService.publishFunction(device.getProductId(), device.getSerialNumber(), null);
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ public class EmqxService {
|
|||||||
device.setSerialNumber(deviceNum);
|
device.setSerialNumber(deviceNum);
|
||||||
deviceService.reportDevice(device,deviceEntity);
|
deviceService.reportDevice(device,deviceEntity);
|
||||||
// 发布设备状态
|
// 发布设备状态
|
||||||
publishStatus(productId, deviceNum, 3, deviceEntity.getIsShadow());
|
publishStatus(productId, deviceNum, 3, deviceEntity.getIsShadow(),device.getRssi());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("接收设备信息,解析数据时异常 message={}", e.getMessage());
|
logger.error("接收设备信息,解析数据时异常 message={}", e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -216,8 +216,8 @@ public class EmqxService {
|
|||||||
/**
|
/**
|
||||||
* 1.发布设备状态
|
* 1.发布设备状态
|
||||||
*/
|
*/
|
||||||
public void publishStatus(Long productId, String deviceNum, int deviceStatus, int isShadow) {
|
public void publishStatus(Long productId, String deviceNum, int deviceStatus, int isShadow,int rssi) {
|
||||||
String message = "{\"status\":" + deviceStatus + ",\"isShadow\":" + isShadow + "}";
|
String message = "{\"status\":" + deviceStatus + ",\"isShadow\":" + isShadow + ",\"rssi\":" + rssi + "}";
|
||||||
emqxClient.publish(1, false, "/" + productId + "/" + deviceNum + pStatusTopic, message);
|
emqxClient.publish(1, false, "/" + productId + "/" + deviceNum + pStatusTopic, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<sql id="selectWebhookDeviceVo">
|
<sql id="selectWebhookDeviceVo">
|
||||||
select device_id, device_name,product_id, serial_number,user_id, user_name, tenant_id, tenant_name, status,is_shadow ,location_way,things_model_value, active_time from iot_device
|
select device_id, device_name,product_id, serial_number,user_id, user_name, tenant_id, tenant_name, status,is_shadow, rssi ,location_way,things_model_value, active_time from iot_device
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectDeviceList" parameterType="com.ruoyi.iot.domain.Device" resultMap="DeviceResult">
|
<select id="selectDeviceList" parameterType="com.ruoyi.iot.domain.Device" resultMap="DeviceResult">
|
||||||
|
|||||||
Reference in New Issue
Block a user