lyhzzz 8 months ago
parent
commit
efb98bbcbb

+ 8 - 1
src/main/java/com/fdkankan/ucenter/UserCenterApplication.java

@@ -8,6 +8,7 @@ import org.springframework.boot.CommandLineRunner;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
@@ -18,6 +19,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 @EnableScheduling
 @ComponentScan(basePackages = {"com.fdkankan.*"})
 @MapperScan("com.fdkankan.**.mapper")
+@RefreshScope
 public class UserCenterApplication implements CommandLineRunner {
 
     @Value("${fyun.bucket}")
@@ -28,7 +30,10 @@ public class UserCenterApplication implements CommandLineRunner {
     private String mainUrl;
     @Value("${spring.profiles.active}")
     private String activeFile;
-
+    @Value("${camera.check.url}")
+    private String fdMain;
+    @Value("${camera.check.companyId}")
+    private Long companyId;
     public static void main(String[] args) {
         SpringApplication.run(UserCenterApplication.class, args);
     }
@@ -38,6 +43,8 @@ public class UserCenterApplication implements CommandLineRunner {
         NacosProperty.bucket = bucket;
         NacosProperty.uploadType = uploadType;
         NacosProperty.activeFile = activeFile;
+        NacosProperty.companyId = companyId;
+        NacosProperty.fdMain = fdMain;
         NacosProperty.setMainUrl(mainUrl);
     }
 }

+ 1 - 1
src/main/java/com/fdkankan/ucenter/common/CameraTypeEnum.java

@@ -7,7 +7,7 @@ public enum CameraTypeEnum {
     DOUBLE_EYE(0,"KK-","4DKKLITE_","旧双目相机"),
     FDKK_PRO(1,"KK-","4DKKPRO_","四维看看pro八目相机"),
     FDKK_LITE(2,"KK-","4DKKLITE_","四维看看lite"),
-    ZHIHOUSE_REDHOUSE(5,"KK-","4DKKLITE_","指房宝小红屋相机"),
+    ZHIHOUSE_REDHOUSE(5,"YZL-","","第三方相机圆周率"),
     DOUBLE_EYE_TURN(9,"KJ-","4DKKLITE_","双目转台"),
     LASER_TURN(10,"SS-","4DSS_","激光转台"),
     SG_TURN(11,"SG-","4DSG_","激光转台");

+ 2 - 0
src/main/java/com/fdkankan/ucenter/common/constants/NacosProperty.java

@@ -11,6 +11,8 @@ public class NacosProperty {
     public static String uploadType;
     public static String activeFile;
     private static String mainUrl;
+    public static String fdMain;
+    public static Long companyId;
 
     public static String getMainUrl() {
 //        if(StringUtils.isBlank(mainUrl)){

+ 4 - 0
src/main/java/com/fdkankan/ucenter/constant/CameraConstant.java

@@ -94,4 +94,8 @@ public class CameraConstant {
 
     public static final int FAILURE_CODE_6030 = 6030;
     public static final String FAILURE_MSG_6030 = "绑定相机类型有误,请先切换相机类型后再绑定";
+
+
+    public static final int FAILURE_CODE_6031 = 6031;
+    public static final String FAILURE_MSG_6031 = "请先联系客服入库。";
 }

+ 25 - 0
src/main/java/com/fdkankan/ucenter/httpClient/client/FdkankanClient.java

@@ -0,0 +1,25 @@
+package com.fdkankan.ucenter.httpClient.client;
+
+import com.dtflys.forest.annotation.*;
+import com.fdkankan.ucenter.common.Result;
+import com.fdkankan.ucenter.common.constants.NacosProperty;
+import com.fdkankan.ucenter.httpClient.address.LaserAddressSource;
+import com.fdkankan.ucenter.httpClient.param.SSDownSceneParam;
+import com.fdkankan.ucenter.httpClient.param.SsBindParam;
+import com.fdkankan.ucenter.httpClient.vo.LaserSceneParam;
+import org.springframework.web.bind.annotation.PathVariable;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 获取,调用激光服务
+ */
+public interface FdkankanClient {
+
+
+    @Get(
+            url="{url}"
+    )
+    Result get(@Var("url") String url);
+}

+ 25 - 0
src/main/java/com/fdkankan/ucenter/service/impl/CameraServiceImpl.java

@@ -1,21 +1,25 @@
 package com.fdkankan.ucenter.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
 import com.amazonaws.services.simpleworkflow.flow.annotations.NoWait;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkankan.common.constant.AppConstant;
+import com.fdkankan.common.constant.ErrorCode;
 import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.ucenter.common.CameraTypeEnum;
 import com.fdkankan.ucenter.common.PageInfo;
 import com.fdkankan.common.util.DateUtil;
 import com.fdkankan.common.util.FileSizeUtil;
+import com.fdkankan.ucenter.common.Result;
 import com.fdkankan.ucenter.common.constants.NacosProperty;
 import com.fdkankan.ucenter.common.constants.ResultCode;
 import com.fdkankan.ucenter.constant.CameraConstant;
 import com.fdkankan.ucenter.constant.LoginConstant;
 import com.fdkankan.ucenter.constant.OrderConstant;
 import com.fdkankan.ucenter.entity.*;
+import com.fdkankan.ucenter.httpClient.client.FdkankanClient;
 import com.fdkankan.ucenter.httpClient.service.LaserService;
 import com.fdkankan.ucenter.mapper.ICameraMapper;
 import com.fdkankan.ucenter.service.*;
@@ -27,6 +31,7 @@ import com.fdkankan.ucenter.vo.response.CameraAppVo;
 import com.fdkankan.ucenter.vo.response.CameraSpaceVo;
 import com.fdkankan.ucenter.vo.response.CameraVo;
 import com.fdkankan.ucenter.vo.response.GroupByCount;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.joda.time.DateTime;
 import org.joda.time.Days;
@@ -46,6 +51,7 @@ import java.util.stream.Stream;
  * @since 2022-07-04
  */
 @Service
+@Slf4j
 public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implements ICameraService {
 
     @Autowired
@@ -286,6 +292,8 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
         sceneResourceCameraService.deleteByCameraIds(cameraIds);       //删除协作相机
 
     }
+    @Autowired
+    FdkankanClient fdkankanClient;
 
     @Override
     public void bind(Integer cameraType, String snCodes, String username) {
@@ -304,6 +312,23 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
             }else {
                 snCode = wifiName;
             }
+            try {
+                Result result = fdkankanClient.get(NacosProperty.fdMain+"/ucenter/_inner/getSnCode/"+snCode);
+                if(result.getCode() !=0){
+                    throw new BusinessException(CameraConstant.FAILURE_CODE_6031,wifiName +"-"+ CameraConstant.FAILURE_MSG_6031);
+                }
+                JSONObject jsonObject = (JSONObject) result.getData();
+                Long companyId = jsonObject.getLong("companyId");
+                if(!companyId.equals(NacosProperty.companyId)){
+                    throw new BusinessException(CameraConstant.FAILURE_CODE_6031,wifiName +"-"+ CameraConstant.FAILURE_MSG_6031);
+                }
+
+            }catch (Exception e){
+                log.info("相机查询4dkankan失败:{}",snCode);
+                throw new BusinessException(CameraConstant.FAILURE_CODE_6031,wifiName +"-"+ CameraConstant.FAILURE_MSG_6031);
+            }
+
+
             CameraInStoreParam param = new CameraInStoreParam();
             param.setCameraType(cameraType);
             param.setSnCode(snCode);