lyhzzz 1 year ago
parent
commit
91e94cef56
30 changed files with 717 additions and 32 deletions
  1. 11 0
      README.md
  2. 1 1
      pom.xml
  3. 2 1
      src/main/java/com/fdkankan/fusion/common/FilePath.java
  4. 7 1
      src/main/java/com/fdkankan/fusion/common/ResultCode.java
  5. 140 0
      src/main/java/com/fdkankan/fusion/common/util/MD5Checksum.java
  6. 122 5
      src/main/java/com/fdkankan/fusion/common/util/UploadToOssUtil.java
  7. 61 0
      src/main/java/com/fdkankan/fusion/controller/CaseSettingsResourceController.java
  8. 51 0
      src/main/java/com/fdkankan/fusion/controller/ModelController.java
  9. 50 0
      src/main/java/com/fdkankan/fusion/controller/SceneController.java
  10. 6 0
      src/main/java/com/fdkankan/fusion/entity/CaseEntity.java
  11. 10 0
      src/main/java/com/fdkankan/fusion/entity/CaseSettings.java
  12. 62 0
      src/main/java/com/fdkankan/fusion/entity/CaseSettingsResource.java
  13. 6 0
      src/main/java/com/fdkankan/fusion/entity/TmProject.java
  14. 5 5
      src/main/java/com/fdkankan/fusion/generate/AutoGenerate.java
  15. 11 0
      src/main/java/com/fdkankan/fusion/httpClient/FdService.java
  16. 3 0
      src/main/java/com/fdkankan/fusion/httpClient/client/FdKKClient.java
  17. 18 0
      src/main/java/com/fdkankan/fusion/mapper/ICaseSettingsResourceMapper.java
  18. 2 0
      src/main/java/com/fdkankan/fusion/request/ScenePram.java
  19. 29 0
      src/main/java/com/fdkankan/fusion/response/FileInfoVo.java
  20. 19 0
      src/main/java/com/fdkankan/fusion/service/ICaseSettingsResourceService.java
  21. 2 0
      src/main/java/com/fdkankan/fusion/service/IModelService.java
  22. 2 0
      src/main/java/com/fdkankan/fusion/service/ISceneService.java
  23. 1 1
      src/main/java/com/fdkankan/fusion/service/impl/CaseNumServiceImpl.java
  24. 30 0
      src/main/java/com/fdkankan/fusion/service/impl/CaseSettingsResourceServiceImpl.java
  25. 30 0
      src/main/java/com/fdkankan/fusion/service/impl/ModelServiceImpl.java
  26. 9 0
      src/main/java/com/fdkankan/fusion/service/impl/SceneService.java
  27. 17 17
      src/main/java/com/fdkankan/fusion/service/impl/ThreadService.java
  28. 4 0
      src/main/java/com/fdkankan/fusion/service/impl/TmProjectServiceImpl.java
  29. 1 1
      src/main/resources/application-test.yaml
  30. 5 0
      src/main/resources/mapper/fusion/CaseSettingsResourceMapper.xml

+ 11 - 0
README.md

@@ -49,4 +49,15 @@
 3.添加多数据源配置
 4.下载记录日志记录
 5.所属架构数据过滤
+~~~~
+
+
+###**xj**
+~~~~
+1.设置支持上传自定义图片
+    http://120.25.146.52:3090/project/369/interface/api/cat_1905
+2.案件设置地图链接
+    /addNewProject,/updateProject   接口添加参数 mapUrl和latAndLong
+3.添加场景复制,模型复制
+    http://120.25.146.52:3090/project/369/interface/api/cat_1909
 ~~~~

+ 1 - 1
pom.xml

@@ -120,7 +120,7 @@
         <dependency>
             <groupId>com.aliyun.oss</groupId>
             <artifactId>aliyun-sdk-oss</artifactId>
-            <version>2.8.3</version>
+            <version>3.6.0</version>
         </dependency>
 
 

+ 2 - 1
src/main/java/com/fdkankan/fusion/common/FilePath.java

