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