Browse Source

兼容旧设备

chenyi406 2 years ago
parent
commit
dcfdd9f506

+ 5 - 1
src/main/java/com/zy/omp/controller/wx/DeviceController.java

@@ -73,8 +73,12 @@ public class DeviceController extends BaseController {
         //校验设备码有效性
         if (deviceService.getOne(new QueryWrapper<Device>().eq("openNum", relation.getOpenNum())) == null)
             return ServerResponse.createByWarning("设备码无效!");
+        if (relationService.getOne(new QueryWrapper<Relation>().eq("openNum", relation.getOpenNum()).eq("openId", getOpenId())) != null) {
+            return ServerResponse.createByWarning("已经绑定该设备!");
+        }
         relation.setOpenId(getOpenId());
-        return ServerResponse.createBySuccess(relationService.saveRelation(relation));
+        relationService.saveRelation(relation);
+        return ServerResponse.createBySuccess();
     }
 
     /**

+ 17 - 0
src/main/java/com/zy/omp/pojo/vo/DeviceDetailVO.java

@@ -3,6 +3,7 @@ package com.zy.omp.pojo.vo;
 import lombok.Data;
 
 import java.time.LocalDateTime;
+import java.util.Objects;
 
 /**
  * 设备最新详情状态信息
@@ -72,4 +73,20 @@ public class DeviceDetailVO {
      * 数据上传时间
      */
     private LocalDateTime uploadTime;
+
+    public Double getLon() {
+        return lon == null || Objects.equals(lon, "") ? null : Double.parseDouble(lon);
+    }
+
+    public Double getLat() {
+        return lat == null || Objects.equals(lat, "") ? null : Double.parseDouble(lat);
+    }
+
+    public Double getLonGcj() {
+        return lonGcj == null || Objects.equals(lonGcj, "") ? null : Double.parseDouble(lonGcj);
+    }
+
+    public Double getLatGcj() {
+        return latGcj == null || Objects.equals(latGcj, "") ? null : Double.parseDouble(latGcj);
+    }
 }

+ 1 - 2
src/main/java/com/zy/omp/service/RelationService.java

@@ -50,12 +50,11 @@ public class RelationService extends ServiceImpl<RelationMapper, Relation> {
      *
      * @return 当前绑定的设备列表
      */
-    public List<Relation> saveRelation(Relation relation) {
+    public void saveRelation(Relation relation) {
         //保存新纪录
         save(relation);
         //设置默认设备
         updateDefaultDevice(relation.getOpenNum(), relation.getOpenId());
-        return listByOpenId(relation.getOpenId());
     }
 
     /**