Ver código fonte

add 默认标签

18339543638 4 anos atrás
pai
commit
3daae2cef8

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

@@ -22,6 +22,7 @@ import javax.persistence.Table;
 import javax.persistence.Transient;
 import javax.validation.constraints.NotBlank;
 import java.util.Date;
+import java.util.Objects;
 
 @Getter
 @Setter
@@ -99,6 +100,20 @@ public class DeviceTagEntity extends GenericEntity<String> {
         return tag;
     }
 
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        DeviceTagEntity that = (DeviceTagEntity) o;
+        return
+            Objects.equals(getDeviceId(), that.getDeviceId()) &&
+            Objects.equals(getKey(), that.getKey());
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(getDeviceId(), getKey(), getName(), getValue(), getType(), getCreateTime(), getDescription(), isAutoUpdate());
+    }
 
     public static String createTagId(String deviceId, String key) {
         return DigestUtils.md5Hex(deviceId + ":" + key);

+ 10 - 6
jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/response/DeviceDetail.java

@@ -178,15 +178,19 @@ public class DeviceDetail {
                     DeviceTagEntity::getKey,
                     Function.identity(),
                     (_1, _2) -> StringUtils.hasText(_1.getValue()) ? _1 : _2));
+        DeviceTagEntity geoTag = new DeviceTagEntity();
+        geoTag.setDeviceId(this.id);
+        geoTag.setKey("coordinate");
 
+        //将地理位置放于首位
         this.tags = new ArrayList<>(map.values());
+        if (tags.contains(geoTag)) {
+            int index = tags.indexOf(geoTag);
+            geoTag= tags.get(index);
+            tags.remove(index);
+        }
         this.tags.sort(Comparator.comparing(DeviceTagEntity::getCreateTime));
-
-//        if (StringUtils.hasText(id)) {
-//            for (DeviceTagEntity tag : getTags()) {
-//                tag.setId(DeviceTagEntity.createTagId(id, tag.getKey()));
-//            }
-//        }
+        this.tags.add(0,geoTag);
         return this;
     }
 

+ 12 - 2
jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/service/GeoDataSaveService.java

@@ -1,11 +1,21 @@
 package org.jetlinks.community.device.service;
 
+import org.jetlinks.core.metadata.types.GeoPoint;
+import reactor.core.publisher.Mono;
+
 /**
  * @author lifang
  * @version 1.0.0
  * @ClassName GeoDataSaveService.java
- * @Description TODO
+ * @Description
  * @createTime 2021年10月21日 10:36:00
  */
-public class GeoDataSaveService {
+public interface GeoDataSaveService {
+    /**
+     * 获取设备地理标签信息
+     * @return
+     */
+    Mono<GeoPoint> getGeoTag(String deviceId);
+
+    Mono<Void> putGeoTag(String deviceId, GeoPoint geoPoint);
 }

+ 1 - 3
jetlinks-manager/visualization-manager/src/main/java/org/jetlinks/community/visualization/entity/VisualizationCategory.java

@@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import lombok.Getter;
 import lombok.Setter;
+import org.hswebframework.web.api.crud.entity.GenericEntity;
 import org.hswebframework.web.api.crud.entity.GenericTreeSortSupportEntity;
 
 import javax.persistence.Column;
@@ -14,9 +15,6 @@ import java.util.List;
 @Data
 public class VisualizationCategory extends GenericTreeSortSupportEntity<String> {
 
-    @Schema(description = "ID")
-    @Column(name = "id")
-    private String id;
 
     @Schema(description = "标识")
     @Column(name = "key")

+ 1 - 24
jetlinks-manager/visualization-manager/src/main/java/org/jetlinks/community/visualization/web/VisualizationCategoryController.java

@@ -29,14 +29,6 @@ public class VisualizationCategoryController implements
         return service;
     }
 
-//    @PostMapping
-//    @Operation(summary = "添加目录")
-//    public Mono<?>  add(@RequestBody Mono<DeviceCategory> payload){
-//        return this.service.insert(payload)
-//            .thenReturn(payload)
-//            .onErrorMap(e->new BusinessException("服务器繁忙,请稍后重试",e))
-//            ;
-//    }
 
     @DeleteMapping("/recursion/{id}")
     @Operation(summary = "删除目录")
@@ -54,22 +46,7 @@ public class VisualizationCategoryController implements
                 }
             })
             .onErrorStop()
-//            .flatMap(count->{
-//                //判断是否有绑定产品
-//                return visualizationService
-//                    .createQuery()
-//                    .where(DataVisualizationEntity::getClassifiedId,id)
-//                    .count();
-//            })
-//            .flatMap(productCount->{
-//                if(productCount>0){
-//                    return Mono.error(new BusinessException("该目录已被绑定产品,不可删除"));
-//                }else {
-//                    return Mono.just(productCount);
-//                }
-//            })
-            .map(productCount-> this.service.deleteById(Mono.just(id)))
-            ;
+            .flatMap(ignore-> this.service.deleteById(Mono.just(id)));
     }
 
 

+ 1 - 1
jetlinks-standalone/src/main/resources/application.yml

@@ -74,7 +74,7 @@ device:
       time-series:
         enabled: true #写出设备消息数据到elasticsearch
 captcha:
-  enabled: true # 开启验证码
+  enabled: false # 开启验证码
   ttl: 5m #验证码过期时间,2分钟
 hsweb:
   cors: