浏览代码

fix:数据初始化、插件上报等修改

xiwa 1 年之前
父节点
当前提交
62c3be6ea0

+ 16 - 0
data/init/oauthClient.json

@@ -0,0 +1,16 @@
+[
+  {
+    "clientId": "iotkit",
+    "name": "奇特物联",
+    "clientSecret": "b86cb53d-c005-48a3-bb02-3c262151b68c",
+    "allowUrl": "*",
+    "createAt": 1652840868485
+  },
+  {
+    "clientId": "dueros",
+    "name": "小度音箱",
+    "clientSecret": "750c67c2-29cb-40c3-bf4d-c0b9bf3eed88",
+    "allowUrl": "*",
+    "createAt": 1652840868485
+  }
+]

+ 58 - 0
data/init/pluginInfo.json

@@ -0,0 +1,58 @@
+[ {
+  "createDept" : null,
+  "createBy" : null,
+  "createTime" : 1708317062484,
+  "updateBy" : null,
+  "updateTime" : 1708317122265,
+  "id" : 516835985375301,
+  "pluginId" : "http-plugin",
+  "name" : "http插件",
+  "description" : "http示例插件,配置参数:端口(port)默认9081",
+  "deployType" : "upload",
+  "file" : "http-plugin-1.0.1-repackage.jar",
+  "version" : "1.0.1",
+  "type" : null,
+  "protocol" : null,
+  "state" : "running",
+  "configSchema" : "[\n  {\n    \"id\": \"port\",\n    \"name\": \"端口\",\n    \"type\": \"number\",\n    \"value\": 9081,\n    \"desc\": \"http端口,默认为9081\"\n  },\n  {\n    \"id\": \"a\",\n    \"name\": \"测试参数1\",\n    \"type\": \"radio\",\n    \"value\": 0,\n    \"desc\": \"单选参数a\",\n    \"options\": [\n      {\n        \"name\": \"值0\",\n        \"value\": 0\n      },\n      {\n        \"name\": \"值1\",\n        \"value\": 11\n      }\n    ]\n  }\n]",
+  "config" : null,
+  "script" : ""
+}, {
+  "createDept" : null,
+  "createBy" : null,
+  "createTime" : 1708317067797,
+  "updateBy" : null,
+  "updateTime" : 1708317171964,
+  "id" : 516836007116869,
+  "pluginId" : "mqtt-plugin",
+  "name" : "mqtt插件",
+  "description" : "mqtt示例插件",
+  "deployType" : "upload",
+  "file" : "mqtt-plugin-1.0.1-repackage.jar",
+  "version" : "1.0.1",
+  "type" : null,
+  "protocol" : null,
+  "state" : "running",
+  "configSchema" : "[\n  {\n    \"id\": \"port\",\n    \"name\": \"端口\",\n    \"type\": \"number\",\n    \"value\": 1883,\n    \"desc\": \"mqtt端口,默认为1883\"\n  }\n]",
+  "config" : null,
+  "script" : ""
+}, {
+  "createDept" : null,
+  "createBy" : null,
+  "createTime" : 1708317072837,
+  "updateBy" : null,
+  "updateTime" : 1708317204758,
+  "id" : 516836027760709,
+  "pluginId" : "tcp-plugin",
+  "name" : "tcp插件",
+  "description" : "tcp示例插件",
+  "deployType" : "upload",
+  "file" : "tcp-plugin-1.0.4-repackage.jar",
+  "version" : "1.0.4",
+  "type" : null,
+  "protocol" : null,
+  "state" : "running",
+  "configSchema" : "[\n  {\n    \"id\": \"host\",\n    \"name\": \"绑定ip\",\n    \"type\": \"text\",\n    \"value\": \"127.0.0.1\",\n    \"desc\": \"tcp绑定ip,默认为127.0.0.1\"\n  },\n  {\n    \"id\": \"port\",\n    \"name\": \"端口\",\n    \"type\": \"number\",\n    \"value\": 6883,\n    \"desc\": \"tcp端口,默认为6883\"\n  }\n]",
+  "config" : null,
+  "script" : "function hexToByte(hexString) {\n    if (hexString.length % 2 !== 0) {\n        throw new Error('Invalid hex string. String must have an even number of characters.');\n    }\n\n    let byteArray = [];\n    for (let i = 0; i < hexString.length; i += 4) {\n        byteArray.push(parseInt(hexString.substr(i, 4), 16));\n    }\n\n    return byteArray;\n}\nfunction byteToHex(bytes) {\n    for (var hex = [], i = 0; i < bytes.length; i++) {\n        hex.push((bytes[i] >>> 4).toString(16));\n        hex.push((bytes[i] & 0xF).toString(16));\n    }\n    return hex.join(\"\");\n}\n\nthis.decode=function(data){\n    hex=data.payload;\n    const bytes=hexToByte(hex);\n    return {\n        \"rssi\":bytes[0],\n        \"powerstate\":bytes[1]\n    };\n}\n\nthis.encode=function(params){\n    const hex=byteToHex([params.powerstate]);\n    return hex;\n}"
+} ]

