ソースを参照

Merge branch 'test'

lyhzzz 2 年 前
コミット
135350a607

+ 6 - 0
pom.xml

@@ -156,6 +156,12 @@
       <version>3.0.0-SNAPSHOT</version>
     </dependency>
 
+    <dependency>
+      <groupId>com.fdkankan</groupId>
+      <artifactId>4dkankan-utils-elasticsearch</artifactId>
+      <version>3.0.0-SNAPSHOT</version>
+    </dependency>
+
   </dependencies>
 
   <build>

+ 3 - 1
src/main/java/com/fdkankan/manage/common/ResultCode.java

@@ -45,7 +45,7 @@ public enum ResultCode  {
     TEMPLATE_TYPE_ERROR(50028, "模板格式错误"),
     EXCEL_MSG_ERROR(50029, "模板格式错误"),
     CAMERA_TYPE_ERROR(50030, "相机类型错误"),
-    CAMERA_SPACE_ERROR(50031, "相机容量不足,不能迁移"),
+    CAMERA_SPACE_ERROR(50031, "相机容量不足"),
     CAMERA_TYPE_NOT_ERROR(50032, "必须迁移至相同的类型的相机下面!"),
     MAIL_SEND_ERROR(50033, "邮件发送失败!"),
     CAMERA_SN_NOT_EXIST(50034, "sn码不存在!"),
@@ -69,6 +69,8 @@ public enum ResultCode  {
     MOVE_SCENE_ERROR(50052, "迁移失败!"),
     SS_GET_ERROR(50053, "访问深时失败!"),
     SCENE_IS_BUILDING(50054, "场景计算中,不能复制!"),
+    MOVE_ERROR(50055, "原始资源不存在,不能迁移!"),
+    MOVE_ERROR_COPY(50055, "复制场景,不能迁移!"),
 
     ;
 

+ 1 - 0
src/main/java/com/fdkankan/manage/httpClient/param/LaserSceneMoveParam.java

@@ -10,4 +10,5 @@ public class LaserSceneMoveParam {
     private String snCode;
     private String toSnCode;
     private Long userId;
+    private String dataSource;
 }

+ 2 - 1
src/main/java/com/fdkankan/manage/httpClient/service/LaserService.java

@@ -197,12 +197,13 @@ public class LaserService {
         }
     }
 
-    public void move(String num, String snCode, String toSnCode,Long userId) {
+    public void move(String num, String snCode, String toSnCode,Long userId,String newDataSource) {
         LaserSceneMoveParam param = new LaserSceneMoveParam();
         param.setSceneCode(num);
         //param.setSnCode(snCode);
         param.setToSnCode(toSnCode);
         param.setUserId(userId);
+        param.setDataSource(newDataSource+"_laserData/laserData");
         if(userId != null){
             User user = userService.getById(userId);
             if(user != null){

+ 50 - 6
src/main/java/com/fdkankan/manage/service/impl/SceneProServiceImpl.java

@@ -415,6 +415,23 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         if(!oldCameraDetail.getType().equals(cameraDetail.getType())){
             throw new BusinessException(ResultCode.CAMERA_TYPE_NOT_ERROR);
         }
+        String home = dataSource.replace("/mnt/data", "home")+"/data.fdage";
+        if(!fYunFileServiceInterface.fileExist(home)){
+            throw new BusinessException(ResultCode.MOVE_ERROR);
+        }
+
+        HashMap<String, SceneCopyLog> byNewNumList = copyLogService.getByNewNumList(Arrays.asList(param.getNum()));
+        if(byNewNumList.size() >0){
+            throw new BusinessException(ResultCode.MOVE_ERROR_COPY);
+        }
+
+        if(cameraDetail.getType() == 10 || cameraDetail.getType() == 11) {       //深时场景
+            //迁移深时 dataSource
+            File file = new File(dataSource + "_laserData/laserData");
+            if (!file.exists()) {
+                throw new BusinessException(ResultCode.MOVE_ERROR);
+            }
+        }
 
         Long oldUseSpace = oldCameraDetail.getUsedSpace() - space < 0 ? 0 : oldCameraDetail.getUsedSpace() - space;
         oldCameraDetail.setUsedSpace(oldUseSpace);
@@ -456,10 +473,15 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         }
         //协作相机
         sceneResourceCameraService.setCooperationUser(cameraDetail,param.getNum());
+
+        String newDataSource = updateFdageNewDataSource(scenePro, scenePlus, oldCamera.getSnCode(), param.getSnCode(), dataSource);
+
         if(cameraDetail.getType() == 10 || cameraDetail.getType() == 11){       //深时场景
-            laserService.move(param.getNum(),oldCamera.getSnCode(),camera.getSnCode(),cameraDetail.getUserId());
+            //迁移深时 dataSource
+            FileUtil.move(new File(dataSource +"_laserData/laserData"),new File(newDataSource+"_laserData/laserData"),true);
+            laserService.move(param.getNum(),oldCamera.getSnCode(),camera.getSnCode(),cameraDetail.getUserId(),newDataSource);
         }
-        updateFdageNewDataSource(scenePro,scenePlus,oldCamera.getSnCode(),param.getSnCode(),dataSource);
+
     }
 
 
@@ -483,7 +505,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     /**
      * 兼容,之前迁移,不使用旧snCode 替换新snCode。重写文件
      */
-    public void updateFdageNewDataSource(ScenePro scenePro,ScenePlus scenePlus,String oldSnCode,String newSnCode,String dataSource) {
+    public String updateFdageNewDataSource(ScenePro scenePro,ScenePlus scenePlus,String oldSnCode,String newSnCode,String dataSource) {
         String localPathFdage = null;
         try {
             newSnCode = newSnCode.toLowerCase();
@@ -511,6 +533,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
                 fYunFileServiceInterface.deleteFolder(oldFdagePaht);
             }
             sceneMoveLogService.saveLog(scenePro,scenePlus,oldSnCode,newSnCode,dataSource,newDataSource, fileContent);
+            return newDataSource;
         }catch (Exception e){
             log.error("updateFdage-error:oldSnCode:{},newSnCode:{},dataSource:{}",oldSnCode,newSnCode,dataSource);
             log.error("updateFdage-error:",e);
@@ -576,9 +599,30 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         if(sceneStatus != -2){
             throw new BusinessException(ResultCode.SCENE_IS_BUILDING);
         }
-//        if(detailEntity.getType() == 10  ){
-//            throw new BusinessException(ResultCode.SS_NO_COPY);
-//        }
+        Long totalSpace = detailEntity.getTotalSpace();
+        UserIncrement userIncrement = userIncrementService.getByCameraId(cameraId);
+        if(userIncrement != null && userIncrement.getIsExpired() ==0){
+            IncrementType incrementType = incrementTypeService.getById(userIncrement.getIncrementTypeId());
+            totalSpace = incrementType.getCameraCapacity() * 1024 * 1024 * 1024L;
+        }
+        if(detailEntity.getType() == 10  || detailEntity.getType() == 11){
+            totalSpace = -1L;
+        }
+
+        Long needSpace = 0L;
+        if(scenePro != null){
+            needSpace = scenePro.getSpace();
+        }
+        if(scenePlus != null){
+            ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
+            if(scenePlusExt != null && scenePlusExt.getSpace() != null){
+                needSpace = scenePlusExt.getSpace();
+            }
+        }
+
+        if( totalSpace > 0 && detailEntity.getUsedSpace() + needSpace > totalSpace){
+            throw new BusinessException(ResultCode.CAMERA_SPACE_ERROR);
+        }
 
         HashMap<String, Object> param = new HashMap<>();
         param.put("num",sceneNum);

+ 0 - 4
src/main/java/com/fdkankan/manage/service/impl/SysUserServiceImpl.java

@@ -45,10 +45,6 @@ public class SysUserServiceImpl extends ServiceImpl<ISysUserMapper, SysUser> imp
     @Autowired
     private ISysRoleService roleService;
     @Autowired
-    private ISysMenuService menuService;
-    @Autowired
-    private RedisUtil redisUtil;
-    @Autowired
     private ISysMenuService sysMenuService;
 
     @Override

+ 28 - 2
src/main/java/com/fdkankan/manage/test/TestController.java

@@ -4,6 +4,9 @@ import cn.hutool.core.io.FileUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.common.util.FileUtils;
+import com.fdkankan.elasticsearch.service.DocumentService;
+import com.fdkankan.elasticsearch.service.IndexService;
+import com.fdkankan.elasticsearch.service.QueryDataService;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.manage.common.OssPath;
 import com.fdkankan.manage.common.ResultCode;
@@ -18,6 +21,7 @@ import com.fdkankan.manage.service.ISceneProService;
 import com.fdkankan.manage.util.Dateutils;
 import com.fdkankan.manage.util.ExcelUtil;
 import lombok.extern.slf4j.Slf4j;
+import org.elasticsearch.rest.RestStatus;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -39,13 +43,35 @@ public class TestController {
     FYunFileServiceInterface fYunFileServiceInterface;
     @Autowired
     ICameraService cameraService;
+    @Autowired
+    IndexService indexService;
+    @Autowired
+    QueryDataService queryDataService;
+    @Autowired
+    DocumentService documentService;
 
     @RequestMapping("/test")
     public ResultData test(@RequestParam(required = false) String oldSnCode,
                            @RequestParam(required = false)String newSnCode,
-                           @RequestParam(required = false)String dataSource){
+                           @RequestParam(required = false)String dataSource) throws Exception {
 
-        return ResultData.ok();
+//        RestStatus restStatus = documentService.addDocument("abc-test1", null, "1", "{\n" +
+//                "    \"appId\": \"7b5958d5-1ae6-4ad5-8a87-5fc8a4b92999\",\n" +
+//                "    \"module\": \"module\",\n" +
+//                "    \"userId\": null,\n" +
+//                "    \"time\": 1662519289298,\n" +
+//                "    \"url\": \"/#/roam\",\n" +
+//                "    \"urlParam\": null,\n" +
+//                "    \"requestData\": {\n" +
+//                "      \"screen\": \"1920x1080\",\n" +
+//                "      \"click\": \"filter\",\n" +
+//                "      \"user\": \"\",\n" +
+//                "      \"version\": \"1\"\n" +
+//                "    }}");
+//        log.info("{}",restStatus);
+        List<String> strings = queryDataService.boolQuery("abc-test1", String.class);
+
+        return ResultData.ok(JSONObject.toJSONString(strings));
     }
 
     /**

+ 6 - 0
src/main/java/com/fdkankan/manage/util/ElasticSearchUtils.java

@@ -0,0 +1,6 @@
+package com.fdkankan.manage.util;
+
+public class ElasticSearchUtils {
+
+
+}

+ 4 - 0
src/main/resources/bootstrap-dev.yml

@@ -39,6 +39,10 @@ spring:
           - data-id: sa-token-config.yaml
             group: DEFAULT_GROUP
             refresh: true
+
+          - data-id: elasticsearch-config.yaml
+            group: DEFAULT_GROUP
+            refresh: true
       discovery:
         server-addr: ${spring.cloud.nacos.config.server-addr}
         namespace: ${spring.cloud.nacos.config.namespace}

+ 4 - 0
src/main/resources/bootstrap-test-eur.yml

@@ -35,6 +35,10 @@ spring:
           - data-id: sa-token-config.yaml
             group: DEFAULT_GROUP
             refresh: true
+
+          - data-id: elasticsearch-config.yaml
+            group: DEFAULT_GROUP
+            refresh: true
       discovery:
         server-addr: ${spring.cloud.nacos.config.server-addr}
         namespace: ${spring.cloud.nacos.config.namespace}

+ 4 - 0
src/main/resources/bootstrap-test.yml

@@ -39,6 +39,10 @@ spring:
           - data-id: sa-token-config.yaml
             group: DEFAULT_GROUP
             refresh: true
+
+          - data-id: elasticsearch-config.yaml
+            group: DEFAULT_GROUP
+            refresh: true
       discovery:
         server-addr: ${spring.cloud.nacos.config.server-addr}
         namespace: ${spring.cloud.nacos.config.namespace}

+ 1 - 0
src/main/resources/logback-spring.xml

@@ -4,6 +4,7 @@
 <!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
 <!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
 <configuration scan="true" scanPeriod="10 seconds">
+	<springProperty scope="context" name="LOG_PATH" source="logging.path"/>
 
 	<contextName>logback</contextName>
 	<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->