lyhzzz пре 7 месеци
родитељ
комит
1189effb55

+ 21 - 0
src/main/java/com/fdkankan/fusion/common/util/MinIoChunkUtils.java

@@ -272,6 +272,9 @@ public class MinIoChunkUtils implements InitializingBean {
         }
         Map<Integer,String> chunkMap = new HashMap<>(chunkPaths.size());
         for (String chunkName : chunkPaths) {
+            if(!chunkName.contains(".chunk")){
+                continue;
+            }
             Integer partNumber = Integer.parseInt(chunkName.substring(chunkName.indexOf("/") + 1,chunkName.lastIndexOf(".")));
             chunkMap.put(partNumber,chunkName);
         }
@@ -350,6 +353,24 @@ public class MinIoChunkUtils implements InitializingBean {
         }
         return exist;
     }
+
+    /**
+     * 判断目录是否存在
+     *
+     * @param bucketName 存储桶
+     * @param objectName 文件名
+     * @return
+     */
+    public static boolean isObjectFloadExist(String bucketName, String objectName) {
+        boolean exist = true;
+        try {
+            //minioClient.listObjects(StatObjectArgs.builder().bucket(bucketName).object(objectName).build());
+        } catch (Exception e) {
+            exist = false;
+        }
+        return exist;
+    }
+
     public static String buZero(Long size,Integer index){
         String numStr = String.valueOf(size);
         return StringUtils.leftPad(String.valueOf(index),numStr.length()+1,'0');

+ 1 - 10
src/main/java/com/fdkankan/fusion/controller/UploadController.java

@@ -44,8 +44,6 @@ public class UploadController extends BaseController{
 
     @Autowired
     IUploadChunkService uploadChunkService;
-    @Autowired
-    RedisUtil redisUtil;
 
     @PostMapping("/init-chunk-upload")
     public ResultData initChunkUpload(@RequestBody UploadChunk uploadDto){
@@ -53,10 +51,6 @@ public class UploadController extends BaseController{
                 || StringUtils.isBlank(uploadDto.getFileName()) || uploadDto.getFileSize() ==null){
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
-        String redisKey = "fusion:upload-chunk:"+uploadDto.getFileMd5();
-        if(redisUtil.hasKey(redisKey)){
-            return ResultData.ok(redisUtil.get(redisKey));
-        }
         uploadDto.setDeptId(getDeptId());
         uploadDto.setUserName(getUserName());
         String suffix = uploadDto.getFileName().substring(uploadDto.getFileName().lastIndexOf("."));
@@ -71,9 +65,7 @@ public class UploadController extends BaseController{
             Map<Integer,String> okChunkMap = new HashMap<>();
             if(uploadDto.getChunkCount() >1){
                 //获取到该文件已上传分片
-                if( MinIoChunkUtils.isObjectExist(MinIoChunkUtils.chunkBucKet,uploadDto.getFileMd5())){
-                    okChunkMap = MinIoChunkUtils.mapChunkObjectNames(MinIoChunkUtils.chunkBucKet,uploadDto.getFileMd5());
-                }
+                okChunkMap = MinIoChunkUtils.mapChunkObjectNames(MinIoChunkUtils.chunkBucKet,uploadDto.getFileMd5());
             }
             for (int i = 1; i <= uploadDto.getChunkCount(); i++) {
                 if(okChunkMap.containsKey(i)){
@@ -100,7 +92,6 @@ public class UploadController extends BaseController{
         BeanUtils.copyProperties(uploadDto,vo);
         vo.setUploadChunkVos(uploadChunkVos);
 
-        redisUtil.set(redisKey, JSONObject.toJSONString(vo),5);
         return ResultData.ok(vo);
     }
 

+ 3 - 2
src/main/java/com/fdkankan/fusion/httpClient/FdService.java

@@ -136,10 +136,11 @@ public class FdService {
         return fdkkResponse.getData();
     }
 
-    public void copyScene(String num) {
+    public void copyScene(String num,Integer sourceId) {
         HashMap<String, Object> param = new HashMap<>();
         param.put("num",num);
-        JSONObject jsonObject = fdKKClient.copyScene(param, new Date().getTime());
+        param.put("sourceId",sourceId);
+        JSONObject jsonObject = fdKKClient.copyScene(param, "m_a_n_a_g_e");
         Integer code = jsonObject.getInteger("code");
         String message = jsonObject.getString("message");
         if(code != 0){

+ 4 - 2
src/main/java/com/fdkankan/fusion/httpClient/client/FdKKClient.java

@@ -105,8 +105,10 @@ public interface FdKKClient {
     @Post("/api/user/scene/delete")
     void deleteNum(@JSONBody FdkkDelNumParam param, @Header("token")  String fdToken);
 
-    @Get("/service/manage/inner/copyScene")
-    JSONObject copyScene( @Query HashMap<String, Object> param ,@Header("sign") Long sign);
+
+    @Get("/ucenter/_manage/_copy_scene")
+    JSONObject copyScene( @Query HashMap<String, Object> param ,@Header("sign") String sign);
+
     @Post("/api/scene/file/reverseScene")
     JSONObject reverseScene( @JSONBody UploadEditSceneParam param);
 }

+ 1 - 0
src/main/java/com/fdkankan/fusion/response/ModelVo.java

@@ -8,5 +8,6 @@ public class ModelVo extends Model {
     private Integer uploadStatus;
     private String uploadTitle;
     private Integer fileType;
+    private String nickName;
 
 }

+ 1 - 0
src/main/java/com/fdkankan/fusion/response/SceneVo.java

@@ -40,4 +40,5 @@ public class SceneVo extends Model {
      *             "    Scene_Location_SLAMPointAndSFMAI  6   //slam实时拍+站点\n" +
      */
     private Integer location;
+    private String nickName;
 }

+ 1 - 0
src/main/java/com/fdkankan/fusion/service/ITmUserService.java

@@ -55,4 +55,5 @@ public interface ITmUserService extends IService<TmUser> {
     List<TmUser> getByDeptIds(List<String> deptIds);
 
     HashMap<String, TmDepartment> getMapByUserNames(List<String> userNameList);
+    HashMap<String, TmUser> getUserMapByUserNames(List<String> userNameList);
 }

+ 11 - 1
src/main/java/com/fdkankan/fusion/service/impl/ModelServiceImpl.java

@@ -205,7 +205,7 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
                 }
             }
         }
-        if(modelId == null && uploadId != null){
+        if(uploadId != null){
             UploadChunk uploadChunk = uploadChunkService.getById(uploadId);
             if(uploadChunk != null){
                 uploadChunkService.removeById(uploadChunk.getId());
@@ -325,6 +325,15 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
         }
         modelEntity.setModelTitle(modelEntity.getModelTitle() +"(copy)");
         modelEntity.setModelId(null);
+        Integer sourceId = null;
+        if(modelEntity.getUploadId() != null){
+            UploadChunk uploadChunk = uploadChunkService.getById(modelEntity.getUploadId());
+            uploadChunk.setId(null);
+            uploadChunk.setTitle(uploadChunk.getTitle() +"(copy)");
+            uploadChunkService.save(uploadChunk);
+            sourceId = uploadChunk.getId();
+        }
+        modelEntity.setUploadId(sourceId);
         this.save(modelEntity);
     }
 
@@ -336,6 +345,7 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
         modelEntity.setModelTitle(uploadChunk.getTitle());
         modelEntity.setUserName(uploadChunk.getUserName());
         modelEntity.setDeptId(uploadChunk.getDeptId());
+        modelEntity.setUploadId(uploadChunk.getId());
         modelEntity.setModelId(null);
         this.save(modelEntity);
     }

+ 41 - 5
src/main/java/com/fdkankan/fusion/service/impl/SceneService.java

@@ -89,24 +89,45 @@ public class SceneService implements ISceneService {
         return listAll;
     }
 
+    @Autowired
+    ITmUserRoleService tmUserRoleService;
+    @Autowired
+    ITmRoleService tmRoleService;
+
     @Override
     public PageInfo pageList(ScenePram param) {
         if (param.getType() == null) {
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
-        if (StringUtils.isBlank(param.getShare()) && StringUtils.isNotBlank(StpUtil.getTokenValue())) {
+        Boolean hasSon = false;
+        if (StringUtils.isBlank(param.getShare()) && StringUtils.isNotBlank(StpUtil.getTokenValue()) && StringUtils.isBlank(param.getDeptId())) {
+            TmUser loginUser = tmUserService.getLoginUser();
+            TmRole byUserId = tmRoleService.getByUserId(loginUser.getId());
+            if(!byUserId.getRoleKey().equals("admin-ordinary")){
+                hasSon = true;
+            }
             param.setDeptId(tmUserService.getLoginUser().getDeptId());
         }
         if (param.getCaseId() != null) {
+            hasSon = false;
             String deptId = caseService.getDeptId(param.getCaseId());
             param.setDeptId(deptId);
         }
         if (StringUtils.isNotBlank(param.getDeptId())) {
-            List<TmDepartment> sonByDeptId = tmDepartmentService.getSonByDeptId(param.getDeptId());
-            List<String> deptIds = sonByDeptId.stream().map(TmDepartment::getId).collect(Collectors.toList());
+            List<String> deptIds = new ArrayList<>();
+            if(hasSon){
+                List<TmDepartment> sonByDeptId = tmDepartmentService.getSonByDeptId(param.getDeptId());
+                deptIds = sonByDeptId.stream().map(TmDepartment::getId).collect(Collectors.toList());
+            }
             deptIds.add(param.getDeptId());
             List<TmUser> byDeptIds = tmUserService.getByDeptIds(deptIds);
+            if(byDeptIds.isEmpty()){
+                return  PageInfo.PageInfo(new Page<>(param.getPageNum(),param.getPageSize()));
+            }
             List<String> userNames = byDeptIds.stream().map(TmUser::getUserName).collect(Collectors.toList());
+            if(userNames.isEmpty()){
+                return  PageInfo.PageInfo(new Page<>(param.getPageNum(),param.getPageSize()));
+            }
             param.setUserNames(userNames);
         }
         if((param.getType() == 2 || param.getType() == 5) && StringUtils.isNotBlank(param.getSceneName())){
@@ -148,7 +169,13 @@ public class SceneService implements ISceneService {
 
         List<String> userNameList = sceneVoPage.getRecords().stream().map(Model::getUserName).collect(Collectors.toList());
         HashMap<String, TmDepartment> map = tmUserService.getMapByUserNames(userNameList);
+        HashMap<String, TmUser> mapUser = tmUserService.getUserMapByUserNames(userNameList);
         for (SceneVo sceneVo : sceneVoPage.getRecords()) {
+            TmUser tmUser = mapUser.get(sceneVo.getUserName());
+            if(tmUser != null){
+                sceneVo.setNickName(tmUser.getNickName());
+            }
+
             TmDepartment tmDepartment = map.get(sceneVo.getUserName());
             if (tmDepartment != null) {
                 sceneVo.setDeptId(tmDepartment.getId());
@@ -283,7 +310,7 @@ public class SceneService implements ISceneService {
             }
             fdService.deleteNum(num);
         }
-        if(StringUtils.isBlank(num) && uploadId != null){
+        if( uploadId != null){
             UploadChunk uploadChunk = uploadChunkService.getById(uploadId);
             if(uploadChunk != null){
                 uploadChunkService.removeById(uploadId);
@@ -306,8 +333,17 @@ public class SceneService implements ISceneService {
         if(StringUtils.isEmpty(param.getNum())){
             throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
         }
+        ScenePlus byNum = scenePlusService.getByNum(param.getNum());
+        Integer sourceId = null;
+        if(byNum.getSourceId() != null){
+            UploadChunk uploadChunk = uploadChunkService.getById(byNum.getSourceId());
+            uploadChunk.setId(null);
+            uploadChunk.setTitle(uploadChunk.getTitle() +"(copy)");
+            uploadChunkService.save(uploadChunk);
+            sourceId = uploadChunk.getId();
+        }
 
-        fdService.copyScene(param.getNum());
+        fdService.copyScene(param.getNum(),sourceId);
     }
 
 }

+ 21 - 0
src/main/java/com/fdkankan/fusion/service/impl/TmUserServiceImpl.java

@@ -30,6 +30,7 @@ import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Set;
@@ -381,6 +382,9 @@ public class TmUserServiceImpl extends ServiceImpl<ITmUserMapper, TmUser> implem
 
     @Override
     public List<TmUser> getByDeptIds(List<String> deptIds) {
+        if(deptIds == null || deptIds.isEmpty()){
+            return new ArrayList<>();
+        }
         LambdaQueryWrapper<TmUser> wrapper = new LambdaQueryWrapper<>();
         wrapper.in(TmUser::getDeptId,deptIds);
         return this.list(wrapper);
@@ -412,4 +416,21 @@ public class TmUserServiceImpl extends ServiceImpl<ITmUserMapper, TmUser> implem
         }
         return map;
     }
+
+    @Override
+    public HashMap<String, TmUser> getUserMapByUserNames(List<String> userNameList) {
+
+        HashMap<String, TmUser> map = new HashMap<>();
+        if(userNameList == null || userNameList.isEmpty()){
+            return map;
+        }
+        LambdaQueryWrapper<TmUser> wrapper = new LambdaQueryWrapper<>();
+        wrapper.in(TmUser::getUserName,userNameList);
+        List<TmUser> list = this.list(wrapper);
+        if(list.isEmpty()){
+            return map;
+        }
+        list.forEach(e -> map.put(e.getUserName(),e));
+        return map;
+    }
 }

+ 20 - 4
src/main/java/com/fdkankan/fusion/task/ThreadService2.java

@@ -12,6 +12,7 @@ import com.fdkankan.fusion.entity.UploadChunk;
 import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.service.IModelService;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.Async;
@@ -65,6 +66,7 @@ public class ThreadService2 {
                     resultFormat = "glb";
                     url = uploadObjOss(unZipPath,modelFile);break;
                 case "laz" :
+                    url = uploadLaz(unZipPath,modelFile); break;
                 case "shp" :
                     url = uploadOss(unZipPath,modelFile); break;
                 case "b3dm" :
@@ -78,12 +80,14 @@ public class ThreadService2 {
                 default:
                     break;
             }
-            model.setCreateStatus(1);
             model.setModelDateType(modelFileFormat);
-            model.setModelGlbUrl(url);
             model.setModelType(resultFormat);
-            ShellUtil.yunUpload(zipPath,zipPath.replace(FilePath.localPath,""));
-            model.setFileNewName(ossUrlPrefix + zipPath.replace(FilePath.localPath,""));
+            if(StringUtils.isNotBlank(url)){
+                model.setCreateStatus(1);
+                model.setModelGlbUrl(url);
+                ShellUtil.yunUpload(zipPath,zipPath.replace(FilePath.localPath,""));
+                model.setFileNewName(ossUrlPrefix + zipPath.replace(FilePath.localPath,""));
+            }
         }
 
         modelService.save(model);
@@ -93,6 +97,8 @@ public class ThreadService2 {
     }
 
 
+
+
     private File checkUnzip(File unZipFile) {
         if(!unZipFile.exists() || !unZipFile.isDirectory()){
             log.info("toModel-解压失败-error:,{}",unZipFile.getPath());
@@ -183,4 +189,14 @@ public class ThreadService2 {
         FileUtil.del(unzipPath);
         return ossUrlPrefix +  ossPath + "/webcloud";
     }
+
+    private String uploadLaz(String unzipPath, File modelFile) {
+        String ossPath = unzipPath.replace(FilePath.localPath,"");
+        ShellUtil.yunUpload(unzipPath,ossPath);
+        if(!uploadToOssUtil.existKey(ossPath +"/cloud.js")){
+            return null;
+        }
+        FileUtil.del(unzipPath);
+        return ossUrlPrefix +  ossPath;
+    }
 }

+ 6 - 5
src/main/resources/mapper/fusion/ModelMapper.xml

@@ -6,8 +6,8 @@
         select * from (
         select
         u.model_id,u.model_title,u.model_date_type,u.model_size,u.model_obj_url,u.model_glb_url,u.type,u.user_name,u.create_status,u.num,
-        u.model_type,u.tb_status,u.create_time,u.dept_id,u.file_new_name,u.render_type,u.upload_id,null as uploadTitle,null as uploadStatus,null as fileType
-        from t_model u
+        u.model_type,u.tb_status,u.create_time,u.dept_id,u.file_new_name,u.render_type,u.upload_id,null as uploadTitle,null as uploadStatus,null as fileType,mu.nick_name
+        from t_model u left join  tm_user mu on u.user_name = mu.user_name
         where u.tb_status = 0 and u.type = 3 and u.upload_id is null
         <if test="param.deptId != null and param.deptId != ''">
             and u.dept_id = #{param.deptId}
@@ -19,7 +19,7 @@
             </foreach>
         </if>
         <if test="param.modelTitle != null and param.modelTitle !=''">
-            and u.model_tile like concat ('%',#{param.modelTitle},'%')
+            and u.model_title like concat ('%',#{param.modelTitle},'%')
         </if>
         <if test="param.status != null ">
             and u.create_status = #{param.status}
@@ -27,9 +27,10 @@
         UNION all
         select
         u.model_id,u.model_title,u.model_date_type,u.model_size,u.model_obj_url,u.model_glb_url,u.type,uc.user_name,u.create_status,u.num,
-        u.model_type,uc.tb_status,uc.create_time,uc.dept_id,u.file_new_name,u.render_type,uc.id as upload_id,uc.title as uploadTitle,uc.upload_status ,uc.file_type
+        u.model_type,uc.tb_status,uc.create_time,uc.dept_id,u.file_new_name,u.render_type,uc.id as upload_id,uc.title as uploadTitle,uc.upload_status ,uc.file_type,mu.nick_name
         from t_upload_chunk uc
         left join t_model u on uc.id = u.upload_id and u.tb_status = 0
+        left join tm_user mu on mu.user_name = uc.user_name
         where uc.tb_status = 0 and uc.file_type in (4,5,6)
         <if test="param.deptId != null and param.deptId != ''">
             and uc.dept_id = #{param.deptId}
@@ -42,7 +43,7 @@
         </if>
         <if test="param.modelTitle != null and param.modelTitle !=''">
             and (uc.title like concat ('%',#{param.modelTitle},'%') or
-            u.model_tile like concat ('%',#{param.modelTitle},'%'))
+            u.model_title like concat ('%',#{param.modelTitle},'%'))
         </if>
         <if test="param.status != null ">
             and u.create_status = #{param.status}