+ 0 - 44
data/init/thingModel.json

@@ -1562,17 +1562,6 @@
           "name": "水温度",
           "accessMode": "r"
         },
-        {
-          "identifier": "query",
-          "dataType": {
-            "type": "text",
-            "specs": {
-              "length": "255"
-            }
-          },
-          "name": "查询",
-          "accessMode": "rw"
-        },
         {
           "identifier": "McuStatus",
           "dataType": {
@@ -1968,17 +1957,6 @@
               "name": "防冻",
               "required": false
             },
-            {
-              "identifier": "query",
-              "dataType": {
-                "type": "text",
-                "specs": {
-                  "length": "255"
-                }
-              },
-              "name": "查询",
-              "required": false
-            },
             {
               "identifier": "ActiveTime",
               "dataType": {
@@ -2465,17 +2443,6 @@
               "name": "水温度",
               "required": false
             },
-            {
-              "identifier": "query",
-              "dataType": {
-                "type": "text",
-                "specs": {
-                  "length": "255"
-                }
-              },
-              "name": "查询",
-              "required": false
-            },
             {
               "identifier": "McuStatus",
               "dataType": {
@@ -3009,17 +2976,6 @@
               "name": "水温度",
               "required": false
             },
-            {
-              "identifier": "query",
-              "dataType": {
-                "type": "text",
-                "specs": {
-                  "length": "255"
-                }
-              },
-              "name": "查询",
-              "required": false
-            },
             {
               "identifier": "McuStatus",
               "dataType": {

+ 0 - 5
iot-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceInfoDataImpl.java

@@ -436,11 +436,6 @@ public class DeviceInfoDataImpl implements IDeviceInfoData, IJPACommData<DeviceI
         return deviceInfoRepository.count();
     }
 
-    @Override
-    public List<DeviceInfo> findAll() {
-        return new ArrayList<>();
-    }
-
     @Override
     public Paging<DeviceInfo> findAll(PageRequest<DeviceInfo> pageRequest) {
         Page<TbDeviceInfo> ret = deviceInfoRepository.findAll(PageBuilder.toPageable(pageRequest));

+ 43 - 136
iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/ExampleDataInit.java

@@ -10,6 +10,7 @@
 package cc.iotkit.manager.service;
 
 import cc.iotkit.common.utils.JsonUtils;
+import cc.iotkit.common.utils.SpringUtils;
 import cc.iotkit.data.ICommonData;
 import cc.iotkit.data.manager.*;
 import cc.iotkit.data.system.*;
@@ -23,6 +24,7 @@ import cc.iotkit.model.notify.Channel;
 import cc.iotkit.model.notify.ChannelConfig;
 import cc.iotkit.model.notify.ChannelTemplate;
 import cc.iotkit.model.notify.NotifyMessage;
+import cc.iotkit.model.plugin.PluginInfo;
 import cc.iotkit.model.product.Category;
 import cc.iotkit.model.product.Product;
 import cc.iotkit.model.product.ProductModel;
@@ -39,7 +41,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FileUtils;
 import org.springframework.beans.factory.SmartInitializingSingleton;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
@@ -57,104 +58,8 @@ public class ExampleDataInit implements SmartInitializingSingleton {
     @Value("${iita.init.data:true}")
     private boolean initDataFlg;
 
-    @Autowired
-    private IOauthClientData oauthClientData;
-    @Autowired
-    private ICategoryData categoryData;
-    @Autowired
-    private IDeviceGroupData deviceGroupData;
-    @Autowired
-    @Qualifier("deviceInfoDataCache")
-    private IDeviceInfoData deviceInfoData;
-    @Autowired
-    private IHomeData homeData;
-    @Autowired
-    private IProductData productData;
-    @Autowired
-    private IProductModelData productModelData;
-    @Autowired
-    private IRuleInfoData ruleInfoData;
-    @Autowired
-    private ISpaceData spaceData;
-    @Autowired
-    private ISpaceDeviceData spaceDeviceData;
-    @Autowired
-    private ITaskInfoData taskInfoData;
-    @Autowired
-    private IThingModelData thingModelData;
-    @Autowired
-    private IUserInfoData userInfoData;
-    @Autowired
-    private IVirtualDeviceData virtualDeviceData;
     @Autowired
     private IDbStructureData dbStructureData;
-    @Autowired
-    private IChannelData iChannelData;
-    @Autowired
-    private IChannelConfigData iChannelConfigData;
-    @Autowired
-    private IChannelTemplateData iChannelTemplateData;
-    @Autowired
-    private INotifyMessageData iNotifyMessageData;
-    @Autowired
-    private ISysDeptData sysDeptData;
-
-    @Autowired
-    private ISysMenuData sysMenuData;
-
-    @Autowired
-    private ISysPostData sysPostData;
-
-    @Autowired
-    private ISysRoleData sysRoleData;
-
-    @Autowired
-    private ISysUserData sysUserData;
-
-    @Autowired
-    private ISysTenantData sysTenantData;
-
-    @Autowired
-    private ISysConfigData sysConfigData;
-
-    @Autowired
-    private ISysDictData sysDictData;
-
-    @Autowired
-    private ISysDictTypeData sysDictTypeData;
-
-    @Autowired
-    private ISysLogininforData sysLogininforData;
-
-    @Autowired
-    private ISysNoticeData sysNoticeData;
-
-    @Autowired
-    private ISysOperLogData sysOperLogData;
-
-    @Autowired
-    private ISysOssData sysOssData;
-
-    @Autowired
-    private ISysOssConfigData sysOssConfigData;
-
-    @Autowired
-    private ISysRoleDeptData sysRoleDeptData;
-
-    @Autowired
-    private ISysRoleMenuData sysRoleMenuData;
-
-    @Autowired
-    private ISysTenantPackageData sysTenantPackageData;
-
-    @Autowired
-    private ISysUserPostData sysUserPostData;
-
-    @Autowired
-    private ISysUserRoleData sysUserRoleData;
-
-    @Autowired
-    private ISysAppData sysAppData;
 
     @Override
     public void afterSingletonsInstantiated() {
@@ -172,46 +77,48 @@ public class ExampleDataInit implements SmartInitializingSingleton {
                     if (!initDataFlg) {
                         return;
                     }
-                    initData("category", categoryData, new TypeReference<List<Category>>() {
+                    initData("category", SpringUtils.getBean(ICategoryData.class), new TypeReference<List<Category>>() {
                     });
-                    initData("deviceGroup", deviceGroupData, new TypeReference<List<DeviceGroup>>() {
+                    initData("deviceGroup", SpringUtils.getBean(IDeviceGroupData.class), new TypeReference<List<DeviceGroup>>() {
                     });
-                    initData("deviceInfo", deviceInfoData, new TypeReference<List<DeviceInfo>>() {
+                    initData("deviceInfo", SpringUtils.getBean(IDeviceInfoData.class), new TypeReference<List<DeviceInfo>>() {
                     });
-                    initData("home", homeData, new TypeReference<List<Home>>() {
+                    initData("home", SpringUtils.getBean(IHomeData.class), new TypeReference<List<Home>>() {
                     });
-                    initData("oauthClient", oauthClientData, new TypeReference<List<OauthClient>>() {
+                    initData("oauthClient", SpringUtils.getBean(IOauthClientData.class), new TypeReference<List<OauthClient>>() {
                     });
-                    initData("product", productData, new TypeReference<List<Product>>() {
+                    initData("product", SpringUtils.getBean(IProductData.class), new TypeReference<List<Product>>() {
                     });
-                    initData("productModel", productModelData, new TypeReference<List<ProductModel>>() {
+                    initData("productModel", SpringUtils.getBean(IProductModelData.class), new TypeReference<List<ProductModel>>() {
                     });
-                    initData("ruleInfo", ruleInfoData, new TypeReference<List<RuleInfo>>() {
+                    initData("ruleInfo", SpringUtils.getBean(IRuleInfoData.class), new TypeReference<List<RuleInfo>>() {
                     });
-                    initData("space", spaceData, new TypeReference<List<Space>>() {
+                    initData("space", SpringUtils.getBean(ISpaceData.class), new TypeReference<List<Space>>() {
                     });
-                    initData("spaceDevice", spaceDeviceData, new TypeReference<List<SpaceDevice>>() {
+                    initData("spaceDevice", SpringUtils.getBean(ISpaceDeviceData.class), new TypeReference<List<SpaceDevice>>() {
                     });
-                    initData("taskInfo", taskInfoData, new TypeReference<List<TaskInfo>>() {
+                    initData("taskInfo", SpringUtils.getBean(ITaskInfoData.class), new TypeReference<List<TaskInfo>>() {
                     });
-                    List<ThingModel> thingModels = initData("thingModel", thingModelData, new TypeReference<>() {
+                    List<ThingModel> thingModels = initData("thingModel", SpringUtils.getBean(IThingModelData.class), new TypeReference<>() {
                     });
                     //初始化物模型时序数据结构
                     for (ThingModel thingModel : thingModels) {
                         dbStructureData.defineThingModel(thingModel);
                     }
 
-                    initData("userInfo", userInfoData, new TypeReference<List<UserInfo>>() {
+                    initData("userInfo", SpringUtils.getBean(IUserInfoData.class), new TypeReference<List<UserInfo>>() {
+                    });
+                    initData("virtualDevice", SpringUtils.getBean(IVirtualDeviceData.class), new TypeReference<List<VirtualDevice>>() {
                     });
-                    initData("virtualDevice", virtualDeviceData, new TypeReference<List<VirtualDevice>>() {
+                    initData("channel", SpringUtils.getBean(IChannelData.class), new TypeReference<List<Channel>>() {
                     });
-                    initData("channel", iChannelData, new TypeReference<List<Channel>>() {
+                    initData("channelConfig", SpringUtils.getBean(IChannelConfigData.class), new TypeReference<List<ChannelConfig>>() {
                     });
-                    initData("channelConfig", iChannelConfigData, new TypeReference<List<ChannelConfig>>() {
+                    initData("channelTemplate", SpringUtils.getBean(IChannelTemplateData.class), new TypeReference<List<ChannelTemplate>>() {
                     });
-                    initData("channelTemplate", iChannelTemplateData, new TypeReference<List<ChannelTemplate>>() {
+                    initData("notifyMessage", SpringUtils.getBean(INotifyMessageData.class), new TypeReference<List<NotifyMessage>>() {
                     });
-                    initData("notifyMessage", iNotifyMessageData, new TypeReference<List<NotifyMessage>>() {
+                    initData("pluginInfo", SpringUtils.getBean(IPluginInfoData.class), new TypeReference<List<PluginInfo>>() {
                     });
 
                     initSysData();
@@ -220,7 +127,7 @@ public class ExampleDataInit implements SmartInitializingSingleton {
 
                     FileUtils.write(initFile, "", StandardCharsets.UTF_8);
                 } catch (
-                        Throwable e) {
+                        Exception e) {
                     log.error("init error", e);
                 }
             }
@@ -229,62 +136,62 @@ public class ExampleDataInit implements SmartInitializingSingleton {
     }
 
     private void initSysData() throws IOException {
-        initData("sys_config", sysConfigData, new TypeReference<List<SysConfig>>() {
+        initData("sys_config", SpringUtils.getBean(ISysConfigData.class), new TypeReference<List<SysConfig>>() {
         });
 
-        initData("sys_dept", sysDeptData, new TypeReference<List<SysDept>>() {
+        initData("sys_dept", SpringUtils.getBean(ISysDeptData.class), new TypeReference<List<SysDept>>() {
         });
 
-        initData("sys_dict_data", sysDictData, new TypeReference<List<SysDictData>>() {
+        initData("sys_dict_data", SpringUtils.getBean(ISysDictData.class), new TypeReference<List<SysDictData>>() {
         });
 
-        initData("sys_dict_type", sysDictTypeData, new TypeReference<List<SysDictType>>() {
+        initData("sys_dict_type", SpringUtils.getBean(ISysDictTypeData.class), new TypeReference<List<SysDictType>>() {
         });
 
-        initData("sys_logininfor", sysLogininforData, new TypeReference<List<SysLoginInfo>>() {
+        initData("sys_logininfor", SpringUtils.getBean(ISysLogininforData.class), new TypeReference<List<SysLoginInfo>>() {
         });
-        initData("sys_menu", sysMenuData, new TypeReference<List<SysMenu>>() {
+        initData("sys_menu", SpringUtils.getBean(ISysMenuData.class), new TypeReference<List<SysMenu>>() {
         });
 
-        initData("sys_notice", sysNoticeData, new TypeReference<List<SysNotice>>() {
+        initData("sys_notice", SpringUtils.getBean(ISysNoticeData.class), new TypeReference<List<SysNotice>>() {
         });
 
-        initData("sys_oper_log", sysOperLogData, new TypeReference<List<SysOperLog>>() {
+        initData("sys_oper_log", SpringUtils.getBean(ISysOperLogData.class), new TypeReference<List<SysOperLog>>() {
         });
 
-        initData("sys_oss", sysOssData, new TypeReference<List<SysOss>>() {
+        initData("sys_oss", SpringUtils.getBean(ISysOssData.class), new TypeReference<List<SysOss>>() {
         });
 
-        initData("sys_oss_config", sysOssConfigData, new TypeReference<List<SysOssConfig>>() {
+        initData("sys_oss_config", SpringUtils.getBean(ISysOssConfigData.class), new TypeReference<List<SysOssConfig>>() {
         });
 
-        initData("sys_post", sysPostData, new TypeReference<List<SysPost>>() {
+        initData("sys_post", SpringUtils.getBean(ISysPostData.class), new TypeReference<List<SysPost>>() {
         });
-        initData("sys_role", sysRoleData, new TypeReference<List<SysRole>>() {
+        initData("sys_role", SpringUtils.getBean(ISysRoleData.class), new TypeReference<List<SysRole>>() {
         });
 
-        initData("sys_role_dept", sysRoleDeptData, new TypeReference<List<SysRoleDept>>() {
+        initData("sys_role_dept", SpringUtils.getBean(ISysRoleDeptData.class), new TypeReference<List<SysRoleDept>>() {
         });
 
-        initData("sys_role_menu", sysRoleMenuData, new TypeReference<List<SysRoleMenu>>() {
+        initData("sys_role_menu", SpringUtils.getBean(ISysRoleMenuData.class), new TypeReference<List<SysRoleMenu>>() {
         });
 
-        initData("sys_tenant", sysTenantData, new TypeReference<List<SysTenant>>() {
+        initData("sys_tenant", SpringUtils.getBean(ISysTenantData.class), new TypeReference<List<SysTenant>>() {
         });
 
-        initData("sys_tenant_package", sysTenantPackageData, new TypeReference<List<SysTenantPackage>>() {
+        initData("sys_tenant_package", SpringUtils.getBean(ISysTenantPackageData.class), new TypeReference<List<SysTenantPackage>>() {
         });
 
-        initData("sys_user", sysUserData, new TypeReference<List<SysUser>>() {
+        initData("sys_user", SpringUtils.getBean(ISysUserData.class), new TypeReference<List<SysUser>>() {
         });
 
-        initData("sys_user_post", sysUserPostData, new TypeReference<List<SysUserPost>>() {
+        initData("sys_user_post", SpringUtils.getBean(ISysUserPostData.class), new TypeReference<List<SysUserPost>>() {
         });
 
-        initData("sys_user_role", sysUserRoleData, new TypeReference<List<SysUserRole>>() {
+        initData("sys_user_role", SpringUtils.getBean(ISysUserRoleData.class), new TypeReference<List<SysUserRole>>() {
         });
 
-        initData("sys_app", sysAppData, new TypeReference<List<SysApp>>() {
+        initData("sys_app", SpringUtils.getBean(ISysAppData.class), new TypeReference<List<SysApp>>() {
         });
     }
 

+ 14 - 12
iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/impl/PluginServiceImpl.java

@@ -17,6 +17,7 @@ import com.gitee.starblues.core.descriptor.PluginDescriptor;
 import com.gitee.starblues.integration.AutoIntegrationConfiguration;
 import com.gitee.starblues.integration.operator.PluginOperator;
 import com.gitee.starblues.integration.operator.upload.UploadParam;
+import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -54,7 +55,7 @@ public class PluginServiceImpl implements IPluginService {
             }
             String pluginId = plugin.getPluginId();
 
-            if (pluginId!=null && !file.getOriginalFilename().contains(pluginId)) {
+            if (pluginId != null && !file.getOriginalFilename().contains(pluginId)) {
                 throw new BizException(ErrCode.PLUGIN_INSTALL_FAILED, "文件名与原插件id不匹配");
             }
 
@@ -203,24 +204,25 @@ public class PluginServiceImpl implements IPluginService {
         Executors.newSingleThreadScheduledExecutor().schedule(this::startPlugins, 3, TimeUnit.SECONDS);
     }
 
+    @SneakyThrows
     private void startPlugins() {
-        try {
-            while (!pluginOperator.inited()) {
-                Thread.sleep(1000L);
-            }
+        while (!pluginOperator.inited()) {
+            Thread.sleep(1000L);
+        }
 
-            for (PluginInfo pluginInfo : pluginInfoData.findAll()) {
-                if (!PluginInfo.STATE_RUNNING.equals(pluginInfo.getState())) {
-                    continue;
-                }
-                log.info("start plugin:{}", pluginInfo.getPluginId());
+        for (PluginInfo pluginInfo : pluginInfoData.findAll()) {
+            if (!PluginInfo.STATE_RUNNING.equals(pluginInfo.getState())) {
+                continue;
+            }
+            log.info("start plugin:{}", pluginInfo.getPluginId());
+            try {
                 com.gitee.starblues.core.PluginInfo plugin = pluginOperator.getPluginInfo(pluginInfo.getPluginId());
                 if (plugin != null) {
                     pluginOperator.start(plugin.getPluginId());
                 }
+            } catch (Exception e) {
+                log.error("start plugin error", e);
             }
-        } catch (Exception e) {
-            log.error("start plugins error", e);
         }
     }
 

+ 16 - 2
iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/impl/ProductServiceImpl.java

@@ -4,6 +4,8 @@ import cc.iotkit.common.api.PageRequest;
 import cc.iotkit.common.api.Paging;
 import cc.iotkit.common.enums.ErrCode;
 import cc.iotkit.common.exception.BizException;
+import cc.iotkit.common.oss.entity.UploadResult;
+import cc.iotkit.common.oss.factory.OssFactory;
 import cc.iotkit.common.utils.JsonUtils;
 import cc.iotkit.common.utils.MapstructUtils;
 import cc.iotkit.data.manager.*;
@@ -84,7 +86,7 @@ public class ProductServiceImpl implements IProductService {
         product.setProductSecret(secret);
         String productKey = data.getProductKey();
         Product oldProduct = productData.findByProductKey(productKey);
-        if(oldProduct != null){
+        if (oldProduct != null) {
             throw new BizException(ErrCode.PRODUCT_KEY_EXIST);
         }
 
@@ -187,7 +189,19 @@ public class ProductServiceImpl implements IProductService {
     @Override
     @SneakyThrows
     public String uploadImg(String productKey, MultipartFile file) {
-        return "";
+        String originalFilename = file.getOriginalFilename();
+        if (originalFilename == null) {
+            throw new BizException(ErrCode.PARAMS_EXCEPTION);
+        }
+        String contentType = file.getContentType();
+        if (contentType == null || !contentType.contains("image/")) {
+            throw new BizException(ErrCode.PARAMS_EXCEPTION, "上传的文件不是图片");
+        }
+
+        UploadResult upload = OssFactory.instance().upload(file.getInputStream(),
+                String.format("/product/%s%s", productKey, originalFilename.substring(originalFilename.lastIndexOf("."))),
+                contentType);
+        return upload.getUrl();
     }
 
     @Override

+ 4 - 0
iot-module/iot-plugin/iot-plugin-main/src/main/java/cc/iotkit/plugin/main/ThingServiceImpl.java

@@ -80,6 +80,7 @@ public class ThingServiceImpl implements IThingService {
                                     .type(ThingModelMessage.TYPE_EVENT)
                                     .identifier(eventReport.getName())
                                     .data(eventReport.getParams())
+                                    .time(eventReport.getTime())
                                     .build()
                     );
                     break;
@@ -91,6 +92,8 @@ public class ThingServiceImpl implements IThingService {
                                     .type(ThingModelMessage.TYPE_PROPERTY)
                                     .identifier(ThingModelMessage.ID_PROPERTY_REPORT)
                                     .data(propertyReport.getParams())
+                                    .time(propertyReport.getTime())
+                                    .occurred(propertyReport.getTime())
                                     .build()
                     );
                     break;
@@ -104,6 +107,7 @@ public class ThingServiceImpl implements IThingService {
                                     .mid(serviceReply.getReplyId())
                                     .code(serviceReply.getCode())
                                     .data(serviceReply.getParams())
+                                    .time(serviceReply.getTime())
                                     .build()
                     );
                     break;

+ 2 - 1
iot-module/iot-plugin/iot-plugin-main/src/main/java/cc/iotkit/plugin/main/script/ScriptVerticle.java

@@ -75,7 +75,7 @@ public class ScriptVerticle extends AbstractVerticle {
             String pluginId = plugin.getPluginId();
             String oldMd5 = pluginScripts.get(pluginId);
             String script = plugin.getScript();
-            if(script==null){
+            if (script == null) {
                 continue;
             }
             String md5 = CodecUtil.md5Str(script);
@@ -87,6 +87,7 @@ public class ScriptVerticle extends AbstractVerticle {
             if (scriptEngine == null) {
                 continue;
             }
+            log.info("plugin script has changed");
             pluginScripts.put(pluginId, md5);
             scriptEngine.setScript(script);
         }

+ 3 - 3
iot-starter/pom.xml

@@ -84,9 +84,9 @@
 
         <!--打开注释 启用tdengine数据库-->
 <!--        <dependency>-->
-        <!--            <groupId>cc.iotkit</groupId>-->
-        <!--            <artifactId>iot-temproal-serviceImpl-td</artifactId>-->
-        <!--        </dependency>-->
+<!--            <groupId>cc.iotkit</groupId>-->
+<!--            <artifactId>iot-temporal-serviceImpl-td</artifactId>-->
+<!--        </dependency>-->
 
         <!--====================第三方库===================-->
 

+ 14 - 9
iot-starter/src/main/java/cc/iotkit/config/EmbeddedElasticSearchConfig.java

@@ -24,6 +24,11 @@ public class EmbeddedElasticSearchConfig {
     }
 
     public static boolean embeddedEnable() {
+        try {
+            Class.forName("cc.iotkit.temporal.es.config.ElasticsearchConfiguration");
+        } catch (ClassNotFoundException e) {
+            return false;
+        }
         return !"true".equals(System.getProperty("disabledEmbeddedEs"));
     }
 
@@ -53,15 +58,15 @@ public class EmbeddedElasticSearchConfig {
         @SneakyThrows
         public EmbeddedElasticSearch(ConfigProperty properties) {
             super(InternalSettingsPreparer.prepareEnvironment(
-                    properties.applySetting(
-                            Settings.builder()
-                                    .put("node.name", "test")
-                                    .put("discovery.type", "single-node")
-                                    .put("transport.type", Netty4Plugin.NETTY_TRANSPORT_NAME)
-                                    .put("http.type", Netty4Plugin.NETTY_HTTP_TRANSPORT_NAME)
-                                    .put("network.host", "0.0.0.0")
-                                    .put("http.port", 9200)
-                    ).build(), Collections.emptyMap(), null, () -> "default"),
+                            properties.applySetting(
+                                    Settings.builder()
+                                            .put("node.name", "test")
+                                            .put("discovery.type", "single-node")
+                                            .put("transport.type", Netty4Plugin.NETTY_TRANSPORT_NAME)
+                                            .put("http.type", Netty4Plugin.NETTY_HTTP_TRANSPORT_NAME)
+                                            .put("network.host", "0.0.0.0")
+                                            .put("http.port", 9200)
+                            ).build(), Collections.emptyMap(), null, () -> "default"),
                     Collections.singleton(Netty4Plugin.class), false);
         }
     }

+ 20 - 20
iot-starter/src/main/resources/application.yml

@@ -12,7 +12,7 @@ spring:
   #注: 切换数据库时需要将项目根目录中的.init文件删除再重启
   # <<=======内置H2数据库连接设置开始==========
   jpa:
-    show-sql: true
+    show-sql: false
     hibernate:
       ddl-auto: update
     properties:
@@ -60,7 +60,7 @@ spring:
 #  jpa:
 #    database: MySQL
 #    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
-#    show-sql: true
+#    show-sql: false
 #    hibernate:
 #      ddl-auto: update
 #    properties:
@@ -90,31 +90,31 @@ spring:
   # ============mysql配置结束============>>
 
   #<<================es时序数据配置开始===============
-#  elasticsearch:
-#    rest:
-#      #使用内置es的配置
-#      #uris: http://elasticsearch:9200
-#      uris: http://127.0.0.1:9200
-#      username:
-#      password:
-#      connection-timeout: 10s
+  elasticsearch:
+    rest:
+      #使用内置es的配置
+      #uris: http://elasticsearch:9200
+      uris: http://127.0.0.1:9200
+      username:
+      password:
+      connection-timeout: 10s
   #================es时序数据配置结束===============>>
 
   #<<===========tdengine时序数据库配置开始============
-  #  td-datasource:
-  #    url: jdbc:TAOS-RS://127.0.0.1:6041/iotkit?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8
-  #    username: root
-  #    password: taosdata
-  #    driverClassName: com.taosdata.jdbc.rs.RestfulDriver
+#  td-datasource:
+#    url: jdbc:TAOS-RS://127.0.0.1:6041/iotkit?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8
+#    username: root
+#    password: taosdata
+#    driverClassName: com.taosdata.jdbc.rs.RestfulDriver
   #===========tdengine时序数据库配置开始============>>
 
 
   #<<===========iotdb时序数据库配置开始============
-  iotdb-datasource:
-    host: 127.0.0.1
-    port: 6667
-    username: root
-    password: root
+#  iotdb-datasource:
+#    host: 127.0.0.1
+#    port: 6667
+#    username: root
+#    password: root
   #===========tdengine时序数据库配置开始============>>
 
   redis: