Browse Source

扫描仓库新增

cr 1 day ago
parent
commit
e0d6a56087

+ 10 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ScanFileController.java

@@ -135,6 +135,16 @@ public class ScanFileController {
         IPage<ScanFile> page=scanFileService.getScanFile(contractId,projectId,folderId,query,move);
         return R.data(page);
     }
+    @PostMapping("/addScanFolder")
+    @ApiOperation("新增节点扫描文件夹")
+    public R addScanFolder(Long projectId,Long contractId,String forderName,Long parentId){
+        return R.status(scanFileService.addScanFolder(projectId,contractId,forderName,parentId));
+    }
+    @PostMapping("/addScanFile")
+    @ApiOperation("新增节点扫描文件")
+    public R addScanFile(Long projectId,Long contractId,String forderName,Long forderId){
+        return R.status(scanFileService.addScanFile(projectId,contractId,forderName,forderId));
+    }
     @GetMapping("/getDetil")
     @ApiOperation("获取扫描文件详情")
     @ApiImplicitParam(name = "id", value = "文件ID")

+ 4 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/service/ScanFileService.java

@@ -28,4 +28,8 @@ public interface ScanFileService extends IService<ScanFile> {
     Boolean autoRecognize(String ids);
 
     boolean moveScanFile(List<Long> ids, Long nodeId);
+
+    boolean addScanFolder(Long projectId, Long contractId, String forderName, Long parentId);
+
+    boolean addScanFile(Long projectId, Long contractId, String forderName, Long forderId);
 }

+ 37 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ScanFileServiceImpl.java

@@ -17,6 +17,7 @@ import org.springblade.archive.vo.ScanFolderVO;
 import org.springblade.business.entity.ArchiveFile;
 import org.springblade.business.feign.ArchiveFileClient;
 import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.tool.api.R;
@@ -185,6 +186,42 @@ public class ScanFileServiceImpl  extends ServiceImpl<ScanFileMapper, ScanFile>
         }
     }
 
+    @Override
+    public boolean addScanFolder(Long projectId, Long contractId, String forderName, Long parentId) {
+            ScanFolder scanFolder = new ScanFolder();
+            scanFolder.setId(SnowFlakeUtil.getId());
+            scanFolder.setProjectId(projectId);
+            scanFolder.setContractId(contractId);
+            scanFolder.setFolderName(forderName);
+            scanFolder.setParentId(parentId);
+            scanFolder.setIsDeleted(0);
+            String folderPath="";
+            if(parentId!=0){
+                ScanFolder fatherFolder = scanFolderMapper.selectById(parentId);
+                if (fatherFolder!=null){
+                    String fatherPath = fatherFolder.getFolderPath();
+                    folderPath=fatherPath+"/"+forderName;
+                }
+            }else {
+                 folderPath=ROOT_PREFIX+"/"+contractId+"/"+forderName;
+            }
+            File folder = new File(folderPath);
+           if (!folder.exists()) {
+             boolean created = folder.mkdirs();
+             if (!created) {
+                throw new ServiceException("创建文件夹失败");
+             }
+           }
+          scanFolder.setFolderPath(folderPath);
+          int insert = scanFolderMapper.insert(scanFolder);
+          return insert == 1;
+    }
+
+    @Override
+    public boolean addScanFile(Long projectId, Long contractId, String forderName, Long forderId) {
+        return false;
+    }
+
     /**
      * 入口方法:扫描并入库指定contractId的所有文件夹
      * @param contractId 传入的合同ID(对应D:\PDF下的文件夹名)