Commit 7f31523f by huangjy

fix:修复bug

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