@@ -5,7 +5,7 @@ public class FilePath {
     public final static String LOCAL_BASE_PATH = "/home/tomcat/jar-fusion-8808/";
     public final static String MNT_BASE_PATH = "/mnt/fusion/";
 
-    public final static String OBJ_OSS_PATH = "scene_view_data/%s/data/mesh";
+    public final static String OBJ_OSS_PATH = "scene_view_data/%s/data";
     public final static String GLB_OSS_PATH = "fusion/%s/model/glb/%s/mesh.glb";
     public final static String B3DM_OSS_PATH = "fusion/%s/model/b3dm/%s";
     public final static String VIDEO_OSS_PATH = "fusion/%s/video/%s";
@@ -16,6 +16,7 @@ public class FilePath {
    // public final static String VIDEO_LOCAL_PATH = "D:\\video\\merge";
    public final static String VIDEO_LOCAL_PATH = LOCAL_BASE_PATH + "%s/video/merge";
    public final static String OBJ_LOCAL_PATH = LOCAL_BASE_PATH + "%s/model/%s";
+   public final static String SCENE_LOCAL_PATH = LOCAL_BASE_PATH + "%s/scene/%s";
 
 
 }

+ 7 - 1
src/main/java/com/fdkankan/fusion/common/ResultCode.java

@@ -64,7 +64,13 @@ public enum ResultCode {
     CASE_HAVE_SETTINGS(7019,"案件已有设置,无法新增"),
 
     SS_SCENE_DOWN_ERROR(7020,"深时点云场景下载失败"),
-    FILE_NOT_EXIST(7021,"文件不存在,或已被刪除");
+    FILE_NOT_EXIST(7021,"文件不存在,或已被刪除"),
+
+    CAMERA_SPACE_ERROR(7022, "相机容量不足")
+
+
+    ;
+
 
     public int code;
     public String msg;

+ 140 - 0
src/main/java/com/fdkankan/fusion/common/util/MD5Checksum.java

@@ -0,0 +1,140 @@
+package com.fdkankan.fusion.common.util;
+
+import cn.hutool.core.io.FileUtil;
+import com.aliyun.oss.OSSClient;
+import com.aliyun.oss.model.GetObjectRequest;
+import com.fdkankan.fusion.response.FileInfoVo;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.security.MessageDigest;
+import java.util.Date;
+
+public class MD5Checksum {
+    public static byte[] createChecksum(String filePath,String sign)  {
+        try {
+            InputStream fis = new FileInputStream(filePath);
+            byte[] buffer = new byte[1024];
+            MessageDigest complete = MessageDigest.getInstance(sign);
+            int numRead;
+
+            do {
+                numRead = fis.read(buffer);
+                if (numRead > 0) {
+                    complete.update(buffer, 0, numRead);
+                }
+            } while (numRead != -1);
+
+            fis.close();
+            return complete.digest();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+
+        return null;
+    }
+
+    public static byte[] createChecksum(InputStream fis,String sign)  {
+        try {
+            byte[] buffer = new byte[1024];
+            MessageDigest complete = MessageDigest.getInstance(sign);
+            int numRead;
+
+            do {
+                numRead = fis.read(buffer);
+                if (numRead > 0) {
+                    complete.update(buffer, 0, numRead);
+                }
+            } while (numRead != -1);
+
+            return complete.digest();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+
+        return null;
+    }
+
+    public static String getMD5(String filePath)  {
+        byte[] b = createChecksum(filePath,"MD5");
+        if(b == null){
+            return null;
+        }
+        StringBuilder result = new StringBuilder();
+
+        for (byte element : b) {
+            result.append(Integer.toString((element & 0xff) + 0x100, 16).substring(1));
+        }
+
+        return result.toString();
+    }
+
+    public static String getMD5(InputStream filePath)  {
+        byte[] b = createChecksum(filePath,"MD5");
+        if(b == null){
+            return null;
+        }
+        StringBuilder result = new StringBuilder();
+
+        for (byte element : b) {
+            result.append(Integer.toString((element & 0xff) + 0x100, 16).substring(1));
+        }
+
+        return result.toString();
+    }
+
+    public static String getSHA1(String filePath)  {
+        byte[] b = createChecksum(filePath,"SHA1");
+        StringBuilder result = new StringBuilder();
+        if(b == null){
+            return null;
+        }
+        for (byte element : b) {
+            result.append(Integer.toString((element & 0xff) + 0x100, 16).substring(1));
+        }
+
+        return result.toString();
+    }
+    public static String getSHA1(InputStream filePath)  {
+        byte[] b = createChecksum(filePath,"SHA1");
+        StringBuilder result = new StringBuilder();
+        if(b == null){
+            return null;
+        }
+        for (byte element : b) {
+            result.append(Integer.toString((element & 0xff) + 0x100, 16).substring(1));
+        }
+
+        return result.toString();
+    }
+
+    public static Long getLastModifiedTime(String filePath)  {
+        File file = new File(filePath);
+        return file.lastModified();
+    }
+    public static Long getSize(String filePath)  {
+        File file = new File(filePath);
+        return file.length();
+    }
+
+
+    public static FileInfoVo getFileInfo(String filePath){
+        try {
+            return new FileInfoVo(
+                    getMD5(filePath).toUpperCase(),
+                    getSHA1(filePath).toUpperCase(),
+                    getLastModifiedTime(filePath),
+                    getSize(filePath));
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    public static void main(String[] args) {
+        FileInfoVo fileInfo = getFileInfo("D:\\abc\\1.txt");
+        FileUtil.writeString(fileInfo.toString(),new File("D:\\abc\\hash.txt"),"UTF-8");
+        System.out.println();
+    }
+}

+ 122 - 5
src/main/java/com/fdkankan/fusion/common/util/UploadToOssUtil.java

@@ -3,21 +3,21 @@ package com.fdkankan.fusion.common.util;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.io.FileUtil;
 import com.aliyun.oss.OSSClient;
+import com.aliyun.oss.common.utils.BinaryUtil;
 import com.aliyun.oss.model.*;
+import com.fdkankan.fusion.response.FileInfoVo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
+import org.springframework.util.ObjectUtils;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.commons.CommonsMultipartFile;
 
 import java.io.*;
 import java.net.*;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -39,7 +39,6 @@ public class UploadToOssUtil {
 
 
 
-
 	/**
 	 * 获取文件内容-阿里云
 	 * @param objectName
@@ -213,4 +212,122 @@ public class UploadToOssUtil {
 			}
 		}
 	}
+
+	public void copyFile( String sourcePath, String targetPath) {
+		OSSClient ossClient = new OSSClient(point, key, secrey);
+
+		try {
+			List<String> files = listKeysFromAli( sourcePath);
+			if (ObjectUtils.isEmpty(files)) {
+				return;
+			}
+			files.stream().forEach(file -> {
+				log.info("oss-copy-file---sourcePath:{},targetPath:{}",sourcePath,targetPath);
+				ossClient.copyObject(this.bucket, file, this.bucket, file.replace(sourcePath, targetPath));
+			});
+		} catch (Exception e) {
+			log.error("列举文件目录失败,key:" + sourcePath, e);
+		}finally {
+			if(ossClient != null){
+				ossClient.shutdown();
+			}
+		}
+	}
+
+	private String getMd5(String filePath){
+		OSSClient ossClient = new OSSClient(point, key, secrey);
+		String md5 = null;
+		try {
+			InputStream inputStream = ossClient.getObject(bucket, filePath).getObjectContent();
+			md5 = MD5Checksum.getMD5(inputStream);
+			log.info("Calculated MD5 for " + filePath + " is " + md5);
+			inputStream.close();
+		}catch (Exception e){
+			log.info("oss-getMd5-error:{}",e);
+		}finally {
+			if(ossClient != null){
+				ossClient.shutdown();
+			}
+		}
+		return md5;
+	}
+
+	private String getSHA1(String filePath){
+		OSSClient ossClient = new OSSClient(point, key, secrey);
+		String md5 = null;
+		try {
+			InputStream inputStream = ossClient.getObject(bucket, filePath).getObjectContent();
+			md5 = MD5Checksum.getSHA1(inputStream);
+			log.info("Calculated MD5 for " + filePath + " is " + md5);
+			inputStream.close();
+		}catch (Exception e){
+			log.info("oss-getMd5-error:{}",e);
+		}finally {
+			if(ossClient != null){
+				ossClient.shutdown();
+			}
+		}
+		return md5;
+	}
+	private Long getLastModified(String filePath){
+		OSSClient ossClient = new OSSClient(point, key, secrey);
+		try {
+			GetObjectRequest getObjectMetadataRequest = new GetObjectRequest(bucket, filePath);
+			Date  LastMo = ossClient.getObjectMetadata(getObjectMetadataRequest).getLastModified();
+			return LastMo.getTime();
+		}catch (Exception e){
+			log.info("oss-getMd5-error:{}",e);
+		}finally {
+			if(ossClient != null){
+				ossClient.shutdown();
+			}
+		}
+		return null;
+	}
+
+	public FileInfoVo getFileInfo(String filePath){
+		OSSClient ossClient = new OSSClient(point, key, secrey);
+		try {
+			GetObjectRequest getObjectMetadataRequest = new GetObjectRequest(bucket, filePath);
+			Date LastMo = ossClient.getObjectMetadata(getObjectMetadataRequest).getLastModified();
+			String md5 = ossClient.getObjectMetadata(getObjectMetadataRequest).getETag();
+			Long size = ossClient.getObjectMetadata(getObjectMetadataRequest).getContentLength();
+
+			InputStream inputStream = ossClient.getObject(bucket, filePath).getObjectContent();
+			String sha1 = MD5Checksum.getSHA1(inputStream);
+			return new FileInfoVo(md5,sha1.toUpperCase(),LastMo.getTime(),size);
+		}catch (Exception e){
+			log.info("oss-getFileInfo-error:{}",e);
+		}finally {
+			if(ossClient != null){
+				ossClient.shutdown();
+			}
+		}
+		return null;
+	}
+
+	public Long getSize(String filePath){
+		OSSClient ossClient = new OSSClient(point, key, secrey);
+		Long total = 0L;
+		try {
+			List<String> files = listKeysFromAli( filePath);
+			if (ObjectUtils.isEmpty(files)) {
+				return 0L;
+			}
+			for (String file : files) {
+				GetObjectRequest getObjectMetadataRequest = new GetObjectRequest(bucket, file);
+				Long size = ossClient.getObjectMetadata(getObjectMetadataRequest).getContentLength();
+				total += size;
+			}
+
+		}catch (Exception e){
+			log.info("oss-getFileInfo-error:{}",e);
+		}finally {
+			if(ossClient != null){
+				ossClient.shutdown();
+			}
+		}
+		return total;
+	}
+
 }

+ 61 - 0
src/main/java/com/fdkankan/fusion/controller/CaseSettingsResourceController.java

@@ -0,0 +1,61 @@
+package com.fdkankan.fusion.controller;
+
+
+import com.fdkankan.fusion.common.ResultCode;
+import com.fdkankan.fusion.common.ResultData;
+import com.fdkankan.fusion.entity.CaseSettings;
+import com.fdkankan.fusion.entity.CaseSettingsResource;
+import com.fdkankan.fusion.exception.BusinessException;
+import com.fdkankan.fusion.service.ICaseSettingsResourceService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 
+ * @since 2024-07-03
+ */
+@RestController
+@RequestMapping("/settingsResource")
+public class CaseSettingsResourceController {
+
+    @Autowired
+    ICaseSettingsResourceService caseSettingsResourceService;
+
+
+    @GetMapping("/info")
+    public ResultData info(@RequestParam(required = false) Integer caseId){
+        if(caseId == null){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        return ResultData.ok(caseSettingsResourceService.getByCaseId(caseId));
+    }
+
+
+    @PostMapping("/saveOrUpdate")
+    public ResultData saveOrUpdate(@RequestBody CaseSettingsResource settingsResource){
+        if(settingsResource.getCaseId() == null){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        caseSettingsResourceService.saveOrUpdate(settingsResource);
+        return ResultData.ok();
+    }
+
+    @PostMapping("/delete")
+    public ResultData delete(@RequestBody CaseSettingsResource settingsResource){
+        if(settingsResource.getId() == null){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        CaseSettingsResource byId = caseSettingsResourceService.getById(settingsResource.getId());
+        if(byId != null){
+            caseSettingsResourceService.removeById(settingsResource.getId());
+        }
+        return ResultData.ok();
+    }
+}
+

+ 51 - 0
src/main/java/com/fdkankan/fusion/controller/ModelController.java

@@ -1,21 +1,33 @@
 package com.fdkankan.fusion.controller;
 
 
+import cn.hutool.core.io.FileUtil;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.fdkankan.fusion.common.FilePath;
 import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.common.ResultData;
 import com.fdkankan.fusion.common.ResultCode;
+import com.fdkankan.fusion.common.util.MD5Checksum;
 import com.fdkankan.fusion.entity.Model;
 import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.request.ModelPram;
 import com.fdkankan.fusion.request.ScenePram;
+import com.fdkankan.fusion.response.FileInfoVo;
 import com.fdkankan.fusion.service.*;
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+
 /**
  * <p>
  *  前端控制器
@@ -82,5 +94,44 @@ public class ModelController extends BaseController{
         modelService.update(wrapper);
         return ResultData.ok();
     }
+
+    @PostMapping("/copyModel")
+    public ResultData copyModel(@RequestBody ModelPram param){
+        if(param.getModelId() == null){
+            throw  new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        modelService.copyModel(param.getModelId());
+        return ResultData.ok();
+    }
+
+    @Value("${spring.profiles.active}")
+    private String environment;
+    @GetMapping("/downMD5")
+    public void downMD5(@RequestParam(required = false) Integer modelId,
+                        HttpServletResponse res, HttpServletRequest req) throws IOException {
+        OutputStream os = res.getOutputStream();
+        try {
+            Model model = modelService.getById(modelId);
+            if(model == null){
+                throw new BusinessException(ResultCode.MODEL_NOT_EXIST);
+            }
+
+            String objPath = String.format(FilePath.OBJ_LOCAL_PATH,environment , "modelId_"+modelId) ;
+
+            FileInfoVo fileInfo = MD5Checksum.getFileInfo(objPath + "/" + model.getModelTitle() + ".zip");
+            if(fileInfo == null){
+                throw new BusinessException(ResultCode.FILE_NOT_EXIST);
+            }
+            File file = new File(objPath +"/"+modelId + "_hash.txt");
+
+            FileUtil.writeString(fileInfo.toString(),file,"UTF-8");
+
+            os.write(FileUtils.readFileToByteArray(file));
+            os.flush();
+        } finally {
+            os.close();
+        }
+    }
+
 }
 

+ 50 - 0
src/main/java/com/fdkankan/fusion/controller/SceneController.java

@@ -1,16 +1,31 @@
 package com.fdkankan.fusion.controller;
 
+import cn.hutool.core.io.FileUtil;
+import com.fdkankan.fusion.common.FilePath;
 import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.common.ResultData;
+import com.fdkankan.fusion.common.util.UploadToOssUtil;
 import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.httpClient.request.LaserSceneParam;
 import com.fdkankan.fusion.request.ScenePram;
+import com.fdkankan.fusion.response.FileInfoVo;
 import com.fdkankan.fusion.response.SceneProEntityVo;
 import com.fdkankan.fusion.service.ISceneService;
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+
 @RestController
 @RequestMapping("/scene")
 public class SceneController extends BaseController{
@@ -47,4 +62,39 @@ public class SceneController extends BaseController{
         sceneService.buildSceneObj(param);
         return ResultData.ok();
     }
+
+    @PostMapping("/copyScene")
+    public ResultData copyScene(@RequestBody ScenePram param){
+        sceneService.copyScene(param);
+        return ResultData.ok();
+    }
+
+    @Autowired
+    UploadToOssUtil uploadToOssUtil;
+
+    @Value("${spring.profiles.active}")
+    private String environment;
+    @GetMapping("/downMD5")
+    public void downMD5(@RequestParam(required = false) String num,
+                               HttpServletResponse res, HttpServletRequest req) throws IOException {
+        OutputStream os = res.getOutputStream();
+        try {
+            String sceneObjPath = String.format(FilePath.OBJ_OSS_PATH, "num")+"/data/scene.json" ;
+
+            FileInfoVo fileInfo = uploadToOssUtil.getFileInfo(sceneObjPath);
+            if(fileInfo == null){
+                throw new BusinessException(ResultCode.FILE_NOT_EXIST);
+            }
+            String scenePath = String.format(FilePath.OBJ_OSS_PATH, "num");
+            Long size = uploadToOssUtil.getSize(scenePath);
+            fileInfo.setSize(size);
+            String objPath = String.format(FilePath.OBJ_LOCAL_PATH,environment , "num") ;
+            File file = new File(objPath +"/"+num + "_hash.txt");
+            FileUtil.writeString(fileInfo.toString(),file,"UTF-8");
+            os.write(FileUtils.readFileToByteArray(file));
+            os.flush();
+        } finally {
+            os.close();
+        }
+    }
 }

+ 6 - 0
src/main/java/com/fdkankan/fusion/entity/CaseEntity.java

@@ -62,6 +62,12 @@ public class CaseEntity implements Serializable {
     @TableField("dept_id")
     private String deptId;
 
+    @TableField("map_url")
+    private String mapUrl;
+
+    @TableField("lat_and_long")
+    private String latAndLong;
+
     @TableField(exist = false)
     private String deptName;
 }

+ 10 - 0
src/main/java/com/fdkankan/fusion/entity/CaseSettings.java

@@ -55,6 +55,16 @@ public class CaseSettings implements Serializable {
     @TableField("back")
     private String back;
 
+    /**
+     * 背景类型
+     *   color = "color",
+     *   envImage = "img",
+     *   bottomImage = "bimg",
+     *   icon = "icon",
+     */
+    @TableField("back_type")
+    private String backType;
+
     @TableField("tb_status")
     @TableLogic
     private Integer tbStatus;

+ 62 - 0
src/main/java/com/fdkankan/fusion/entity/CaseSettingsResource.java

@@ -0,0 +1,62 @@
+package com.fdkankan.fusion.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 
+ * @since 2024-07-03
+ */
+@Getter
+@Setter
+@TableName("t_case_settings_resource")
+public class CaseSettingsResource implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    @TableField("case_id")
+    private Integer caseId;
+
+    /**
+     * 名称
+     */
+    @TableField("name")
+    private String name;
+
+    /**
+     * 资源链接
+     */
+    @TableField("resource")
+    private String resource;
+
+    /**
+     */
+    @TableField("back_type")
+    private String backType;
+
+    @TableField("tb_status")
+    @TableLogic
+    private Integer tbStatus;
+
+    @TableField("create_time")
+    private Date createTime;
+
+    @TableField("update_time")
+    private Date updateTime;
+
+
+}

+ 6 - 0
src/main/java/com/fdkankan/fusion/entity/TmProject.java

@@ -186,6 +186,12 @@ public class TmProject implements Serializable {
     @TableField(exist = false)
     private Integer caseId;
 
+    @TableField(exist = false)
+    private String mapUrl;
+
+    @TableField(exist = false)
+    private String latAndLong;
+
     public String getStatusDesc() {
         if(status !=null){
             switch (status){

+ 5 - 5
src/main/java/com/fdkankan/fusion/generate/AutoGenerate.java

@@ -18,7 +18,7 @@ public class AutoGenerate {
         String path =System.getProperty("user.dir") ;
 
         generate(path,"fusion", getTables(new String[]{
-               "t_camera","t_camera_detail"
+               "t_case_settings_resource"
         }));
 
 //        generate(path,"goods", getTables(new String[]{
@@ -46,10 +46,10 @@ public class AutoGenerate {
 
 
     public static void  generate(String path,String moduleName,  List<String> tables){
-//        FastAutoGenerator.create("jdbc:mysql://120.25.146.52:13306/fd_fusion",
-//                "root","JK123456%JIK")
-        FastAutoGenerator.create("jdbc:mysql://120.24.144.164:3306/4dkankan_v4",
-                "root","4Dage@4Dage#@168")
+        FastAutoGenerator.create("jdbc:mysql://120.25.146.52:13306/fd_fusion_xj",
+                "root","JK123456%JIK")
+//        FastAutoGenerator.create("jdbc:mysql://120.24.144.164:3306/4dkankan_v4",
+//                "root","4Dage@4Dage#@168")
                 .globalConfig(builder -> {
                     builder.author("")               //作者
                             .outputDir(path+"\\src\\main\\java")    //输出路径(写到java目录)

+ 11 - 0
src/main/java/com/fdkankan/fusion/httpClient/FdService.java

@@ -27,6 +27,7 @@ import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -125,4 +126,14 @@ public class FdService {
         }
         return fdkkResponse.getData();
     }
+
+    public void copyScene(String num) {
+        HashMap<String, Object> param = new HashMap<>();
+        param.put("num",num);
+        JSONObject jsonObject = fdKKClient.copyScene(param, new Date().getTime());
+        Integer code = jsonObject.getInteger("code");
+        if(code != 0){
+            throw new BusinessException(ResultCode.CAMERA_SPACE_ERROR);
+        }
+    }
 }

+ 3 - 0
src/main/java/com/fdkankan/fusion/httpClient/client/FdKKClient.java

@@ -107,4 +107,7 @@ 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);
 }

+ 18 - 0
src/main/java/com/fdkankan/fusion/mapper/ICaseSettingsResourceMapper.java

@@ -0,0 +1,18 @@
+package com.fdkankan.fusion.mapper;
+
+import com.fdkankan.fusion.entity.CaseSettingsResource;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 
+ * @since 2024-07-03
+ */
+@Mapper
+public interface ICaseSettingsResourceMapper extends BaseMapper<CaseSettingsResource> {
+
+}

+ 2 - 0
src/main/java/com/fdkankan/fusion/request/ScenePram.java

@@ -21,6 +21,8 @@ public class ScenePram extends RequestBase {
 
     private String share;
 
+    private String num;
+
     public String getSceneName() {
         return sceneName== null ?null :sceneName.trim();
     }

+ 29 - 0
src/main/java/com/fdkankan/fusion/response/FileInfoVo.java

@@ -0,0 +1,29 @@
+package com.fdkankan.fusion.response;
+
+
+import cn.hutool.core.date.DateUtil;
+import com.fdkankan.fusion.common.util.DateUtils;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+@AllArgsConstructor
+public class FileInfoVo {
+
+    private String MD5;
+    private String SHA1;
+    private Long lastModified;
+    private Long size;
+
+    @Override
+    public String toString() {
+        return
+                "MD5:" + MD5 + '\n' +
+                "SHA1:" + SHA1 + '\n' +
+                "修改时间:" + DateUtil.format(new Date(lastModified),"yyyy-mm-dd HH:mm:ss") +'\n' +
+                "大小:" + size +"字节"
+                ;
+    }
+}

+ 19 - 0
src/main/java/com/fdkankan/fusion/service/ICaseSettingsResourceService.java

@@ -0,0 +1,19 @@
+package com.fdkankan.fusion.service;
+
+import com.fdkankan.fusion.entity.CaseSettingsResource;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 
+ * @since 2024-07-03
+ */
+public interface ICaseSettingsResourceService extends IService<CaseSettingsResource> {
+
+    List<CaseSettingsResource> getByCaseId(Integer caseId);
+}

+ 2 - 0
src/main/java/com/fdkankan/fusion/service/IModelService.java

@@ -44,4 +44,6 @@ public interface IModelService extends IService<Model> {
     void cancelUpload(Integer modelId);
 
     HashMap<String, Model> getMapByNum(List<String> numList);
+
+    void copyModel(Integer modelId);
 }

+ 2 - 0
src/main/java/com/fdkankan/fusion/service/ISceneService.java

@@ -20,4 +20,6 @@ public interface ISceneService {
     void buildSceneObj(LaserSceneParam param);
 
     Object sceneDetail(LaserSceneParam param);
+
+    void copyScene(ScenePram param);
 }

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

@@ -121,7 +121,7 @@ public class CaseNumServiceImpl extends ServiceImpl<ICaseNumMapper, CaseNumEntit
 //            if(uploadToOssUtil.existKey(glbOssPath)){
 //                return queryPath + "/"+glbOssPath;
 //            }
-            ShellUtil.yunDownload(String.format(FilePath.OBJ_OSS_PATH, num) ,objPath);
+            ShellUtil.yunDownload(String.format(FilePath.OBJ_OSS_PATH, num)+"/data/mesh" ,objPath);
             List<String> localGlbPaths = new ArrayList<>();
             List<String> ossGlbPaths = new ArrayList<>();
             File localFile = new File(objPath);

+ 30 - 0
src/main/java/com/fdkankan/fusion/service/impl/CaseSettingsResourceServiceImpl.java

@@ -0,0 +1,30 @@
+package com.fdkankan.fusion.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.fusion.entity.CaseSettingsResource;
+import com.fdkankan.fusion.mapper.ICaseSettingsResourceMapper;
+import com.fdkankan.fusion.service.ICaseSettingsResourceService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 
+ * @since 2024-07-03
+ */
+@Service
+public class CaseSettingsResourceServiceImpl extends ServiceImpl<ICaseSettingsResourceMapper, CaseSettingsResource> implements ICaseSettingsResourceService {
+
+
+    @Override
+    public List<CaseSettingsResource> getByCaseId(Integer caseId) {
+        LambdaQueryWrapper<CaseSettingsResource> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(CaseSettingsResource::getCaseId,caseId);
+        return this.list(wrapper);
+    }
+}

+ 30 - 0
src/main/java/com/fdkankan/fusion/service/impl/ModelServiceImpl.java

@@ -294,4 +294,34 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
         modelList.forEach(entity-> map.put(entity.getNum() + entity.getType(),entity));
         return map;
     }
+
+    @Override
+    public void copyModel(Integer modelId) {
+        Model modelEntity = this.getById(modelId);
+        if(modelEntity == null){
+            throw new BusinessException(ResultCode.MODEL_NOT_EXIST);
+        }
+        Integer oldId = modelEntity.getModelId();
+        modelEntity.setModelId(null);
+        this.save(modelEntity);
+        if(StringUtils.isNotBlank(modelEntity.getModelGlbUrl())){
+            String modelObjUrl = modelEntity.getModelObjUrl();
+            copyOssResource(modelObjUrl,oldId,modelEntity.getModelId());
+            String newModelObjUrl = modelObjUrl.replaceAll(oldId+"",modelEntity.getModelId()+"");
+            modelEntity.setModelGlbUrl(newModelObjUrl);
+            this.updateById(modelEntity);
+        }
+
+    }
+
+
+    private void copyOssResource(String modelObjUrl,Integer oldModelId,Integer newModelId) {
+        JSONArray jsonArray = JSONArray.parseArray(modelObjUrl);
+        for (Object object : jsonArray) {
+            String ossUrl = (String) object;
+            String oldOssPath = ossUrl.replaceAll(queryPath,"");
+            String newOssPath = oldOssPath.replaceAll(oldModelId+"",newModelId+"");
+            uploadToOssUtil.copyFile(oldOssPath,newOssPath);
+        }
+    }
 }

+ 9 - 0
src/main/java/com/fdkankan/fusion/service/impl/SceneService.java

@@ -300,4 +300,13 @@ public class SceneService implements ISceneService {
     public Object sceneDetail(LaserSceneParam param) {
         return fdService.sceneDetail(param);
     }
+
+    @Override
+    public void copyScene(ScenePram param) {
+        if(StringUtils.isEmpty(param.getNum())){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+
+        fdService.copyScene(param.getNum());
+    }
 }

+ 17 - 17
src/main/java/com/fdkankan/fusion/service/impl/ThreadService.java

@@ -111,8 +111,8 @@ public class ThreadService {
 
             String b3dmPath = objPathFile.getPath().replace(FilePath.LOCAL_BASE_PATH,"fusion/");
             if(name.contains(".osgb")){
-                model.setModelDateType("b3dm");
-                model.setModelType("b3dm");
+                model.setModelDateType("osgb");
+                model.setModelType("osgb");
 
                 redisUtil.set(RedisKeyUtil.modelUpload+model.getModelId(),"60");
                 String localPath = OBJToGLBUtil.OsgbToB3dm(objPathFile);
@@ -145,21 +145,21 @@ public class ThreadService {
             setCreateStatus(model,-1);
             log.error("uploadObj--ThreadError-modeId:{},error:{}",model.getModelId(),e);
         }finally {
-            if(newObjFile!=null){
-                FileUtil.del(newObjFile);
-            }
-            if(objPathFile!=null){
-                FileUtil.del(objPathFile);
-            }
-            if(mntFile!=null){
-                FileUtil.del(mntFile.getParentFile());
-            }
-            if(b3dmFile != null){
-                FileUtil.del(b3dmFile.getParentFile());
-            }
-            if(osgbFile != null){
-                FileUtil.del(osgbFile.getParentFile());
-            }
+//            if(newObjFile!=null){
+//                FileUtil.del(newObjFile);
+//            }
+//            if(objPathFile!=null){
+//                FileUtil.del(objPathFile);
+//            }
+//            if(mntFile!=null){
+//                FileUtil.del(mntFile.getParentFile());
+//            }
+//            if(b3dmFile != null){
+//                FileUtil.del(b3dmFile.getParentFile());
+//            }
+//            if(osgbFile != null){
+//                FileUtil.del(osgbFile.getParentFile());
+//            }
         }
     }
 

+ 4 - 0
src/main/java/com/fdkankan/fusion/service/impl/TmProjectServiceImpl.java

@@ -234,6 +234,8 @@ public class TmProjectServiceImpl extends ServiceImpl<ITmProjectMapper, TmProjec
         caseEntity.setUserName(tmUser.getUserName());
         caseEntity.setType(1);
         caseEntity.setTmProjectId(tmProject.getId());
+        caseEntity.setMapUrl(tmProject.getMapUrl());
+        caseEntity.setLatAndLong(tmProject.getLatAndLong());
         caseService.save(caseEntity);
     }
 
@@ -264,6 +266,8 @@ public class TmProjectServiceImpl extends ServiceImpl<ITmProjectMapper, TmProjec
 
         CaseEntity caseEntity = caseService.getByTmProjectId(tmProject.getId());
         caseEntity.setCaseTitle(tmProject.getProjectName());
+        caseEntity.setMapUrl(tmProject.getMapUrl());
+        caseEntity.setLatAndLong(tmProject.getLatAndLong());
         caseService.updateById(caseEntity);
     }
 

+ 1 - 1
src/main/resources/application-test.yaml

@@ -9,7 +9,7 @@ spring:
         db1:
           driver-class-name: com.mysql.jdbc.Driver
           #url: jdbc:mysql://120.25.146.52:13306/fd_fusion?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true
-          url: jdbc:mysql://127.0.0.1:13306/fd_fusion?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true
+          url: jdbc:mysql://127.0.0.1:13306/fd_fusion_xj?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true
           username: root
           password: JK123456%JIK
         db2:

+ 5 - 0
src/main/resources/mapper/fusion/CaseSettingsResourceMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fdkankan.fusion.mapper.ICaseSettingsResourceMapper">
+
+</mapper>