Selaa lähdekoodia

Merge branch 'project-jp-test' into project-jp

# Conflicts:
#	src/main/java/com/fdkankan/jp/xspace/service/impl/UserServiceImpl.java
dengsixing 4 kuukautta sitten
vanhempi
commit
c0923cc9d4

+ 4 - 0
src/main/java/com/fdkankan/jp/xspace/common/constant/OSSPathConstant.java

@@ -6,6 +6,10 @@ public class OSSPathConstant {
 
     public final static String SCENE_VIEW_DATA_IMAGES = SCENE_VIEW_DATA + "%s/images/";
 
+    public final static String SCENE_VIEW_DATA_VIDEO = SCENE_VIEW_DATA + "%s/video/";
+
+    public final static String SCENE_VIEW_DATA_VOICE = SCENE_VIEW_DATA + "%s/voice/";
+
     public final static String SCENE_VIEW_DATA_DATA = SCENE_VIEW_DATA + "%s/data/";
 
     public final static String SCENE_VIEW_DATA_USER = SCENE_VIEW_DATA + "%s/user/";

+ 6 - 5
src/main/java/com/fdkankan/jp/xspace/controller/SceneXspaceController.java

@@ -6,11 +6,7 @@ import com.fdkankan.jp.xspace.common.Result;
 import com.fdkankan.jp.xspace.dto.XspacePageDTO;
 import com.fdkankan.jp.xspace.service.ISceneXspaceService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -50,5 +46,10 @@ public class SceneXspaceController extends BaseController{
         return sceneXspaceService.sync(nums, this.getUser());
     }
 
+    @PostMapping("/updateSync")
+    public Result replaceSync(@RequestParam("id") Long id){
+        return sceneXspaceService.replaceSync(id, this.getUser());
+    }
+
 }
 

+ 1 - 1
src/main/java/com/fdkankan/jp/xspace/generate/AutoGenerate.java

