Kaynağa Gözat

场景中心代码迁移

by su 3 yıl önce
ebeveyn
işleme
a28957382c

+ 45 - 344
4dkankan-center-scene/src/main/java/com/fdkankan/scene/controller/SceneFileController.java

@@ -166,359 +166,60 @@ public class SceneFileController extends BaseController {
      */
      */
     @PostMapping("uploadSuccess")
     @PostMapping("uploadSuccess")
     public ResultData uploadSuccess(String params) throws Exception {
     public ResultData uploadSuccess(String params) throws Exception {
-        log.info("uploadSuccess-params: " + params);
-        if (StrUtil.isEmpty(params)) {
-            throw new BaseRuntimeException("params为空。");
-        }
-        params = params.replaceAll("%2B", "+");
-        Base64 base64 = new Base64();
-        String cipher = params;
-        // 私钥解密过程
-        byte[] res = RSAEncrypt.decrypt(RSAEncrypt.loadPrivateKeyByStr(RSAEncrypt.loadPrivateKeyByFile()),
-                base64.decode(cipher));
-        String restr = new String(res, "UTF-8");
-        log.debug("uploadSuccess-params解密结果:" + restr);
-        String[] strArr = restr.split(splice);
-        if (strArr.length != 3) {
-            throw new BaseRuntimeException("缺少必要参数。");
-        }
-        String mac = strArr[0];
-        String fileId = strArr[1];
-        String folderName = JedisUtil.getStringValue(fileId);
-        if(StringUtils.isEmpty(folderName)){
-            SceneProEntity sceneProEntity = sceneProService.getSceneStatusByUnicode("/" + fileId + "/", "A");
-            if(sceneProEntity != null){
-                folderName = sceneProEntity.getDataSource().substring(sceneProEntity.getDataSource().lastIndexOf("/") + 1);
-            }
-
-            if(StringUtils.isEmpty(folderName)){
-                SceneFileBuildEntity sceneFileBuildEntity = sceneFileBuildService.findByFileId(fileId);
-                if(sceneFileBuildEntity != null){
-                    folderName = sceneFileBuildEntity.getUnicode();
-                }
-            }
-        }
-        StringBuilder filePathBuffer = new StringBuilder(routeConfig.getHardDisk()).append(mac).append(File.separator).append(fileId).append(File.separator).append(folderName).append(File.separator).append("capture").append(File.separator);
-        boolean flag = sceneFileBuildService.uploadSuccess(fileId, filePathBuffer);
-
-        if(flag){
-            //调用建模的方法
-            buildScene(filePathBuffer.toString(), fileId, false, null);
-        }
-        return Result.success();
+        return sceneFileBuildService.uploadSuccess(params);
     }
     }
 
 
-//    /**
-//     * 更新fileid文件的上传状态
-//     *
-//     * @param params
-//     * @return
-//     */
-//    @PostMapping("uploadSuccessBuild")
-//    @ApiOperation("更新fileid文件的上传状态  - 后端八目上传逻辑")
-//    @ApiImplicitParam(name = "params", value = "加密参数", dataType = "String")
-//    public Result uploadSuccessBuild(String params) throws Exception {
-//        log.info("uploadSuccessBuild-params: " + params);
-//        if (StringUtils.isEmpty(params)) {
-//            throw new BaseRuntimeException("params为空。");
-//        }
-//        params = params.replaceAll("%2B", "+");
-//        Base64 base64 = new Base64();
-//        String cipher = params;
-//        // 私钥解密过程
-//        byte[] res = RSAEncrypt.decrypt(RSAEncrypt.loadPrivateKeyByStr(RSAEncrypt.loadPrivateKeyByFile()),
-//                base64.decode(cipher));
-//        String restr = new String(res, "UTF-8");
-//        log.debug("uploadSuccessBuild-params解密结果:" + restr);
-//        String[] strArr = restr.split(splice);
-//        if (strArr.length != 3) {
-//            throw new BaseRuntimeException("缺少必要参数。");
-//        }
-//        String mac = strArr[0];
-//        String fileId = strArr[1];
-//        String folderName = JedisUtil.getStringValue(fileId);
-//        if(StringUtils.isEmpty(folderName)){
-//            SceneProEntity sceneProEntity = sceneProService.getSceneStatusByUnicode("/" + fileId + "/", "A");
-//            if(sceneProEntity != null){
-//                folderName = sceneProEntity.getDataSource().substring(sceneProEntity.getDataSource().lastIndexOf("/") + 1);
-//            }
-//
-//            if(StringUtils.isEmpty(folderName)){
-//                SceneFileBuildEntity sceneFileBuildEntity = sceneFileBuildService.findByFileId(fileId);
-//                if(sceneFileBuildEntity != null){
-//                    folderName = sceneFileBuildEntity.getUnicode();
-//                }
-//            }
-//        }
-//        StringBuilder filePathBuffer = new StringBuilder(routeConfig.getHardDisk()).append(mac).append(File.separator).append(fileId).append(File.separator).append(folderName).append(File.separator).append("capture").append(File.separator);
-//        StringBuilder prefixBuffer = new StringBuilder(mac).append(File.separator).append(fileId).append(File.separator).append(folderName).append(File.separator);
-//
-//        File filePath = new File(filePathBuffer.toString());
-//        if(!filePath.exists()){
-//            filePath.mkdirs();
-//        }
-//        if("s3".equals(type)){
-//            CreateObjUtil.ossFileCp(ConstantFilePath.OSS_PREFIX + prefixBuffer.toString() + "data.fdage", filePathBuffer.toString() + "data.fdage");
-//        }else {
-//            CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + prefixBuffer.toString() + "data.fdage", filePathBuffer.toString());
-//        }
-//        buildScene(filePathBuffer.toString(), fileId, true, prefixBuffer.toString());
-//        return Result.success();
-//    }
-//
-//    /**
-//     * 更新fileid文件的上传状态
-//     *
-//     * @param params
-//     * @return
-//     */
-//    @PostMapping("turntableUploadSuccess")
-//    @ApiOperation("转台相机,激光相机")
-//    @ApiImplicitParam(name = "params", value = "加密参数", dataType = "String")
-//    public Result turntableUploadSuccess(String params) throws Exception {
-//        log.info("uploadSuccessBuild-params: " + params);
-//        if (StringUtils.isEmpty(params)) {
-//            throw new BaseRuntimeException("params为空。");
-//        }
-//        params = params.replaceAll("%2B", "+");
-//        Base64 base64 = new Base64();
-//        String cipher = params;
-//        // 私钥解密过程
-//        byte[] res = RSAEncrypt.decrypt(RSAEncrypt.loadPrivateKeyByStr(RSAEncrypt.loadPrivateKeyByFile()),
-//                base64.decode(cipher));
-//        String restr = new String(res, "UTF-8");
-//        log.debug("uploadSuccessBuild-params解密结果:" + restr);
-//        String[] strArr = restr.split(splice);
-//        if (strArr.length != 3) {
-//            throw new BaseRuntimeException("缺少必要参数。");
-//        }
-//        String mac = strArr[0];
-//        String fileId = strArr[1];
-//        String folderName = JedisUtil.getStringValue(fileId);
-//        if(StringUtils.isEmpty(folderName)){
-//            SceneProEntity sceneProEntity = sceneProService.getSceneStatusByUnicode("/" + fileId + "/", "A");
-//            if(sceneProEntity != null){
-//                folderName = sceneProEntity.getDataSource().substring(sceneProEntity.getDataSource().lastIndexOf("/") + 1);
-//            }
-//
-//            if(StringUtils.isEmpty(folderName)){
-//                SceneFileBuildEntity sceneFileBuildEntity = sceneFileBuildService.findByFileId(fileId);
-//                if(sceneFileBuildEntity != null){
-//                    folderName = sceneFileBuildEntity.getUnicode();
-//                }
-//            }
-//        }
-//        //判断 是否为激光相机
-//        CameraEntity cameraEntity = goodsService.findByChildName(mac);
-//        CameraDetailEntity cameraDetailEntity = goodsService.findCameraDetailByCameraId(cameraEntity.getId());
-//
-//        String hardDisk = routeConfig.getHardDisk();
-//        if(cameraDetailEntity!=null){
-//            if(cameraDetailEntity.getType() == 10){
-//                hardDisk = routeConfig.getHardDiskLaser();
-//            }
-//        }
-//
-//        log.info("相机 mnt 路径 : " + hardDisk + ", 相机类型 : " + cameraDetailEntity.getType());
-//
-//        StringBuilder filePathBuffer = new StringBuilder(hardDisk).append(mac).append(File.separator).append(fileId).append(File.separator).append(folderName).append(File.separator).append("capture").append(File.separator);
-//        StringBuilder prefixBuffer = new StringBuilder(mac).append(File.separator).append(fileId).append(File.separator).append(folderName).append(File.separator);
-//
-//        File filePath = new File(filePathBuffer.toString());
-//        if(!filePath.exists()){
-//            filePath.mkdirs();
-//        }
-//        if("s3".equals(type)){
-//            CreateObjUtil.ossFileCp(ConstantFilePath.OSS_PREFIX + prefixBuffer.toString() + "data.fdage", filePathBuffer.toString() + "data.fdage");
-//        }else {
-//            CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + prefixBuffer.toString() + "data.fdage", filePathBuffer.toString());
-//        }
-//        turntableBuildScene(filePathBuffer.toString(), fileId, true, prefixBuffer.toString());
-//        return Result.success();
-//    }
-//
-//    /**
-//     * 获取亚马逊S3文件上传url
-//     *
-//     * @return
-//     */
-//    @PostMapping("getS3UploadUrl")
-//    @ApiOperation("获取亚马逊S3文件上传url")
-//    @ApiImplicitParam(name = "params", value = "加密参数", dataType = "String")
-//    public Result getS3UploadUrl(String params) throws Exception {
-//        if (StringUtils.isEmpty(params)) {
-//            throw new BaseRuntimeException("params为空。");
-//        }
-//        JSONObject jsonObject = JSON.parseObject(params);
-//        if(jsonObject == null){
-//            throw new BaseRuntimeException("params数据不正确");
-//        }
-//        JSONArray files = jsonObject.getJSONArray("Files");
-//        if(files == null){
-//            throw new BaseRuntimeException("params数据不正确");
-//        }
-//        List<String> urls = new ArrayList<>();
-//        for(int i = 0, len = files.size(); i < len; i++){
-//            urls.add(files.getJSONObject(i).getString("filename"));
-//        }
-//        return Result.success(uploadToOssUtil.getUploadS3Url(urls));
-//    }
-//
-//    /**
-//     * 计算双目场景
-//     *
-//     * @return
-//     */
+    /**
+     * 更新fileid文件的上传状态  - 后端八目上传逻辑
+     *
+     * @param params
+     * @return
+     */
+    @PostMapping("uploadSuccessBuild")
+    public ResultData uploadSuccessBuild(String params) throws Exception {
+        return sceneFileBuildService.uploadSuccessBuild(params);
+    }
+
+    /**
+     * 更新fileid文件的上传状态  转台相机,激光相机
+     *
+     * @param params
+     * @return
+     */
+    @PostMapping("turntableUploadSuccess")
+    public ResultData turntableUploadSuccess(String params) throws Exception {
+        return sceneFileBuildService.turntableUploadSuccess(params);
+    }
+
+    /**
+     * 获取亚马逊S3文件上传url
+     *
+     * @return
+     */
+    @PostMapping("getS3UploadUrl")
+    public ResultData getS3UploadUrl(String params) throws Exception {
+        return sceneFileBuildService.getS3UploadUrl(params);
+    }
+
+    /**
+     * 计算双目场景 - 新双目相机上传 小红屋
+     *
+     * @return
+     */
 //    @ApiOperation("计算双目场景 - 新双目相机上传 小红屋")
 //    @ApiOperation("计算双目场景 - 新双目相机上传 小红屋")
-//    @PostMapping("buildLiteScene")
+    @PostMapping("buildLiteScene")
 //    @ApiImplicitParams({
 //    @ApiImplicitParams({
 //            @ApiImplicitParam(name = "prefix", value = "文件下载前缀,结尾不加/", dataType = "String"),
 //            @ApiImplicitParam(name = "prefix", value = "文件下载前缀,结尾不加/", dataType = "String"),
 //            @ApiImplicitParam(name = "dataFdage", value = "dataFdage", dataType = "String"),
 //            @ApiImplicitParam(name = "dataFdage", value = "dataFdage", dataType = "String"),
 //            @ApiImplicitParam(name = "zipName", value = "zip文件包名称", dataType = "String"),
 //            @ApiImplicitParam(name = "zipName", value = "zip文件包名称", dataType = "String"),
 //            @ApiImplicitParam(name = "password", value = "密码", dataType = "String"),
 //            @ApiImplicitParam(name = "password", value = "密码", dataType = "String"),
 //            @ApiImplicitParam(name = "userName", value = "用户名", dataType = "String")})
 //            @ApiImplicitParam(name = "userName", value = "用户名", dataType = "String")})
-//    public Result buildLiteScene(String prefix, String dataFdage, String zipName, String userName, String password, String oldNum) throws Exception{
-//        log.info("参数-prefix: {}, dataFdage: {}, zipName: {}, password: {}, userName: {}", prefix,
-//                dataFdage, zipName, password, userName);
-//
-//        if(StringUtils.isEmpty(prefix) || StringUtils.isEmpty(dataFdage) || StringUtils.isEmpty(zipName) ||
-//                StringUtils.isEmpty(userName) || StringUtils.isEmpty(password)){
-//            throw new BaseRuntimeException(LoginConstant.FAILURE_CODE_3001, LoginConstant.FAILURE_MSG_3001);
-//        }
-//
-//        CameraEntity cameraEntity = goodsService.findByChildName(userName);
-//
-//        if(cameraEntity == null){
-//            cameraEntity = goodsService.findBySnCode(userName);
-//        }
-//        if (cameraEntity == null){
-//            throw new BaseRuntimeException(CameraConstant.FAILURE_CODE_6003, CameraConstant.FAILURE_MSG_6003);
-//        }
-//        if(!password.equals(cameraEntity.getChildPassword())){
-//            throw new BaseRuntimeException(LoginConstant.FAILURE_CODE_3014, LoginConstant.FAILURE_MSG_3014);
-//        }
-//
-//        String unicode = prefix.substring(prefix.lastIndexOf("/") + 1);
-//        String path = ConstantFilePath.BUILD_MODEL_PATH + unicode;
-//
-//        //下载data.fdage
-//        FileUtils.downLoadFromUrl(prefix + "/" + dataFdage + "?m=" + System.currentTimeMillis(), dataFdage, path + File.separator + "capture");
-//        String data = FileUtils.readFile(path + File.separator + "capture/" + dataFdage);
-//        JSONObject jsonObject = JSONObject.parseObject(data);
-//        if(jsonObject == null){
-//            log.info("data.fdage不存在");
-//            throw new BaseRuntimeException(CameraConstant.FAILURE_CODE_6009, CameraConstant.FAILURE_MSG_6009);
-//        }
-//
-//        String sceneNum = "";
-//        //查看场景中的文件目录是否有改文件id,有则重新计算改场景,无则新建场景
-//        SceneProEntity proEntity = sceneProService.findByFileId("/" + unicode);
-//        int rebuild = 1;
-//        if(StringUtil.isNotEmpty(oldNum)){
-//            sceneNum = oldNum;
-//        }else {
-//
-//            if(proEntity != null){
-//                sceneNum = proEntity.getNum();
-//                //重算的场景,先移除该场景对应的容量
-//                userService.rebuildReduceSpaceBySceneNum(sceneNum);
-//            }else {
-//                sceneNum = sceneNumService.generateSceneNum();
-//                rebuild = 0;
-//            }
-//        }
-//
-//        String cameraName = jsonObject.getJSONObject("cam").getString("uuid");
-//        log.info("查询相机:" + cameraName);
-//        cameraEntity = goodsService.findByChildName(cameraName);
-//
-//        if(cameraEntity ==  null){
-//            log.error("该相机不存在:" + cameraName);
-//            //偶现data.fdage给的相机码多了或少了4DKKPRO_
-//            if(cameraName.contains("4DKKPRO_")){
-//                cameraEntity = goodsService.findByChildName(cameraName.replace("4DKKPRO_", ""));
-//            }else {
-//                cameraEntity = goodsService.findByChildName("4DKKPRO_" + cameraName);
-//            }
-//            if(cameraEntity == null){
-//                throw new BaseRuntimeException(CameraConstant.FAILURE_CODE_6003, CameraConstant.FAILURE_MSG_6003);
-//            }
-//        }
-//
-//        CameraDetailEntity detailEntity = goodsService.findCameraDetailByCameraId(cameraEntity.getId());
-//        if(detailEntity ==  null){
-//            log.error("该相机详情不存在:" + cameraName);
-//            throw new BaseRuntimeException(CameraConstant.FAILURE_CODE_6003, CameraConstant.FAILURE_MSG_6003);
-//        }
-//
-//        String icon = null;
-//        if(jsonObject.containsKey("icon") && StringUtil.isNotEmpty(jsonObject.getString("icon"))){
-//            //下载封面图icon
-//            FileUtils.downLoadFromUrl(prefix + "/" + jsonObject.getString("icon") + "?m=" + System.currentTimeMillis(), jsonObject.getString("icon"), path + File.separator + "capture");
-//            uploadToOssUtil.upload(path + File.separator + "capture" + File.separator +
-//                    jsonObject.getString("icon"), "images/images" + sceneNum + "/" + jsonObject.getString("icon"));
-//            icon = prefixAli + "images/images" + sceneNum + "/" + jsonObject.getString("icon");
-//            if("s3".equals(type)){
-//                icon = ConstantUrl.PREFIX_AWS + "images/images" + sceneNum + "/" + jsonObject.getString("icon");
-//            }
-//        }
-//
-//        JSONObject firmwareVersion = new JSONObject();
-//        if(jsonObject.containsKey("camSoftwareVersion") && StringUtil.isNotEmpty(jsonObject.getString("camSoftwareVersion"))){
-//            firmwareVersion.put("camSoftwareVersion", jsonObject.getString("camSoftwareVersion"));
-//        }
-//
-//        if(jsonObject.containsKey("version") && StringUtil.isNotEmpty(jsonObject.getString("version"))){
-//            firmwareVersion.put("version", jsonObject.getString("version"));
-//        }
-//
-//        String sceneUrl = mainUrl + sceneProNewUrl;
-//        String buildType = "V3";
-//        //表示新款双目
-//        Long cameraType = 5L;
-//        if(jsonObject.getJSONObject("cam").getIntValue("type") == 5){
-//
-//            //6表示小红屋双目
-//            cameraType = 6L;
-//        }
-//
-//        SceneProEntity scene = ComputerUtil.createScenePro(sceneNum, cameraEntity.getId(), cameraEntity.getChildName(), jsonObject.getString("creator"),
-//                jsonObject.getString("pwd"), unicode,
-//                cameraType, "", prefix, zipName, icon, "0", detailEntity.getUserId(), userName,
-//                jsonObject.getString("location") != null && "1".equals(jsonObject.getString("location")) ? "sfm" : "slam",
-//                jsonObject.getJSONArray("points").size(), jsonObject.getString("name"), jsonObject.getString("info"),
-//                jsonObject.getInteger("scenetype"), jsonObject.getString("gps"), sceneProService, sceneProEditService, rebuild,
-//                producer, 4, firmwareVersion.toString(), sceneUrl, buildType, type, ecsType,
-//                sceneCooperationService, sceneResourceCooperationService, sceneResourceCameraService, detailEntity.getCooperationUser(), rubberSheetingUtil);
-//
-//        if(scene == null){
-//            log.info("双目相机入库失败");
-//            return Result.failure("双目相机异常");
-//        }
-//        JSONObject statusJson = new JSONObject();
-//        //临时将-2改成1,app还没完全更新
-//        statusJson.put("status", scene.getStatus() == -2? 1 : scene.getStatus());
-//        statusJson.put("webSite", scene.getWebSite());
-//        statusJson.put("sceneNum", scene.getNum());
-//        statusJson.put("thumb", scene.getThumb());
-//        statusJson.put("payStatus", scene.getPayStatus());
-//        FileUtils.writeFile(ConstantFilePath.SCENE_PATH+"data/data"+sceneNum+File.separator+"status.json", statusJson.toString());
-//        uploadToOssUtil.upload(ConstantFilePath.SCENE_PATH+"data/data"+sceneNum+File.separator+"status.json",
-//                "data/data"+sceneNum+File.separator+"status.json");
-//
-//        //删除oss的houst_floor.json
-//        uploadToOssUtil.delete("data/data"+sceneNum+File.separator+"houst_floor.json");
-//
-//        producer.sendMsg(scene.getMqMsg());
-//
-//        Map<String, String> map = new HashMap<>();
-//        map.put("sceneNum", sceneNum);
-//        map.put("sceneUrl", sceneUrl + sceneNum);
-//        return Result.success(map);
-//
-//
-//    }
-//
+    public ResultData buildLiteScene(String prefix, String dataFdage, String zipName, String userName, String password, String oldNum) throws Exception{
+        return sceneFileBuildService.buildLiteScene(prefix, dataFdage, zipName, userName, password, oldNum);
+
+
+    }
+
 //    /**
 //    /**
 //     *
 //     *
 //     * @return
 //     * @return

+ 8 - 0
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/ISceneFileBuildService.java

@@ -32,4 +32,12 @@ public interface ISceneFileBuildService extends IService<SceneFileBuild> {
 
 
     ResultData uploadSuccess(String params) throws Exception;
     ResultData uploadSuccess(String params) throws Exception;
 
 
+    ResultData uploadSuccessBuild(String params) throws Exception;
+
+    ResultData turntableUploadSuccess(String params) throws Exception;
+
+    ResultData getS3UploadUrl(String params) throws Exception;
+
+    ResultData buildLiteScene(String prefix, String dataFdage, String zipName, String userName, String password, String oldNum) throws Exception;
+
 }
 }

