fixedBug:#I6460T-多个虚拟设备共用同一个设备导致重复执行

V0.5.x
xiwa 2022-12-02 17:45:18 +08:00
parent 6231e7d63b
commit 91ee9bda5c
3 changed files with 6 additions and 13 deletions

View File

@ -32,6 +32,7 @@
"16537594784840wenshidu0100300013a", "16537594784840wenshidu0100300013a",
"16537594752710wenshidu0100200013d", "16537594752710wenshidu0100200013d",
"16537594707840wenshidu0100100013c", "16537594707840wenshidu0100100013c",
"16538390097670switch0300100500143",
"16514626218250abe124000010000011a" "16514626218250abe124000010000011a"
], ],
"type": "thingModel", "type": "thingModel",

View File

@ -50,7 +50,7 @@ public class VirtualExecutor implements Job {
continue; continue;
} }
log.info("invoke virtual device report,jobKey:{},deviceId:{}", jobKey, device.getDeviceId()); log.info("invoke virtual device report,jobKey:{},deviceId:{}", jobKey, device.getDeviceId());
virtualManager.invokeReport(device); virtualManager.invokeReport(device, virtualDevice.getId());
} }
} catch (Throwable e) { } catch (Throwable e) {
virtualDeviceLog.setResult(e.getMessage()); virtualDeviceLog.setResult(e.getMessage());

View File

@ -269,23 +269,15 @@ public class VirtualManager {
/** /**
* *
*/ */
public void invokeReport(DeviceInfo device) { public void invokeReport(DeviceInfo device, String virtualId) {
//设备上线 //设备上线
deviceOnline(device); deviceOnline(device);
String deviceId = device.getDeviceId(); Object scriptObj = virtualScripts.get(virtualId);
Set<String> virtualIds = deviceIdToVirtualId.get(deviceId); if (scriptObj == null) {
if (virtualIds == null) {
return; return;
} }
processReport(invokeMethod(scriptObj, "report", device));
for (String virtualId : virtualIds) {
Object scriptObj = virtualScripts.get(virtualId);
if (scriptObj == null) {
continue;
}
processReport(invokeMethod(scriptObj, "report", device));
}
} }
/** /**