Browse Source

上传 下载全景图 无论是单个文件还是全部,统一zip格
场景二维码去掉logo,二维码命名规范
上传模型和球幕视频,格式校验

dengsixing 3 years ago
parent
commit
362cc54436

+ 1 - 1
4dkankan-center-platform/src/main/java/com/fdkankan/platform/user/service/sso/LoginService.java

@@ -137,7 +137,7 @@ public class LoginService {
     public JSONObject createLoginQrCode() throws Exception{
     public JSONObject createLoginQrCode() throws Exception{
         String uuid = NumberUtils.getUUID();
         String uuid = NumberUtils.getUUID();
         String filePath = ConstantFilePath.LOGIN_QR_CODE_PATH + uuid + ".png";
         String filePath = ConstantFilePath.LOGIN_QR_CODE_PATH + uuid + ".png";
-        MatrixToImageWriterUtil.createQRCode(mainUrl + "app/index.html?m="+uuid, filePath, null);
+        MatrixToImageWriterUtil.createQRCode(mainUrl + "app/index.html?m="+uuid, filePath, true, null);
         JSONObject json = new JSONObject();
         JSONObject json = new JSONObject();
         json.put("url", filePath.replace(ConstantFilePath.BASE_PATH, ""));
         json.put("url", filePath.replace(ConstantFilePath.BASE_PATH, ""));
         json.put("uuid", uuid);
         json.put("uuid", uuid);

+ 1 - 1
4dkankan-center-scene/src/main/java/com/fdkankan/scene/controller/SceneEditController.java

@@ -707,7 +707,7 @@ public class SceneEditController extends BaseController {
      * @return java.util.List<java.lang.String>
      * @return java.util.List<java.lang.String>
      **/
      **/
     @PostMapping(value = "/uploadPanorama")
     @PostMapping(value = "/uploadPanorama")
-    public List<String> uploadPanorama(@RequestParam(value = "num") String num,
+    public ResultData uploadPanorama(@RequestParam(value = "num") String num,
         @RequestParam("file") MultipartFile file) throws Exception {
         @RequestParam("file") MultipartFile file) throws Exception {
         return sceneEditInfoService.uploadPanorama(num, file);
         return sceneEditInfoService.uploadPanorama(num, file);
     }
     }

+ 0 - 2
4dkankan-center-scene/src/main/java/com/fdkankan/scene/controller/TestController.java

@@ -120,8 +120,6 @@ public class TestController {
     }
     }
 
 
     public static void main(String[] args) throws Exception {
     public static void main(String[] args) throws Exception {
-        MatrixToImageWriterUtil.createQRCode("http://baidu.com" + "123123", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+"123123"+".png",
-                null);
 
 
 //        MatrixToImageWriterUtil.createQRCode("http://baidu.com" + "123123", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+"123123"+".png",
 //        MatrixToImageWriterUtil.createQRCode("http://baidu.com" + "123123", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+"123123"+".png",
 //                ConstantFilePath.SCENE_PATH + "images/images" + "123123" + "/QRShareLogo.png");
 //                ConstantFilePath.SCENE_PATH + "images/images" + "123123" + "/QRShareLogo.png");

+ 4 - 4
4dkankan-center-scene/src/main/java/com/fdkankan/scene/listener/BuildSceneResultMQListener.java

@@ -168,12 +168,12 @@ public class BuildSceneResultMQListener implements RocketMQListener<String> {
             String outPathZh = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+sceneCode+".png";
             String outPathZh = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+sceneCode+".png";
             String outPathEn = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+sceneCode+"_en.png";
             String outPathEn = ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+sceneCode+"_en.png";
             //生成新的分享的二维码-中文版本
             //生成新的分享的二维码-中文版本
-            MatrixToImageWriterUtil.createQRCode(sceneUrl + sceneCode, outPathZh,null);
+            MatrixToImageWriterUtil.createQRCode(sceneUrl + sceneCode, outPathZh, false,null);
             //生成新的分享的二维码-英文版本
             //生成新的分享的二维码-英文版本
-            MatrixToImageWriterUtil.createQRCode(sceneUrl + sceneCode + "&lang=en", outPathEn, null);
+            MatrixToImageWriterUtil.createQRCode(sceneUrl + sceneCode + "&lang=en", outPathEn, false, null);
             //上传二维码
             //上传二维码
-            uploadToOssUtil.upload(outPathZh, String.format(UploadFilePath.DOWNLOADS_QRCODE, sceneCode) + sceneCode + ".png");
-            uploadToOssUtil.upload(outPathEn, String.format(UploadFilePath.DOWNLOADS_QRCODE, sceneCode) + sceneCode + "_en.png");
+            uploadToOssUtil.upload(outPathZh, String.format(UploadFilePath.DOWNLOADS_QRCODE, sceneCode) + "4Dkankan_share.png");
+            uploadToOssUtil.upload(outPathEn, String.format(UploadFilePath.DOWNLOADS_QRCODE, sceneCode) + "4Dkankan_share_en.png");
 
 
             Map<String, String> newUploadFiles = buildScenePreService
             Map<String, String> newUploadFiles = buildScenePreService
                 .uploadFileMapHandler(sceneCode, cameraType, uploadFiles);
                 .uploadFileMapHandler(sceneCode, cameraType, uploadFiles);

+ 1 - 1
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/ISceneEditInfoService.java

@@ -36,7 +36,7 @@ public interface ISceneEditInfoService extends IService<SceneEditInfo> {
 
 
     void upgradeVersionById(Long id);
     void upgradeVersionById(Long id);
 
 
-    List<String> uploadPanorama(String num, MultipartFile file) throws Exception;
+    ResultData uploadPanorama(String num, MultipartFile file) throws Exception;
 
 
     ResultData downloadPanorama(FileParamVO param) throws Exception;
     ResultData downloadPanorama(FileParamVO param) throws Exception;
 
 

+ 19 - 20
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneEditInfoServiceImpl.java

@@ -612,7 +612,12 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
     }
     }
 
 
     @Override
     @Override
-    public List<String> uploadPanorama(String num, MultipartFile file) throws Exception {
+    public ResultData uploadPanorama(String num, MultipartFile file) throws Exception {
+
+        //校验压缩包格式
+        if(!file.getOriginalFilename().endsWith(".zip")){
+            throw new BusinessException(ErrorCode.FAILURE_CODE_7015);
+        }
 
 
         ScenePro scenePro = sceneProService.findBySceneNum(num);
         ScenePro scenePro = sceneProService.findBySceneNum(num);
         if(scenePro == null){
         if(scenePro == null){
@@ -649,7 +654,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
         //获取解压后的文件列表
         //获取解压后的文件列表
         List<String> uploadFileList = FileUtil.getFileList(targetImagesPath);
         List<String> uploadFileList = FileUtil.getFileList(targetImagesPath);
         if(CollUtil.isEmpty(uploadFileList)){
         if(CollUtil.isEmpty(uploadFileList)){
-            return null;
+            throw new BusinessException(ErrorCode.FAILURE_CODE_7014);
         }
         }
 
 
         //列出caches/images中的文件列表
         //列出caches/images中的文件列表
@@ -672,7 +677,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
 
 
         //有文件对不上号,就退出
         //有文件对不上号,就退出
         if(CollUtil.isNotEmpty(notExistFileList)){
         if(CollUtil.isNotEmpty(notExistFileList)){
-            return notExistFileList;
+            return ResultData.error(ErrorCode.FAILURE_CODE_7012, notExistFileList);
         }
         }
 
 
         //上传
         //上传
@@ -814,24 +819,18 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
                 String imageUrl = ossUrlPrefix + filePath + "?t=" + System.currentTimeMillis();
                 String imageUrl = ossUrlPrefix + filePath + "?t=" + System.currentTimeMillis();
                 FileUtils.downLoadFromUrl(imageUrl, fileName, localImagesPath);
                 FileUtils.downLoadFromUrl(imageUrl, fileName, localImagesPath);
             }
             }
-            //上传
-            uploadToOssUtil.upload(localImagesPath + fileName, String.format(cacheImageFormat, num) + fileName);
-            String url = ossUrlPrefix + String.format(cacheImageFormat, num) + fileName + "?t=" + Calendar.getInstance().getTimeInMillis();
-            Map<String, Object> map = new HashMap<>();
-            map.put("fileUrl", url + "?t=" + System.currentTimeMillis());
-            map.put("fileName", fileName);
-            return ResultData.ok(map);
+        }else{
+            //先下载到本地
+            List<String> keyList = uploadToOssUtil.listKeys(imgCachePath);
+            if (!StorageType.LOCAL.code().equals(this.type)) {// TODO: 2022/2/15 这里有可能有问题,可能还需要考虑本地部署的情况
+                keyList.stream().forEach(key->{
+                    String file = key.substring(key.lastIndexOf("/") + 1);
+                    String imageUrl = ossUrlPrefix + imgCachePath + file + "?t=" + System.currentTimeMillis();
+                    FileUtils.downLoadFromUrl(imageUrl, file, localImagesPath);
+                });
+            }
         }
         }
 
 
-        //先下载到本地
-        List<String> keyList = uploadToOssUtil.listKeys(imgCachePath);
-        if (!StorageType.LOCAL.code().equals(this.type)) {// TODO: 2022/2/15 这里有可能有问题,可能还需要考虑本地部署的情况
-            keyList.stream().forEach(key->{
-                String file = key.substring(key.lastIndexOf("/") + 1);
-                String imageUrl = ossUrlPrefix + imgCachePath + file + "?t=" + System.currentTimeMillis();
-                FileUtils.downLoadFromUrl(imageUrl, file, localImagesPath);
-            });
-        }
         //打包
         //打包
         String zipName = num + "_images.zip";
         String zipName = num + "_images.zip";
         String zipPath = cachePath + zipName;
         String zipPath = cachePath + zipName;
@@ -932,7 +931,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
 
 
         //校验格式
         //校验格式
         if(!fileName.endsWith(".mp4")){
         if(!fileName.endsWith(".mp4")){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_7007.code(), ErrorCode.FAILURE_CODE_7007.formatMessage("mp4"));
+            throw new BusinessException(ErrorCode.FAILURE_CODE_7016);
         }
         }
         String videosViewPath = String.format(UploadFilePath.VIDEOS_VIEW_PATH, num);
         String videosViewPath = String.format(UploadFilePath.VIDEOS_VIEW_PATH, num);
 
 

+ 8 - 8
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneFileBuildServiceImpl.java

@@ -1082,10 +1082,10 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
 
 
                     //生成新的分享的二维码-中文版本
                     //生成新的分享的二维码-中文版本
                     MatrixToImageWriterUtil.createQRCode(sceneUrl + sceneNum, ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+sceneNum+".png",
                     MatrixToImageWriterUtil.createQRCode(sceneUrl + sceneNum, ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+sceneNum+".png",
-                            ConstantFilePath.SCENE_PATH + "images/images" + sceneNum + "/QRShareLogo.png");
+                        false, ConstantFilePath.SCENE_PATH + "images/images" + sceneNum + "/QRShareLogo.png");
                     //生成新的分享的二维码-英文版本
                     //生成新的分享的二维码-英文版本
                     MatrixToImageWriterUtil.createQRCode(sceneUrl + sceneNum + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+sceneNum+"_en.png",
                     MatrixToImageWriterUtil.createQRCode(sceneUrl + sceneNum + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+sceneNum+"_en.png",
-                            ConstantFilePath.SCENE_PATH + "images/images" + sceneNum + "/QRShareLogo.png");
+                        false,  ConstantFilePath.SCENE_PATH + "images/images" + sceneNum + "/QRShareLogo.png");
                 }
                 }
 
 
                 if(StrUtil.isNotEmpty(company.getMarkerLogo())){
                 if(StrUtil.isNotEmpty(company.getMarkerLogo())){
@@ -1415,9 +1415,9 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
 
 
                             //生成新的分享的二维码
                             //生成新的分享的二维码
                             MatrixToImageWriterUtil.createQRCode(sceneUrl + sceneNum, ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+sceneNum+".png",
                             MatrixToImageWriterUtil.createQRCode(sceneUrl + sceneNum, ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+sceneNum+".png",
-                                    ConstantFilePath.SCENE_PATH + "images/images" + sceneNum + "/QRShareLogo.png");
+                                false, ConstantFilePath.SCENE_PATH + "images/images" + sceneNum + "/QRShareLogo.png");
                             MatrixToImageWriterUtil.createQRCode(sceneUrl + sceneNum + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+sceneNum+"_en.png",
                             MatrixToImageWriterUtil.createQRCode(sceneUrl + sceneNum + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+sceneNum+"_en.png",
-                                    ConstantFilePath.SCENE_PATH + "images/images" + sceneNum + "/QRShareLogo.png");
+                                false,  ConstantFilePath.SCENE_PATH + "images/images" + sceneNum + "/QRShareLogo.png");
                         }
                         }
 
 
                         if(StrUtil.isNotEmpty(company.getMarkerLogo())){
                         if(StrUtil.isNotEmpty(company.getMarkerLogo())){
@@ -1607,8 +1607,8 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
 //        UploadToOssUtil.upload(ConstantFilePath.SCENE_PATH+"data/data"+projectNum+File.separator+"scene.json", "data/data"+projectNum+File.separator+"scene.json");
 //        UploadToOssUtil.upload(ConstantFilePath.SCENE_PATH+"data/data"+projectNum+File.separator+"scene.json", "data/data"+projectNum+File.separator+"scene.json");
 
 
         //生成二维码
         //生成二维码
-        MatrixToImageWriterUtil.createQRCode(url + projectNum, ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+".png", null);
-        MatrixToImageWriterUtil.createQRCode(url + projectNum + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+"_en.png", null);
+        MatrixToImageWriterUtil.createQRCode(url + projectNum, ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+".png", false, null);
+        MatrixToImageWriterUtil.createQRCode(url + projectNum + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+"_en.png", false, null);
         log.info("二维码生成完成");
         log.info("二维码生成完成");
 
 
         BeanUtil.copyProperties(sceneExt, scenePo);
         BeanUtil.copyProperties(sceneExt, scenePo);
@@ -1913,8 +1913,8 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         FileUtils.writeFile(ConstantFilePath.SCENE_PATH+"data/data"+projectNum+File.separator+"scene.json", scenejson.toString());
         FileUtils.writeFile(ConstantFilePath.SCENE_PATH+"data/data"+projectNum+File.separator+"scene.json", scenejson.toString());
 
 
         //生成二维码
         //生成二维码
-        MatrixToImageWriterUtil.createQRCode(url + projectNum, ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+".png", null);
-        MatrixToImageWriterUtil.createQRCode(url + projectNum + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+"_en.png", null);
+        MatrixToImageWriterUtil.createQRCode(url + projectNum, ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+".png", false, null);
+        MatrixToImageWriterUtil.createQRCode(url + projectNum + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+"_en.png", false, null);
         log.info("二维码生成完成");
         log.info("二维码生成完成");
 
 
         //当mq排队数大于指定数量时使用弹性升缩
         //当mq排队数大于指定数量时使用弹性升缩

+ 13 - 13
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneProServiceImpl.java

@@ -3077,12 +3077,12 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
             sceneProEdit.setUpdateTime(Calendar.getInstance().getTime());
             sceneProEdit.setUpdateTime(Calendar.getInstance().getTime());
             sceneProEditService.updateById(sceneProEdit);
             sceneProEditService.updateById(sceneProEdit);
             if("V2".equals(scenePro.getBuildType())){
             if("V2".equals(scenePro.getBuildType())){
-                MatrixToImageWriterUtil.createQRCode(mainUrl + sceneProUrl + scenePro.getNum(), ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+scenePro.getNum()+".png", path + File.separator + fileName);
-                MatrixToImageWriterUtil.createQRCode(mainUrl + sceneProUrl + scenePro.getNum() + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+scenePro.getNum()+"_en.png", path + File.separator + fileName);
+                MatrixToImageWriterUtil.createQRCode(mainUrl + sceneProUrl + scenePro.getNum(), ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+scenePro.getNum()+".png", true,  path + File.separator + fileName);
+                MatrixToImageWriterUtil.createQRCode(mainUrl + sceneProUrl + scenePro.getNum() + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+scenePro.getNum()+"_en.png", true, path + File.separator + fileName);
             }
             }
             if("V3".equals(scenePro.getBuildType())){
             if("V3".equals(scenePro.getBuildType())){
-                MatrixToImageWriterUtil.createQRCode(mainUrl + sceneProNewUrl + scenePro.getNum(), ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+scenePro.getNum()+".png", path + File.separator + fileName);
-                MatrixToImageWriterUtil.createQRCode(mainUrl + sceneProNewUrl + scenePro.getNum() + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+scenePro.getNum()+"_en.png", path + File.separator + fileName);
+                MatrixToImageWriterUtil.createQRCode(mainUrl + sceneProNewUrl + scenePro.getNum(), ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+scenePro.getNum()+".png", true, path + File.separator + fileName);
+                MatrixToImageWriterUtil.createQRCode(mainUrl + sceneProNewUrl + scenePro.getNum() + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+scenePro.getNum()+"_en.png", true, path + File.separator + fileName);
             }
             }
         }
         }
         return ResultData.ok(imagesBuf.toString() + fileName);
         return ResultData.ok(imagesBuf.toString() + fileName);
@@ -3424,15 +3424,15 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         }
         }
 
 
         //文件上传的位置可以自定义
         //文件上传的位置可以自定义
