Procházet zdrojové kódy

深时GPS,点位数量

lyhzzz před 2 roky
rodič
revize
a21da040ae

+ 2 - 0
src/main/java/com/fdkankan/manage/common/RedisKeyUtil.java

@@ -7,6 +7,8 @@ public class RedisKeyUtil {
     public static final String SCENE_NUMS_LOADING = "4dkankan:scene:nums:loading";
     public static final String SCENE_NUMS_LOADING = "4dkankan:scene:nums:loading";
     public static final String loginNum= "manage:login:userName:%s:ip:%s";
     public static final String loginNum= "manage:login:userName:%s:ip:%s";
     public static final String gpsKey= "manage:gps:%s";
     public static final String gpsKey= "manage:gps:%s";
+    public static final String numGpsKey= "manage:gps:num:%s";
+    public static final String numShootKey= "manage:shoot:num:%s";
     public static final String restStoreKey= "manage:reststore:%s";
     public static final String restStoreKey= "manage:reststore:%s";
 
 
     public static final String loginToken= "manage:login:token:%s";
     public static final String loginToken= "manage:login:token:%s";

+ 43 - 4
src/main/java/com/fdkankan/manage/httpClient/service/LaserService.java

@@ -1,17 +1,15 @@
 package com.fdkankan.manage.httpClient.service;
 package com.fdkankan.manage.httpClient.service;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.bean.BeanUtil;
+import com.fdkankan.manage.entity.*;
 import com.fdkankan.manage.mq.common.MqQueueUtil;
 import com.fdkankan.manage.mq.common.MqQueueUtil;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
+import com.fdkankan.redis.util.RedisUtil;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Lists;
 
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkankan.manage.common.*;
 import com.fdkankan.manage.common.*;
-import com.fdkankan.manage.entity.Camera;
-import com.fdkankan.manage.entity.CameraDetail;
-import com.fdkankan.manage.entity.SceneBuildProcessLog;
-import com.fdkankan.manage.entity.User;
 import com.fdkankan.manage.exception.BusinessException;
 import com.fdkankan.manage.exception.BusinessException;
 import com.fdkankan.manage.httpClient.client.LaserClient;
 import com.fdkankan.manage.httpClient.client.LaserClient;
 import com.fdkankan.manage.httpClient.param.LaserSceneMoveParam;
 import com.fdkankan.manage.httpClient.param.LaserSceneMoveParam;
@@ -54,7 +52,15 @@ public class LaserService {
     @Autowired
     @Autowired
     IScenePlusService scenePlusService;
     IScenePlusService scenePlusService;
     @Autowired
     @Autowired
+    IScenePlusExtService scenePlusExtService;
+    @Autowired
     RabbitMqProducer rabbitMqProducer;
     RabbitMqProducer rabbitMqProducer;
+    @Autowired
+    ICommonService commonService;
+    @Autowired
+    ISceneProService sceneProService;
+    @Autowired
+    RedisUtil redisUtil;
 
 
 
 
     public PageInfo pageList(SceneParam param) {
     public PageInfo pageList(SceneParam param) {
@@ -98,6 +104,9 @@ public class LaserService {
                         vo.setDataSource(scenePlusService.getDataSourceByNum(vo.getNum()));
                         vo.setDataSource(scenePlusService.getDataSourceByNum(vo.getNum()));
                     }
                     }
                 }
                 }
+                vo.setShootCount(this.getLaserSceneShootNum(vo.getNum()));
+                vo.setGps(this.getLaserSceneGps(vo.getNum()));
+                vo.setAddressComponent(commonService.getAddressComponent(vo.getGps()));
                 sceneVoList.add(vo);
                 sceneVoList.add(vo);
             }
             }
 
 
@@ -113,6 +122,36 @@ public class LaserService {
         return PageInfo.PageInfo(voPage);
         return PageInfo.PageInfo(voPage);
     }
     }
 
 
