浏览代码

优化标签导入

zhou-hao 5 年之前
父节点
当前提交
529e03541b

+ 1 - 1
jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/entity/DeviceTagEntity.java

@@ -60,6 +60,6 @@ public class DeviceTagEntity extends GenericEntity<String> {
     }
 
     public static String createTagId(String deviceId,String key){
-        return DigestUtils.md5Hex(deviceId.concat(":").concat(key));
+        return DigestUtils.md5Hex(deviceId + ":" + key);
     }
 }

+ 5 - 3
jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/web/excel/DeviceExcelInfo.java

@@ -33,7 +33,7 @@ public class DeviceExcelInfo {
     private long rowNumber;
 
 
-    public void tag(String key, String name, Object value,String type) {
+    public void tag(String key, String name, Object value, String type) {
         if (value == null) {
             return;
         }
@@ -43,13 +43,15 @@ public class DeviceExcelInfo {
         entity.setName(name);
         entity.setDeviceId(id);
         entity.setType(type);
-        entity.setId(String.valueOf(id).concat(":").concat(key));
+        entity.setId(DeviceTagEntity.createTagId(id,key));
         tags.add(entity);
     }
+
     public void setId(String id) {
         this.id = id;
         for (DeviceTagEntity tag : tags) {
-            tag.setId(String.valueOf(id).concat(":").concat(tag.getKey()));
+            tag.setDeviceId(id);
+            tag.setId(DeviceTagEntity.createTagId(tag.getDeviceId(),tag.getKey()));
         }
     }