-//        String path = sceneProExt.getDataSource() + "_obj2txt";
-//        String zipPath = path + "/zip/";
-//        String filePath =  path + "/extras/";
-//        String resultPath = path + "/results/";
+        String path = sceneProExt.getDataSource() + "_obj2txt";
+        String zipPath = path + "/zip/";
+        String filePath =  path + "/extras/";
+        String resultPath = path + "/results/";
 
 
-        String path = "F:\\uploadModel" + "_obj2txt";
-        String zipPath = path + "\\zip\\";
-        String filePath =  path + "\\extras\\";
-        String resultPath = path + "\\results\\";
+//        String path = "F:\\uploadModel" + "_obj2txt";
+//        String zipPath = path + "\\zip\\";
+//        String filePath =  path + "\\extras\\";
+//        String resultPath = path + "\\results\\";
 
 
         //压缩文件处理:解压缩,解压缩后复制等操作
         //压缩文件处理:解压缩,解压缩后复制等操作
         this.objAndImgFileHandler(resultPath, filePath, zipPath, file);
         this.objAndImgFileHandler(resultPath, filePath, zipPath, file);
@@ -3478,7 +3478,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         String uploadJsonPath = path + File.separator + "results" +File.separator+"upload.json";
         String uploadJsonPath = path + File.separator + "results" +File.separator+"upload.json";
         boolean exist = ComputerUtil.checkComputeCompleted(uploadJsonPath, 5, 5000);
         boolean exist = ComputerUtil.checkComputeCompleted(uploadJsonPath, 5, 5000);
         if(!exist){
         if(!exist){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5042);
+            throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
         }
         }
         String uploadData = FileUtils.readFile(uploadJsonPath);
         String uploadData = FileUtils.readFile(uploadJsonPath);
         JSONObject uploadJson = null;
         JSONObject uploadJson = null;

+ 0 - 2
4dkankan-center-scene/src/test/java/com/fdkankan/scene/SceneApplicationTests.java

@@ -27,8 +27,6 @@ class ApplicationTests {
     @Test
     @Test
     public String test2() throws Exception {
     public String test2() throws Exception {
 
 
-        MatrixToImageWriterUtil.createQRCode("http://baidu.com" + "123123", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+"123123"+".png",
-                null);
 
 
         return "123";
         return "123";