dengsixing 6 kuukautta sitten
vanhempi
commit
2d4508b932

+ 106 - 109
src/main/java/com/fdkankan/common/util/OBJToGLBUtil.java

@@ -22,121 +22,118 @@ public class OBJToGLBUtil {
      * @param objPath obj文件的目录
      * @param glbPath glb文件的最对路径
      */
-    public static void objToGlb(String objPath, String glbPath) {
-        OBJToGLBUtil.checkObj(objPath);
-        objPath = OBJToGLBUtil.getObj(objPath);
-        String command = "obj2gltf -i " + objPath + " -o " + glbPath;
-        log.info("开始执行obj转换gbl命令-{}", command);
-        Process exec = RuntimeUtil.exec(command);
-        log.info("结束执行obj转换gbl命令-{}", command);
-    }
+//    public static void objToGlb(String objPath, String glbPath) {
+//        OBJToGLBUtil.checkObj(objPath);
+//        objPath = OBJToGLBUtil.getObj(objPath);
+//        String command = "obj2gltf -i " + objPath + " -o " + glbPath;
+//        log.info("开始执行obj转换gbl命令-{}", command);
+//        Process exec = RuntimeUtil.exec(command);
+//        log.info("结束执行obj转换gbl命令-{}", command);
+//    }
 
-    static String getObj(String objPath) {
-        List<File> files = FileUtil.loopFiles(objPath);
-        if (objPath.toLowerCase(Locale.ROOT).contains(".obj")) {
-            return objPath;
-        }
-        for (File file2 : files) {
-            if (file2.isDirectory()) {
-                continue;
-            }
-            if (FileUtil.extName(file2.getName()).toLowerCase(Locale.ROOT).equals("obj")) {
-                return file2.getAbsolutePath();
-            }
-        }
-        return "";
-    }
+//    static String getObj(String objPath) {
+//        List<File> files = FileUtil.loopFiles(objPath);
+//        if (objPath.toLowerCase(Locale.ROOT).contains(".obj")) {
+//            return objPath;
+//        }
+//        for (File file2 : files) {
+//            if (file2.isDirectory()) {
+//                continue;
+//            }
+//            if (FileUtil.extName(file2.getName()).toLowerCase(Locale.ROOT).equals("obj")) {
+//                return file2.getAbsolutePath();
+//            }
+//        }
+//        return "";
+//    }
 
 
-    private static boolean checkObj(String objPath) {
-        if (objPath.contains(".obg")) {
-            objPath = FileUtil.file(objPath).getParent();
-        }
-        File file1 = new File(objPath);
-        File[] files = file1.listFiles();
-        if (files == null || files.length <= 0) {
-            throw new BusinessException(ErrorCode.FAILURE_CODE_7014);
-        }
-        File mtlFile = null;
-        File objFile = null;
-        for (File file2 : files) {
-            if (file2.getName().endsWith(".obj")) {
-//                if (StringUtils.isChinese(file2.getName())) {
-//                    throw new ServiceException(HttpStatus.e7008.getMsg(), HttpStatus.e7008.getCode());
+//    private static boolean checkObj(String objPath) {
+//        if (objPath.contains(".obg")) {
+//            objPath = FileUtil.file(objPath).getParent();
+//        }
+//        File file1 = new File(objPath);
+//        File[] files = file1.listFiles();
+//        if (files == null || files.length <= 0) {
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_7014);
+//        }
+//        File mtlFile = null;
+//        File objFile = null;
+//        for (File file2 : files) {
+//            if (file2.getName().endsWith(".obj")) {
+////                if (StringUtils.isChinese(file2.getName())) {
+////                    throw new ServiceException(HttpStatus.e7008.getMsg(), HttpStatus.e7008.getCode());
+////                }
+//                objFile = file2;
+//            }
+//            if (file2.getName().endsWith(".mtl")) {
+////                if (StringUtils.isChinese(file2.getName())) {
+////                    throw new ServiceException(HttpStatus.e7008.getMsg(), HttpStatus.e7008.getCode());
+////                }
+//                mtlFile = file2;
+//            }
+//            if (FileUtil.getType(file2).equals("jpg") || FileUtil.getType(file2).equals("png")) {
+//                BufferedImage read = ImgUtil.read(file2);
+//                int widthImg = read.getWidth();
+//                int heightImg = read.getHeight();
+//                if (widthImg > 2048 && heightImg > 2048) {
+//                    OBJToGLBUtil.log.info("尺寸大2k,执行压缩");
+//                    ImgUtil.scale(file2,
+//                            file2,
+//                            2048, 2048, null);
 //                }
-                objFile = file2;
-            }
-            if (file2.getName().endsWith(".mtl")) {
-//                if (StringUtils.isChinese(file2.getName())) {
-//                    throw new ServiceException(HttpStatus.e7008.getMsg(), HttpStatus.e7008.getCode());
-//                }
-                mtlFile = file2;
-            }
-            if (FileUtil.getType(file2).equals("jpg") || FileUtil.getType(file2).equals("png")) {
-                BufferedImage read = ImgUtil.read(file2);
-                int widthImg = read.getWidth();
-                int heightImg = read.getHeight();
-                if (widthImg > 2048 && heightImg > 2048) {
-                    OBJToGLBUtil.log.info("尺寸大2k,执行压缩");
-                    ImgUtil.scale(file2,
-                            file2,
-                            2048, 2048, null);
-                }
-            }
-        }
-        if (mtlFile == null || objFile == null) {
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5059);
-        }
-        return OBJToGLBUtil.checkMtl(file1, mtlFile);
-    }
+//            }
+//        }
+//        if (mtlFile == null || objFile == null) {
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_5059);
+//        }
+//        return OBJToGLBUtil.checkMtl(file1, mtlFile);
+//    }
 
-    private static boolean checkMtl(File allFile, File file) {
-        if (!file.getName().endsWith(".mtl")) {
-            return false;
-        }
-        LinkedHashSet<String> imgName = new LinkedHashSet<>();
-        if (allFile == null || allFile.length() <= 0) {
-            return false;
-        }
-        File[] files = allFile.listFiles();
-        if (files == null || files.length <= 0) {
-            return false;
-        }
-        for (File listFile : files) {
-            String modelName = listFile.getName();
-            imgName.add(modelName);
-        }
-        LinkedHashSet<String> imgMtl = OBJToGLBUtil.readMtlFile(file.getPath());
-        for (String mtlName : imgMtl) {
-            if (!imgName.contains(mtlName)) {
-                throw new BusinessException(ErrorCode.FAILURE_CODE_5065);
-            }
-        }
-        return true;
-    }
+//    private static boolean checkMtl(File allFile, File file) {
+//        if (!file.getName().endsWith(".mtl")) {
+//            return false;
+//        }
+//        LinkedHashSet<String> imgName = new LinkedHashSet<>();
+//        if (allFile == null || allFile.length() <= 0) {
+//            return false;
+//        }
+//        File[] files = allFile.listFiles();
+//        if (files == null || files.length <= 0) {
+//            return false;
+//        }
+//        for (File listFile : files) {
+//            String modelName = listFile.getName();
+//            imgName.add(modelName);
+//        }
+//        LinkedHashSet<String> imgMtl = OBJToGLBUtil.readMtlFile(file.getPath());
+//        for (String mtlName : imgMtl) {
+//            if (!imgName.contains(mtlName)) {
+//                throw new BusinessException(ErrorCode.FAILURE_CODE_5065);
+//            }
+//        }
+//        return true;
+//    }
 
