devops преди 3 месеца
родител
ревизия
bf4b7f8da3

+ 74 - 1
digital-module-system/digital-manager/src/main/java/com/trs/digital/module/manager/controller/admin/search/controller/AdvSearchController.java

@@ -1,5 +1,6 @@
 package com.trs.digital.module.manager.controller.admin.search.controller;
 
+import cn.hutool.core.io.FileUtil;
 import cn.hutool.extra.ftp.Ftp;
 import cn.hutool.extra.ssh.Sftp;
 import com.alibaba.fastjson.JSONArray;
@@ -465,7 +466,7 @@ public class AdvSearchController {
     }
 
 
-    @CrossOrigin
+/*    @CrossOrigin
     @Operation(summary = "检索-下载")
     //@PreAuthorize("@ss.hasPermission('adv/search:ftp1')")
     @PermitAll
@@ -529,6 +530,78 @@ public class AdvSearchController {
 
         // 获取字节数组
         return byteArrayOutputStream.toByteArray();
+    }*/
+
+
+    @CrossOrigin
+    @Operation(summary = "检索-下载")
+    //@PreAuthorize("@ss.hasPermission('adv/search:ftp1')")
+    @PermitAll
+    @RequestMapping("/download4")
+    public byte[] download4(@RequestBody AdvSearchSaveLabelsReqVO reqVO) throws IOException  {
+
+        String filePath = reqVO.getFilePath();
+        /*String sourcename = reqVO.getSourcename();
+        String host = "";
+        String user = "";
+        String pass = "";
+
+        if ("ftp02".equals(sourcename)||"ftp2".equals(sourcename)) {
+            host = host_1;
+            user = user_1;
+            pass = pwd_1;
+        } else {
+            host = host_2;
+            user = user_2;
+            pass = pwd_2;
+        }*/
+        // 创建 FTP 客户端
+        /*FTPClient client = new FTPClient();
+        client.setControlEncoding("UTF-8");
+        client.connect(host, 21);
+        if (FTPReply.isPositiveCompletion(client.getReplyCode())) {
+            String userName = user;
+            String password = pass;
+            if (StringUtil.isEmpty(userName)) {
+                userName = "anonymous"; //$NON-NLS-1$
+                password = ""; //$NON-NLS-1$
+            }
+            if (!client.login(userName, password)) {
+                throw new IOException("user name or password is not correct, please check it."); //$NON-NLS-1$
+            }
+            client.setBufferSize(1024 * 1024);
+            client.setFileType(FTP.BINARY_FILE_TYPE);
+        }*/
+        // 获取文件内容
+//        String ftpPath = filePath.replace("\\", "/").substring(filePath.indexOf("/") + 1);
+        String ftpPath = "/ftp"+filePath;
+        Sftp sftp = new Sftp(remoteHost, port, username, password);
+        File destFile = FileUtils.createTempFile();
+        sftp.download(ftpPath, destFile);
+        /*String filepath = ftpPath.substring(0, ftpPath.lastIndexOf("/"));
+        String filename = ftpPath.substring(ftpPath.lastIndexOf("/") + 1);
+        InputStream inputStream = client.retrieveFileStream(filePath);
+
+        // 使用 ByteArrayOutputStream 将文件内容写入字节数组
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        byte[] buffer = new byte[1024];
+        int bytesRead;
+
+        try {
+            //
+            while ((bytesRead = inputStream.read(buffer)) != -1) {
+                byteArrayOutputStream.write(buffer, 0, bytesRead);
+            }
+        } finally {
+            // 关闭流和FTP连接
+            inputStream.close();
+            client.logout();
+            client.disconnect();
+        }*/
+
+        // 获取字节数组
+//        return byteArrayOutputStream.toByteArray();
+        return FileUtil.readBytes(destFile);
     }
 
 

+ 4 - 1
digital-module-system/digital-manager/src/main/java/com/trs/digital/module/manager/controller/admin/search/service/SearchService.java

@@ -154,7 +154,10 @@ public class SearchService {
 
         String condition_temp = condition;
         AdminUserDO user = userService.getUser(getLoginUserId());
-        String username = user.getNickname();
+        String username = "";
+        if(user!=null){
+            username = user.getUsername();
+        }
         if(StringUtils.isNotBlank(username)){
             condition = "("+condition+" NOT (sourcename#LIST:user))";
             condition+= " OR ("+condition_temp+" AND (username:"+username+"))";

+ 2 - 2
digital-server/src/main/resources/application.yaml

@@ -295,7 +295,7 @@ sourcename:
     ftpuser: trsmedia
     password: Acq%7j0py5*g
 ssh:
-  remoteHost: localhost
+  remoteHost: 192.168.182.130
   port: 22
   username: root
-  password: 111
+  password: 123456

+ 1 - 1
digital-ui-250219/src/views/search/index.vue

@@ -2555,7 +2555,7 @@ export default {
         // if(this.detailData.file_path == "" || this.detailData.file_path == null ){
         //   this.downloadShow = false ;
         // }
-        if (this.detailData.sourcename === 'oracle' ){
+        if (this.detailData.sourcename === 'oracle' && this.detailData.attpath !=null ){
           this.downloadShow = true;
         }else{
           this.downloadShow = false;