lyhzzz 4 months ago
parent
commit
526a805728
30 changed files with 851 additions and 237 deletions
  1. 14 3
      pom.xml
  2. 13 0
      src/main/java/com/fdkankan/fusion/common/OssPath.java
  3. 6 1
      src/main/java/com/fdkankan/fusion/common/ResultCode.java
  4. 50 0
      src/main/java/com/fdkankan/fusion/common/enums/FileTypeEnum.java
  5. 50 0
      src/main/java/com/fdkankan/fusion/common/util/CaseNumTypeUtil.java
  6. 8 0
      src/main/java/com/fdkankan/fusion/common/util/FileWriterUtil.java
  7. 1 1
      src/main/java/com/fdkankan/fusion/common/util/OBJToGLBUtil.java
  8. 1 1
      src/main/java/com/fdkankan/fusion/common/util/RedisKeyUtil.java
  9. 78 0
      src/main/java/com/fdkankan/fusion/common/util/SceneTypeUtil.java
  10. 1 1
      src/main/java/com/fdkankan/fusion/common/util/ShellUtil.java
  11. 5 2
      src/main/java/com/fdkankan/fusion/config/FusionConfig.java
  12. 1 73
      src/main/java/com/fdkankan/fusion/config/SaTokenConfigure.java
  13. 6 3
      src/main/java/com/fdkankan/fusion/controller/AiController.java
  14. 50 0
      src/main/java/com/fdkankan/fusion/controller/DictController.java
  15. 45 0
      src/main/java/com/fdkankan/fusion/controller/DictFileController.java
  16. 15 4
      src/main/java/com/fdkankan/fusion/controller/UploadController.java
  17. 22 9
      src/main/java/com/fdkankan/fusion/mq/consumer/OsgbToB3dmConsumer.java
  18. 17 0
      src/main/java/com/fdkankan/fusion/request/DictFileParam.java
  19. 10 0
      src/main/java/com/fdkankan/fusion/request/DictParam.java
  20. 27 0
      src/main/java/com/fdkankan/fusion/response/DictFileVo.java
  21. 10 7
      src/main/java/com/fdkankan/fusion/service/ICommonUploadService.java
  22. 9 3
      src/main/java/com/fdkankan/fusion/service/IDictFileService.java
  23. 11 2
      src/main/java/com/fdkankan/fusion/service/IDictService.java
  24. 255 37
      src/main/java/com/fdkankan/fusion/service/impl/CommonUploadServiceImpl.java
  25. 45 16
      src/main/java/com/fdkankan/fusion/service/impl/DictFileServiceImpl.java
  26. 54 16
      src/main/java/com/fdkankan/fusion/service/impl/DictServiceImpl.java
  27. 0 56
      src/main/java/com/fdkankan/fusion/task/TaskService.java
  28. 6 1
      src/main/resources/bootstrap-dev.yml
  29. 6 1
      src/main/resources/bootstrap-test.yml
  30. 35 0
      src/main/resources/mapper/fusion/DictFileMapper.xml

+ 14 - 3
pom.xml

@@ -144,11 +144,22 @@
 
 
         <dependency>
-            <groupId>com.aliyun.oss</groupId>
-            <artifactId>aliyun-sdk-oss</artifactId>
-            <version>3.6.0</version>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-utils-fyun-parent</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-utils-fyun-s3</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fdkankan</groupId>
+            <artifactId>4dkankan-utils-rabbitmq</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
+        </dependency>
 
         <!-- Sa-Token 权限认证, 在线文档:http://sa-token.dev33.cn/ -->
         <dependency>

+ 13 - 0
src/main/java/com/fdkankan/fusion/common/OssPath.java

@@ -0,0 +1,13 @@
+package com.fdkankan.fusion.common;
+
+import com.fdkankan.fusion.config.CacheUtil;
+
+public class OssPath {
+
+    public final static String localPath = "/mnt/fusion/";
+    public final static String MANAGE_FILE_PATH = "fusion/media-library/file/%s";
+    public final static String MANAGE_MODEL_FILE_PATH = "fusion/media-library/model/%s";
+
+
+
+}

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

