xiewenjie před 3 roky
rodič
revize
0c408fd6eb

+ 90 - 89
sxz-core/src/main/java/com/fdkk/sxz/webApi/controller/ManagerController.java

@@ -10,19 +10,19 @@ import com.fdkk.sxz.annotation.auth.NoAuthentication;
 import com.fdkk.sxz.annotation.log.AroundLog;
 import com.fdkk.sxz.base.BaseController;
 import com.fdkk.sxz.base.Result;
+import com.fdkk.sxz.constant.CodeConstant;
 import com.fdkk.sxz.entity.*;
 import com.fdkk.sxz.exception.BusinessException;
-import com.fdkk.sxz.util.*;
-import com.fdkk.sxz.webApi.service.*;
-import com.github.pagehelper.Page;
-import com.github.pagehelper.PageInfo;
-import com.fdkk.sxz.constant.CodeConstant;
 import com.fdkk.sxz.other.mq.TopicRabbitConfig;
+import com.fdkk.sxz.util.*;
 import com.fdkk.sxz.vo.request.RequestRenovationParts;
 import com.fdkk.sxz.vo.request.RequestRenovationPartsDetailManager;
 import com.fdkk.sxz.vo.response.ResponseRenovationPartsAttaching;
 import com.fdkk.sxz.vo.response.ResponseRenovationPartsDetailManager;
 import com.fdkk.sxz.vo.response.ResponseRenovationPartsSize;
+import com.fdkk.sxz.webApi.service.*;
+import com.github.pagehelper.Page;
+import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -138,13 +138,13 @@ public class ManagerController extends BaseController {
 
         String fileId = null;
         ModelUploadEntity modelUploadEntity = null;
-        ComponentModelUploadEntity componentModelUploadEntity =null;
+        ComponentModelUploadEntity componentModelUploadEntity = null;
         do {
             fileId = RandomUtil.generateShortUuid();
             modelUploadEntity = modelUploadService.findByFileId(fileId);
-            componentModelUploadEntity= componentModelUploadService.findByFileId(fileId);
+            componentModelUploadEntity = componentModelUploadService.findByFileId(fileId);
 
-        } while (modelUploadEntity != null&&componentModelUploadEntity!=null);
+        } while (modelUploadEntity != null && componentModelUploadEntity != null);
 
         modelUploadEntity = new ModelUploadEntity();
         modelUploadEntity.setUserId(Long.valueOf(userId));
