|  | @@ -0,0 +1,61 @@
 | 
	
		
			
				|  |  | +package fi.em.formPlugin;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import kd.bos.form.events.AfterDoOperationEventArgs;
 | 
	
		
			
				|  |  | +import kd.bos.form.plugin.AbstractFormPlugin;
 | 
	
		
			
				|  |  | +import sys.sc.opplugin.utils.InterFaceImgUtils;
 | 
	
		
			
				|  |  | +import sys.sc.opplugin.utils.SftpClient;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +import javax.swing.filechooser.FileSystemView;
 | 
	
		
			
				|  |  | +import java.io.File;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * @author cjz
 | 
	
		
			
				|  |  | + * @date 2024/11/7 20:35
 | 
	
		
			
				|  |  | + * @description:点击按钮下载对应薪酬计提分录模板文件
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +public class SalaryDownloadFilePlugin extends AbstractFormPlugin {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    //获取文件上传接口配置信息
 | 
	
		
			
				|  |  | +    public InterFaceImgUtils interFaceImgUtils=new InterFaceImgUtils("downloadurl");
 | 
	
		
			
				|  |  | +    //端口号
 | 
	
		
			
				|  |  | +    int port= interFaceImgUtils.getPort();
 | 
	
		
			
				|  |  | +    //服务器地址
 | 
	
		
			
				|  |  | +    String serverurl= interFaceImgUtils.getServerName();
 | 
	
		
			
				|  |  | +    //用户
 | 
	
		
			
				|  |  | +    String user= interFaceImgUtils.getServerUser();
 | 
	
		
			
				|  |  | +    //密码
 | 
	
		
			
				|  |  | +    String password= interFaceImgUtils.getServerPassword();
 | 
	
		
			
				|  |  | +    //文件名
 | 
	
		
			
				|  |  | +    String filename= interFaceImgUtils.getFileName();
 | 
	
		
			
				|  |  | +    //获取文件路径
 | 
	
		
			
				|  |  | +    String fileurl= interFaceImgUtils.getServerUrl();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    //获取sftp链接对象
 | 
	
		
			
				|  |  | +    public SftpClient sftpClient=new SftpClient(serverurl,user,password,port);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    //点击按钮下载文件
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public void afterDoOperation(AfterDoOperationEventArgs arg){
 | 
	
		
			
				|  |  | +        super.afterDoOperation(arg);
 | 
	
		
			
				|  |  | +        String operateKey = arg.getOperateKey();
 | 
	
		
			
				|  |  | +        //审核操作代码
 | 
	
		
			
				|  |  | +        String downloadBut="download";
 | 
	
		
			
				|  |  | +        if (downloadBut.equals(operateKey)) {
 | 
	
		
			
				|  |  | +            //获取桌面路径
 | 
	
		
			
				|  |  | +            String path = FileSystemView.getFileSystemView().getHomeDirectory().getPath();
 | 
	
		
			
				|  |  | +            this.getView().showMessage(path);
 | 
	
		
			
				|  |  | +            try {
 | 
	
		
			
				|  |  | +                //获取服务器链接
 | 
	
		
			
				|  |  | +                sftpClient.connect();
 | 
	
		
			
				|  |  | +                sftpClient.downloadFile(fileurl+ File.separator+filename,path);
 | 
	
		
			
				|  |  | +                this.getView().showMessage("文件生成成功,文件位置为:"+path);
 | 
	
		
			
				|  |  | +                sftpClient.disconnect();
 | 
	
		
			
				|  |  | +            } catch (Exception e) {
 | 
	
		
			
				|  |  | +                throw new RuntimeException(e);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +}
 |