Commit 5248fa5c by huangjy

fix:修复bug

parent 4ea26e5f
...@@ -74,5 +74,5 @@ public interface PlatDeviceService extends IService<PlatDevice> { ...@@ -74,5 +74,5 @@ public interface PlatDeviceService extends IService<PlatDevice> {
void batchEditProperties(PlatDeviceAttrDTO dto); void batchEditProperties(PlatDeviceAttrDTO dto);
void updateDeviceStatus(String messageType, String deviceId, String iot_tenantId); boolean updateDeviceStatus(String messageType, String deviceId, String iot_tenantId);
} }
...@@ -607,7 +607,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -607,7 +607,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
@Override @Override
@TenantIdIgnore @TenantIdIgnore
public void updateDeviceStatus(String messageType, String deviceId, String iot_tenantId) { public boolean updateDeviceStatus(String messageType, String deviceId, String iot_tenantId) {
try { try {
if (org.apache.commons.lang3.StringUtils.equalsAnyIgnoreCase(messageType, com.makeit.module.iot.enums.DeviceState.offline.getValue(), com.makeit.module.iot.enums.DeviceState.online.getValue())) { if (org.apache.commons.lang3.StringUtils.equalsAnyIgnoreCase(messageType, com.makeit.module.iot.enums.DeviceState.offline.getValue(), com.makeit.module.iot.enums.DeviceState.online.getValue())) {
...@@ -618,16 +618,17 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -618,16 +618,17 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
LambdaQueryWrapper<PlatDevice> deviceLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatDevice> deviceLambdaQueryWrapper = new LambdaQueryWrapper<>();
deviceLambdaQueryWrapper.eq(PlatDevice::getOriDeviceId, deviceId); deviceLambdaQueryWrapper.eq(PlatDevice::getOriDeviceId, deviceId);
List<PlatDevice> deviceList = list(deviceLambdaQueryWrapper); List<PlatDevice> deviceList = list(deviceLambdaQueryWrapper);
if (CollectionUtils.isEmpty(deviceList)) { if (CollectionUtils.isNotEmpty(deviceList)) {
return;
}
for (PlatDevice platDevice : deviceList) { for (PlatDevice platDevice : deviceList) {
platDevice.setStatus(messageType.toLowerCase()); platDevice.setStatus(messageType.toLowerCase());
} }
deviceCacheUtil.putAll(deviceList); deviceCacheUtil.putAll(deviceList);
} }
return true;
}
}catch (Exception e){ }catch (Exception e){
log.error("更新设备状态:",e); log.error("更新设备状态:",e);
} }
return false;
} }
} }
...@@ -116,7 +116,10 @@ public class PushCallback implements MqttCallback { ...@@ -116,7 +116,10 @@ public class PushCallback implements MqttCallback {
String deviceId = device.getDeviceId(); String deviceId = device.getDeviceId();
String messageType = device.getMessageType(); String messageType = device.getMessageType();
//更新设备状态 //更新设备状态
platDeviceService.updateDeviceStatus(messageType,deviceId,""); boolean statusFlag = platDeviceService.updateDeviceStatus(messageType, deviceId, "");
if (statusFlag) {
return;
}
for (HeaderInfo.Bind binding : bindings) { for (HeaderInfo.Bind binding : bindings) {
try { try {
String iot_tenantId = binding.getId(); String iot_tenantId = binding.getId();
......
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