commit
58883ecc81
|
@ -104,17 +104,16 @@ public class PluginMainImpl implements IPluginMain, DeviceService {
|
|||
throw new BizException(ErrCode.PLUGIN_SERVICE_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (!(service.getParams() instanceof Map)) {
|
||||
throw new BizException(ErrCode.PARAMS_EXCEPTION);
|
||||
}
|
||||
Map<String, ?> params = (Map<String, ?>) service.getParams();
|
||||
|
||||
IDevice deviceService = deviceServices.get(0);
|
||||
String type = service.getType();
|
||||
String identifier = service.getIdentifier();
|
||||
ActionResult result = null;
|
||||
|
||||
if (ThingService.TYPE_SERVICE.equals(type)) {
|
||||
if (!(service.getParams() instanceof Map)) {
|
||||
throw new BizException(ErrCode.PARAMS_EXCEPTION);
|
||||
}
|
||||
Map<String, ?> params = (Map<String, ?>) service.getParams();
|
||||
//服务调用
|
||||
ServiceInvoke action = ServiceInvoke.builder()
|
||||
.id(service.getMid())
|
||||
|
@ -128,6 +127,10 @@ public class PluginMainImpl implements IPluginMain, DeviceService {
|
|||
publish(service, result.getCode());
|
||||
} else if (ThingService.TYPE_PROPERTY.equals(type)) {
|
||||
if ("set".equals(identifier)) {
|
||||
if (!(service.getParams() instanceof Map)) {
|
||||
throw new BizException(ErrCode.PARAMS_EXCEPTION);
|
||||
}
|
||||
Map<String, ?> params = (Map<String, ?>) service.getParams();
|
||||
//属性设置
|
||||
PropertySet action = PropertySet.builder()
|
||||
.id(service.getMid())
|
||||
|
@ -144,7 +147,7 @@ public class PluginMainImpl implements IPluginMain, DeviceService {
|
|||
.id(service.getMid())
|
||||
.productKey(linkPk)
|
||||
.deviceName(linkDn)
|
||||
.keys(new ArrayList<>(params.keySet()))
|
||||
.keys((List<String>) service.getParams())
|
||||
.build();
|
||||
//调用插件设备服务接口
|
||||
result = deviceService.propertyGet(action);
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.springframework.context.ApplicationContext;
|
|||
import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
|
@ -53,6 +54,9 @@ public class RuleDeviceConsumer implements ConsumerHandler<ThingModelMessage>, A
|
|||
for (DeviceMessageHandler handler : this.handlers) {
|
||||
messageHandlerPool.submit(() -> {
|
||||
try {
|
||||
if (!(msg.getData() instanceof Map)) {
|
||||
msg.setData(new HashMap<>());
|
||||
}
|
||||
handler.handle(msg);
|
||||
} catch (Throwable e) {
|
||||
log.error("handler message error", e);
|
||||
|
|
Loading…
Reference in New Issue