zhouger před 5 měsíci
rodič
revize
1cf510e0de

+ 4 - 2
src/main/java/fi/em/formPlugin/SalaryDownloadFilePlugin.java

@@ -2,6 +2,7 @@ package fi.em.formPlugin;
 
 import kd.bos.form.events.AfterDoOperationEventArgs;
 import kd.bos.form.plugin.AbstractFormPlugin;
+import org.apache.commons.io.FileUtils;
 import sys.sc.opplugin.utils.InterFaceImgUtils;
 import sys.sc.opplugin.utils.SftpClient;
 
@@ -46,9 +47,10 @@ public class SalaryDownloadFilePlugin extends AbstractFormPlugin {
             try {
                 //获取服务器链接
                 sftpClient.connect();
-                sftpClient.downloadFile(fileurl+ File.separator+filename,path);
-                this.getView().showMessage("文件生成成功,文件位置为:"+path);
+                File file=new File(path+File.separator+"模板文件.xls");
+                FileUtils.copyInputStreamToFile(sftpClient.downloadFile(fileurl+ File.separator+filename),file);
                 sftpClient.disconnect();
+                this.getView().showMessage("文件生成成功,文件位置为:"+path);
             } catch (Exception e) {
                 throw new RuntimeException(e);
             }

+ 2 - 2
src/main/java/sys/sc/opplugin/utils/SftpClient.java

@@ -66,8 +66,8 @@ public class SftpClient {
     }
 
     //下载文件到桌面
-    public void downloadFile(String url,String localpath) throws SftpException {
-        sftpChannel.get(url,localpath);
+    public InputStream downloadFile(String url) throws SftpException {
+        return   sftpChannel.get(url);
     }
 
     public ChannelSftp getSftpChannel() {