Przeglądaj źródła

Merge branch 'project-jmga-2.2.0-2.0.1' into project-jmga-dev

# Conflicts:
#	src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java
dengsixing 1 miesiąc temu
rodzic
commit
c13e1bf2b7

+ 7 - 0
src/main/java/com/fdkankan/contro/constant/ZipConstant.java

@@ -0,0 +1,7 @@
+package com.fdkankan.contro.constant;
+
+public class ZipConstant {
+
+    public static final String zipPassword = "a3ad34136de359536af553f9e7f3cefd";
+
+}

+ 28 - 0
src/main/java/com/fdkankan/contro/controller/JmgaController.java

@@ -0,0 +1,28 @@
+package com.fdkankan.contro.controller;
+
+import com.fdkankan.contro.service.IJmgaService;
+import com.fdkankan.contro.vo.UploadSceneOrigParamVo;
+import com.fdkankan.web.response.ResultData;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+
+@RestController
+@RequestMapping("/api/scene/file/jmga")
+public class JmgaController {
+
+    @Autowired
+    private IJmgaService jmgaService;
+
+    @PostMapping("/uploadSceneOrig")
+    public ResultData uploadSceneOrig(@RequestBody @Valid UploadSceneOrigParamVo param) throws Exception {
+        jmgaService.uploadSceneOrig(param);
+        return ResultData.ok();
+    }
+
+
+}

+ 7 - 19
src/main/java/com/fdkankan/contro/controller/SceneFileController.java

@@ -1,8 +1,6 @@
 package com.fdkankan.contro.controller;
 
-import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.StrUtil;
-import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -10,6 +8,7 @@ import com.fdkankan.common.constant.ErrorCode;
 import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.contro.bean.SendCallAlgorithmDetail;
 import com.fdkankan.contro.service.IAppCameraFailLogService;
+import com.fdkankan.contro.service.IJmgaService;
 import com.fdkankan.contro.service.ISceneFileBuildService;
 import com.fdkankan.contro.service.ISceneUploadCountService;
 import com.fdkankan.contro.vo.ReportFailLogVO;
@@ -32,7 +31,6 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.stream.Collectors;
 
 /**
  * 场景文件上传模块
@@ -54,6 +52,9 @@ public class SceneFileController{
     @Autowired
     private IAppCameraFailLogService appCameraFailLogService;
 
+    @Autowired
+    private IJmgaService jmgaService;
+
 
     /**
      * 场景文件上传之前先获取fileId
@@ -74,7 +75,7 @@ public class SceneFileController{
      */
     @PostMapping("uploadSuccessBuild")
     public ResultData uploadSuccessBuild(String params) throws Exception {
-        return sceneFileBuildService.uploadSuccessBuild(params);
+        return sceneFileBuildService.uploadSuccessBuild(params, null);
     }
 
     /**
@@ -85,7 +86,7 @@ public class SceneFileController{
      */
     @PostMapping("turntableUploadSuccess")
     public ResultData turntableUploadSuccess(String params) throws Exception {
-        return sceneFileBuildService.turntableUploadSuccess(params);
+        return sceneFileBuildService.turntableUploadSuccess(params, null);
     }
 
     @GetMapping("rebuildScene")
@@ -223,20 +224,7 @@ public class SceneFileController{
 
     @PostMapping("/send_bd")
     public ResultData noticeBuildBd(String ossHost, String uuid, String dir) throws Exception {
-        String prefix = "http://" + ossHost + "/";
-        String path = "/oss/4dkankan/bd_server/" + dir;
-        List<File> files = FileUtil.loopFiles(path).stream().filter(file -> !file.getAbsolutePath().contains("backup")).collect(Collectors.toList());
-        files.parallelStream().forEach(file ->{
-            String url = prefix.concat(file.getAbsolutePath().substring(1).replace("/4dkankan",""));
-            SendCallAlgorithmDetail detail = new SendCallAlgorithmDetail();
-            detail.setFileName(FileUtil.getName(file.getAbsolutePath()));
-            detail.setUuid(uuid);
-            SendCallAlgorithmParam param = new SendCallAlgorithmParam();
-            param.setFilepath(url);
-            param.setDetails(detail);
-            HttpUtil.post("http://localhost:8085/api/scene/file/sendCallAlgorithm", JSON.toJSONString(param));
-        });
-
+        jmgaService.noticeBuildBd(ossHost, uuid, dir);
         return ResultData.ok();
     }
 

+ 5 - 0
src/main/java/com/fdkankan/contro/service/IJmgaService.java

@@ -1,6 +1,7 @@
 package com.fdkankan.contro.service;
 
 import com.alibaba.fastjson.JSONObject;
+import com.fdkankan.contro.vo.UploadSceneOrigParamVo;
 
 import java.util.Map;
 
@@ -12,4 +13,8 @@ public interface IJmgaService {
 
     void checkLackFile(String dataSource);
 
+    void uploadSceneOrig(UploadSceneOrigParamVo param) throws Exception;
+
+    void noticeBuildBd(String ossHost, String uuid, String dir);
+
 }

+ 5 - 2
src/main/java/com/fdkankan/contro/service/ISceneFileBuildService.java

@@ -2,6 +2,7 @@ package com.fdkankan.contro.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fdkankan.contro.entity.SceneFileBuild;
+import com.fdkankan.contro.entity.User;
 import com.fdkankan.contro.vo.ResponseSceneFile;
 import com.fdkankan.contro.vo.SendCallAlgorithmParam;
 import com.fdkankan.web.response.ResultData;
@@ -23,9 +24,9 @@ public interface ISceneFileBuildService extends IService<SceneFileBuild> {
 
     ResponseSceneFile preUpload(String params) throws Exception;
 
-    ResultData uploadSuccessBuild(String params) throws Exception;
+    ResultData uploadSuccessBuild(String params, User user) throws Exception;
 
-    ResultData turntableUploadSuccess(String params) throws Exception;
+    ResultData turntableUploadSuccess(String params, User user) throws Exception;
 
     ResultData rebuildScene(String num,Boolean force,Boolean deleteExtras, String from) throws IOException;
 
@@ -36,4 +37,6 @@ public interface ISceneFileBuildService extends IService<SceneFileBuild> {
     ResultData uploadFile(SendCallAlgorithmParam param) throws Exception;
 
     ResultData noticeBuild(String params) throws Exception;
+
+    String getFileId(String snCode, String uuid);
 }

+ 91 - 7
src/main/java/com/fdkankan/contro/service/impl/JmgaServiceImpl.java

@@ -1,30 +1,39 @@
 package com.fdkankan.contro.service.impl;
 
+import cn.hutool.core.codec.Base64;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.lang.UUID;
+import cn.hutool.core.util.ZipUtil;
+import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.fdkankan.common.constant.ErrorCode;
 import com.fdkankan.common.exception.BusinessException;
+import com.fdkankan.common.util.CmdUtils;
+import com.fdkankan.contro.bean.SendCallAlgorithmDetail;
+import com.fdkankan.contro.constant.ZipConstant;
 import com.fdkankan.contro.entity.OrigFileUpload;
 import com.fdkankan.contro.entity.OrigFileUploadBatch;
-import com.fdkankan.contro.service.IJmgaService;
-import com.fdkankan.contro.service.IOrigFileUploadBatchService;
-import com.fdkankan.contro.service.IOrigFileUploadService;
+import com.fdkankan.contro.entity.User;
+import com.fdkankan.contro.service.*;
+import com.fdkankan.contro.vo.SendCallAlgorithmParam;
+import com.fdkankan.contro.vo.UploadSceneOrigParamVo;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
+import com.fdkankan.model.constants.ConstantFilePath;
 import com.fdkankan.rabbitmq.util.RabbitMqProducer;
+import com.fdkankan.web.util.RSAEncrypt;
 import lombok.extern.slf4j.Slf4j;
+import net.lingala.zip4j.core.ZipFile;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -40,6 +49,12 @@ public class JmgaServiceImpl implements IJmgaService {
     private FYunFileServiceInterface fileServiceInterface;
     @Resource
     private RabbitMqProducer mqProducer;
+    @Resource
+    private FYunFileServiceInterface fYunFileService;
+    @Autowired
+    private ISceneFileBuildService sceneFileBuildService;
+    @Autowired
+    private IUserService userService;
 
     @Override
     public void checkFileWhole(String uuid, String dataSource, JSONObject fdageData) {
@@ -181,4 +196,73 @@ public class JmgaServiceImpl implements IJmgaService {
         throw new BusinessException(ErrorCode.FAILURE_CODE_4001.code(), ErrorCode.FAILURE_CODE_4001.formatMessage(fileName));
     }
 
+    @Override
+    public void uploadSceneOrig(UploadSceneOrigParamVo param) throws Exception {
+
+        User user = userService.getById(param.getUserId());
+        if(Objects.isNull(user)){
+            throw new BusinessException(ErrorCode.USER_NOT_EXIST);
+        }
+
+        String uuid = UUID.randomUUID().toString();
+        String zipName = uuid + ".zip";
+        String zipDir = "/oss/4dkankan/bd_server/";
+        fYunFileService.downloadFileByCommand(zipDir + zipName, param.getFilePath());
+//        fYunFileService.deleteFile(param.getFilePath());
+
+        //解压缩
+//        String unzipCmd = "unzip -P " + ZipConstant.zipPassword + " " + zipDir +  zipName + " -d " + zipDir + uuid;
+//        CmdUtils.callLineSh(unzipCmd);
+        ZipFile zipFile = new ZipFile(new File(zipDir +  zipName));
+        if (zipFile.isEncrypted()) {
+            zipFile.setPassword(ZipConstant.zipPassword);
+            zipFile.extractAll(zipDir + uuid);
+        } else {
+            ZipUtil.unzip(zipDir +  zipName, zipDir + uuid);
+        }
+//        FileUtil.del(zipDir +  zipName);
+
+        //去读data.fdage
+        File dataFdageFile = FileUtil.loopFiles(zipDir + uuid).stream().filter(v -> v.getName().equals("data.fdage")).findFirst().get();
+        if(dataFdageFile == null){
+            throw new BusinessException(ErrorCode.FAILURE_CODE_4002.code(), ErrorCode.FAILURE_CODE_4002.formatMessage("data.fdage"));
+        }
+        JSONObject dataFdageObj = JSONObject.parseObject(FileUtil.readUtf8String(dataFdageFile));
+        int camType = dataFdageObj.getJSONObject("cam").getIntValue("type");
+        String snCode = dataFdageObj.getJSONObject("cam").getString("uuid");
+        String uuidTime = dataFdageObj.getString("uuidtime");
+        String uniCode = snCode + "_" + uuidTime;
+        String fileId = sceneFileBuildService.getFileId(snCode, uniCode);
+        String homePath = "/oss/4dkankan/" + ConstantFilePath.OSS_PREFIX + snCode + "/" + fileId + "/" + uniCode;
+        FileUtil.mkdir(homePath);
+        String cpCmd = "cp -p -r " + zipDir + uuid + "/*/* " + homePath;
+        CmdUtils.callLineSh(cpCmd);
+//        FileUtil.del(zipDir + uuid);
+
+        String params = snCode + "#" + fileId + "#" + uniCode;
+        String encode = Base64.encode(RSAEncrypt.encrypt(RSAEncrypt.loadPublicKeyByStr(RSAEncrypt.loadPublicKeyByFile()), params.getBytes(StandardCharsets.UTF_8)));
+        if(camType == 9 || camType == 10 || camType == 11){
+            sceneFileBuildService.turntableUploadSuccess(encode, user);
+        }else{
+            sceneFileBuildService.uploadSuccessBuild(encode, user);
+        }
+    }
+
+
+    @Override
+    public void noticeBuildBd(String ossHost, String uuid, String dir) {
+        String prefix = "http://" + ossHost + "/";
+        String path = "/oss/4dkankan/bd_server/" + dir;
+        List<File> files = FileUtil.loopFiles(path).stream().filter(file -> !file.getAbsolutePath().contains("backup")).collect(Collectors.toList());
+        files.parallelStream().forEach(file ->{
+            String url = prefix.concat(file.getAbsolutePath().substring(1).replace("/4dkankan",""));
+            SendCallAlgorithmDetail detail = new SendCallAlgorithmDetail();
+            detail.setFileName(FileUtil.getName(file.getAbsolutePath()));
+            detail.setUuid(uuid);
+            SendCallAlgorithmParam param = new SendCallAlgorithmParam();
+            param.setFilepath(url);
+            param.setDetails(detail);
+            HttpUtil.post("http://127.0.0.1:8085/api/scene/file/sendCallAlgorithm", JSON.toJSONString(param));
+        });
+    }
 }

+ 33 - 28
src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java

@@ -25,6 +25,7 @@ import com.fdkankan.common.util.*;
 import com.fdkankan.contro.bean.SendCallAlgorithmDetail;
 import com.fdkankan.contro.common.Result;
 import com.fdkankan.contro.constant.RedisConstants;
+import com.fdkankan.contro.constant.ZipConstant;
 import com.fdkankan.contro.entity.*;
 import com.fdkankan.contro.httpclient.MyClient;
 import com.fdkankan.contro.enums.CameraTypeEnum;
@@ -89,8 +90,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
 
     private static final String sendCallAlgorithmPath = "/mnt/sendCallAlgorithm/";
 
-    private static final String zipPassword = "a3ad34136de359536af553f9e7f3cefd";
-
     private static final String URL_ADD_UCENTER_USER = "/service/manage/inner/addUcenterUser";
 
     @Value("${main.url}")
@@ -381,7 +380,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         return list.get(0);
     }
 
-    public ScenePlusVO buildScene(String fileId, String prefix,JSONObject jsonObject,String buildType,long cameraType) throws Exception{
+    public ScenePlusVO buildScene(String fileId, String prefix,JSONObject jsonObject,String buildType,long cameraType, User user) throws Exception{
         //调用createScene方法生成scene数据和加入算法队列
         String sceneNum = "";
 
@@ -397,27 +396,29 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         ResultData post = myClient.post(cameraInStoreUrl, cameraInStoreParams);
         log.info("---------cameraInStore result:{}-----------", post);
 
-        JSONObject configJson = JSONObject.parseObject(fYunFileService.getFileContent(ConstantFilePath.OSS_PREFIX + prefix + "config.json"));
-        String folderName = configJson.getString("id");
-        String customUserId = configJson.getString("customUserId");
-        String customUserName = configJson.getString("customUserName");
-        String customUserPwd = configJson.getString("customUserPwd");
-        if(StrUtil.isBlank(folderName) || StrUtil.isBlank(jsonObject.getString("creator"))){
-            throw new RuntimeException("config.json 文件有误!");
-        }
+        if(Objects.isNull(user)){
+            JSONObject configJson = JSONObject.parseObject(fYunFileService.getFileContent(ConstantFilePath.OSS_PREFIX + prefix + "config.json"));
+            String folderName = configJson.getString("id");
+            String customUserId = configJson.getString("customUserId");
+            String customUserName = configJson.getString("customUserName");
+            String customUserPwd = configJson.getString("customUserPwd");
+            if(StrUtil.isBlank(folderName) || StrUtil.isBlank(jsonObject.getString("creator"))){
+                throw new RuntimeException("config.json 文件有误!");
+            }
 
-        //调注册用户接口
-        Map<String, Object> params = new HashMap<>();
-        params.put("ryId", customUserId);
-        params.put("ryNo", customUserName);
+            //调注册用户接口
+            Map<String, Object> params = new HashMap<>();
+            params.put("ryId", customUserId);
+            params.put("ryNo", customUserName);
 //        params.put("nickName", customUserName);//去掉昵称,又燕海的接口进行判断
-        params.put("password", AesUtil.encryptCBC(customUserPwd, userPasswordKey, userPasswordIv, AesUtil.ALMODE_CBC_NOPADDING));
-        String url = fdServiceUrl.concat(URL_ADD_UCENTER_USER);
-        myClient.post(url, params);
-        JyUser jyUser = jyUserService.getByRyId(customUserId);
-        User user = userService.getById(jyUser.getUserId());
-        if(Objects.isNull(jyUser)){
-            throw new RuntimeException("注册用户失败");
+            params.put("password", AesUtil.encryptCBC(customUserPwd, userPasswordKey, userPasswordIv, AesUtil.ALMODE_CBC_NOPADDING));
+            String url = fdServiceUrl.concat(URL_ADD_UCENTER_USER);
+            myClient.post(url, params);
+            JyUser jyUser = jyUserService.getByRyId(customUserId);
+            user = userService.getById(jyUser.getUserId());
+            if(Objects.isNull(jyUser)){
+                throw new RuntimeException("注册用户失败");
+            }
         }
 
 
@@ -688,7 +689,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
     }
 
     @Override
-    public ResultData uploadSuccessBuild(String params) throws Exception {
+    public ResultData uploadSuccessBuild(String params, User user) throws Exception {
         log.info("uploadSuccessBuild-params: " + params);
         String preParams = params;
         if (StringUtils.isEmpty(params)) {
@@ -758,7 +759,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
 
 
         if (ObjectUtils.isEmpty(scenePro) || (!ObjectUtils.isEmpty(scenePro.getIsUpgrade()) && scenePro.getIsUpgrade() == 1)) {
-            buildScene(fileId, prefixBuffer.toString(),fdageJson,buildType,cameraType);
+            buildScene(fileId, prefixBuffer.toString(),fdageJson,buildType,cameraType, user);
         }else{
             buildV3Scene(scenePro,fileId, prefixBuffer.toString(),fdageJson,buildType,cameraType);
         }
@@ -840,7 +841,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
     }
 
     @Override
-    public ResultData turntableUploadSuccess(String params) throws Exception {
+    public ResultData turntableUploadSuccess(String params, User user) throws Exception {
         log.info("turntableUploadSuccess-params: " + params);
         String preParams = params;
         if (StringUtils.isEmpty(params)) {
@@ -915,7 +916,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         ScenePlusVO scenePlusVO = null;
 
         if (ObjectUtils.isEmpty(scenePro) || (!ObjectUtils.isEmpty(scenePro.getIsUpgrade()) && scenePro.getIsUpgrade() == 1)) {
-            scenePlusVO = buildScene(fileId, prefixBuffer.toString(), fdageJson, buildType, cameraType);
+            scenePlusVO = buildScene(fileId, prefixBuffer.toString(), fdageJson, buildType, cameraType, user);
         } else {
             scenePlusVO = buildV3Scene(scenePro,fileId, prefixBuffer.toString(), fdageJson, buildType, cameraType);
         }
@@ -2251,7 +2252,7 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
                     log.info("开始异步解压文件");
                     ZipFile zipFile = new ZipFile(new File(localFilePath));
                     if (zipFile.isEncrypted()) {
-                        zipFile.setPassword(zipPassword);
+                        zipFile.setPassword(ZipConstant.zipPassword);
                         zipFile.extractAll(parentPath);
                     } else {
                         ZipUtil.unzip(localFilePath, parentPath);
@@ -2349,6 +2350,9 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
 //        System.out.println(s);
 //        System.out.println(UUID.fastUUID());
 
+        String test = "bpvt00017#1396877795149217792#";
+        String[] split = test.split("#");
+        System.out.println(split);
 
     }
 
@@ -2556,7 +2560,8 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         return ResultData.ok();
     }
 
-    public String getFileId(String snCode, String uuid) throws Exception {
+    @Override
+    public String getFileId(String snCode, String uuid){
 
         // 检测是否有生成
         String fileId = null;

+ 17 - 0
src/main/java/com/fdkankan/contro/vo/UploadSceneOrigParamVo.java

@@ -0,0 +1,17 @@
+package com.fdkankan.contro.vo;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+@Data
+public class UploadSceneOrigParamVo {
+
+    @NotBlank(message = "原始资源路径不能为空")
+    private String filePath;
+
+    @NotNull(message = "userId不能为空")
+    private Long userId;
+
+}

+ 5 - 5
src/main/resources/logback-nacos.xml

@@ -9,11 +9,11 @@
 	<springProperty name="LOG_PATH" source="log.path" default="/www/VR/4dkankan/modeling-control/logs"/>
 
 	<!-- 定义日志目录 -->
-	<property name="SQL_LOG_PATH" value="${LOG_PATH}/logs/sql"/>
-	<property name="DEBUG_LOG_PATH" value="${LOG_PATH}/logs/debug"/>
-	<property name="INFO_LOG_PATH" value="${LOG_PATH}/logs/info"/>
-	<property name="WARN_LOG_PATH" value="${LOG_PATH}/logs/warn"/>
-	<property name="ERROR_LOG_PATH" value="${LOG_PATH}/logs/error"/>
+	<property name="SQL_LOG_PATH" value="${LOG_PATH}/sql"/>
+	<property name="DEBUG_LOG_PATH" value="${LOG_PATH}/debug"/>
+	<property name="INFO_LOG_PATH" value="${LOG_PATH}/info"/>
+	<property name="WARN_LOG_PATH" value="${LOG_PATH}/warn"/>
+	<property name="ERROR_LOG_PATH" value="${LOG_PATH}/error"/>
 	<!-- 定义日志保留天数 -->
 	<property name="MAX_HISTORY" value="180"/>
 	<!-- 定义日志文件总大小 -->