xiewj 2 лет назад
Родитель
Сommit
a63ba8be28

+ 1 - 0
720yun_fd_manage/gis_common/src/main/java/com/gis/common/constant/ErrorEnum.java

@@ -63,6 +63,7 @@ public enum ErrorEnum {
     FAILURE_CODE_3101(3101, "素材已经被引用, 不能删除"),
     FAILURE_CODE_3102(3102, "计算中的场景不能删除"),
     FAILURE_CODE_3103(3103, "服务器someData.json文件不存在"),
+    FAILURE_CODE_3104(3104, "存在同名文件夹,请直接移动素材"),
 
     // 32XX -> 请求第三方API错误
     FAILURE_API_3200(3200, "请求第三方API失败"),

+ 2 - 0
720yun_fd_manage/gis_mapper/src/main/java/com/gis/mapper/DirMapper.java

@@ -16,6 +16,8 @@ public interface DirMapper extends IBaseMapper<DirEntity, Long> {
 
     @SelectProvider(type = BaseProvider.class, method = "selectSql")
     void updateParentId(String sqlStr);
+    @SelectProvider(type = BaseProvider.class, method = "selectSql")
+    void update(String sqlStr);
 
     @SelectProvider(type = BaseProvider.class, method = "selectSql")
     List<String> getListStr(String sqlStr);

+ 3 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/DirService.java

@@ -16,4 +16,7 @@ public interface DirService extends IBaseService<DirEntity, Long>{
     Result move(DirMoveDto param);
 
     Result remove(Long id);
+
+    DirEntity findByIdAndName(Long parentId,String name);
+
 }

+ 2 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/FodderService.java

@@ -49,4 +49,6 @@ public interface FodderService extends IBaseService<FodderEntity, Long> {
     Integer getVolume(String unit);
 
     int getTodaySize(LocalDate today , String unit);
+
+    Result handelRemove(Long id);
 }

+ 29 - 4
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/DirServiceImpl.java

@@ -1,5 +1,6 @@
 package com.gis.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.gis.common.constant.ErrorEnum;
 import com.gis.common.exception.BaseRuntimeException;
@@ -80,7 +81,17 @@ public class DirServiceImpl extends IBaseServiceImpl<DirEntity, Long> implements
 
     @Override
     public Result move(DirMoveDto param) {
+        String[] split = param.getDirIds().split(",");
+        for (String s : split) {
+            DirEntity byId = this.findById(Long.valueOf(s));
+            log.info("文件夹名称查询{}",byId);
+            DirEntity byIdAndName = findByIdAndName(param.getParentId(), byId.getName());
+            if (ObjectUtil.isNotNull(byIdAndName)){
+                log.info("{}",byIdAndName);
+                throw new BaseRuntimeException(ErrorEnum.FAILURE_CODE_3104.code(), ErrorEnum.FAILURE_CODE_3104.message());
 
+            }
+        }
         // 移动目录
         this.updateParentId(param.getParentId(), param.getDirIds(), param.getAncestors());
         // 移动素材
@@ -89,6 +100,14 @@ public class DirServiceImpl extends IBaseServiceImpl<DirEntity, Long> implements
         return Result.success();
     }
 
+    @Override
+    public DirEntity findByIdAndName(Long parentId, String name) {
+        DirEntity parm=new DirEntity();
+        parm.setName(name);
+        parm.setParentId(parentId);
+        return getBaseMapper().selectOne(parm);
+    }
+
     /**
      * 删除目录
      * 若删除的文件夹包括图片、视频、音频,可直接删除
@@ -103,21 +122,21 @@ public class DirServiceImpl extends IBaseServiceImpl<DirEntity, Long> implements
 //        if ("pano".equals(type)){
 //            // 查询子节点
 //            String dirs = getChildIdById(id);
-//            BaseRuntimeException.isTrue(checkPanoUse(dirs), ErrorEnum.FAILURE_CODE_3101.code(), ErrorEnum.FAILURE_CODE_3101.message());
-//            this.deleteByIds(dirs);
+//            BaseRuntimeException.isTrue(checkPanoUse(dirs,type), ErrorEnum.FAILURE_CODE_3101.code(), ErrorEnum.FAILURE_CODE_3101.message());
+//            this.removeIds(dirs);
 //            fodderService.removeByDirIds(dirs);
 //        } else {
 //            // 子目录跟子素材没有进行递归删除
 //            //20230420 增加删除子目录
 //            String dirs = getChildIdById(id);
-//            this.deleteByIds(dirs);
+//            this.removeIds(dirs);
 //            fodderService.removeByDirIds(dirs);
 //        }
         // 查询子节点
         String dirs = getChildIdById(id);
         log.info("删除类型{},dir-ids:{}",type,dirs);
         BaseRuntimeException.isTrue(checkPanoUse(dirs,type), ErrorEnum.FAILURE_CODE_3101.code(), ErrorEnum.FAILURE_CODE_3101.message());
-        this.deleteByIds(dirs);
+        this.removeIds(dirs);
         fodderService.removeByDirIds(dirs);
         return Result.success();
     }
@@ -171,7 +190,13 @@ public class DirServiceImpl extends IBaseServiceImpl<DirEntity, Long> implements
         return works;
 
     }
+    private void removeIds(String dirIds){
+        if (StrUtil.isNotBlank(dirIds)){
+            log.info("删除状态标记: {} ", dirIds );
+            entityMapper.update(StrUtil.format("update tb_dir set is_delete=1 where is_delete=0 and id in ({}) ", dirIds));
+        }
 
+    }
     private void updateParentId(Long parentId, String dirIds, String ancestors){
         if (StrUtil.isNotBlank(dirIds)){
             log.info("移动目录: {} 到 {}", dirIds, parentId);

+ 48 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/FodderServiceImpl.java

@@ -3,7 +3,9 @@ package com.gis.service.impl;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.io.FileTypeUtil;
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import com.amazonaws.services.dynamodbv2.xspec.S;
 import com.gis.common.config.RabbitConfig;
 import com.gis.common.constant.CmdConstant;
 import com.gis.common.constant.ConfigConstant;
@@ -650,5 +652,51 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
         return ImageUtil.dpi(file);
     }
 
+    @Override
+    public Result handelRemove(Long id) {
+        Condition condition = new Condition(DirEntity.class);
+        if (ObjectUtil.isNotNull(id)&&id!=0){
+            condition.and().andEqualTo("id", id);
+        }
 
+        //查询出所有素材,去查询他的最大父节点存在否,不存在设置为删除状态
+        for (FodderEntity fodderEntity : findAll(condition)) {
+            if (ObjectUtil.isNotEmpty(fodderEntity.getDirId())&&fodderEntity.getDirId()>1){
+                log.info("此素材需要查询文件夹节点id:{},name{}",fodderEntity.getId(),fodderEntity.getName());
+                DirEntity dir = dirService.findById(fodderEntity.getDirId());
+                if (ObjectUtil.isNotNull(dir) ){
+                    if (StrUtil.isNotEmpty(dir.getAncestors())){
+                        String[] split = dir.getAncestors().split(",");
+                        if (split.length>=2){
+                            String s = split[1];
+                            DirEntity byId = dirService.findById(Long.valueOf(s));
+                            if (byId!=null){
+                                log.info("顶层目录是:{},name{}",Long.valueOf(s),byId.getName());
+                            }else {
+                                log.error("顶层目录是不存在:{},split{}",Long.valueOf(s),split);
+                            }
+                        }
+                    }
+//                    dirService.remove(dirByParentId.getId());
+                }
+
+            }
+        }
+        return null;
+    }
+    //获取顶层的dir
+    DirEntity getDirByParentId( DirEntity dirs){
+        DirEntity dir = dirService.findById(dirs.getParentId());
+        if (ObjectUtil.isNull(dir)){
+            return dirs;
+        }else if (ObjectUtil.isNotNull(dir)&&ObjectUtil.isNotNull(dir.getParentId())&&dir.getParentId()!=1){
+            DirEntity dirByParentId = getDirByParentId(dir);
+            if (ObjectUtil.isNull(dirByParentId)){
+                return dirs;
+            }
+        }else if (ObjectUtil.isNotNull(dir)&&ObjectUtil.isNotNull(dir.getParentId())&&dir.getParentId()!=1){
+            return null;
+        }
+        return null;
+    }
 }

+ 5 - 1
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/FodderController.java

@@ -139,7 +139,11 @@ public class FodderController extends BaseController {
     }
 
 
-
+    @ApiOperation(value = "处理历史数据")
+    @PostMapping("/handelRemove/{id}")
+    public Result handelRemove(@PathVariable Long id ) {
+        return fodderService.handelRemove(id);
+    }
 
 
 }