소스 검색

2.0.project-jmga-2.2.0-2.0.1

dengsixing 1 개월 전
부모
커밋
8c9424bcbe

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

@@ -19,7 +19,7 @@ public class JmgaController {
     private IJmgaService jmgaService;
 
     @PostMapping("/uploadSceneOrig")
-    public ResultData uploadSceneOrig(@RequestBody @Valid UploadSceneOrigParamVo param){
+    public ResultData uploadSceneOrig(@RequestBody @Valid UploadSceneOrigParamVo param) throws Exception {
         jmgaService.uploadSceneOrig(param);
         return ResultData.ok();
     }

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

@@ -75,7 +75,7 @@ public class SceneFileController{
      */
     @PostMapping("uploadSuccessBuild")
     public ResultData uploadSuccessBuild(String params) throws Exception {
-        return sceneFileBuildService.uploadSuccessBuild(params);
+        return sceneFileBuildService.uploadSuccessBuild(params, null);
     }
 
     /**
@@ -86,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")

+ 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);
 }

+ 44 - 23
src/main/java/com/fdkankan/contro/service/impl/JmgaServiceImpl.java

@@ -1,5 +1,6 @@
 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;
@@ -15,23 +16,22 @@ 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 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
@@ -49,6 +49,10 @@ public class JmgaServiceImpl implements IJmgaService {
     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) {
@@ -192,32 +196,49 @@ public class JmgaServiceImpl implements IJmgaService {
 
     @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 = FileUtil.getName(param.getFilePath());
         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;
+        String unzipCmd = "unzip -P " + ZipConstant.zipPassword + " " + zipDir +  zipName + " -d " + zipDir + uuid;
         CmdUtils.callLineSh(unzipCmd);
+        FileUtil.del(zipDir +  zipName);
 
-//        this.noticeBuildBd();
-
-
-
-
-
-
-
+        //去读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);
+        }
     }
 
-//    public static void main(String[] args) {
-//        //解压缩
-//        ZipUtil.unzip(new File("D:\\test\\" + "123123.zip"), new File("D:\\test\\"));
-//        ZipUtil.unzip
-//
-//    }
 
     @Override
     public void noticeBuildBd(String ossHost, String uuid, String dir) {

+ 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);
         }
@@ -2244,7 +2245,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);
@@ -2342,6 +2343,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);
 
     }
 
@@ -2549,7 +2553,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;