Commit 7ed60ff7 by 罗志长

feat: 独立部署设备消息过滤

parent 423fd9b1
......@@ -101,6 +101,8 @@ public class RedisConst {
public static final String ALARM_CONFIG_ORG_ID = "alarm:config:org:id:";
public static final String PLAT_IOT_DEVICE_PREFIX = "plat:iot:device:";
public static final String PLAT_OWN_IOT_DEVICE_ID = "plat:own:iot:device:id:";
public static final String ELDER_DAY_DURATION_PREFIX = "plat:day:duration:device:";
public static final String LOCK_ALARM = "lock:alarm:device:id:";
......
......@@ -43,11 +43,16 @@ public class DeviceCacheUtil implements ApplicationRunner {
PlatTenant platTenant = platTenantService.getById(platDevice.getTenantId());
if(StringUtils.equals(platDevice.getStatus(),DeviceState.online.getValue())) {
RedisUtil.set(RedisConst.PLAT_IOT_DEVICE_PREFIX + platDevice.getOriDeviceId()+":"+platTenant.getIotOrgId(), platDevice);
RedisUtil.set(RedisConst.PLAT_OWN_IOT_DEVICE_ID + platDevice.getOriDeviceId(), platDevice);
}else {
String key = RedisConst.PLAT_IOT_DEVICE_PREFIX + platDevice.getOriDeviceId()+":"+platTenant.getIotOrgId();
if(RedisUtil.exist(key)){
RedisUtil.delete(RedisConst.PLAT_IOT_DEVICE_PREFIX + platDevice.getOriDeviceId()+":"+platTenant.getIotOrgId());
}
String key1 = RedisConst.PLAT_OWN_IOT_DEVICE_ID + platDevice.getOriDeviceId();
if(RedisUtil.exist(key1)){
RedisUtil.delete(key1);
}
}
}
......
......@@ -115,6 +115,12 @@ public class PushCallback implements MqttCallbackExtended {
// 解析数据
DeviceInfo device = JSON.parseObject(payload, DeviceInfo.class);
// 独立部署的服务过滤出平台自己的设备消息
String key = RedisConst.PLAT_OWN_IOT_DEVICE_ID + device.getDeviceId();
if (!RedisUtil.exist(key)) {
return;
}
syncProperties(device);
checkAlarm(device);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment