From 723585f47c314aed06689066c840af594773146d Mon Sep 17 00:00:00 2001 From: xiwa Date: Mon, 30 Oct 2023 08:39:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=8F=92=E4=BB=B6=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E5=BC=95=E6=93=8E=E8=8E=B7=E5=8F=96=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cc/iotkit/manager/service/impl/PluginServiceImpl.java | 8 ++++---- .../main/java/cc/iotkit/plugin/main/PluginMainImpl.java | 6 +----- .../main/java/cc/iotkit/plugin/main/ThingServiceImpl.java | 3 +++ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/impl/PluginServiceImpl.java b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/impl/PluginServiceImpl.java index 7b5c1683..bec64db7 100644 --- a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/impl/PluginServiceImpl.java +++ b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/impl/PluginServiceImpl.java @@ -92,7 +92,10 @@ public class PluginServiceImpl implements IPluginService { log.info("script:{}", script); } - plugin.setState(PluginInfo.STATE_STOPPED); + PluginState pluginState = pluginInfo.getPluginState(); + if (pluginState == PluginState.STARTED) { + plugin.setState(PluginInfo.STATE_RUNNING); + } plugin.setPluginId(pluginInfo.getPluginId()); plugin.setFile(file.getOriginalFilename()); plugin.setConfigSchema(configJson); @@ -102,9 +105,6 @@ public class PluginServiceImpl implements IPluginService { plugin.setVersion(pluginDescriptor.getPluginVersion()); plugin.setDescription(pluginDescriptor.getDescription()); pluginInfoData.save(plugin); - - //默认停止 - pluginOperator.stop(pluginId); } catch (Exception e) { throw new BizException(ErrCode.PLUGIN_INSTALL_FAILED, e); } diff --git a/iot-module/iot-plugin/iot-plugin-main/src/main/java/cc/iotkit/plugin/main/PluginMainImpl.java b/iot-module/iot-plugin/iot-plugin-main/src/main/java/cc/iotkit/plugin/main/PluginMainImpl.java index 2ea29d31..7c17c551 100644 --- a/iot-module/iot-plugin/iot-plugin-main/src/main/java/cc/iotkit/plugin/main/PluginMainImpl.java +++ b/iot-module/iot-plugin/iot-plugin-main/src/main/java/cc/iotkit/plugin/main/PluginMainImpl.java @@ -67,17 +67,13 @@ public class PluginMainImpl implements IPluginMain, DeviceService { @Autowired private MqProducer producer; - private static final Map SCRIPT_ENGINE_MAP = new HashMap<>(); - public IScriptEngine initScriptEngine(String pluginId) { PluginInfo pluginInfo = pluginInfoData.findByPluginId(pluginId); if (pluginInfo == null) { - SCRIPT_ENGINE_MAP.put(pluginId, null); return null; } String script = pluginInfo.getScript(); if (StringUtils.isBlank(script)) { - SCRIPT_ENGINE_MAP.put(pluginId, null); return null; } @@ -88,7 +84,7 @@ public class PluginMainImpl implements IPluginMain, DeviceService { @Override public IScriptEngine getScriptEngine(String pluginId) { - return SCRIPT_ENGINE_MAP.put(pluginId, initScriptEngine(pluginId)); + return initScriptEngine(pluginId); } @Override diff --git a/iot-module/iot-plugin/iot-plugin-main/src/main/java/cc/iotkit/plugin/main/ThingServiceImpl.java b/iot-module/iot-plugin/iot-plugin-main/src/main/java/cc/iotkit/plugin/main/ThingServiceImpl.java index 4589aacb..45fb3b36 100644 --- a/iot-module/iot-plugin/iot-plugin-main/src/main/java/cc/iotkit/plugin/main/ThingServiceImpl.java +++ b/iot-module/iot-plugin/iot-plugin-main/src/main/java/cc/iotkit/plugin/main/ThingServiceImpl.java @@ -155,6 +155,9 @@ public class ThingServiceImpl implements IThingService { if (device != null) { log.info("device already registered"); device.setModel(register.getModel()); + device.setProductKey(register.getProductKey()); + device.setSecret(RandomStringUtils.randomAlphabetic(16)); + deviceInfoData.save(device); } else { //不存在,注册新设备 device = new DeviceInfo();