Dosya farkı çok büyük olduğundan ihmal edildi
+ 752 - 263
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneFileBuildServiceImpl.java


+ 0 - 3
4dkankan-center-scene/src/main/java/com/fdkankan/scene/vo/ResponseSceneFile.java

@@ -1,6 +1,5 @@
 package com.fdkankan.scene.vo;
 package com.fdkankan.scene.vo;
 
 
-import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
 
 
 import java.io.Serializable;
 import java.io.Serializable;
@@ -10,9 +9,7 @@ public class ResponseSceneFile implements Serializable {
 
 
     private static final long serialVersionUID = 1279396211495565258L;
     private static final long serialVersionUID = 1279396211495565258L;
 
 
-    @ApiModelProperty(value = "文件id", name = "fileId")
     private String fileId;
     private String fileId;
 
 
-    @ApiModelProperty(value = "上传状态", name = "uploadStatus")
     private int uploadStatus;
     private int uploadStatus;
 }
 }

+ 1 - 0
4dkankan-common/src/main/java/com/fdkankan/common/constant/ErrorCode.java

@@ -5,6 +5,7 @@ public enum ErrorCode {
     SYSTEM_ERROR(-1, "服务器异常"),
     SYSTEM_ERROR(-1, "服务器异常"),
     PARAM_ERROR(-2, "解析请求参数出错"),
     PARAM_ERROR(-2, "解析请求参数出错"),
     PARAM_REQUIRED(-3, "缺少必要参数"),
     PARAM_REQUIRED(-3, "缺少必要参数"),
+    PARAM_FORMAT_ERROR(-4, "解析请求参数出错"),
     AUTH_FAIL(4000, "鉴权失败!"),
     AUTH_FAIL(4000, "鉴权失败!"),
     NON_TOKEN(4001, "无token,请重新登录"),
     NON_TOKEN(4001, "无token,请重新登录"),
     TOKEN_ILLEGAL(4002, "token不合法"),
     TOKEN_ILLEGAL(4002, "token不合法"),