@@ -18,7 +18,7 @@ public class AutoGenerate {
         String path =System.getProperty("user.dir");
 
         generate(path,"jp.xspace", getTables(new String[]{
-                "t_unity_config"
+                "t_user_platform"
         }));
 
 //        generate(path,"goods", getTables(new String[]{

+ 0 - 7
src/main/java/com/fdkankan/jp/xspace/listener/RabbitMqListener.java

@@ -118,14 +118,7 @@ public class RabbitMqListener {
         try {
             if(bean.getStatus() == CommonSuccessStatus.FAIL.code()){
                 User user = userService.getById(bean.getUserId());
-                String errorLogPath = workPath + "error.log";
-                String errorLogKey = String.format(OSSPathConstant.XSPACE_SCENE_FORMAT, bean.getNum(), bean.getSerial()) + "log/error.log";
-                String logUrl = fYunFileConfig.getHost() + errorLogKey;
                 String extContent = null;
-                if(FileUtil.exist(errorLogPath)){
-                    fYunFileService.uploadFile(errorLogPath, errorLogKey);
-                    extContent = "**error-log**: " + logUrl + "\n\n";
-                }
                 String content = String.format(DINGTALK_MSG_PATTERN, profile, errorReason, bean.getNum(), user.getUserName(), workPath);
                 if(StrUtil.isNotEmpty(extContent)){
                     content = content + extContent;

+ 2 - 0
src/main/java/com/fdkankan/jp/xspace/service/ISceneXspaceService.java

@@ -27,4 +27,6 @@ public interface ISceneXspaceService extends IService<SceneXspace> {
 
     SceneXspace getByNumAndUserId(String num, long userId);
 
+    Result replaceSync(Long id, User user);
+
 }

+ 34 - 4
src/main/java/com/fdkankan/jp/xspace/service/impl/SceneXspaceServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fdkankan.common.constant.CommonOperStatus;
 import com.fdkankan.common.constant.RecStatus;
 import com.fdkankan.fyun.face.FYunFileServiceInterface;
 import com.fdkankan.jp.xspace.common.PageInfo;
@@ -33,10 +34,7 @@ import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -178,4 +176,36 @@ public class SceneXspaceServiceImpl extends ServiceImpl<ISceneXspaceMapper, Scen
     public SceneXspace getByNumAndUserId(String num, long userId) {
         return this.getOne(new LambdaQueryWrapper<SceneXspace>().eq(SceneXspace::getNum, num).eq(SceneXspace::getUserId, userId));
     }
+
+    @Override
+    public Result replaceSync(Long id,User user) {
+
+        SceneXspace sceneXspace = this.getById(id);
+        if(Objects.isNull(sceneXspace)){
+            throw new BusinessException(ResultCode.NOT_RECORD);
+        }
+
+        //校验数据
+        Set<Long> roleIds = userRoleService.getByUser(user);
+        boolean notPermission = false;
+        if(!roleIds.contains(5L)){//平台管理员可以看到所有
+            if(roleIds.contains(6L)){//公司管理员可以看到同一公司下所有
+                User sceneUser = userService.getById(sceneXspace.getUserId());
+                notPermission = !sceneUser.getCompanyId().equals(user.getCompanyId());
+            }else{//普通员工只能删除自己的
+                notPermission = !sceneXspace.getUserId().equals(user.getId());
+            }
+        }
+        if(notPermission){
+            return Result.failure(ResultCode.NOT_PERMISSION);
+        }
+
+        sceneXspace.setStatus(CommonOperStatus.WAITING.code());
+        sceneXspace.setUpdateTime(new Date());
+        this.updateById(sceneXspace);
+
+        mqProducer.sendByWorkQueue(RabbitmqConstant.QUEUE_PACK_XSPACE, sceneXspace);
+
+        return Result.success();
+    }
 }

+ 59 - 28
src/main/java/com/fdkankan/jp/xspace/service/impl/UnityServiceImpl.java

@@ -1,8 +1,10 @@
 package com.fdkankan.jp.xspace.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.fdkankan.common.constant.CommonStatus;
@@ -67,6 +69,29 @@ public class UnityServiceImpl implements IUnityService {
             fYunFileService.downloadFile(v, localMeshPath + v.replace(meshKey, ""));
         });
 
+        //如果有三维模型,需要下载三维模型原始文件
+        String sceneJsonKey = String.format(OSSPathConstant.SCENE_VIEW_DATA_DATA, bean.getNum()) + "scene.json";
+        String sceneJsonStr = fYunFileService.getFileContent(sceneJsonKey);
+        JSONObject sceneJsonObj = JSON.parseObject(sceneJsonStr);
+        String boxModelsStr = sceneJsonObj.getString("boxModels");
+        if(StrUtil.isNotEmpty(boxModelsStr)){
+            List<JSONObject> jsonObjects = JSON.parseArray(boxModelsStr, JSONObject.class);
+            if(CollUtil.isNotEmpty(jsonObjects)){
+                String userViewPath = String.format(OSSPathConstant.SCENE_VIEW_DATA_USER, bean.getNum());
+                jsonObjects.stream().forEach(item->{
+                    String sid = item.getString("sid");
+                    String origObjPath = userViewPath + "boxModels/" + sid + "/";
+                    List<String> objFileList = fYunFileService.listRemoteFiles(origObjPath);
+                    if(CollUtil.isNotEmpty(objFileList)){
+                        objFileList.stream().forEach(objKey->{
+                            fYunFileService.downloadFile(objKey, workPath + objKey.replace(OSSPathConstant.SCENE_VIEW_DATA + bean.getNum() + "/", ""));
+                        });
+                    }
+                });
+            }
+        }
+
+
         return workPath;
     }
 
@@ -117,42 +142,48 @@ public class UnityServiceImpl implements IUnityService {
 
         String xspaceSceneOssPath = String.format(OSSPathConstant.XSPACE_SCENE_FORMAT,bean.getNum(), bean.getSerial());
 
-        //上传mesh
-        List<File> fileList = FileUtil.loopFiles(workPath);
-        fileList.parallelStream().forEach(v->{
-            fYunFileService.uploadFile(v.getAbsolutePath(), v.getAbsolutePath().replace(workPath, xspaceSceneOssPath));
-        });
+        //复制user
+        String sourceUserPath = String.format(OSSPathConstant.SCENE_VIEW_DATA_USER, bean.getNum());
+        String targetUserPath = xspaceSceneOssPath + "user/";
+        fYunFileService.copyFileInBucket(sourceUserPath, targetUserPath);
 
-        //上传文件映射json
-//        fYunFileService.uploadFile(workPath + "xxx.json", xspaceSceneOssPath + "xxx.json");
+        //复制data
+        String sourceDataPath = String.format(OSSPathConstant.SCENE_VIEW_DATA_DATA, bean.getNum());
+        String targetDataPath = xspaceSceneOssPath + "data/";
+        fYunFileService.copyFileInBucket(sourceDataPath, targetDataPath);
+        //删除mesh
+        fYunFileService.deleteFolder(targetDataPath + "mesh");
 
-        //复制skybox图
-        String sourceImagesPath = String.format(OSSPathConstant.SCENE_VIEW_DATA_IMAGES, bean.getNum()) + "tiles/4k/";
+        //复制images
+        String sourceImagesPath = String.format(OSSPathConstant.SCENE_VIEW_DATA_IMAGES, bean.getNum());
         String targetImagesPath = xspaceSceneOssPath + "images/";
         fYunFileService.copyFileInBucket(sourceImagesPath, targetImagesPath);
 
-        //复制user
-        String sourceUserPath = String.format(OSSPathConstant.SCENE_VIEW_DATA_USER, bean.getNum());
-        String targetUserPath = xspaceSceneOssPath + "user/";
-        fYunFileService.copyFileInBucket(sourceUserPath, targetUserPath);
+        //复制video
+        String sourceVideoPath = String.format(OSSPathConstant.SCENE_VIEW_DATA_VIDEO, bean.getNum());
+        String targetVideoPath = xspaceSceneOssPath + "video/";
+        fYunFileService.copyFileInBucket(sourceVideoPath, targetVideoPath);
 
-        //上传getInfo.json
-        String getInfoKey = xspaceSceneOssPath + "getInfo.json";
-        SceneInfoVO getInfoJson = this.getSceneInfo4View(bean.getNum());
-        fYunFileService.uploadFile(JSON.toJSONString(getInfoJson).toString().getBytes(StandardCharsets.UTF_8), getInfoKey);
+        //复制vioce
+        String sourceVoicePath = String.format(OSSPathConstant.SCENE_VIEW_DATA_VOICE, bean.getNum());
+        String targetVoicePath = xspaceSceneOssPath + "vioce/";
+        fYunFileService.copyFileInBucket(sourceVoicePath, targetVoicePath);
 
-        //上传floorplan.json
-        String floorplanPath = String.format(OSSPathConstant.SCENE_VIEW_DATA_DATA, bean.getNum()) + "floorplan.json";
-        if(getInfoJson.getFloorPlanUser() == 1){
-            floorplanPath = String.format(OSSPathConstant.SCENE_VIEW_DATA_USER, bean.getNum()) + "floorplan.json";
-        }
-        String xspaceFloorplanPath = xspaceSceneOssPath + "floorplan.json";
-        fYunFileService.copyFileInBucket(floorplanPath, xspaceFloorplanPath);
+        //上传mesh
+        List<File> fileList = FileUtil.loopFiles(workPath);
+        fileList.parallelStream().forEach(v->{
+            fYunFileService.uploadFile(v.getAbsolutePath(), v.getAbsolutePath().replace(workPath, targetDataPath));
+        });
 
-        //复制vision.modeldata
-        String sourceVisionPath = String.format(OSSPathConstant.SCENE_VIEW_DATA_IMAGES, bean.getNum()) + "vision.modeldata";
-        String tagetVisionPath = xspaceSceneOssPath + "vision.modeldata";
-        fYunFileService.copyFileInBucket(sourceVisionPath, tagetVisionPath);
+        //三维模型
+        String ossBoxModelPath = targetUserPath + "boxModels/";
+        String boxModelPath = workPath + "user/boxModels/";
+        List<File> files = FileUtil.loopFiles(boxModelPath);
+        if(CollUtil.isNotEmpty(files)){
+            files.stream().forEach(file->{
+                fYunFileService.uploadFile(file.getAbsolutePath(), file.getAbsolutePath().replace(boxModelPath, ossBoxModelPath));
+            });
+        }
 
     }
 

+ 4 - 7
src/main/java/com/fdkankan/jp/xspace/service/impl/UserServiceImpl.java

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fdkankan.common.constant.ErrorCode;
 import com.fdkankan.common.util.Base64Converter;
 import com.fdkankan.common.util.JwtUtil;
 import com.fdkankan.common.util.SecurityUtil;
@@ -77,13 +78,9 @@ public class UserServiceImpl extends ServiceImpl<IUserMapper, User> implements I
             throw new BusinessException(ResultCode.PASSWORD_ERROR);
         }
 
-        List<UserRole> userRoles = userRoleService.getByUserId(user.getId());
-        boolean isPlatform = userRoles.stream().anyMatch(v -> v.getRoleId() == 5);
-        if(!isPlatform){
-            List<UserPlatform> xspases = userPlatformService.list(new LambdaQueryWrapper<UserPlatform>().eq(UserPlatform::getUserId, user.getId()).eq(UserPlatform::getPlatformKey, "xspase"));
-            if(CollUtil.isEmpty(xspases)){
-                throw new BusinessException(XspaceErrorCode.CODE_90001.code(), XspaceErrorCode.CODE_90001.message());
-            }
+        List<UserPlatform> xspases = userPlatformService.list(new LambdaQueryWrapper<UserPlatform>().eq(UserPlatform::getUserId, user.getId()).eq(UserPlatform::getPlatformKey, "xspase"));
+        if(CollUtil.isEmpty(xspases)){
+            throw new BusinessException(XspaceErrorCode.CODE_90001.code(), XspaceErrorCode.CODE_90001.message());
         }
 
         String token = this.redisLogin(user.getUserName(), JSONObject.toJSONString(user),"user");