-    private static LinkedHashSet<String> readMtlFile(String mtlPath) {
-        LinkedHashSet<String> imgName = new LinkedHashSet<>();
-        FileReader fileReader = new FileReader(mtlPath);
-        try {
-            List<String> lines = fileReader.readLines();
-            for (String line : lines) {
-                String[] tempsa = line.split("[ ]+");
-                if (tempsa[0].trim().equals("map_Ka")) {
-                    imgName.add(tempsa[1]);
-                }
-                if (tempsa[0].trim().equals("map_Kd")) {
-                    imgName.add(tempsa[1]);
-                }
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return imgName;
-    }
+//    private static LinkedHashSet<String> readMtlFile(String mtlPath) {
+//        LinkedHashSet<String> imgName = new LinkedHashSet<>();
+//        FileReader fileReader = new FileReader(mtlPath);
+//        try {
+//            List<String> lines = fileReader.readLines();
+//            for (String line : lines) {
+//                String[] tempsa = line.split("[ ]+");
+//                if (tempsa[0].trim().equals("map_Ka")) {
+//                    imgName.add(tempsa[1]);
+//                }
+//                if (tempsa[0].trim().equals("map_Kd")) {
+//                    imgName.add(tempsa[1]);
+//                }
+//            }
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//        return imgName;
+//    }
 
 
-    public static void main(String[] args) {
-        System.out.println(OBJToGLBUtil.checkObj("F:\\test\\新建文件夹\\police模型"));
-    }
 }

+ 1 - 1
src/main/java/com/fdkankan/scene/Interceptor/CheckTokenAspect.java

@@ -78,7 +78,7 @@ public class CheckTokenAspect {
 		String encode = ThreeDESUtil.encode(JSON.toJSONString(params), gatewayKey);
 		checkProwadaTokenParam.put("args", encode);
 		JSONObject result = ws4AServiceClient.checkProwadaToken(checkProwadaTokenParam);
-		log.info("场景:{},4A校验token结果:{}", num, result);
+//		log.info("场景:{},4A校验token结果:{}", num, result);
 		if(!"SUCCESS".equals(result.getString("resultStat"))){
 			throw new BusinessException(4000, "4A鉴权失败");
 		}

+ 3 - 3
src/main/java/com/fdkankan/scene/Interceptor/ViewLogAspect.java

@@ -96,7 +96,7 @@ public class ViewLogAspect {
 		String encode = ThreeDESUtil.encode(JSON.toJSONString(params), gatewayKey);
 		checkProwadaTokenParam.put("args", encode);
 		JSONObject result = ws4AServiceClient.checkProwadaToken(checkProwadaTokenParam);
-		log.info("场景:{},4A校验token结果:{}", num, result);
+//		log.info("场景:{},4A校验token结果:{}", num, result);
 		if(!SUCCESS_KEY.equals(result.getString(RESULT_STAT))){
 			throw new BusinessException(4000, "4A鉴权失败");
 		}
@@ -120,7 +120,7 @@ public class ViewLogAspect {
 		String queryLoginUserInfoResp = HttpUtil.get(gatewayUrl + "/QUERY4A/user/queryLoginUserInfo?args=" + encode);
 		result = JSON.parseObject(queryLoginUserInfoResp);
 //		result = ws4AServiceClient.queryLoginUserInfo(encode);
-		log.info("场景:{},4A查询用户信息结果:{}", num, result);
+//		log.info("场景:{},4A查询用户信息结果:{}", num, result);
 		if(!SUCCESS_KEY.equals(result.getString(RESULT_STAT))){
 			throw new BusinessException(4000, "4A查询用户信息失败");
 		}
@@ -140,7 +140,7 @@ public class ViewLogAspect {
 //		result = ws4AServiceClient.queryOrgs(encode);
 		String queryOrgsResp = HttpUtil.get(gatewayUrl + "/QUERY4A/query/queryOrgs?args=" + encode);
 		result = JSON.parseObject(queryOrgsResp);
-		log.info("场景:{},4A查询用户组织结果:{}", num, result);
+//		log.info("场景:{},4A查询用户组织结果:{}", num, result);
 		if(!SUCCESS_KEY.equals(result.getString(RESULT_STAT))){
 			throw new BusinessException(4000, "查询用户组织失败");
 		}

+ 6 - 4
src/main/java/com/fdkankan/scene/controller/SceneController.java

@@ -16,6 +16,7 @@ import com.fdkankan.scene.service.SceneService;
 import com.fdkankan.scene.service.SystemSecretService;
 import com.fdkankan.scene.vo.SceneCheckKeyParamVO;
 import com.fdkankan.scene.vo.SceneInfoParamVO;
+import com.fdkankan.scene.vo.SceneInfoVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.Resource;
 import org.springframework.http.ResponseEntity;
@@ -47,6 +48,8 @@ public class SceneController extends BaseController{
     private SceneEditInfoService sceneEditInfoService;
     @Autowired
     private FdfsUtil fdfsUtil;
+    @Autowired
+    private SystemSecretService systemSecretService;
     /**
      * <p>
      获取场景详情
@@ -63,7 +66,9 @@ public class SceneController extends BaseController{
     public ResultData getInfo(@Validated SceneInfoParamVO param) throws Exception{
         param.setReqType(SceneInfoReqType.VIEW.code());
 //        param.setSubgroup(this.getSubgroup());
-        return ResultData.ok(sceneEditInfoService.getSceneInfo(param));
+        response.setHeader("Set-Cookie","cookiename=cookievalue; path=/; Domain=domainvaule; Max-age=seconds; HttpOnly");
+        SceneInfoVO sceneInfo = sceneEditInfoService.getSceneInfo(param);
+        return ResultData.ok(sceneInfo);
     }
 
 //    @GetMapping("/file")
@@ -96,9 +101,6 @@ public class SceneController extends BaseController{
         return ResultData.ok(stringStringMap);
     }
 
-    @Autowired
-    private SystemSecretService systemSecretService;
-
     @GetMapping("/test")
     public ResultData test(){
         return ResultData.ok(systemSecretService.list());

+ 46 - 44
src/main/java/com/fdkankan/scene/controller/SceneEditController.java

@@ -266,6 +266,7 @@ public class SceneEditController extends BaseController{
     @GetMapping(value = "/getInfo")
     public SceneInfoVO getInfo(@Validated SceneInfoParamVO param) throws Exception{
         param.setReqType(SceneInfoReqType.EDIT.code());
+        response.setHeader("Set-Cookie","cookiename=cookievalue; path=/; Domain=domainvaule; Max-age=seconds; HttpOnly");
         return sceneEditInfoService.getSceneInfo(param);
     }
 
@@ -300,32 +301,32 @@ public class SceneEditController extends BaseController{
         return sceneEditInfoService.downloadPanorama(param);
     }
 
-    /**
-     * <p>
-     下载模型
-     * </p>
-     * @author dengsixing
-     * @param num
-     * @return com.fdkankan.web.response.ResultData
-     **/
-    @PostMapping(value = "/downloadModel")
-    public ResultData downloadModel(@RequestParam("num") String num) throws Exception {
-        return sceneProService.downloadModel(num, this.getSubgroup(), this.getUpTime());
-    }
+//    /**
+//     * <p>
+//     下载模型
+//     * </p>
+//     * @author dengsixing
+//     * @param num
+//     * @return com.fdkankan.web.response.ResultData
+//     **/
+//    @PostMapping(value = "/downloadModel")
+//    public ResultData downloadModel(@RequestParam("num") String num) throws Exception {
+//        return sceneProService.downloadModel(num, this.getSubgroup(), this.getUpTime());
+//    }
 
-    /**
-     * <p>
-     上传模型
-     * </p>
-     * @author dengsixing
-     * @param num
-     * @param file
-     * @return com.fdkankan.web.response.ResultData
-     **/
-    @PostMapping(value = "/uploadModel")
-    public ResultData uploadModel(@RequestParam("num") String num, @RequestParam("file") MultipartFile file) throws Exception {
-        return sceneProService.uploadModel(num, this.getSubgroup(), this.getUpTime(), file);
-    }
+//    /**
+//     * <p>
+//     上传模型
+//     * </p>
+//     * @author dengsixing
+//     * @param num
+//     * @param file
+//     * @return com.fdkankan.web.response.ResultData
+//     **/
+//    @PostMapping(value = "/uploadModel")
+//    public ResultData uploadModel(@RequestParam("num") String num, @RequestParam("file") MultipartFile file) throws Exception {
+//        return sceneProService.uploadModel(num, this.getSubgroup(), this.getUpTime(), file);
+//    }
 
     @RequestMapping(value = "/upload/files", method = RequestMethod.POST)
     public String uploads(@RequestParam(value = "base64",required = false) String base64,
@@ -337,6 +338,7 @@ public class SceneEditController extends BaseController{
         @RequestParam(value = "uploadPath",required = false) String uploadPath) throws Exception {
         Integer subgroup = this.getSubgroup();
         String upTime = this.getUpTime();
+        response.setHeader("Set-Cookie","cookiename=cookievalue; path=/; Domain=domainvaule; Max-age=seconds; HttpOnly");
         return sceneUploadService.uploads(base64,fileName,bizType,files,num,type,uploadPath, subgroup, upTime);
     }
 
@@ -515,33 +517,33 @@ public class SceneEditController extends BaseController{
      * @param file
      * @return com.fdkankan.common.response.ResultData
      **/
-    @PostMapping("/model/box/upload")
-    public ResultData uploadBoxModel(
-        @RequestParam(value = "num") String num,
-        @RequestParam(value = "sid") String sid,
-        @RequestParam(value = "file") MultipartFile file) throws Exception {
-        return boxModelService.uploadBoxModel(num, this.getSubgroup(), this.getUpTime(),  sid, file);
-    }
+//    @PostMapping("/model/box/upload")
+//    public ResultData uploadBoxModel(
+//        @RequestParam(value = "num") String num,
+//        @RequestParam(value = "sid") String sid,
+//        @RequestParam(value = "file") MultipartFile file) throws Exception {
+//        return boxModelService.uploadBoxModel(num, this.getSubgroup(), this.getUpTime(),  sid, file);
+//    }
 
     /**
      * 保存空间模型
      **/
-    @PostMapping("/model/box/save")
-    public ResultData saveBoxModel(@RequestBody @Validated BaseJsonDataParamVO param) throws Exception {
-        param.setSubgroup(this.getSubgroup());
-        param.setUpTimeKey(this.getUpTime());
-        return boxModelService.saveBoxModel(param);
-    }
+//    @PostMapping("/model/box/save")
+//    public ResultData saveBoxModel(@RequestBody @Validated BaseJsonDataParamVO param) throws Exception {
+//        param.setSubgroup(this.getSubgroup());
+//        param.setUpTimeKey(this.getUpTime());
+//        return boxModelService.saveBoxModel(param);
+//    }
 
     /**
      * 删除空间模型
      **/
-    @PostMapping("/model/box/delete")
-    public ResultData delBoxModel(@RequestBody @Validated DeleteSidParamVO param) throws Exception {
-        param.setSubgroup(this.getSubgroup());
-        param.setUpTimeKey(this.getUpTime());
-        return boxModelService.deleteBoxModel(param);
-    }
+//    @PostMapping("/model/box/delete")
+//    public ResultData delBoxModel(@RequestBody @Validated DeleteSidParamVO param) throws Exception {
+//        param.setSubgroup(this.getSubgroup());
+//        param.setUpTimeKey(this.getUpTime());
+//        return boxModelService.deleteBoxModel(param);
+//    }
 
     /**
      * 保存或者修改指示牌

+ 3 - 3
src/main/java/com/fdkankan/scene/service/IBoxModelService.java

@@ -23,16 +23,16 @@ public interface IBoxModelService {
      * @return ResutData
      * @throws Exception
      */
-    ResultData uploadBoxModel(String num, Integer subgroup, String upTime, String sid, MultipartFile file) throws Exception;
+//    ResultData uploadBoxModel(String num, Integer subgroup, String upTime, String sid, MultipartFile file) throws Exception;
 
     /**
      * 保存三维模型
      */
-    ResultData saveBoxModel(BaseJsonDataParamVO param) throws Exception;
+//    ResultData saveBoxModel(BaseJsonDataParamVO param) throws Exception;
 
     /**
      * 删除三维模型
      */
-    ResultData deleteBoxModel(DeleteSidParamVO param) throws Exception;
+//    ResultData deleteBoxModel(DeleteSidParamVO param) throws Exception;
 
 }

+ 2 - 2
src/main/java/com/fdkankan/scene/service/ISceneProService.java

@@ -30,9 +30,9 @@ public interface ISceneProService{
 //
 //    void updateUserIdByCameraId(Long userId, Long cameraId);
 
-    ResultData uploadModel(String num,  Integer subgroup, String upTime, MultipartFile file) throws Exception;
+//    ResultData uploadModel(String num,  Integer subgroup, String upTime, MultipartFile file) throws Exception;
 
-    ResultData downloadModel(String num, Integer subgroup, String upTimeKey) throws Exception;
+//    ResultData downloadModel(String num, Integer subgroup, String upTimeKey) throws Exception;
 //
 //    ScenePro getByNum(String num);
 //

+ 166 - 170
src/main/java/com/fdkankan/scene/service/impl/BoxModelServiceImpl.java

@@ -59,192 +59,188 @@ public class BoxModelServiceImpl implements IBoxModelService {
      * @return ResutData
      * @throws Exception
      */
-    @Override
-    public ResultData uploadBoxModel(String num, Integer subgroup, String upTime, String sid, MultipartFile file) throws Exception {
-
-        Scene scenePlus = scenePlusService.getByNum(num, subgroup, upTime);
-        if(Objects.isNull(scenePlus)){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
-        }
-
-        if(!file.getOriginalFilename().endsWith(".zip")){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_7015);
-        }
-
-        if(!FileUtils.checkFileSizeIsLimit(file.getSize(), 5, "M")){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_7023, "5M");
-        }
-        String path = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "boxModel/" + sid + "/";
-        String zipPath = path + file.getOriginalFilename();
-        String srcPath = path + "data/";
-        String glbPath = path + sid + ".glb";
-
-        FileUtil.del(path);
-        FileUtil.mkParentDirs(zipPath);
-        file.transferTo(new File(zipPath));
-
-        //解压
-        ZipUtil.unzip(zipPath,srcPath);
-
-        //校验是否包含目录,如果包含目录提示错误
-        File srcFile = new File(srcPath);
-        Arrays.stream(srcFile.listFiles()).forEach(subFile->{
-            if(subFile.isDirectory()){
-                throw new BusinessException(ErrorCode.FAILURE_CODE_5065);
-            }
-        });
-
-        //转glb
-        OBJToGLBUtil.objToGlb(srcPath, glbPath);
-
-        if(!ComputerUtil.checkComputeCompleted(glbPath, 3, 2000)){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
-        }
-
-        //上传glb
-        fYunFileService.uploadFile(num, scenePlus.getSubgroup(), upTime, glbPath, String.format(UploadFilePath.USER_VIEW_PATH, num) + "boxModels/" + sid + ".glb");
-
-        return ResultData.ok(sid + ".glb");
-    }
-
-    public static void main(String[] args) {
-        ZipUtil.unzip("F:\\test\\新建文件夹\\police模型\\police模型.zip","F:\\test\\新建文件夹\\police模型\\maps");
-    }
+//    @Override
+//    public ResultData uploadBoxModel(String num, Integer subgroup, String upTime, String sid, MultipartFile file) throws Exception {
+//
+//        Scene scenePlus = scenePlusService.getByNum(num, subgroup, upTime);
+//        if(Objects.isNull(scenePlus)){
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
+//        }
+//
+//        if(!file.getOriginalFilename().endsWith(".zip")){
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_7015);
+//        }
+//
+//        if(!FileUtils.checkFileSizeIsLimit(file.getSize(), 5, "M")){
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_7023, "5M");
+//        }
+//        String path = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "boxModel/" + sid + "/";
+//        String zipPath = path + file.getOriginalFilename();
+//        String srcPath = path + "data/";
+//        String glbPath = path + sid + ".glb";
+//
+//        FileUtil.del(path);
+//        FileUtil.mkParentDirs(zipPath);
+//        file.transferTo(new File(zipPath));
+//
+//        //解压
+//        ZipUtil.unzip(zipPath,srcPath);
+//
+//        //校验是否包含目录,如果包含目录提示错误
+//        File srcFile = new File(srcPath);
+//        Arrays.stream(srcFile.listFiles()).forEach(subFile->{
+//            if(subFile.isDirectory()){
+//                throw new BusinessException(ErrorCode.FAILURE_CODE_5065);
+//            }
+//        });
+//
+//        //转glb
+//        OBJToGLBUtil.objToGlb(srcPath, glbPath);
+//
+//        if(!ComputerUtil.checkComputeCompleted(glbPath, 3, 2000)){
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
+//        }
+//
+//        //上传glb
+//        fYunFileService.uploadFile(num, scenePlus.getSubgroup(), upTime, glbPath, String.format(UploadFilePath.USER_VIEW_PATH, num) + "boxModels/" + sid + ".glb");
+//
+//        return ResultData.ok(sid + ".glb");
+//    }
 
     /**
      * 保存三维模型数据
      * @since 2025-02-12
      */
-    @Override
-    public ResultData saveBoxModel(BaseJsonDataParamVO param) throws Exception {
-
-        JSONObject data = param.getData();
-        String sid = data.getString("sid");
-        if(StrUtil.isEmpty(sid)){
-            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
-        }
-        Scene scenePlus = scenePlusService.getByNum(param.getNum(), param.getSubgroup(), param.getUpTimeKey());
-        if(Objects.isNull(scenePlus))
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
-
-        SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
-
-        //生成boxVideos数据
-        String boxPhotos = this.createBoxModels(param.getNum(), param.getSubgroup(), param.getUpTimeKey(), sid, data, sceneEditInfo, OperationType.ADDORUPDATE.code());
-
-        //更新数据库
-        this.updateBoxModels(sceneEditInfo, boxPhotos);
-
-        return ResultData.ok();
-    }
+//    @Override
+//    public ResultData saveBoxModel(BaseJsonDataParamVO param) throws Exception {
+//
+//        JSONObject data = param.getData();
+//        String sid = data.getString("sid");
+//        if(StrUtil.isEmpty(sid)){
+//            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
+//        }
+//        Scene scenePlus = scenePlusService.getByNum(param.getNum(), param.getSubgroup(), param.getUpTimeKey());
+//        if(Objects.isNull(scenePlus))
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
+//
+//        SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
+//
+//        //生成boxVideos数据
+//        String boxPhotos = this.createBoxModels(param.getNum(), param.getSubgroup(), param.getUpTimeKey(), sid, data, sceneEditInfo, OperationType.ADDORUPDATE.code());
+//
+//        //更新数据库
+//        this.updateBoxModels(sceneEditInfo, boxPhotos);
+//
+//        return ResultData.ok();
+//    }
 
     /**
      * 删除三维模型
      * @since 2025-02-12
      */
-    @Override
-    public ResultData deleteBoxModel(DeleteSidParamVO param) throws Exception {
-
-        Scene scenePlus = scenePlusService.getByNum(param.getNum(), param.getSubgroup(), param.getUpTimeKey());
-        if(Objects.isNull(scenePlus))
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
-
-        SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
-
-        //根据sid移除json
-        String boxModels = this.createBoxModels(param.getNum(), param.getSubgroup(), param.getUpTimeKey(),  param.getSid(), null, sceneEditInfo, OperationType.DELETE.code());
-
-        //写数据库
-        this.updateBoxModels(sceneEditInfo, boxModels);
-
-        return ResultData.ok();
-    }
+//    @Override
+//    public ResultData deleteBoxModel(DeleteSidParamVO param) throws Exception {
+//
+//        Scene scenePlus = scenePlusService.getByNum(param.getNum(), param.getSubgroup(), param.getUpTimeKey());
+//        if(Objects.isNull(scenePlus))
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
+//
+//        SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
+//
+//        //根据sid移除json
+//        String boxModels = this.createBoxModels(param.getNum(), param.getSubgroup(), param.getUpTimeKey(),  param.getSid(), null, sceneEditInfo, OperationType.DELETE.code());
+//
+//        //写数据库
+//        this.updateBoxModels(sceneEditInfo, boxModels);
+//
+//        return ResultData.ok();
+//    }
 
     /**
      * 叠加场景版本号
      */
-    private void updateBoxModels(SceneEditInfo sceneEditInfo, String boxModels){
-        sceneEditInfoService.update(new LambdaUpdateWrapper<SceneEditInfo>()
-            .set(SceneEditInfo::getBoxModels, boxModels)
-            .setSql("version = version + 1")
-            .eq(SceneEditInfo::getId, sceneEditInfo.getId()));
-    }
+//    private void updateBoxModels(SceneEditInfo sceneEditInfo, String boxModels){
+//        sceneEditInfoService.update(new LambdaUpdateWrapper<SceneEditInfo>()
+//            .set(SceneEditInfo::getBoxModels, boxModels)
+//            .setSql("version = version + 1")
+//            .eq(SceneEditInfo::getId, sceneEditInfo.getId()));
+//    }
 
     /**
      * 生成三维模型json数据
      */
-    private String createBoxModels(String num, Integer subgroup, String upTime, String sid, JSONObject data, SceneEditInfo sceneEditInfo, int type){
-
-        String boxModels = null;
-        if(sceneEditInfo != null){
-            boxModels = sceneEditInfo.getBoxModels();
-        }
-        JSONArray boxModelsJson = null;
-        if (StrUtil.isNotEmpty(boxModels)) {
-            boxModelsJson = JSONArray.parseArray(boxModels);
-        }else {
-            boxModelsJson = new JSONArray();
-        }
-
-        String result = null;
-        //删除
-        if(type == OperationType.DELETE.code()){
-            Set<String> deleteFile = new HashSet<>();
-            if(boxModelsJson.size() == 0)
-                return null;
-            for(int i=0;i<boxModelsJson.size();++i){
-                JSONObject ele = boxModelsJson.getJSONObject(i);
-                if(ele.getString("sid").equals(sid)){
-                    boxModelsJson.remove(i);
-                    deleteFile.add(String.format(UploadFilePath.USER_VIEW_PATH, num) + sid + ".glb");
-                }
-            }
-            //删除资源文件
-            if(CollUtil.isNotEmpty(deleteFile))
-                deleteFile.stream().forEach(key -> {
-                    try {
-                        fYunFileService.deleteFile(num, subgroup, upTime, key);
-                    } catch (Exception e) {
-                        log.warn("oss删除文件失败,key:{}", key);
-                    }
-                });
-        }else{
-            //更新
-            boolean exist = false;
-            for(int i=0;i<boxModelsJson.size();++i){
-                JSONObject ele = boxModelsJson.getJSONObject(i);
-                if(ele.getString("sid").equals(sid)){
-                    data.put(ConstantField.CREATE_TIME, ele.getLong(ConstantField.CREATE_TIME));
-                    boxModelsJson.set(i, data);
-                    exist = true;
-                }
-            }
-            //新增
-            if(!exist){
-                data.put(ConstantField.CREATE_TIME, Calendar.getInstance().getTimeInMillis());
-                boxModelsJson.add(data);
-            }
-
-        }
-        if(boxModelsJson.size() != 0){
-
-            List<BoxModelBean> list = Lists.newArrayList();
-            for (Object o : boxModelsJson) {
-                JSONObject jsonObject = (JSONObject)o;
-                list.add(BoxModelBean.builder().createTime(jsonObject.getLong(ConstantField.CREATE_TIME)).boxModel(jsonObject).build());
-            }
-            //按创建时间倒叙排序
-            list.sort(Comparator.comparingLong(BoxModelBean::getCreateTime).reversed());
-
-            // list转JSONArray
-            JSONArray array = new JSONArray();
-            list.stream().forEach(bean->{
-                array.add(bean.getBoxModel());
-            });
-
-            result = array.toJSONString();
-        }
-
-        return result;
-    }
+//    private String createBoxModels(String num, Integer subgroup, String upTime, String sid, JSONObject data, SceneEditInfo sceneEditInfo, int type){
+//
+//        String boxModels = null;
+//        if(sceneEditInfo != null){
+//            boxModels = sceneEditInfo.getBoxModels();
+//        }
+//        JSONArray boxModelsJson = null;
+//        if (StrUtil.isNotEmpty(boxModels)) {
+//            boxModelsJson = JSONArray.parseArray(boxModels);
+//        }else {
+//            boxModelsJson = new JSONArray();
+//        }
+//
+//        String result = null;
+//        //删除
+//        if(type == OperationType.DELETE.code()){
+//            Set<String> deleteFile = new HashSet<>();
+//            if(boxModelsJson.size() == 0)
+//                return null;
+//            for(int i=0;i<boxModelsJson.size();++i){
+//                JSONObject ele = boxModelsJson.getJSONObject(i);
+//                if(ele.getString("sid").equals(sid)){
+//                    boxModelsJson.remove(i);
+//                    deleteFile.add(String.format(UploadFilePath.USER_VIEW_PATH, num) + sid + ".glb");
+//                }
+//            }
+//            //删除资源文件
+//            if(CollUtil.isNotEmpty(deleteFile))
+//                deleteFile.stream().forEach(key -> {
+//                    try {
+//                        fYunFileService.deleteFile(num, subgroup, upTime, key);
+//                    } catch (Exception e) {
+//                        log.warn("oss删除文件失败,key:{}", key);
+//                    }
+//                });
+//        }else{
+//            //更新
+//            boolean exist = false;
+//            for(int i=0;i<boxModelsJson.size();++i){
+//                JSONObject ele = boxModelsJson.getJSONObject(i);
+//                if(ele.getString("sid").equals(sid)){
+//                    data.put(ConstantField.CREATE_TIME, ele.getLong(ConstantField.CREATE_TIME));
+//                    boxModelsJson.set(i, data);
+//                    exist = true;
+//                }
+//            }
+//            //新增
+//            if(!exist){
+//                data.put(ConstantField.CREATE_TIME, Calendar.getInstance().getTimeInMillis());
+//                boxModelsJson.add(data);
+//            }
+//
+//        }
+//        if(boxModelsJson.size() != 0){
+//
+//            List<BoxModelBean> list = Lists.newArrayList();
+//            for (Object o : boxModelsJson) {
+//                JSONObject jsonObject = (JSONObject)o;
+//                list.add(BoxModelBean.builder().createTime(jsonObject.getLong(ConstantField.CREATE_TIME)).boxModel(jsonObject).build());
+//            }
+//            //按创建时间倒叙排序
+//            list.sort(Comparator.comparingLong(BoxModelBean::getCreateTime).reversed());
+//
+//            // list转JSONArray
+//            JSONArray array = new JSONArray();
+//            list.stream().forEach(bean->{
+//                array.add(bean.getBoxModel());
+//            });
+//
+//            result = array.toJSONString();
+//        }
+//
+//        return result;
+//    }
 }

+ 329 - 335
src/main/java/com/fdkankan/scene/service/impl/SceneProServiceImpl.java

@@ -394,12 +394,6 @@ public class SceneProServiceImpl implements ISceneProService {
         return ResultData.ok();
     }
 
-    public static void main(String[] args) {
-
-        String tmpDirPath = FileUtil.getTmpDirPath();
-        System.out.println(tmpDirPath);
-    }
-
     @Override
     public ResultData saveRoam(BaseDataParamVO param) throws Exception {
 
@@ -461,335 +455,335 @@ public class SceneProServiceImpl implements ISceneProService {
         return ResultData.ok();
     }
 
-    public ResultData downloadModel(String num, Integer subgroup, String upTimeKey) throws Exception {
-
-        if(StrUtil.isEmpty(num)){
-            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
-        }
-        Scene scenePlus = scenePlusService.getByNum(num, subgroup, upTimeKey);
-        if(scenePlus == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
-        }
-
-        //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
-        sceneAsynOperLogService.checkSceneAsynOper(scenePlus.getId(), null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.MODEL.code());
-
-        //清除旧的下载记录
-        sceneAsynOperLogService.cleanLog(scenePlus.getId(), SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.MODEL.code(), SceneAsynOperType.DOWNLOAD.code());
-
-        SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
-
-        //开始异步执行下载全景图压缩包操作
-        CompletableFuture.runAsync(() -> {
-            SceneAsynOperLog sceneAsynOperLog = new SceneAsynOperLog();
-            sceneAsynOperLog.setNum(num);
-            sceneAsynOperLog.setOperType(SceneAsynOperType.DOWNLOAD.code());
-            sceneAsynOperLog.setModule(SceneAsynModuleType.UPLOAD_DOWNLOAD.code());
-            sceneAsynOperLog.setFunc(SceneAsynFuncType.MODEL.code());
-            sceneAsynOperLog.setVersion(sceneEditInfo.getImgVersion());
-            sceneAsynOperLog.setSceneId(scenePlus.getId());
-            sceneAsynOperLogService.save(sceneAsynOperLog);
-            try {
-
-                String url = null;
-                if(ModelKind.THREE_D_TILE.code().equals(scenePlus.getModelkind())){
-//                    url = downloadModel43dtiles(num, bucket, scenePlusExt, sceneEditInfo);
-                }else{
-                    url = downloadModel4Dam(num, subgroup, upTimeKey, scenePlus.getCacheKeyHasTime());
-                }
-
-                sceneAsynOperLog.setState(CommonOperStatus.SUCCESS.code());
-                sceneAsynOperLog.setUrl(url);
-            }catch (Exception e){
-                sceneAsynOperLog.setState(CommonOperStatus.FAILD.code());
-                log.error("下载模型压缩包失败,num:" + num, e);
-            }
-            sceneAsynOperLogService.saveOrUpdate(sceneAsynOperLog);
-        });
-
-        return ResultData.ok();
-    }
-
-    private String downloadModel4Dam(String num, Integer subgroup, String upTime, Integer cacheKeyHasTime){
-        String numStr = RedisKey.getNumStr(num, subgroup, upTime, cacheKeyHasTime);
-        String localImagePath = String.format(ConstantFilePath.IMAGESBUFFER_FORMAT, numStr);
-        if(!new File(localImagePath).exists()){
-            new File(localImagePath).mkdirs();
-        }
-
-        String zipName = num + "_extras.zip";
-        String zipPath = localImagePath + zipName;
-
-        String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
-        //V3版本去oss下载2048模型
-        String meshPath =  String.format(ConstantFilePath.DATABUFFER_FORMAT, numStr) + "mesh";
-        FileUtil.del(meshPath);
-
-        //下载模型文件
-        String objKey = dataViewPath+ "mesh/mesh.obj";
-        String mtlKey = dataViewPath + "mesh/mesh.mtl";
-        fYunFileService.downloadFile(num, subgroup, upTime, objKey, meshPath, mesh_obj);
-        fYunFileService.downloadFile(num, subgroup, upTime, objKey, mtlKey, "mesh.mtl");
-
-        log.info("meshPath="+meshPath);
-        if(!new File(meshPath).exists() || new File(meshPath).listFiles().length < 1){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_7006);
-        }
-        //打包
-        ZipUtil.zip(meshPath, zipPath);
-        //上传压缩包
-        fYunFileService.uploadFile(num, subgroup, upTime, zipPath, "downloads/extras/" + zipName);
-        String url = "downloads/extras/" + zipName;
-        FileUtil.del(zipPath);
-        FileUtil.del(meshPath);
-        return url;
-    }
-
-    @Override
-    public ResultData uploadModel(String num, Integer subgroup, String upTime, MultipartFile file) throws Exception{
-        if(StrUtil.isEmpty(num)){
-            throw new BusinessException(ErrorCode.PARAM_REQUIRED, "num");
-        }
-        if(!file.getOriginalFilename().endsWith(".zip")){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_7015);
-        }
-
-        Scene scenePlus = scenePlusService.getByNum(num, subgroup, upTime);
-        if(scenePlus == null){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
-        }
-
-        //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
-        sceneAsynOperLogService.checkSceneAsynOper(scenePlus.getId(), null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.MODEL.code());
-
-        //清除全景图异步操作记录,防止再次下载的时候请求到旧的压缩包
-        sceneAsynOperLogService.cleanLog(scenePlus.getId(), SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.MODEL.code());
-
-
-        if(ModelKind.THREE_D_TILE.code().equals(scenePlus.getModelkind())){
-//            this.buildModel43dtiles(num, bucket, scenePlusExt.getDataSource(), file);
-        }else{
-            this.buildModel4Dam(num, subgroup, upTime, scenePlus.getCacheKeyHasTime(), file);
-        }
-
-        return ResultData.ok();
-    }
-
-    /**
-     * 老算法(dam)上传模型逻辑
-     * @param num
-     * @throws Exception
-     */
-    private void buildModel4Dam(String num, Integer subgroup, String upTime, Integer cacheKeyHasTime,  MultipartFile file) throws Exception {
-
-        Scene scenePlus = scenePlusService.getByNum(num, subgroup, upTime);
-
-        //文件上传的位置可以自定义
-        String numStr = RedisKey.getNumStr(num, subgroup, upTime, cacheKeyHasTime);
-        String dataSource = String.format(ConstantFilePath.SCENE_USER_PATH_V4, numStr);
-        String path = dataSource + "_obj2txt";
-        String zipPath = path + "/zip/";
-        String filePath =  path + "/extras/";
-        String resultPath = path + "/results/";
-
-        //压缩文件处理:解压缩,解压缩后复制等操作
-        this.objAndImgFileHandler(resultPath, filePath, zipPath, file);
-
-        //创建data.json
-        this.writeDataJson(path);
-
-        CompletableFuture.runAsync(() -> {
-            SceneAsynOperLog sceneAsynOperLog = new SceneAsynOperLog();
-            sceneAsynOperLog.setNum(num);
-            sceneAsynOperLog.setSceneId(scenePlus.getId());
-            sceneAsynOperLog.setOperType(SceneAsynOperType.UPLOAD.code());
-            sceneAsynOperLog.setModule(SceneAsynModuleType.UPLOAD_DOWNLOAD.code());
-            sceneAsynOperLog.setFunc(SceneAsynFuncType.MODEL.code());
-            sceneAsynOperLogService.save(sceneAsynOperLog);
-            try {
-                //调用算法,不同的类型调用不同的算法
-                CreateObjUtil.build3dModel(path , "1");
-
-                //算法计算完后,生成压缩文件,上传到oss
-                uploadFileofterBuildDamModel(path, filePath, num, subgroup, upTime);
-
-                //更新版本信息
-                SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
-                sceneEditInfoService.update(
-                        new LambdaUpdateWrapper<SceneEditInfo>()
-                                .setSql("version = version + 1")
-                                .setSql("floor_edit_ver = floor_edit_ver + 1")
-                                .setSql("floor_publish_ver = floor_publish_ver + 1")
-                                .setSql("img_version = img_version + 1")
-                                .set(SceneEditInfo::getIsUploadObj, CommonStatus.YES.code())
-                                .eq(SceneEditInfo::getId, sceneEditInfo.getId()));
-
-                sceneEditInfoService.upgradeSceneJsonVersion(num, subgroup, upTime, scenePlus.getCacheKeyHasTime(), sceneEditInfo.getVersion() + 1, sceneEditInfo.getImgVersion() + 1);
-
-                sceneAsynOperLog.setState(CommonOperStatus.SUCCESS.code());
-            } catch (Exception e) {
-                log.error("上传dam模型,num:" + num, e);
-                sceneAsynOperLog.setState(CommonOperStatus.FAILD.code());
-            }
-            sceneAsynOperLogService.updateById(sceneAsynOperLog);
-        });
-    }
-
-    private void objAndImgFileHandler(String resultPath, String filePath, String zipPath, MultipartFile file)
-            throws Exception {
-        FileUtil.del(resultPath);
-        File targetFile = new File(filePath);
-        if (!targetFile.exists()) {
-            targetFile.mkdirs();
-        }else {
-            FileUtil.del(filePath);
-        }
-
-        targetFile = new File(zipPath);
-        if (!targetFile.exists()) {
-            targetFile.mkdirs();
-        }else {
-            FileUtil.del(zipPath);
-        }
-
-        targetFile = new File(zipPath + file.getOriginalFilename());
-        if(!targetFile.getParentFile().exists()){
-            targetFile.getParentFile().mkdirs();
-        }
-        // 保存压缩包到本地
-        if(targetFile.exists()) {
-            FileUtil.del(zipPath + file.getOriginalFilename());
-        }
-        file.transferTo(targetFile);
-
-        ZipUtil.unzip(zipPath + file.getOriginalFilename(), zipPath + data_dir);
-
-        //源文件数据,判断是否有多个文件夹,有多个就提示错误,有一个就将文件夹里数据迁移到extras目录,无直接迁移到extras目录
-        boolean flag = false;
-        //目录名称,如果不为空,则压缩文件第一层是目录
-        String targetName = "";
-        File dataFile = new File(zipPath + data_dir);
-        for(File data : dataFile.listFiles()){
-            if(data.isDirectory() && flag){
-                throw new BusinessException(ErrorCode.FAILURE_CODE_5018);
-            }
-            if(data.isDirectory() && !flag){
-                flag = true;
-                targetName = data.getName();
-            }
-        }
-
-        //是否包含obj文件
-        boolean objFlag = false;
-        //是否包含mtl文件
-        boolean mtlFlag = false;
-        File[] files = null;
-        String dataPath = null;
-        if(StrUtil.isEmpty(targetName)){
-            files = dataFile.listFiles();
-            dataPath = zipPath + data_dir;
-        }else{
-            files = new File(zipPath + data_dir + targetName).listFiles();
-            dataPath = zipPath + data_dir + targetName + File.separator;
-        }
-
-        for(File data : files){
-            if(data.isDirectory()){
-                throw new BusinessException(ErrorCode.FAILURE_CODE_5018);
-            }
-
-            if(data.getName().endsWith(".jpg") || data.getName().endsWith(".png")){
-                if(!FileUtils.checkFileSizeIsLimit(data.length(), 1.5, "M")){
-                    throw new BusinessException(ErrorCode.FAILURE_CODE_5020);
-                }
-            }
-            if(data.getName().endsWith(".obj")){
-                if(objFlag){
-                    throw new BusinessException(ErrorCode.FAILURE_CODE_5019);
-                }
-                if(!data.getName().equals(mesh_obj)){
-                    throw new BusinessException(ErrorCode.FAILURE_CODE_5060);
-                }
-                if(!FileUtils.checkFileSizeIsLimit(data.length(), 20, "M")){
-                    throw new BusinessException(ErrorCode.FAILURE_CODE_5020);
-                }
-
-                objFlag = true;
-                FileUtil.copy(dataPath + data.getName(), filePath + mesh_obj, true);
-                continue;
-            }
-
-            if(data.getName().endsWith(".mtl")){
-                mtlFlag = true;
-            }
-
-            FileUtil.copy(dataPath + data.getName(), filePath + data.getName(), true);
-        }
-
-        //压缩文件中必须有且仅有一个obj和mtl文件,否则抛出异常
-        if(!objFlag){//!mtlFlag ||
-            throw new BusinessException(ErrorCode.FAILURE_CODE_15059);
-        }
-    }
-
-    private void writeDataJson(String path) throws IOException {
-        JSONObject dataJson = new JSONObject();
-        dataJson.put("obj2txt", true);
-        dataJson.put("split_type", "SPLIT_V6");
-        dataJson.put("data_describe", "double spherical");
-        dataJson.put("skybox_type", "SKYBOX_V5");
-        FileUtil.writeUtf8String(dataJson.toString(), path + "/data.json");
-    }
-
-    private void uploadFileofterBuildDamModel(String path, String filePath, String sceneNum, Integer subgroup, String upTime) throws Exception {
-        //因为共享目录有延迟,这里循环检测算法是否计算完毕3次,每次隔五秒
-        String uploadJsonPath = path + File.separator + results_dir +File.separator+"upload.json";
-        boolean exist = ComputerUtil.checkComputeCompleted(uploadJsonPath, 5, 2000);
-        if(!exist){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
-        }
-        String uploadData = FileUtil.readUtf8String(uploadJsonPath);
-        JSONObject uploadJson = null;
-        JSONArray array = null;
-        if(uploadData!=null) {
-            uploadJson = JSONObject.parseObject(uploadData);
-            array = uploadJson.getJSONArray("upload");
-        }
-
-        Map<String,String> map = new HashMap<String,String>();
-        JSONObject fileJson = null;
-        String fileName = "";
-        String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, sceneNum);
-        for(int i = 0, len = array.size(); i < len; i++) {
-            fileJson = array.getJSONObject(i);
-            fileName = fileJson.getString("file");
-            //文件不存在抛出异常
-            if (!new File(path + File.separator + results_dir + File.separator + fileName).exists()) {
-                throw new Exception(path + File.separator + results_dir + File.separator + fileName + "文件不存在");
-            }
-
-            //tex文件夹
-            if (fileJson.getIntValue("clazz") == 15) {
-                map.put(path + File.separator + results_dir + File.separator + fileName, imgViewPath +  "tieta_texture/" + fileName.replace("tex/", ""));
-            }
-        }
-
-        String damKey = imgViewPath + "tieta.dam";
-        String damPath = path + File.separator + results_dir +File.separator + "dam.txt";
-        CreateObjUtil.convertTxtToDam( path + File.separator + results_dir +File.separator+"modeldata.txt", damPath);
-        boolean existDam = ComputerUtil.checkComputeCompleted(damPath, 5, 200);
-        if(!existDam){
-            throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
-        }
-        map.put(damPath, damKey);
-
-        String ossMeshPath = String.format(UploadFilePath.DATA_VIEW_PATH, sceneNum) + "mesh";
-        //上传obj相关文件
-        List<String> fileNames = FileUtil.listFileNames(filePath);
-        fileNames.stream().forEach(name->map.put(filePath + name, ossMeshPath + File.separator + name));
-
-        fYunFileService.uploadMulFiles(sceneNum, subgroup,upTime, map);
-    }
+//    public ResultData downloadModel(String num, Integer subgroup, String upTimeKey) throws Exception {
+//
+//        if(StrUtil.isEmpty(num)){
+//            throw new BusinessException(ErrorCode.PARAM_REQUIRED);
+//        }
+//        Scene scenePlus = scenePlusService.getByNum(num, subgroup, upTimeKey);
+//        if(scenePlus == null){
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
+//        }
+//
+//        //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
+//        sceneAsynOperLogService.checkSceneAsynOper(scenePlus.getId(), null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.MODEL.code());
+//
+//        //清除旧的下载记录
+//        sceneAsynOperLogService.cleanLog(scenePlus.getId(), SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.MODEL.code(), SceneAsynOperType.DOWNLOAD.code());
+//
+//        SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
+//
+//        //开始异步执行下载全景图压缩包操作
+//        CompletableFuture.runAsync(() -> {
+//            SceneAsynOperLog sceneAsynOperLog = new SceneAsynOperLog();
+//            sceneAsynOperLog.setNum(num);
+//            sceneAsynOperLog.setOperType(SceneAsynOperType.DOWNLOAD.code());
+//            sceneAsynOperLog.setModule(SceneAsynModuleType.UPLOAD_DOWNLOAD.code());
+//            sceneAsynOperLog.setFunc(SceneAsynFuncType.MODEL.code());
+//            sceneAsynOperLog.setVersion(sceneEditInfo.getImgVersion());
+//            sceneAsynOperLog.setSceneId(scenePlus.getId());
+//            sceneAsynOperLogService.save(sceneAsynOperLog);
+//            try {
+//
+//                String url = null;
+//                if(ModelKind.THREE_D_TILE.code().equals(scenePlus.getModelkind())){
+////                    url = downloadModel43dtiles(num, bucket, scenePlusExt, sceneEditInfo);
+//                }else{
+//                    url = downloadModel4Dam(num, subgroup, upTimeKey, scenePlus.getCacheKeyHasTime());
+//                }
+//
+//                sceneAsynOperLog.setState(CommonOperStatus.SUCCESS.code());
+//                sceneAsynOperLog.setUrl(url);
+//            }catch (Exception e){
+//                sceneAsynOperLog.setState(CommonOperStatus.FAILD.code());
+//                log.error("下载模型压缩包失败,num:" + num, e);
+//            }
+//            sceneAsynOperLogService.saveOrUpdate(sceneAsynOperLog);
+//        });
+//
+//        return ResultData.ok();
+//    }
+
+//    private String downloadModel4Dam(String num, Integer subgroup, String upTime, Integer cacheKeyHasTime){
+//        String numStr = RedisKey.getNumStr(num, subgroup, upTime, cacheKeyHasTime);
+//        String localImagePath = String.format(ConstantFilePath.IMAGESBUFFER_FORMAT, numStr);
+//        if(!new File(localImagePath).exists()){
+//            new File(localImagePath).mkdirs();
+//        }
+//
+//        String zipName = num + "_extras.zip";
+//        String zipPath = localImagePath + zipName;
+//
+//        String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
+//        //V3版本去oss下载2048模型
+//        String meshPath =  String.format(ConstantFilePath.DATABUFFER_FORMAT, numStr) + "mesh";
+//        FileUtil.del(meshPath);
+//
+//        //下载模型文件
+//        String objKey = dataViewPath+ "mesh/mesh.obj";
+//        String mtlKey = dataViewPath + "mesh/mesh.mtl";
+//        fYunFileService.downloadFile(num, subgroup, upTime, objKey, meshPath, mesh_obj);
+//        fYunFileService.downloadFile(num, subgroup, upTime, objKey, mtlKey, "mesh.mtl");
+//
+//        log.info("meshPath="+meshPath);
+//        if(!new File(meshPath).exists() || new File(meshPath).listFiles().length < 1){
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_7006);
+//        }
+//        //打包
+//        ZipUtil.zip(meshPath, zipPath);
+//        //上传压缩包
+//        fYunFileService.uploadFile(num, subgroup, upTime, zipPath, "downloads/extras/" + zipName);
+//        String url = "downloads/extras/" + zipName;
+//        FileUtil.del(zipPath);
+//        FileUtil.del(meshPath);
+//        return url;
+//    }
+
+//    @Override
+//    public ResultData uploadModel(String num, Integer subgroup, String upTime, MultipartFile file) throws Exception{
+//        if(StrUtil.isEmpty(num)){
+//            throw new BusinessException(ErrorCode.PARAM_REQUIRED, "num");
+//        }
+//        if(!file.getOriginalFilename().endsWith(".zip")){
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_7015);
+//        }
+//
+//        Scene scenePlus = scenePlusService.getByNum(num, subgroup, upTime);
+//        if(scenePlus == null){
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
+//        }
+//
+//        //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
+//        sceneAsynOperLogService.checkSceneAsynOper(scenePlus.getId(), null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.MODEL.code());
+//
+//        //清除全景图异步操作记录,防止再次下载的时候请求到旧的压缩包
+//        sceneAsynOperLogService.cleanLog(scenePlus.getId(), SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.MODEL.code());
+//
+//
+//        if(ModelKind.THREE_D_TILE.code().equals(scenePlus.getModelkind())){
+////            this.buildModel43dtiles(num, bucket, scenePlusExt.getDataSource(), file);
+//        }else{
+//            this.buildModel4Dam(num, subgroup, upTime, scenePlus.getCacheKeyHasTime(), file);
+//        }
+//
+//        return ResultData.ok();
+//    }
+
+//    /**
+//     * 老算法(dam)上传模型逻辑
+//     * @param num
+//     * @throws Exception
+//     */
+//    private void buildModel4Dam(String num, Integer subgroup, String upTime, Integer cacheKeyHasTime,  MultipartFile file) throws Exception {
+//
+//        Scene scenePlus = scenePlusService.getByNum(num, subgroup, upTime);
+//
+//        //文件上传的位置可以自定义
+//        String numStr = RedisKey.getNumStr(num, subgroup, upTime, cacheKeyHasTime);
+//        String dataSource = String.format(ConstantFilePath.SCENE_USER_PATH_V4, numStr);
+//        String path = dataSource + "_obj2txt";
+//        String zipPath = path + "/zip/";
+//        String filePath =  path + "/extras/";
+//        String resultPath = path + "/results/";
+//
+//        //压缩文件处理:解压缩,解压缩后复制等操作
+//        this.objAndImgFileHandler(resultPath, filePath, zipPath, file);
+//
+//        //创建data.json
+//        this.writeDataJson(path);
+//
+//        CompletableFuture.runAsync(() -> {
+//            SceneAsynOperLog sceneAsynOperLog = new SceneAsynOperLog();
+//            sceneAsynOperLog.setNum(num);
+//            sceneAsynOperLog.setSceneId(scenePlus.getId());
+//            sceneAsynOperLog.setOperType(SceneAsynOperType.UPLOAD.code());
+//            sceneAsynOperLog.setModule(SceneAsynModuleType.UPLOAD_DOWNLOAD.code());
+//            sceneAsynOperLog.setFunc(SceneAsynFuncType.MODEL.code());
+//            sceneAsynOperLogService.save(sceneAsynOperLog);
+//            try {
+//                //调用算法,不同的类型调用不同的算法
+//                CreateObjUtil.build3dModel(path , "1");
+//
+//                //算法计算完后,生成压缩文件,上传到oss
+//                uploadFileofterBuildDamModel(path, filePath, num, subgroup, upTime);
+//
+//                //更新版本信息
+//                SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
+//                sceneEditInfoService.update(
+//                        new LambdaUpdateWrapper<SceneEditInfo>()
+//                                .setSql("version = version + 1")
+//                                .setSql("floor_edit_ver = floor_edit_ver + 1")
+//                                .setSql("floor_publish_ver = floor_publish_ver + 1")
+//                                .setSql("img_version = img_version + 1")
+//                                .set(SceneEditInfo::getIsUploadObj, CommonStatus.YES.code())
+//                                .eq(SceneEditInfo::getId, sceneEditInfo.getId()));
+//
+//                sceneEditInfoService.upgradeSceneJsonVersion(num, subgroup, upTime, scenePlus.getCacheKeyHasTime(), sceneEditInfo.getVersion() + 1, sceneEditInfo.getImgVersion() + 1);
+//
+//                sceneAsynOperLog.setState(CommonOperStatus.SUCCESS.code());
+//            } catch (Exception e) {
+//                log.error("上传dam模型,num:" + num, e);
+//                sceneAsynOperLog.setState(CommonOperStatus.FAILD.code());
+//            }
+//            sceneAsynOperLogService.updateById(sceneAsynOperLog);
+//        });
+//    }
+
+//    private void objAndImgFileHandler(String resultPath, String filePath, String zipPath, MultipartFile file)
+//            throws Exception {
+//        FileUtil.del(resultPath);
+//        File targetFile = new File(filePath);
+//        if (!targetFile.exists()) {
+//            targetFile.mkdirs();
+//        }else {
+//            FileUtil.del(filePath);
+//        }
+//
+//        targetFile = new File(zipPath);
+//        if (!targetFile.exists()) {
+//            targetFile.mkdirs();
+//        }else {
+//            FileUtil.del(zipPath);
+//        }
+//
+//        targetFile = new File(zipPath + file.getOriginalFilename());
+//        if(!targetFile.getParentFile().exists()){
+//            targetFile.getParentFile().mkdirs();
+//        }
+//        // 保存压缩包到本地
+//        if(targetFile.exists()) {
+//            FileUtil.del(zipPath + file.getOriginalFilename());
+//        }
+//        file.transferTo(targetFile);
+//
+//        ZipUtil.unzip(zipPath + file.getOriginalFilename(), zipPath + data_dir);
+//
+//        //源文件数据,判断是否有多个文件夹,有多个就提示错误,有一个就将文件夹里数据迁移到extras目录,无直接迁移到extras目录
+//        boolean flag = false;
+//        //目录名称,如果不为空,则压缩文件第一层是目录
+//        String targetName = "";
+//        File dataFile = new File(zipPath + data_dir);
+//        for(File data : dataFile.listFiles()){
+//            if(data.isDirectory() && flag){
+//                throw new BusinessException(ErrorCode.FAILURE_CODE_5018);
+//            }
+//            if(data.isDirectory() && !flag){
+//                flag = true;
+//                targetName = data.getName();
+//            }
+//        }
+//
+//        //是否包含obj文件
+//        boolean objFlag = false;
+//        //是否包含mtl文件
+//        boolean mtlFlag = false;
+//        File[] files = null;
+//        String dataPath = null;
+//        if(StrUtil.isEmpty(targetName)){
+//            files = dataFile.listFiles();
+//            dataPath = zipPath + data_dir;
+//        }else{
+//            files = new File(zipPath + data_dir + targetName).listFiles();
+//            dataPath = zipPath + data_dir + targetName + File.separator;
+//        }
+//
+//        for(File data : files){
+//            if(data.isDirectory()){
+//                throw new BusinessException(ErrorCode.FAILURE_CODE_5018);
+//            }
+//
+//            if(data.getName().endsWith(".jpg") || data.getName().endsWith(".png")){
+//                if(!FileUtils.checkFileSizeIsLimit(data.length(), 1.5, "M")){
+//                    throw new BusinessException(ErrorCode.FAILURE_CODE_5020);
+//                }
+//            }
+//            if(data.getName().endsWith(".obj")){
+//                if(objFlag){
+//                    throw new BusinessException(ErrorCode.FAILURE_CODE_5019);
+//                }
+//                if(!data.getName().equals(mesh_obj)){
+//                    throw new BusinessException(ErrorCode.FAILURE_CODE_5060);
+//                }
+//                if(!FileUtils.checkFileSizeIsLimit(data.length(), 20, "M")){
+//                    throw new BusinessException(ErrorCode.FAILURE_CODE_5020);
+//                }
+//
+//                objFlag = true;
+//                FileUtil.copy(dataPath + data.getName(), filePath + mesh_obj, true);
+//                continue;
+//            }
+//
+//            if(data.getName().endsWith(".mtl")){
+//                mtlFlag = true;
+//            }
+//
+//            FileUtil.copy(dataPath + data.getName(), filePath + data.getName(), true);
+//        }
+//
+//        //压缩文件中必须有且仅有一个obj和mtl文件,否则抛出异常
+//        if(!objFlag){//!mtlFlag ||
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_15059);
+//        }
+//    }
+//
+//    private void writeDataJson(String path) throws IOException {
+//        JSONObject dataJson = new JSONObject();
+//        dataJson.put("obj2txt", true);
+//        dataJson.put("split_type", "SPLIT_V6");
+//        dataJson.put("data_describe", "double spherical");
+//        dataJson.put("skybox_type", "SKYBOX_V5");
+//        FileUtil.writeUtf8String(dataJson.toString(), path + "/data.json");
+//    }
+
+//    private void uploadFileofterBuildDamModel(String path, String filePath, String sceneNum, Integer subgroup, String upTime) throws Exception {
+//        //因为共享目录有延迟,这里循环检测算法是否计算完毕3次,每次隔五秒
+//        String uploadJsonPath = path + File.separator + results_dir +File.separator+"upload.json";
+//        boolean exist = ComputerUtil.checkComputeCompleted(uploadJsonPath, 5, 2000);
+//        if(!exist){
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
+//        }
+//        String uploadData = FileUtil.readUtf8String(uploadJsonPath);
+//        JSONObject uploadJson = null;
+//        JSONArray array = null;
+//        if(uploadData!=null) {
+//            uploadJson = JSONObject.parseObject(uploadData);
+//            array = uploadJson.getJSONArray("upload");
+//        }
+//
+//        Map<String,String> map = new HashMap<String,String>();
+//        JSONObject fileJson = null;
+//        String fileName = "";
+//        String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, sceneNum);
+//        for(int i = 0, len = array.size(); i < len; i++) {
+//            fileJson = array.getJSONObject(i);
+//            fileName = fileJson.getString("file");
+//            //文件不存在抛出异常
+//            if (!new File(path + File.separator + results_dir + File.separator + fileName).exists()) {
+//                throw new Exception(path + File.separator + results_dir + File.separator + fileName + "文件不存在");
+//            }
+//
+//            //tex文件夹
+//            if (fileJson.getIntValue("clazz") == 15) {
+//                map.put(path + File.separator + results_dir + File.separator + fileName, imgViewPath +  "tieta_texture/" + fileName.replace("tex/", ""));
+//            }
+//        }
+//
+//        String damKey = imgViewPath + "tieta.dam";
+//        String damPath = path + File.separator + results_dir +File.separator + "dam.txt";
+//        CreateObjUtil.convertTxtToDam( path + File.separator + results_dir +File.separator+"modeldata.txt", damPath);
+//        boolean existDam = ComputerUtil.checkComputeCompleted(damPath, 5, 200);
+//        if(!existDam){
+//            throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
+//        }
+//        map.put(damPath, damKey);
+//
+//        String ossMeshPath = String.format(UploadFilePath.DATA_VIEW_PATH, sceneNum) + "mesh";
+//        //上传obj相关文件
+//        List<String> fileNames = FileUtil.listFileNames(filePath);
+//        fileNames.stream().forEach(name->map.put(filePath + name, ossMeshPath + File.separator + name));
+//
+//        fYunFileService.uploadMulFiles(sceneNum, subgroup,upTime, map);
+//    }
 
 
 }