@@ -81,7 +81,12 @@ public enum ResultCode {
 
     AI_ERROR(8031, "调用ai出错"),
 
-    ;
+    FILE_TYPE_ERROR2(8032, "文件类型错误"),
+    UNZIP_ERROR(8033, "解压出错"),
+
+
+    UPLOAD_FILE_ERROR(8034, "上传文件错误"),
+    FILE_TYPE_ERROR23(8035, "文件名称错误不能有中文");
 
 
 

+ 50 - 0
src/main/java/com/fdkankan/fusion/common/enums/FileTypeEnum.java

@@ -0,0 +1,50 @@
+package com.fdkankan.fusion.common.enums;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Arrays;
+import java.util.List;
+
+public enum FileTypeEnum {
+    IMAGE(0,"图片", Arrays.asList("jpg","png","jpeg")),
+    VIDEO(1,"视频",Arrays.asList("mp4")),
+    MUSIC(2,"音频",Arrays.asList("wav","mp3")),
+    MODEL(3,"模型",Arrays.asList("obj","osgb","b3dm","ply","las","laz")),
+    OTHER(4,"其他",Arrays.asList("shp")),
+    DOC(5,"文档",Arrays.asList("doc","docx","pdf")),
+
+    ;
+    int code;
+    String msg;
+    List<String> typeList;
+
+    FileTypeEnum(int code, String msg, List<String> typeList) {
+        this.code = code;
+        this.msg = msg;
+        this.typeList = typeList;
+    }
+
+    public int getCode() {
+        return code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public List<String> getTypeList() {
+        return typeList;
+    }
+
+    public static FileTypeEnum getByType(String fileType){
+        if(StringUtils.isNotBlank(fileType)){
+            FileTypeEnum[] values = FileTypeEnum.values();
+            for (FileTypeEnum value : values) {
+                if(value.typeList.contains(fileType)){
+                    return value;
+                }
+            }
+        }
+        return null;
+    }
+}

+ 50 - 0
src/main/java/com/fdkankan/fusion/common/util/CaseNumTypeUtil.java

@@ -0,0 +1,50 @@
+package com.fdkankan.fusion.common.util;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fdkankan.fusion.entity.Scene;
+import com.fdkankan.fusion.service.ISceneService;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Arrays;
+import java.util.List;
+
+@Service
+public class CaseNumTypeUtil {
+    @Autowired
+    ISceneService sceneService;
+
+    //0 四维看看,1看见场景,2 深时场景,3 三维模型,4深时obj ,5深光点云,6深光obj,7第三方相机
+    public  Integer getCaseNumType(String num,Integer numType){
+        if(StringUtils.isBlank(num)){
+            return null;
+        }
+        LambdaQueryWrapper<Scene> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(Scene::getSceneCode,num);
+        Scene one = sceneService.getOne(wrapper);
+        if(one == null){
+            return null;
+        }
+        return SceneTypeUtil.getTypeBySceneSource(one.getSceneSource(),numType);
+
+
+    }
+    public static Integer getType(Integer numType){
+        if(numType == 2 || numType == 5){
+            return 0;
+        }
+        return 1;
+    }
+
+    public static List<Integer> getNumType(Integer type){
+        if(type == 0){
+            return Arrays.asList(2,5);
+        }
+        return Arrays.asList(0,1,4,6,7);
+    }
+
+    public static List<Integer> getNumType(){
+        return Arrays.asList(0,1,2,4,5,6,7);
+    }
+}

+ 8 - 0
src/main/java/com/fdkankan/fusion/common/util/FileWriterUtil.java

@@ -6,6 +6,8 @@ import java.nio.file.Paths;
 import java.nio.file.StandardCopyOption;
 import java.util.List;
 import java.util.Objects;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import static cn.hutool.core.util.ClassUtil.getClassLoader;
 
@@ -96,4 +98,10 @@ public class FileWriterUtil {
         return null;
     }
 
+    public static boolean isChinese(String str) {
+        String regEx = "[\\u4e00-\\u9fa5]+";
+        Pattern p = Pattern.compile(regEx);
+        Matcher m = p.matcher(str);
+        return m.find();
+    }
 }

+ 1 - 1
src/main/java/com/fdkankan/fusion/common/util/OBJToGLBUtil.java

@@ -180,7 +180,7 @@ public class OBJToGLBUtil {
         return imgName;
     }
 
-    public static File lasOrPlyToBin(File srcFile) throws IOException {
+    public static File lasOrPlyToBin(File srcFile)  {
         if(!srcFile.exists()){
             srcFile.mkdirs();
         }

+ 1 - 1
src/main/java/com/fdkankan/fusion/common/util/RedisKeyUtil.java

@@ -21,6 +21,6 @@ public class RedisKeyUtil {
 
     public static final String SCENE_VERSION = "scenejson:num:%s";
 
-    public static final String loginToken= "manage:login:token:%s";
+    public static final String loginToken= "token#%s";
     public static final String loginUserName= "manage:login:userName:%s";
 }

+ 78 - 0
src/main/java/com/fdkankan/fusion/common/util/SceneTypeUtil.java

@@ -0,0 +1,78 @@
+package com.fdkankan.fusion.common.util;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class SceneTypeUtil {
+
+
+    public static Integer getSceneSource(Integer type){
+        switch (type){
+            case 0: return 1;
+            case 1: return 3;
+            case 2: return 4;
+            case 4: return 4;
+            case 5: return 5;
+            case 6: return 5;
+            default:return 1;
+        }
+    }
+
+    /**
+     * @param numType  //0点云,1mesh
+     */
+    public static Integer getTypeBySceneSource(Integer sceneSource ,Integer numType){
+        switch (sceneSource){
+            case 3: return 1;
+            case 4: return numType ==0 ?2 :4;
+            case 5: return numType ==0 ?5 :6;
+            default:return 0;
+        }
+    }
+
+    public static Boolean isLaser(Integer type){
+        if(type == null){
+            return false;
+        }
+        switch (type){
+            case 0: return false;
+            case 1: return false;
+            case 2: return true;
+            case 4: return false;
+            case 5: return true;
+            case 6: return false;
+            default:return false;
+        }
+    }
+
+    public static Boolean isLaserMesh(Integer type){
+        switch (type){
+            case 0: return false;
+            case 1: return false;
+            case 2: return false;
+            case 4: return true;
+            case 5: return false;
+            case 6: return true;
+            default:return false;
+        }
+    }
+
+    public static List<Integer> getSceneSourceList(Integer isObj) {
+        if(isObj == 0){
+            return Arrays.asList(4,5);
+        }
+        return Arrays.asList(1,3,4,5);
+    }
+
+    public static Boolean isLaserBySceneSource(Integer sceneSource) {
+        if(sceneSource == null){
+            return false;
+        }
+        switch (sceneSource){
+            case 4: return true;
+            case 5: return true;
+            case 6: return false;
+            default:return false;
+        }
+    }
+}

+ 1 - 1
src/main/java/com/fdkankan/fusion/common/util/ShellUtil.java

@@ -146,7 +146,7 @@ public class ShellUtil {
      * @return
      * @throws IOException
      */
-    public static JSONObject fixCloud(String path) throws IOException {
+    public static JSONObject fixCloud(String path)  {
         FileReader fileReader = new FileReader(path);
         String str = fileReader.readString();
         JSONObject json = JSONObject.parseObject(str);

+ 5 - 2
src/main/java/com/fdkankan/fusion/config/FusionConfig.java

@@ -10,6 +10,9 @@ import org.springframework.context.annotation.Configuration;
 @Data
 public class FusionConfig {
 
-    @Value("${fusion.ai-url}")
-    private String aiUrl;
+    @Value("${upload.type}")
+    private String uploadType;
+
+    @Value("${upload.query-path}")
+    private String ossUrlPrefix;
 }

+ 1 - 73
src/main/java/com/fdkankan/fusion/config/SaTokenConfigure.java

@@ -57,17 +57,7 @@ public class SaTokenConfigure {
                 .addInclude("/**").addExclude("/**/test/**","/**/inner/**","/**/notAuth/**","/**/systemSetting/**","/**/downMD5/**","/**/downDocx/**","/**ws/**")
                 // 认证函数: 每次请求执行
                 .setAuth(obj -> {
-                    String sign = SaHolder.getRequest().getHeader("sign");
-                    String pageType = SaHolder.getRequest().getHeader("page-type");
-                    String caseId = SaHolder.getRequest().getHeader("caseId");
-                    if(StringUtils.isNotBlank(sign)){
-                        String clientIP = ServletUtil.getClientIP(SpringMVCUtil.getRequest());
-                        SaRouter.match("/**", "/case/addScene", r -> checkSign(sign,clientIP));
-                    }else {
-                        SaRouter.match("/**", "/case/addScene", r ->checkCaseAuth(caseId,pageType));
-                        SaRouter.match("/**", "/fdLogin", r ->checkLogin() );
-                    }
-
+                    SaRouter.match("/**", "/fdLogin", r ->checkLogin() );
 
                     SaRouter.match("/sceneDownLog/list", r -> StpUtil.checkRoleOr("admin-super","admin-system","admin") );
 
@@ -144,71 +134,9 @@ public class SaTokenConfigure {
         if(!redisUtil.hasKey(redisKey)){
             throw new BusinessException(ResultCode.USER_NOT_LOGIN);
         }
-        String userStr = redisUtil.get(redisKey);
-        ManageLoginResponse result = JSONObject.parseObject(userStr,ManageLoginResponse.class);
-        Long userId = result.getUserId();
-        if(userId == null || result.getStatus() == 0){
-            String redisKey2 = String.format(RedisKeyUtil.loginUserName,result.getUserName());
-            redisUtil.del(redisKey);
-            redisUtil.del(redisKey2);
-            throw new BusinessException(ResultCode.USERNAME_ERROR);
-        }
-
         redisUtil.expire(redisKey,2 * 60 * 60);
     }
 
-    private void checkCaseAuth(String caseId,String pageType) {
-
-        fdService.checkCaseAuth(caseId,pageType,StpUtil.getTokenValue());
-    }
-
-
-    public   void  checkSign(String sign,String remoteIp){
-        if(StringUtils.isBlank(sign)){
-            throw new BusinessException(ResultCode.AUTH_ERROR.code, "签名为空");
-        }
-        String userName = null, ip = null, timestamp = null;
-
-        if(StrUtil.isNotEmpty(sign)){
-            sign = sign.replaceAll("%2B", "+").replaceAll(" ", "+");
-            String[] split = null;
-            try {
-                String decode = AesUtil.decryptECB(sign, SignUtil.ENCRYPT_KEY, "AES/ECB/PKCS5Padding");
-                split = decode.split("@");
-
-            }catch (Exception e){
-                log.info("签名解密失败", e);
-                throw new BusinessException(ResultCode.AUTH_ERROR.code, "签名解密失败");
-            }
-
-            if(Objects.isNull(split) || split.length == 1){
-                throw new BusinessException(ResultCode.AUTH_ERROR.code, "签名参数错误");
-            }else{
-                for (int i = 0; i < split.length; i++){
-                    if(i == 0){
-                        userName = split[i];
-                    }
-                    if(i == 1){
-                        ip = split[i];
-                    }
-                    if(i == 2){
-                        timestamp = split[i];
-                    }
-                }
-
-                log.info("请求ip:{}", remoteIp);
-                log.info("参数ip:{}", ip);
-                if(StrUtil.isNotEmpty(ip) && !ip.equals(remoteIp)){
-                    throw new BusinessException(ResultCode.AUTH_ERROR.code, "ip不匹配");
-                }
-
-                if(StrUtil.isNotEmpty(timestamp) && Calendar.getInstance().getTime().after(new Date(Long.valueOf(timestamp) * 1000))){
-                    throw new BusinessException(ResultCode.AUTH_ERROR.code, "超出访问截止时间");
-                }
-            }
-        }
-    }
-
 
     //Sa-Token    整合 jwt
     //Stateless   无状态模式 纯jwt

+ 6 - 3
src/main/java/com/fdkankan/fusion/controller/AiController.java

@@ -67,20 +67,23 @@ public class AiController {
             if(caseNumEntity.getNumType() == 3){
                 continue;
             }
-            FloorPathVo pathVo = new FloorPathVo();
-            pathVo.setNum(caseNumEntity.getNum());
+
             String path = String.format(foorPath, caseNumEntity.getNum());
             File file = new File(path);
             File[] files = file.listFiles();
             if(files == null || files.length <=0){
                 continue;
             }
+            FloorPathVo pathVo = new FloorPathVo();
             for (File file1 : files) {
                 if(file1.getName().contains(fileName) && file1.getName().contains(extName)){
+                    pathVo.setNum(caseNumEntity.getNum());
                     pathVo.getUrls().add(file1.getPath().replace("4dkankan/",""));
                 }
             }
-            pathVos.add(pathVo);
+            if(!pathVo.getUrls().isEmpty()){
+                pathVos.add(pathVo);
+            }
         }
 
         return ResultData.ok(pathVos);

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

@@ -0,0 +1,50 @@
+package com.fdkankan.fusion.controller;
+
+
+import com.fdkankan.fusion.common.ResultData;
+import com.fdkankan.fusion.entity.Dict;
+import com.fdkankan.fusion.request.DictParam;
+import com.fdkankan.fusion.service.IDictService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 
+ * @since 2024-12-02
+ */
+@RestController
+@RequestMapping("/dict")
+public class DictController extends BaseController{
+
+    @Autowired
+    IDictService dictService;
+
+    @GetMapping("/getByKey/{dictKey}")
+    public ResultData getByKey(@PathVariable String dictKey){
+        return ResultData.ok(dictService.getByKey(dictKey));
+    }
+
+    @PostMapping("/pageList/{dictKey}")
+    public ResultData pageList(@RequestBody DictParam param, @PathVariable String dictKey){
+        param.setDictKey(dictKey);
+        return ResultData.ok(dictService.pageList(param));
+    }
+
+    @PostMapping("/addOrUpdate/{dictKey}")
+    public ResultData addOrUpdate(@RequestBody Dict dict, @PathVariable String dictKey){
+        dict.setDictKey(dictKey);
+        dictService.addOrUpdate(dict);
+        return ResultData.ok();
+    }
+
+    @PostMapping("/del/{dictKey}")
+    public ResultData del(@RequestBody Dict dict,@PathVariable String dictKey){
+        dictService.del(dict);
+        return ResultData.ok();
+    }
+}
+

+ 45 - 0
src/main/java/com/fdkankan/fusion/controller/DictFileController.java

@@ -0,0 +1,45 @@
+package com.fdkankan.fusion.controller;
+
+
+import com.fdkankan.fusion.common.ResultData;
+import com.fdkankan.fusion.entity.DictFile;
+import com.fdkankan.fusion.request.DictFileParam;
+import com.fdkankan.fusion.service.IDictFileService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 
+ * @since 2024-12-02
+ */
+@RestController
+@RequestMapping("/dictFile")
+public class DictFileController extends BaseController{
+
+    @Autowired
+    IDictFileService dictFileService;
+
+    @PostMapping("/pageList/{typeKey}")
+    public ResultData pageList(@RequestBody DictFileParam param, @PathVariable String typeKey){
+        param.setTypeKey(typeKey);
+        return ResultData.ok(dictFileService.pageList(param));
+    }
+
+    @PostMapping("/addOrUpdate/{typeKey}")
+    public ResultData addOrUpdate(@RequestBody DictFile dictFile, @PathVariable String typeKey){
+        dictFile.setTypeKey(typeKey);
+        dictFileService.addOrUpdate(dictFile);
+        return ResultData.ok();
+    }
+
+    @PostMapping("/del/{typeKey}")
+    public ResultData del(@RequestBody DictFile dictFile,@PathVariable String typeKey){
+        dictFileService.del(dictFile);
+        return ResultData.ok();
+    }
+}
+

+ 15 - 4
src/main/java/com/fdkankan/fusion/controller/UploadController.java

@@ -5,14 +5,12 @@ import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.common.ResultData;
 import com.fdkankan.fusion.common.ResultCode;
+import com.fdkankan.fusion.service.ICommonUploadService;
 import com.fdkankan.fusion.service.impl.UploadService;
 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.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
@@ -27,10 +25,23 @@ public class UploadController {
     UploadService uploadService;
     @Value("${spring.profiles.active}")
     private String environment;
+    @Autowired
+    ICommonUploadService commonUploadService;
 
     @PostMapping("/file")
     public ResultData file(@RequestParam(required = false) MultipartFile file) throws Exception {
 
         return ResultData.ok( uploadService.uploadFile(file,true,String.format(FilePath.File_OSS_PATH,environment,"")));
     }
+
+
+    /**
+     * 文件上传
+     */
+    @RequestMapping(value = "/fileNew", method = RequestMethod.POST)
+    public ResultData uploadNew(@RequestParam(required = false) MultipartFile file,
+            @RequestParam(value = "dictId",required = false) Integer dictId) {
+
+        return commonUploadService.uploadFileNew(dictId,file);
+    }
 }

+ 22 - 9
src/main/java/com/fdkankan/fusion/mq/consumer/OsgbToB3dmConsumer.java

@@ -3,8 +3,11 @@ package com.fdkankan.fusion.mq.consumer;
 import cn.hutool.core.io.FileUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.fdkankan.fusion.common.FilePath;
+import com.fdkankan.fusion.common.OssPath;
 import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.common.util.*;
+import com.fdkankan.fusion.config.CacheUtil;
+import com.fdkankan.fusion.entity.CommonUpload;
 import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.service.ICommonUploadService;
 import com.fdkankan.geo.GeoTransformUtil;
@@ -20,6 +23,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import scala.Int;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -44,7 +48,9 @@ public class OsgbToB3dmConsumer {
             ,concurrency = "1"
     )
     public void consumerQueue(Channel channel, Message message)  {
+        String sourcePath = null;
         String localPath = null;
+        Integer uploadId = null;
         try {
             String messageId = message.getMessageProperties().getMessageId();
             String msg = new String(message.getBody(), StandardCharsets.UTF_8);
@@ -52,16 +58,20 @@ public class OsgbToB3dmConsumer {
 
             channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
             JSONObject jsonObject = JSONObject.parseObject(msg);
-            localPath = jsonObject.getString("path");
+            uploadId = jsonObject.getInteger("uploadId");
+            CommonUpload commonUpload = commonUploadService.getById(uploadId);
+            localPath = commonUpload.getUnzipPath();
+
 
             File file = new File(localPath);
             if(!file.exists()){
                 log.info("osgbToB3dm-mq--messageId:{},msg:{},文件不存在",messageId,localPath);
                 return;
             }
-            commonUploadService.updateStatus(localPath,0);
+            commonUploadService.updateStatus(uploadId,0);
             ///mnt/manage/media-library/result/ea041f3237df46568f4e83e723e743d4
-            String sourcePath = file.getParentFile().getPath() +"/"+UUID.randomUUID().toString().replace("-","");
+            String dir = String.format(OssPath.MANAGE_MODEL_FILE_PATH ,UUID.randomUUID().toString().replace("-",""));
+            sourcePath = OssPath.localPath +File.separator+ dir;
 
             OBJToGLBUtil.OsgbToB3dm(localPath,sourcePath);
             String b3dmJsonPath =  FileWriterUtil.checkB3dmTileset(new File(sourcePath));
@@ -74,19 +84,22 @@ public class OsgbToB3dmConsumer {
             String url = ossUrlPrefix + b3dmJsonPath.replace("/mnt/","");
             HashMap<String,String> resultMap = ReadXmlUtil.getLatMap(file);
             if(resultMap != null && !resultMap.isEmpty()){
-                commonUploadService.updateByPath(localPath,url,resultMap.get("wgs84"),resultMap.get("gcj02"));
+                commonUploadService.updateByPath(uploadId,url,resultMap.get("wgs84"),resultMap.get("gcj02"));
             }else {
-                commonUploadService.updateByPath(localPath,url);
+                commonUploadService.updateByPath(uploadId,url);
             }
-            FileUtil.del(localPath);
-            FileUtil.del(sourcePath);
         }catch (Exception e){
             log.info("osgbToB3dm-status----消费失败",e);
             if(localPath != null){
-                commonUploadService.updateStatus(localPath,-1);
+                commonUploadService.updateStatus(uploadId,-1);
             }
         }finally {
-
+            try {
+                FileUtil.del(localPath);
+                FileUtil.del(sourcePath);
+            }catch ( Exception e){
+                log.info("删除文件失败:{}",e);
+            }
         }
 
     }

+ 17 - 0
src/main/java/com/fdkankan/fusion/request/DictFileParam.java

@@ -0,0 +1,17 @@
+package com.fdkankan.fusion.request;
+
+import com.fdkankan.fusion.common.RequestBase;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class DictFileParam extends RequestBase {
+    private String name;
+    private Integer dictId;
+    private String typeKey;
+    private Integer fileType;
+    private List<String> fileFormats;
+    private List<Integer> dictIds;
+    private Long sysUserId;
+}

+ 10 - 0
src/main/java/com/fdkankan/fusion/request/DictParam.java

@@ -0,0 +1,10 @@
+package com.fdkankan.fusion.request;
+
+import com.fdkankan.fusion.common.RequestBase;
+import lombok.Data;
+
+@Data
+public class DictParam extends RequestBase {
+    private String dictName;
+    private String dictKey;
+}

+ 27 - 0
src/main/java/com/fdkankan/fusion/response/DictFileVo.java

@@ -0,0 +1,27 @@
+package com.fdkankan.fusion.response;
+
+import com.fdkankan.fusion.entity.DictFile;
+import lombok.Data;
+
+@Data
+public class DictFileVo extends DictFile {
+
+    private String fileName;
+
+    private String fileUrl;
+
+    private String fileSize;
+
+    private String newFileName;
+
+    private Integer fileType;
+    private String fileTypeStr;
+
+    private String fileFormat;
+
+    private Integer status;
+
+    private String unzipPath;
+
+    private String dictName;
+}

+ 10 - 7
src/main/java/com/fdkankan/fusion/service/ICommonUploadService.java

@@ -1,7 +1,10 @@
 package com.fdkankan.fusion.service;
 
+import com.fdkankan.fusion.common.ResultData;
+import com.fdkankan.fusion.common.enums.FileTypeEnum;
 import com.fdkankan.fusion.entity.CommonUpload;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
 
@@ -11,18 +14,18 @@ import java.util.List;
  * </p>
  *
  * @author 
- * @since 2024-12-06
+ * @since 2025-02-10
  */
 public interface ICommonUploadService extends IService<CommonUpload> {
 
-    List<CommonUpload> getByStatus(Integer status);
+    ResultData uploadFileNew( Integer dictId,MultipartFile file);
 
-    void updateByPath(String msg, String url);
-    void updateByPath(String msg, String url,String wgs84 ,String gcj02);
+    CommonUpload add(String replace, String url, String s, String uuid, FileTypeEnum fileTypeEnum,String resultFormat, String replace1, Integer status, String unzipPath, Integer dictId);
 
-    void updateStatus(String localPath,Integer status);
+    void updateStatus(Integer localPath, Integer i);
+
+    void updateByPath(Integer uploadId, String url, String wgs84, String gcj02);
+    void updateByPath(Integer uploadId, String url);
 
-    List<CommonUpload> getIsSystem();
 
-    CommonUpload addSystemFile(String ossKey,Long fileSize,String fileName);
 }

+ 9 - 3
src/main/java/com/fdkankan/fusion/service/IDictFileService.java

@@ -1,8 +1,8 @@
 package com.fdkankan.fusion.service;
 
-import com.fdkankan.fusion.entity.CommonUpload;
 import com.fdkankan.fusion.entity.DictFile;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.fdkankan.fusion.request.DictFileParam;
 
 /**
  * <p>
@@ -10,9 +10,15 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * </p>
  *
  * @author 
- * @since 2024-12-06
+ * @since 2025-02-10
  */
 public interface IDictFileService extends IService<DictFile> {
 
-    void addSystemFile(CommonUpload commonUpload);
+    Object pageList(DictFileParam param);
+
+    void addOrUpdate(DictFile dictFile);
+
+    void del(DictFile dictFile);
+
+    void updateDictId(Integer dictId, Integer UpDictId);
 }

+ 11 - 2
src/main/java/com/fdkankan/fusion/service/IDictService.java

@@ -2,6 +2,9 @@ package com.fdkankan.fusion.service;
 
 import com.fdkankan.fusion.entity.Dict;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.fdkankan.fusion.request.DictParam;
+
+import java.util.List;
 
 /**
  * <p>
@@ -9,9 +12,15 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * </p>
  *
  * @author 
- * @since 2024-12-06
+ * @since 2025-02-10
  */
 public interface IDictService extends IService<Dict> {
 
-    Dict getBySystemFile();
+    List<Dict> getByKey(String dictKey);
+
+    void addOrUpdate(Dict dict);
+
+    void del(Dict dict);
+
+    Object pageList(DictParam param);
 }

+ 255 - 37
src/main/java/com/fdkankan/fusion/service/impl/CommonUploadServiceImpl.java

@@ -1,18 +1,38 @@
 package com.fdkankan.fusion.service.impl;
 
+
 import cn.hutool.core.io.FileUtil;
-import com.baomidou.dynamic.datasource.annotation.DS;
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.fdkankan.fusion.common.OssPath;
+import com.fdkankan.fusion.common.ResultCode;
+import com.fdkankan.fusion.common.ResultData;
+import com.fdkankan.fusion.common.enums.FileTypeEnum;
+import com.fdkankan.fusion.common.util.FileWriterUtil;
+import com.fdkankan.fusion.common.util.OBJToGLBUtil;
+import com.fdkankan.fusion.common.util.ShellUtil;
+import com.fdkankan.fusion.common.util.LocalToOssUtil;
+import com.fdkankan.fusion.config.CacheUtil;
+import com.fdkankan.fusion.config.FusionConfig;
 import com.fdkankan.fusion.entity.CommonUpload;
+import com.fdkankan.fusion.entity.DictFile;
+import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.mapper.ICommonUploadMapper;
+import com.fdkankan.fusion.mq.consumer.OsgbToB3dmConsumer;
 import com.fdkankan.fusion.service.ICommonUploadService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fdkankan.fusion.service.IDictFileService;
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
+import com.fdkankan.rabbitmq.util.RabbitMqProducer;
+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.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+import scala.Int;
 
 import java.io.File;
-import java.util.List;
+import java.util.*;
 
 /**
  * <p>
@@ -20,40 +40,242 @@ import java.util.List;
  * </p>
  *
  * @author 
- * @since 2024-12-06
+ * @since 2025-02-10
  */
 @Service
-@DS("db2")
+@Slf4j
 public class CommonUploadServiceImpl extends ServiceImpl<ICommonUploadMapper, CommonUpload> implements ICommonUploadService {
 
+
+    @Autowired
+    ICommonUploadService commonUploadService;
+    @Autowired
+    IDictFileService dictFileService;
+    @Autowired
+    FusionConfig fusionConfig;
+    @Autowired
+    FYunFileServiceInterface fYunFileServiceInterface;
+    @Autowired
+    RabbitMqProducer rabbitMqProducer;
+    @Override
+    public ResultData uploadFileNew( Integer dictId,MultipartFile file) {
+        if( file.isEmpty() ){
+            throw new BusinessException(ResultCode.UPLOAD_ERROR);
+        }
+        File  tempFile = null;
+
+        try {
+            String uuid = UUID.randomUUID().toString().replace("-","");
+            String name = file.getOriginalFilename();
+            String extName = name.substring(name.lastIndexOf(".")).toLowerCase();
+            String ossPath = String.format(OssPath.MANAGE_FILE_PATH, uuid + extName);
+
+            tempFile = new File(OssPath.localPath + ossPath);
+            if(!tempFile.getParentFile().exists()){
+                tempFile.getParentFile().mkdirs();
+            }
+            file.transferTo(tempFile);
+            if(extName.equals(".zip")){
+                return uploadModelZip(name.replace(extName, ""),tempFile,dictId);
+            }
+            fYunFileServiceInterface.uploadFile(tempFile.getPath(), ossPath);
+            //String url = this.ossUrlPrefix + ossPath;
+            String url = fusionConfig.getOssUrlPrefix() + ossPath;
+
+            FileTypeEnum fileTypeEnum = FileTypeEnum.getByType(extName.replace(".", ""));
+            if(fileTypeEnum == null){
+                throw new BusinessException(ResultCode.FILE_TYPE_ERROR2);
+            }
+            String format = extName.replace(".", "");
+            CommonUpload commonUpload = commonUploadService.add(name.replace(extName, ""), url, String.valueOf(file.getSize()), uuid, fileTypeEnum, format,format,1,null,dictId);
+            return ResultData.ok(commonUpload);
+        }catch ( BusinessException e){
+            log.info("upload-file-error:{}",e);
+            throw e;
+        }catch (Exception e){
+            log.info("upload-file-error:{}",e);
+            throw new BusinessException(ResultCode.UPLOAD_ERROR);
+        }
+    }
+
+    private ResultData uploadModelZip(String oldName,File file,Integer dictId) {
+
+        String ossZipPath = String.format(OssPath.MANAGE_MODEL_FILE_PATH, UUID.randomUUID().toString().replace("-", ""));
+        String unzipPath = OssPath.localPath + ossZipPath;
+        ShellUtil.unZip(file.getPath(),unzipPath);
+        try {
+            Thread.sleep(1000L);
+            FileUtil.del(file.getPath());
+        }catch (Exception e){
+            log.info("删除文件失败:{}",e);
+        }
+
+        //FileUtil.copyContent(file,new File(unzipPath),true);
+        File unZipFile = new File(unzipPath);
+
+        if(!unZipFile.exists() || !unZipFile.isDirectory() ){
+            throw new BusinessException(ResultCode.UNZIP_ERROR);
+        }
+        List<File> fileList = new ArrayList<>();
+        FileWriterUtil.getCanRunList(fileList,unZipFile);
+        if(fileList.size() <=0){
+            throw new BusinessException(ResultCode.UPLOAD_FILE_ERROR);
+        }
+        File modelFile = fileList.get(0);
+
+        if(FileWriterUtil.isChinese(modelFile.getName())){
+            throw new BusinessException(ResultCode.FILE_TYPE_ERROR23);
+        }
+        if(FileWriterUtil.isChinese(modelFile.getPath())){
+            throw new BusinessException(ResultCode.FILE_TYPE_ERROR23);
+        }
+        String modelFileFormat = modelFile.getName().split("\\.")[1].toLowerCase();
+        String url = null;
+        String resultFormat = modelFileFormat;
+        switch (modelFileFormat){
+            case "obj" :  resultFormat = "obj";
+                url = uploadObjOss(ossZipPath,modelFile);break;
+            case "laz" :    url = uploadLazOss(ossZipPath,modelFile); break;
+            case "shp" :   url = uploadOss(ossZipPath,modelFile); break;
+            case "b3dm" :  url = uploadB3dm(ossZipPath,modelFile); break;
+            case "las" :
+            case "ply" :  url = uploadLasOrPly(ossZipPath,modelFile);break;
+            case "osgb":
+                    resultFormat = "b3dm";
+                   break;
+            default: break;
+        }
+        FileTypeEnum fileTypeEnum = FileTypeEnum.getByType(modelFileFormat);
+        if(fileTypeEnum == null){
+            throw new BusinessException(ResultCode.FILE_TYPE_ERROR2);
+        }
+        Integer status = StringUtils.isNotBlank(url) ? 1: -1;
+        url = StringUtils.isNotBlank(url) ? fusionConfig.getOssUrlPrefix() + url : null;
+        CommonUpload commonUpload = commonUploadService.add(oldName,url, String.valueOf(getDirectorySize(unZipFile)),
+                null, fileTypeEnum, modelFileFormat,resultFormat,status,unZipFile.getPath(),dictId);
+        if("osgb".equals(modelFileFormat)){
+            uploadOsgb(commonUpload.getId()) ;
+        }
+        return ResultData.ok(commonUpload);
+    }
+
+    private String uploadObjOss(String unzipPath, File modelFile) {
+        OBJToGLBUtil.checkObj(modelFile.getPath());
+        //String localGlbPath = modelFile.getPath().replace(".obj",".glb");
+        //OBJToGLBUtil.objToGlb2(modelFile.getPath(),localGlbPath);
+//        File file = new File(localGlbPath);
+//        if(!file.exists()){
+//            throw new BusinessException(ResultCode.UPLOAD_FILE_ERROR);
+//        }
+        String ossKey = unzipPath.replace(OssPath.localPath,"");
+        ShellUtil.yunUpload(unzipPath,ossKey);
+        return  fusionConfig.getOssUrlPrefix() + ossKey +File.separator+modelFile.getName();
+    }
+
+    private String uploadB3dm(String unzipPath, File modelFile) {
+        String b3dmJsonPath = FileWriterUtil.checkB3dmTileset(new File(OssPath.localPath + unzipPath));
+        if(b3dmJsonPath == null){
+            throw new BusinessException(ResultCode.UPLOAD_FILE_OBJ_ERROR);
+        }
+        //uploadOss(unzipPath,modelFile);
+        File file = new File(b3dmJsonPath);
+        if(!file.exists()){
+            throw new BusinessException(ResultCode.UPLOAD_FILE_ERROR);
+        }
+        String ossKey = unzipPath.replace(OssPath.localPath,"");
+        ShellUtil.yunUpload(unzipPath,ossKey);
+        return ossKey +File.separator +file.getName();
+    }
+
+
+    private void uploadOsgb(Integer uploadId) {
+         //osgbToB3dmConsumer.consumerQueue(CacheUtil.basePath + unzipPath);
+        HashMap<String,Integer> map = new HashMap<>();
+        map.put("uploadId",uploadId);
+        rabbitMqProducer.sendByWorkQueue("queue-model-osgbToB3dm",map);
+    }
+
+    private String uploadLazOss(String unzipPath,File modelFile) {
+        if(!modelFile.exists()){
+            throw new BusinessException(ResultCode.UPLOAD_FILE_ERROR);
+        }
+        String ossKey = unzipPath.replace(OssPath.localPath,"");
+        ShellUtil.yunUpload(unzipPath,ossKey);
+       return  ossKey ;
+       // return  modelFile.getParentFile().getPath();
+    }
+
+    private String uploadOss(String unzipPath,File modelFile) {
+        if(!modelFile.exists()){
+            throw new BusinessException(ResultCode.UPLOAD_FILE_ERROR);
+        }
+        String ossKey = unzipPath.replace(OssPath.localPath,"");
+        ShellUtil.yunUpload(unzipPath,ossKey);
+        return ossKey;
+       // return  modelFile.getPath();
+    }
+
+    private String uploadLasOrPly(String unzipPath ,File modelFile) {
+        File mntFile = OBJToGLBUtil.lasOrPlyToBin(modelFile);
+        File file = new File(mntFile.getPath() + "/webcloud/cloud.js");
+        if(!file.exists()){
+            throw new BusinessException(ResultCode.UPLOAD_FILE_ERROR);
+        }
+        String ossKey = unzipPath.replace(OssPath.localPath,"");
+        ShellUtil.yunUpload(unzipPath,ossKey);
+        return  ossKey + File.separator +"webcloud";
+       // return  mntFile.getPath()+ File.separator +"webcloud";
+
+    }
+
+
+
     @Override
-    public List<CommonUpload> getByStatus(Integer status) {
-        LambdaQueryWrapper<CommonUpload> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(CommonUpload::getStatus,status);
-        return this.list(wrapper);
+    public CommonUpload add(String fileName, String url, String fileSize, String uuid, FileTypeEnum fileTypeEnum, String resultFormat,String replace1, Integer status, String unzipPath, Integer dictId) {
+        CommonUpload upload = new CommonUpload();
+        upload.setFileName(fileName);
+        upload.setFileUrl(url);
+        upload.setFileSize(fileSize);
+        upload.setNewFileName(uuid);
+        upload.setFileType(fileTypeEnum.getCode());
+        upload.setFileTypeStr(fileTypeEnum.getMsg());
+        upload.setFileFormat(resultFormat);
+        upload.setResultFileFormat(replace1);
+        upload.setStatus(status);
+        upload.setUnzipPath(unzipPath);
+        this.save(upload);
+
+        DictFile dictFile = new DictFile();
+        dictFile.setName(fileName);
+        dictFile.setTypeKey("media-library");
+        dictFile.setUploadId(upload.getId());
+        dictFile.setDictId(dictId);
+        dictFileService.saveOrUpdate(dictFile);
+
+        return upload;
     }
 
     @Override
-    public void updateByPath(String msg, String url) {
+    public void updateByPath(Integer uploadId, String url) {
         LambdaUpdateWrapper<CommonUpload> wrapper = new LambdaUpdateWrapper<>();
-        wrapper.eq(CommonUpload::getUnzipPath,msg);
+        wrapper.eq(CommonUpload::getId,uploadId);
         wrapper.set(CommonUpload::getStatus,1);
         wrapper.set(CommonUpload::getFileUrl,url);
         this.update(wrapper);
     }
 
     @Override
-    public void updateStatus(String localPath,Integer status) {
+    public void updateStatus(Integer uploadId,Integer status) {
         LambdaUpdateWrapper<CommonUpload> wrapper = new LambdaUpdateWrapper<>();
-        wrapper.eq(CommonUpload::getUnzipPath,localPath);
+        wrapper.eq(CommonUpload::getId,uploadId);
         wrapper.set(CommonUpload::getStatus,status);
         this.update(wrapper);
     }
 
     @Override
-    public void updateByPath(String msg, String url,String wgs84 ,String gcj02) {
+    public void updateByPath(Integer uploadId, String url,String wgs84 ,String gcj02) {
         LambdaUpdateWrapper<CommonUpload> wrapper = new LambdaUpdateWrapper<>();
-        wrapper.eq(CommonUpload::getUnzipPath,msg);
+        wrapper.eq(CommonUpload::getId,uploadId);
         wrapper.set(CommonUpload::getStatus,1);
         wrapper.set(CommonUpload::getFileUrl,url);
         wrapper.set(CommonUpload::getWgs84,wgs84);
@@ -61,27 +283,23 @@ public class CommonUploadServiceImpl extends ServiceImpl<ICommonUploadMapper, Co
         this.update(wrapper);
     }
 
-    @Override
-    public List<CommonUpload> getIsSystem() {
-        LambdaQueryWrapper<CommonUpload> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(CommonUpload::getUseType,"animation");
-        return this.list(wrapper);
-    }
 
-    @Override
-    public CommonUpload addSystemFile(String ossKey,Long fileSize,String fileName) {
-        CommonUpload commonUpload = new CommonUpload();
-        commonUpload.setFileName(fileName);
-        commonUpload.setFileUrl(ossKey);
-        commonUpload.setFileSize(fileSize+"");
-        commonUpload.setNewFileName(fileName);
-        commonUpload.setFileType(3);
-        commonUpload.setFileTypeStr("模型");
-        commonUpload.setFileFormat("glb");
-        commonUpload.setResultFileFormat("glb");
-        commonUpload.setStatus(1);
-        commonUpload.setUseType("animation");
-        this.save(commonUpload);
-        return commonUpload;
+    public static long getDirectorySize(File directory) {
+        long size = 0;
+        try {
+            File[] files = directory.listFiles();
+            if (files != null) {
+                for (File file : files) {
+                    if (file.isFile()) {
+                        size += file.length();
+                    } else if (file.isDirectory()) {
+                        size += getDirectorySize(file);
+                    }
+                }
+            }
+        }catch (Exception e){
+        }
+        return size;
     }
+
 }

+ 45 - 16
src/main/java/com/fdkankan/fusion/service/impl/DictFileServiceImpl.java

@@ -1,13 +1,20 @@
 package com.fdkankan.fusion.service.impl;
 
-import com.baomidou.dynamic.datasource.annotation.DS;
-import com.fdkankan.fusion.entity.CommonUpload;
-import com.fdkankan.fusion.entity.Dict;
+
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fdkankan.fusion.common.PageInfo;
+import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.entity.DictFile;
+import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.mapper.IDictFileMapper;
+import com.fdkankan.fusion.request.DictFileParam;
+import com.fdkankan.fusion.response.DictFileVo;
+import com.fdkankan.fusion.service.ICommonUploadService;
 import com.fdkankan.fusion.service.IDictFileService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.fusion.service.IDictService;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -17,26 +24,48 @@ import org.springframework.stereotype.Service;
  * </p>
  *
  * @author 
- * @since 2024-12-06
+ * @since 2025-02-10
  */
 @Service
-@DS("db2")
 public class DictFileServiceImpl extends ServiceImpl<IDictFileMapper, DictFile> implements IDictFileService {
 
     @Autowired
+    ICommonUploadService commonUploadService;
+    @Autowired
     IDictService dictService;
 
+
+    @Override
+    public Object pageList(DictFileParam param) {
+        if(StringUtils.isBlank(param.getTypeKey())){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        Page<DictFileVo> pageVo = this.getBaseMapper().pageList(new Page<>(param.getPageNum(),param.getPageSize()),param);
+        return PageInfo.PageInfo(pageVo);
+    }
+
+    @Override
+    public void addOrUpdate(DictFile dictFile) {
+        if(StringUtils.isBlank(dictFile.getTypeKey())
+                || dictFile.getDictId() == null ){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        this.saveOrUpdate(dictFile);
+    }
+
+    @Override
+    public void del(DictFile dictFile) {
+        if(dictFile.getId() == null){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        this.removeById(dictFile.getId());
+    }
+
     @Override
-    public void addSystemFile(CommonUpload commonUpload) {
-        Dict dict = dictService.getBySystemFile();
-
-        DictFile dictFile = new DictFile();
-        dictFile.setName(commonUpload.getFileName());
-        dictFile.setTypeKey("media-library");
-        dictFile.setDictId(dict.getId());
-        dictFile.setUploadId(commonUpload.getId());
-        dictFile.setUseType("animation");
-        dictFile.setSysUserId(1);
-        this.save(dictFile);
+    public void updateDictId(Integer dictId, Integer UpDictId) {
+        LambdaUpdateWrapper<DictFile> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.eq(DictFile::getDictId,dictId);
+        wrapper.set(DictFile::getDictId,UpDictId);
+        this.update(wrapper);
     }
 }

+ 54 - 16
src/main/java/com/fdkankan/fusion/service/impl/DictServiceImpl.java

@@ -1,11 +1,19 @@
 package com.fdkankan.fusion.service.impl;
 
-import com.baomidou.dynamic.datasource.annotation.DS;
+
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fdkankan.fusion.common.PageInfo;
+import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.entity.Dict;
+import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.mapper.IDictMapper;
+import com.fdkankan.fusion.request.DictParam;
+import com.fdkankan.fusion.service.IDictFileService;
 import com.fdkankan.fusion.service.IDictService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -16,27 +24,57 @@ import java.util.List;
  * </p>
  *
  * @author 
- * @since 2024-12-06
+ * @since 2025-02-10
  */
 @Service
-@DS("db2")
 public class DictServiceImpl extends ServiceImpl<IDictMapper, Dict> implements IDictService {
 
+    @Autowired
+    IDictFileService dictFileService;
+
     @Override
-    public Dict getBySystemFile() {
+    public List<Dict> getByKey(String dictKey) {
+        if(StringUtils.isBlank(dictKey)){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
         LambdaQueryWrapper<Dict> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(Dict::getUseType,"animation");
-        List<Dict> list = this.list(wrapper);
-        if(list.isEmpty()){
-            Dict dict = new Dict();
-            dict.setDictName("动画模型");
-            dict.setDictKey("media-library");
-            dict.setSort(1);
-            dict.setSysUserId(1);
-            dict.setUseType("animation");
-            this.save(dict);
-            return dict;
+        wrapper.eq(Dict::getDictKey,dictKey);
+        wrapper.orderByAsc(Dict::getSort);
+        wrapper.orderByDesc(Dict::getId);
+        return list(wrapper);
+    }
+
+    @Override
+    public Object pageList(DictParam param) {
+        if(StringUtils.isBlank(param.getDictKey())){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        LambdaQueryWrapper<Dict> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(Dict::getDictKey,param.getDictKey());
+        if(StringUtils.isNotBlank(param.getDictName())){
+            wrapper.like(Dict::getDictName,param.getDictName());
         }
-        return list.get(0);
+        wrapper.orderByAsc(Dict::getSort);
+        wrapper.orderByDesc(Dict::getId);
+        Page<Dict> page = this.page(new Page<>(param.getPageNum(), param.getPageSize()), wrapper);
+        return PageInfo.PageInfo(page);
+    }
+
+    @Override
+    public void addOrUpdate(Dict dict) {
+        if(StringUtils.isBlank(dict.getDictName()) || StringUtils.isBlank(dict.getDictKey())){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        this.saveOrUpdate(dict);
+    }
+
+    @Override
+    public void del(Dict dict) {
+        if(dict.getId() == null){
+            throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
+        }
+        dictFileService.updateDictId(dict.getId(),null);
+        this.removeById(dict.getId());
+
     }
 }

+ 0 - 56
src/main/java/com/fdkankan/fusion/task/TaskService.java

@@ -29,61 +29,5 @@ import static com.fdkankan.fusion.down.CaseDownService.downProcessKey;
 @Slf4j
 public class TaskService {
 
-    @Autowired
-    ICaseLiveService caseLiveService;
-
-
-    @Autowired
-    RedisUtil redisUtil;
-    @PostConstruct
-    public void cleanRedisKey(){
-        String redisKey = String.format(downProcessKey, "*");
-        Set<String>  keys = redisUtil.keys(redisKey);
-        if(keys != null && !keys.isEmpty()){
-            for (String key : keys) {
-                redisUtil.del(key);
-            }
-        }
-
-        checkSystemModel();
-    }
-
-    @Autowired
-    ICommonUploadService commonUploadService;
-    @Autowired
-    IDictFileService dictFileService;
-
-    private void checkSystemModel() {
-        try {
-            log.info("检查是否存在系统默认动画模型");
-            String dfModel = "/oss/4dkankan/fusion/default/model/glb";
-
-            List<CommonUpload> uploadList = commonUploadService.getIsSystem();
-            File file = new File(dfModel);
-            File[] files = file.listFiles();
-            if(files == null || files.length <=0){
-                return;
-            }
-            if(files.length != uploadList.size()){
-                List<String> dbUrlList = uploadList.stream().map(CommonUpload::getFileUrl).collect(Collectors.toList());
-                for (File s : files) {
-                    String path = s.getPath();
-                    String name = FileUtil.mainName(s);
-                    path = path.replace("4dkankan/","");
-                    if(dbUrlList.contains(path)){
-                        continue;
-                    }
-                    log.info(path);
-                    CommonUpload commonUpload = commonUploadService.addSystemFile(path,s.length(),name);
-                    if(commonUpload != null){
-                        dictFileService.addSystemFile(commonUpload);
-                    }
-                }
-            }
-        }catch (Exception e){
-            log.info("检查是否存在系统默认动画模型:{}",e);
-        }
-
-    }
 
 }

+ 6 - 1
src/main/resources/bootstrap-dev.yml

@@ -11,7 +11,12 @@ spring:
           - data-id: 4dkankan-fusion.yaml
             group: DEFAULT_GROUP
             refresh: true
-
+          - data-id: common-rabbitmq-config.yaml
+            group: DEFAULT_GROUP
+            refresh: true
+          - data-id: common-fyun-config.yaml
+            group: DEFAULT_GROUP
+            refresh: true
       discovery:
         server-addr: ${spring.cloud.nacos.config.server-addr}
         namespace: ${spring.cloud.nacos.config.namespace}

+ 6 - 1
src/main/resources/bootstrap-test.yml

@@ -11,7 +11,12 @@ spring:
           - data-id: 4dkankan-fusion.yaml
             group: DEFAULT_GROUP
             refresh: true
-
+          - data-id: common-rabbitmq-config.yaml
+            group: DEFAULT_GROUP
+            refresh: true
+          - data-id: common-fyun-config.yaml
+            group: DEFAULT_GROUP
+            refresh: true
       discovery:
         server-addr: ${spring.cloud.nacos.config.server-addr}
         namespace: ${spring.cloud.nacos.config.namespace}

+ 35 - 0
src/main/resources/mapper/fusion/DictFileMapper.xml

@@ -1,5 +1,40 @@
 <?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.IDictFileMapper">
+    <select id="pageList" resultType="com.fdkankan.fusion.response.DictFileVo">
+        SELECT * from t_dict_file df
+        LEFT JOIN t_dict d on df.dict_id = d.id
+        LEFT JOIN t_common_upload cu on df.upload_id = cu.id
+        where df.rec_status = 'A'
+        <if test="param.sysUserId != null">
+            and df.sys_user_id = #{param.sysUserId}
+        </if>
+        <if test="param.name != null and param.name !=''">
+            and df.name like concat('%',#{param.name}, '%')
+        </if>
+        <if test="param.typeKey != null and param.typeKey !=''">
+            and df.type_key = #{param.typeKey}
+        </if>
+        <if test="param.fileType != null">
+            and cu.file_type = #{param.fileType}
+        </if>
+        <if test="param.dictId != null">
+            and df.dict_id = #{param.dictId}
+        </if>
+        <if test="param.fileFormats != null and param.fileFormats.size>0">
+            and cu.file_format in
+            <foreach collection="param.fileFormats" item="fileFormat" open="(" separator="," close=")">
+                #{fileFormat}
+            </foreach>
+        </if>
+        <if test="param.dictIds != null and param.dictIds.size>0">
+            and df.dict_id in
+            <foreach collection="param.dictIds" item="dict" open="(" separator="," close=")">
+                #{dict}
+            </foreach>
+        </if>
 
+        order by df.id desc
+
+    </select>
 </mapper>