@@ -190,16 +190,16 @@ public class ManagerController extends BaseController {
 
         boolean falg = true;
         for (String targetPath : allList) {
-            log.info("解压后的-{}文件全路径是-{}", fileId, targetPath);
+            ManagerController.log.info("解压后的-{}文件全路径是-{}", fileId, targetPath);
             if (targetPath.toLowerCase().endsWith(".max")) {
                 falg = false;
-                new File(targetPath).renameTo(new File(targetPath.substring( 0, targetPath.lastIndexOf(File.separator) + 1) + fileId + ".max"));
+                new File(targetPath).renameTo(new File(targetPath.substring(0, targetPath.lastIndexOf(File.separator) + 1) + fileId + ".max"));
                 break;
             }
         }
 
         if (falg) {
-            log.error("上传的数据类型不正确-{}", fileId);
+            ManagerController.log.error("上传的数据类型不正确-{}", fileId);
             return Result.failure(CodeConstant.FAILURE_CODE_4013, CodeConstant.FAILURE_MSG_4013);
         }
 
@@ -215,7 +215,7 @@ public class ManagerController extends BaseController {
 //            }
 //        }
 
-        rabbitTemplate.convertAndSend(TopicRabbitConfig.TOPICE, TopicRabbitConfig.MODEL, modelUploadEntity.getId() + ":;" + fileId + ":;" + userId + ":;" + modelType+ ":;" +"false"+":;" +"1");
+        rabbitTemplate.convertAndSend(TopicRabbitConfig.TOPICE, TopicRabbitConfig.MODEL, modelUploadEntity.getId() + ":;" + fileId + ":;" + userId + ":;" + modelType + ":;" + "false" + ":;" + "1");
 
         return Result.success(modelUploadEntity);
     }
@@ -301,9 +301,9 @@ public class ManagerController extends BaseController {
         jsonObject.put("name", modelUploadEntity.getFileId());
         jsonObject.put("taskId", String.valueOf(modelUploadEntity.getUserId()));
         jsonObject.put("data", json);
-        log.info("保存数据,准备修改obj文件数据-{}", jsonObject.toJSONString());
+        ManagerController.log.info("保存数据,准备修改obj文件数据-{}", jsonObject.toJSONString());
         String result = OkHttpUtils.httpPostJson(modelBuildUrl + "fixmodel", jsonObject.toJSONString());
-        log.info(modelBuildUrl + "fixmodel:" + result);
+        ManagerController.log.info(modelBuildUrl + "fixmodel:" + result);
         return Result.success();
     }
 
@@ -367,7 +367,7 @@ public class ManagerController extends BaseController {
         if (!new File(objPath).exists()) {
             modelUploadEntity.setStatus(-1);
             modelUploadService.updateById(modelUploadEntity);
-            log.error("转换obj数据失败-{}", modelUploadEntity.getFileId());
+            ManagerController.log.error("转换obj数据失败-{}", modelUploadEntity.getFileId());
             return Result.failure(CodeConstant.FAILURE_CODE_4006, CodeConstant.FAILURE_MSG_4006);
         }
 
@@ -518,12 +518,12 @@ public class ManagerController extends BaseController {
         renovationPartsDetailService.updateById(renovationPartsDetailEntity);
         if ("I".equals(renovationPartsDetailEntity.getRecStatus())) {
             boolean removeById = renovationPartsDetailService.removeById(renovationPartsDetailEntity.getId());
-            log.info("删除renovationPartsDetailEntity-{}",removeById);
+            ManagerController.log.info("删除renovationPartsDetailEntity-{}", removeById);
             ModelUploadEntity modelUploadEntity = modelUploadService.findByPartsDetailId(renovationPartsDetailEntity.getId());
             if (modelUploadEntity != null) {
                 modelUploadService.removeById(modelUploadEntity.getId());
             }
-        }else {
+        } else {
             RenovationPartsAttachingEntity renovationPartsAttachingEntity = renovationPartsAttachingService.findByDetailId(renovationPartsDetailEntity.getId());
             if (renovationPartsAttachingEntity != null) {
                 if ("wall".equals(param.getAttachingType())) {
@@ -563,7 +563,6 @@ public class ManagerController extends BaseController {
         }
 
 
-
         return Result.success();
     }
 
@@ -592,35 +591,35 @@ public class ManagerController extends BaseController {
         CreateObjUtil.objHandle(buildPath + modelUploadEntity.getObjPath());
 
 
-        log.info("配件obj转换成mview格式");
+        ManagerController.log.info("配件obj转换成mview格式");
         Map<String, String> paramsMap = new HashMap<>();
-        paramsMap.put("uuid",modelUploadEntity.getFileId());
-        paramsMap.put("inObj",buildPath + modelUploadEntity.getObjPath());
-        paramsMap.put("outFilePath",buildPath + modelUploadEntity.getObjPath().replace(".obj", ""));
-        OkHttpUtils.httpPostForm(maxObjUrl+"toToolbag",paramsMap);
+        paramsMap.put("uuid", modelUploadEntity.getFileId());
+        paramsMap.put("inObj", buildPath + modelUploadEntity.getObjPath());
+        paramsMap.put("outFilePath", buildPath + modelUploadEntity.getObjPath().replace(".obj", ""));
+        OkHttpUtils.httpPostForm(maxObjUrl + "toToolbag", paramsMap);
         Thread.sleep(1000);
 
-        log.info("上传开始");
-        int count=4;
-        boolean flag=true;
-        while (flag){
-            if(FileUtil.exist(buildPath + modelUploadEntity.getObjPath().replace(".obj", ".mview"))){
-                log.info("文件存在");
+        ManagerController.log.info("上传开始");
+        int count = 10;
+        boolean flag = true;
+        while (flag) {
+            if (FileUtil.exist(buildPath + modelUploadEntity.getObjPath().replace(".obj", ".mview"))) {
+                ManagerController.log.info("文件存在");
                 uploadToOssUtil.uploadTo4dTjw(buildPath + modelUploadEntity.getObjPath().replace(".obj", ".mview"), "domain/eHome/furniture/temp/" + modelUploadEntity.getFileId() + ".mview");
-                flag=false;
-            }else {
+                flag = false;
+            } else {
                 Thread.sleep(1000);
             }
-            if (count<=0){
+            if (count <= 0) {
                 break;
             }
             count -= 1;
         }
-        log.info("配件obj转换成mview格式结束{}",modelUploadEntity.getObjPath().replace(".obj", ".mview"));
+        ManagerController.log.info("配件obj转换成mview格式结束{}", modelUploadEntity.getObjPath().replace(".obj", ".mview"));
 
         //obj转换成glb格式
         String glbPath = buildPath + "upload/" + modelUploadEntity.getFileId() + "/" + modelUploadEntity.getFileId() + ".glb";
-        log.info("obj转换成glb格式路径-{}", glbPath);
+        ManagerController.log.info("obj转换成glb格式路径-{}", glbPath);
         CreateObjUtil.objToGlb(buildPath + modelUploadEntity.getObjPath(), glbPath);
         modelUploadEntity.setObjSize((int) new File(buildPath + modelUploadEntity.getObjPath()).length());
         modelUploadService.updateById(modelUploadEntity);
@@ -652,8 +651,11 @@ public class ManagerController extends BaseController {
         renovationPartsDetailEntity.setExamine(0);
         renovationPartsDetailEntity.setName(modelUploadEntity.getFileId());
         renovationPartsDetailEntity.setPath(prefix + "domain/eHome/furniture/temp/" + modelUploadEntity.getFileId() + ".glb");
-        if(FileUtil.exist(buildPath + modelUploadEntity.getObjPath().replace(".obj", ".mview"))){
-            log.info("文件存在");
+        if (FileUtil.exist(buildPath + modelUploadEntity.getObjPath().replace(".obj", ".mview"))) {
+            ManagerController.log.info("文件存在");
+            if (!uploadToOssUtil.existFileToOSS(renovationPartsDetailEntity.getMviewPath(), "4d-tjw")) {
+                uploadToOssUtil.uploadTo4dTjw(buildPath + modelUploadEntity.getObjPath().replace(".obj", ".mview"), "domain/eHome/furniture/temp/" + modelUploadEntity.getFileId() + ".mview");
+            }
             renovationPartsDetailEntity.setMviewPath(prefix + "domain/eHome/furniture/temp/" + modelUploadEntity.getFileId() + ".mview");
         }
 
@@ -669,7 +671,7 @@ public class ManagerController extends BaseController {
                                                ModelUploadEntity modelUploadEntity, String glbPath,
                                                RenovationPartsDetailEntity renovationPartsDetailEntity) throws Exception {
         if (checkReaptPost(param)) {
-            log.info("模型已被提交,模型id-{}", param.getModelUploadId());
+            ManagerController.log.info("模型已被提交,模型id-{}", param.getModelUploadId());
             return Result.failure(9999, "模型已被提交,模型id-" + param.getModelUploadId());
         }
 
@@ -691,7 +693,7 @@ public class ManagerController extends BaseController {
             renovationPartsDetailEntity.setHasToolbag(1);
         }
 
-        Boolean saveFlag=renovationPartsDetailService.save(renovationPartsDetailEntity);
+        Boolean saveFlag = renovationPartsDetailService.save(renovationPartsDetailEntity);
         if (!saveFlag) {
             return Result.failure(CodeConstant.FAILURE_CODE_4008, CodeConstant.FAILURE_MSG_4008);
         }
@@ -730,7 +732,7 @@ public class ManagerController extends BaseController {
         //修改上传信息,关联模型id
         modelUploadEntity.setPartsDetailId(renovationPartsDetailEntity.getId());
         Boolean row = modelUploadService.updateById(modelUploadEntity);
-        log.info("执行行数-{}", row);
+        ManagerController.log.info("执行行数-{}", row);
         return Result.success();
     }
 
@@ -780,60 +782,59 @@ public class ManagerController extends BaseController {
             renovationPartsDetailEntity.setExamine(param.getExamine());
             renovationPartsDetailEntity.setExamineTime(new Date());
             ModelUploadEntity modelUploadEntity = modelUploadService.findByPartsDetailId(param.getId());
-            if (ObjectUtil.isNotNull(modelUploadEntity)){
-            //入库前先提交模型到模型库,失败返回提示
-            String version = SnowFlakeUUidUtils.generaUUid(null, null, null);
-            JSONObject jsonObject = new JSONObject();
-            JSONArray array = new JSONArray();
-            JSONObject object = new JSONObject();
-            object.put("Name", renovationPartsDetailEntity.getName());
-            object.put("UserID", modelUploadEntity.getUserId());
-            String postfix = "datasmith";
-            if (modelUploadEntity.getFileType() == 0) {
-                postfix = "fbx";
-            }
-            object.put("Postfix", postfix);
-            object.put("ObjAliPath", "domain/eHome/furniture/simpleObj-Mtl/" + modelUploadEntity.getFileId());
-            array.add(object);
-            jsonObject.put("version", version);
-
-            log.info("更新模型库,syncmodel接口参数:" + jsonObject.toJSONString());
-            uploadToOssUtil.uploadTo4dTjw(array.toJSONString().getBytes(), "domain/eHome/furniture/syncdata/" +
-                    version + "/SyncData.json");
-
-            String resultData = OkHttpUtils.httpPostJson(buildUrl + "syncmodel", jsonObject.toJSONString());
-            JSONObject resultJson = JSONObject.parseObject(resultData);
-            if ("error".equals(resultJson.getString("state"))) {
-                log.info("更新模型库,syncmodel接口失败:" + resultData);
-                renovationPartsDetailEntity.setExamine(0);
-                return Result.failure(CodeConstant.FAILURE_CODE_4015, CodeConstant.FAILURE_MSG_4015);
-            }
+            if (ObjectUtil.isNotNull(modelUploadEntity)) {
+                //入库前先提交模型到模型库,失败返回提示
+                String version = SnowFlakeUUidUtils.generaUUid(null, null, null);
+                JSONObject jsonObject = new JSONObject();
+                JSONArray array = new JSONArray();
+                JSONObject object = new JSONObject();
+                object.put("Name", renovationPartsDetailEntity.getName());
+                object.put("UserID", modelUploadEntity.getUserId());
+                String postfix = "datasmith";
+                if (modelUploadEntity.getFileType() == 0) {
+                    postfix = "fbx";
+                }
+                object.put("Postfix", postfix);
+                object.put("ObjAliPath", "domain/eHome/furniture/simpleObj-Mtl/" + modelUploadEntity.getFileId());
+                array.add(object);
+                jsonObject.put("version", version);
+
+                ManagerController.log.info("更新模型库,syncmodel接口参数:" + jsonObject.toJSONString());
+                uploadToOssUtil.uploadTo4dTjw(array.toJSONString().getBytes(), "domain/eHome/furniture/syncdata/" +
+                        version + "/SyncData.json");
+
+                String resultData = OkHttpUtils.httpPostJson(buildUrl + "syncmodel", jsonObject.toJSONString());
+                JSONObject resultJson = JSONObject.parseObject(resultData);
+                if ("error".equals(resultJson.getString("state"))) {
+                    ManagerController.log.info("更新模型库,syncmodel接口失败:" + resultData);
+                    renovationPartsDetailEntity.setExamine(0);
+                    return Result.failure(CodeConstant.FAILURE_CODE_4015, CodeConstant.FAILURE_MSG_4015);
+                }
 
-            uploadToOssUtil.copyTo4dTjw(renovationPartsDetailEntity.getImg().replace(prefix, ""),
-                    renovationPartsDetailEntity.getImg().replace("/temp/", "/models/").replace(prefix, ""));
-            uploadToOssUtil.copyTo4dTjw(renovationPartsDetailEntity.getPath().replace(prefix, ""),
-                    renovationPartsDetailEntity.getPath().replace("/temp/", "/models/").replace(prefix, ""));
-            if (ObjectUtil.isNotNull(renovationPartsDetailEntity.getMviewPath())){
-                uploadToOssUtil.copyTo4dTjw(renovationPartsDetailEntity.getMviewPath().replace(prefix, ""),
-                        renovationPartsDetailEntity.getMviewPath().replace("/temp/", "/models/").replace(prefix, ""));
-                renovationPartsDetailEntity.setMviewPath(renovationPartsDetailEntity.getMviewPath().replace("/temp/", "/models/"));
-                uploadToOssUtil.deleteTo4dTjw(renovationPartsDetailEntity.getMviewPath().replace(prefix, ""));
+                uploadToOssUtil.copyTo4dTjw(renovationPartsDetailEntity.getImg().replace(prefix, ""),
+                        renovationPartsDetailEntity.getImg().replace("/temp/", "/models/").replace(prefix, ""));
+                uploadToOssUtil.copyTo4dTjw(renovationPartsDetailEntity.getPath().replace(prefix, ""),
+                        renovationPartsDetailEntity.getPath().replace("/temp/", "/models/").replace(prefix, ""));
+                if (ObjectUtil.isNotNull(renovationPartsDetailEntity.getMviewPath())) {
+                    uploadToOssUtil.copyTo4dTjw(renovationPartsDetailEntity.getMviewPath().replace(prefix, ""),
+                            renovationPartsDetailEntity.getMviewPath().replace("/temp/", "/models/").replace(prefix, ""));
+                    renovationPartsDetailEntity.setMviewPath(renovationPartsDetailEntity.getMviewPath().replace("/temp/", "/models/"));
+                    uploadToOssUtil.deleteTo4dTjw(renovationPartsDetailEntity.getMviewPath().replace(prefix, ""));
 
-            }
+                }
 
-            uploadToOssUtil.deleteTo4dTjw(renovationPartsDetailEntity.getImg().replace(prefix, ""));
-            uploadToOssUtil.deleteTo4dTjw(renovationPartsDetailEntity.getPath().replace(prefix, ""));
+                uploadToOssUtil.deleteTo4dTjw(renovationPartsDetailEntity.getImg().replace(prefix, ""));
+                uploadToOssUtil.deleteTo4dTjw(renovationPartsDetailEntity.getPath().replace(prefix, ""));
 
-            renovationPartsDetailEntity.setImg(renovationPartsDetailEntity.getImg().replace("/temp/", "/models/"));
-            renovationPartsDetailEntity.setHighImg(renovationPartsDetailEntity.getHighImg().replace("/temp/", "/models/"));
-            renovationPartsDetailEntity.setPath(renovationPartsDetailEntity.getPath().replace("/temp/", "/models/"));
+                renovationPartsDetailEntity.setImg(renovationPartsDetailEntity.getImg().replace("/temp/", "/models/"));
+                renovationPartsDetailEntity.setHighImg(renovationPartsDetailEntity.getHighImg().replace("/temp/", "/models/"));
+                renovationPartsDetailEntity.setPath(renovationPartsDetailEntity.getPath().replace("/temp/", "/models/"));
             }
         }
 
         renovationPartsDetailService.updateById(renovationPartsDetailEntity);
 
 
-
         return Result.success();
     }
 
@@ -919,9 +920,9 @@ public class ManagerController extends BaseController {
         ModelUploadEntity modelUploadEntity = new ModelUploadEntity();
         for (String id : idArray) {
             modelUploadService.removeById(id);
-            if(param.getFileType()==2){
-                List<ComponentModelUploadEntity> entityList= componentModelUploadService.findPartsModelUploadId(Long.valueOf(id));
-                entityList.forEach(a->{
+            if (param.getFileType() == 2) {
+                List<ComponentModelUploadEntity> entityList = componentModelUploadService.findPartsModelUploadId(Long.valueOf(id));
+                entityList.forEach(a -> {
                     componentModelUploadService.removeById(a.getId());
                 });
             }
@@ -956,7 +957,7 @@ public class ManagerController extends BaseController {
 
         rabbitTemplate.convertAndSend(TopicRabbitConfig.TOPICE, TopicRabbitConfig.LIGHT,
                 modelUploadEntity.getFileId() + ":;" + modelUploadEntity.getUserId() + ":;" +
-                        modelUploadEntity.getId() + ":;" + jsonData + ":;modelPreview:;"+1);
+                        modelUploadEntity.getId() + ":;" + jsonData + ":;modelPreview:;" + 1);
 
         modelUploadService.updateById(modelUploadEntity);
         return Result.success();
@@ -1069,7 +1070,7 @@ public class ManagerController extends BaseController {
             String glbPath = buildPath + "upload/" + fileId + "/" + fileId + ".glb";
             CreateObjUtil.objToGlb(buildPath + "upload/" + fileId + "/" + fileId + ".obj", glbPath);
 
-            log.info("glb生成完成:" + fileId);
+            ManagerController.log.info("glb生成完成:" + fileId);
             uploadToOssUtil.uploadTo4dTjw(buildPath + "upload/" + fileId + "/" + fileId + ".glb",
                     "domain/eHome/furniture/models/" + fileId + ".glb");
             uploadToOssUtil.uploadTo4dTjw(buildPath + "upload/" + fileId + "/" + fileId + ".glb",
@@ -1098,7 +1099,7 @@ public class ManagerController extends BaseController {
         for (String fileId : fileIdArr) {
 
             objToToolbagUtil.convertobjTomview(fileId);
-            log.info(fileId + "转换Toolbag结束");
+            ManagerController.log.info(fileId + "转换Toolbag结束");
         }
         return Result.success();
     }