+    private Integer getLaserSceneShootNum(String num) {
+        String redisKey2 = String.format(RedisKeyUtil.numShootKey, num);
+        if(redisUtil.hasKey(redisKey2)){
+            return Integer.valueOf(redisUtil.get(String.format(RedisKeyUtil.numShootKey, num)));
+        }
+        return null;
+    }
+
+    private String getLaserSceneGps(String num) {
+        String redisKey = String.format(RedisKeyUtil.numGpsKey, num);
+        String redisKey2 = String.format(RedisKeyUtil.numShootKey, num);
+        if(redisUtil.hasKey(redisKey)){
+            return redisUtil.get(redisKey);
+        }
+        ScenePro pro = sceneProService.getByNum(num);
+        if(pro != null){
+            redisUtil.set(redisKey,pro.getGps());
+            redisUtil.set(redisKey2,String.valueOf(pro.getShootCount()== null ? 0 :pro.getShootCount()));
+            return pro.getGps();
+        }
+        ScenePlus plus = scenePlusService.getByNum(num);
+        if(plus != null){
+            ScenePlusExt ext = scenePlusExtService.getByPlusId(plus.getId());
+            redisUtil.set(redisKey,ext.getGps());
+            redisUtil.set(redisKey2,String.valueOf(ext.getShootCount()== null ? 0 :ext.getShootCount()));
+            return ext.getGps();
+        }
+        return null;
+    }
+
     private LaserSceneParam getLaserSceneParam(SceneParam param) {
     private LaserSceneParam getLaserSceneParam(SceneParam param) {
         LaserSceneParam newParam = new LaserSceneParam();
         LaserSceneParam newParam = new LaserSceneParam();
         if(param.getCompanyId()!= null){ //客户场景
         if(param.getCompanyId()!= null){ //客户场景

+ 3 - 0
src/main/java/com/fdkankan/manage/service/ICommonService.java

@@ -2,6 +2,8 @@ package com.fdkankan.manage.service;
 
 
 import com.fdkankan.manage.common.ResultData;
 import com.fdkankan.manage.common.ResultData;
 import java.io.IOException;
 import java.io.IOException;
+
+import com.fdkankan.manage.vo.response.AddressComponent;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
 
 
 /**
 /**
@@ -17,4 +19,5 @@ public interface ICommonService {
     ResultData uploadFile(MultipartFile file) throws IOException;
     ResultData uploadFile(MultipartFile file) throws IOException;
 
 
 
 
+    AddressComponent getAddressComponent(String gps);
 }
 }

+ 37 - 0
src/main/java/com/fdkankan/manage/service/impl/CommonServiceImpl.java

@@ -1,7 +1,9 @@
 package com.fdkankan.manage.service.impl;
 package com.fdkankan.manage.service.impl;
 
 
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.manage.common.OssPath;
 import com.fdkankan.manage.common.OssPath;
+import com.fdkankan.manage.common.RedisKeyUtil;
 import com.fdkankan.manage.common.ResultData;
 import com.fdkankan.manage.common.ResultData;
 import com.fdkankan.common.util.DateExtUtil;
 import com.fdkankan.common.util.DateExtUtil;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
@@ -10,6 +12,12 @@ import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
 import java.util.Calendar;
 import java.util.Calendar;
 import java.util.UUID;
 import java.util.UUID;
+
+import com.fdkankan.manage.util.ProvinceUtils;
+import com.fdkankan.manage.vo.response.AddressComponent;
+import com.fdkankan.manage.vo.response.GpsVo;
+import com.fdkankan.redis.util.RedisUtil;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -32,6 +40,8 @@ public class CommonServiceImpl implements ICommonService {
     private String ossUrlPrefix;
     private String ossUrlPrefix;
    @Autowired
    @Autowired
     private FYunFileServiceInterface fYunFileServiceInterface;
     private FYunFileServiceInterface fYunFileServiceInterface;
+   @Autowired
+    RedisUtil redisUtil;
 
 
     @Override
     @Override
     public ResultData uploadFile(MultipartFile file) throws IOException {
     public ResultData uploadFile(MultipartFile file) throws IOException {
@@ -48,4 +58,31 @@ public class CommonServiceImpl implements ICommonService {
         return ResultData.ok(url);
         return ResultData.ok(url);
 
 
     }
     }
+
+    @Override
+    public AddressComponent getAddressComponent(String gps){
+        if(StringUtils.isNotBlank(gps)){
+            GpsVo gpsVo = JSONObject.parseObject(gps, GpsVo.class);
+            if(gpsVo!=null && StringUtils.isNotBlank(gpsVo.getLatitude()) && StringUtils.isNotBlank(gpsVo.getAltitude())){
+                String points = gpsVo.getLongitude()+","+gpsVo.getLatitude();
+                String rediskey = String.format(RedisKeyUtil.gpsKey, points);
+                AddressComponent addressComponent = null;
+                if(redisUtil.hasKey(rediskey)){
+                    String s = redisUtil.get(rediskey);
+                    if(StringUtils.isNotBlank(s)){
+                        addressComponent = JSONObject.parseObject(s, AddressComponent.class);
+                    }
+                }else {
+                    addressComponent = ProvinceUtils.pointsToLocationsAll(points);
+                    if(addressComponent != null){
+                        redisUtil.set(String.format(RedisKeyUtil.gpsKey,points),JSONObject.toJSONString(addressComponent));
+                    }else {
+                        redisUtil.set(String.format(RedisKeyUtil.gpsKey,points),"");
+                    }
+                }
+                return addressComponent;
+            }
+        }
+        return null;
+    }
 }
 }

+ 2 - 23
src/main/java/com/fdkankan/manage/service/impl/SceneProServiceImpl.java

@@ -104,7 +104,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     @Autowired
     @Autowired
     ISceneColdStorageService sceneColdStorageService;
     ISceneColdStorageService sceneColdStorageService;
     @Autowired
     @Autowired
-    ThreadService threadService;
+    ICommonService commonService;
 
 
 
 
     @Override
     @Override
@@ -238,28 +238,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
                 }
                 }
             }
             }
             //{"latitude":22.3672085,"longitude":113.595673,"altitude":9.275519,"horizontalAccuracy":65.0,"verticalAccuracy":10.0,"timestamp":1564381147.2775609}
             //{"latitude":22.3672085,"longitude":113.595673,"altitude":9.275519,"horizontalAccuracy":65.0,"verticalAccuracy":10.0,"timestamp":1564381147.2775609}
-            if(StringUtils.isNotBlank(record.getGps())){
-                GpsVo gpsVo = JSONObject.parseObject(record.getGps(), GpsVo.class);
-                if(gpsVo!=null && StringUtils.isNotBlank(gpsVo.getLatitude()) && StringUtils.isNotBlank(gpsVo.getAltitude())){
-                    String points = gpsVo.getLongitude()+","+gpsVo.getLatitude();
-                    String rediskey = String.format(RedisKeyUtil.gpsKey, points);
-                    AddressComponent addressComponent = null;
-                    if(redisUtil.hasKey(rediskey)){
-                        String s = redisUtil.get(rediskey);
-                        if(StringUtils.isNotBlank(s)){
-                            addressComponent = JSONObject.parseObject(s, AddressComponent.class);
-                        }
-                    }else {
-                        addressComponent = ProvinceUtils.pointsToLocationsAll(points);
-                        if(addressComponent != null){
-                            redisUtil.set(String.format(RedisKeyUtil.gpsKey,points),JSONObject.toJSONString(addressComponent));
-                        }else {
-                            redisUtil.set(String.format(RedisKeyUtil.gpsKey,points),"");
-                        }
-                    }
-                    record.setAddressComponent(addressComponent);
-                }
-            }
+            record.setAddressComponent(commonService.getAddressComponent(record.getGps()));
         }
         }
         return PageInfo.PageInfo(page);
         return PageInfo.PageInfo(page);
     }
     }