|  | @@ -1,6 +1,7 @@
 | 
											
												
													
														|  |  package sys.sc.formplugin;
 |  |  package sys.sc.formplugin;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  import com.alipay.api.kms.aliyun.utils.BackoffUtils;
 |  |  import com.alipay.api.kms.aliyun.utils.BackoffUtils;
 | 
											
												
													
														|  | 
 |  | +import com.jcraft.jsch.SftpException;
 | 
											
												
													
														|  |  import kd.bos.dataentity.entity.DynamicObject;
 |  |  import kd.bos.dataentity.entity.DynamicObject;
 | 
											
												
													
														|  |  import kd.bos.dataentity.entity.DynamicObjectCollection;
 |  |  import kd.bos.dataentity.entity.DynamicObjectCollection;
 | 
											
												
													
														|  |  import kd.bos.form.events.AfterDoOperationEventArgs;
 |  |  import kd.bos.form.events.AfterDoOperationEventArgs;
 | 
											
										
											
												
													
														|  | @@ -77,15 +78,11 @@ public class CreatDatPlugin extends AbstractListPlugin {
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  |                  this.getView().showMessage("创建成功"+filePath);
 |  |                  this.getView().showMessage("创建成功"+filePath);
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |              //分割符号
 |  |              //分割符号
 | 
											
												
													
														|  |              String spiltsign=jkdataDy.getString("nckd_split");
 |  |              String spiltsign=jkdataDy.getString("nckd_split");
 | 
											
												
													
														|  |              //结束符号
 |  |              //结束符号
 | 
											
												
													
														|  |              String endsign=jkdataDy.getString("nckd_endsign");
 |  |              String endsign=jkdataDy.getString("nckd_endsign");
 | 
											
												
													
														|  | -            //文件生成到本地路径
 |  | 
 | 
											
												
													
														|  | -            DatFileCreatUtils datFileCreatUtils=new DatFileCreatUtils(tablenumber,bizappnum,fileList,filePath,spiltsign,endsign);
 |  | 
 | 
											
												
													
														|  | -            //生成dat文件到本地
 |  | 
 | 
											
												
													
														|  | -            datFileCreatUtils.creatDatFile();
 |  | 
 | 
											
												
													
														|  | -            //上传文件到服务器中
 |  | 
 | 
											
												
													
														|  |              //服务器端口
 |  |              //服务器端口
 | 
											
												
													
														|  |              String host=jkdataDy.getString("nckd_servername");
 |  |              String host=jkdataDy.getString("nckd_servername");
 | 
											
												
													
														|  |              //服务器用户名
 |  |              //服务器用户名
 | 
											
										
											
												
													
														|  | @@ -94,35 +91,43 @@ public class CreatDatPlugin extends AbstractListPlugin {
 | 
											
												
													
														|  |              String password=jkdataDy.getString("nckd_password");
 |  |              String password=jkdataDy.getString("nckd_password");
 | 
											
												
													
														|  |              //服务器端口号
 |  |              //服务器端口号
 | 
											
												
													
														|  |              int port=jkdataDy.getInt("nckd_port");
 |  |              int port=jkdataDy.getInt("nckd_port");
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            //上传文件到服务器中
 | 
											
												
													
														|  |              SftpClient sftpClient=new SftpClient(host,username,password,port);
 |  |              SftpClient sftpClient=new SftpClient(host,username,password,port);
 | 
											
												
													
														|  | -            //获取服务器连接
 |  | 
 | 
											
												
													
														|  |              try {
 |  |              try {
 | 
											
												
													
														|  | -                sftpClient.connect();
 |  | 
 | 
											
												
													
														|  | -                //上传文件到服务器指定路径
 |  | 
 | 
											
												
													
														|  | -                sftpClient.fileCreat(filePath,nckd_url+filename);
 |  | 
 | 
											
												
													
														|  | -            } catch (Exception e) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +                //临时文件
 | 
											
												
													
														|  | 
 |  | +                Path localFile = Files.createTempFile(tablenumber, ".dat");
 | 
											
												
													
														|  | 
 |  | +                //文件生成到本地路径
 | 
											
												
													
														|  | 
 |  | +                DatFileCreatUtils datFileCreatUtils=new DatFileCreatUtils(tablenumber,bizappnum,fileList,localFile.toString(),spiltsign,endsign);
 | 
											
												
													
														|  | 
 |  | +                //生成dat文件到本地
 | 
											
												
													
														|  | 
 |  | +                datFileCreatUtils.creatDatFile();
 | 
											
												
													
														|  | 
 |  | +                sftpClient.fileCreat(String.valueOf(localFile),nckd_url);
 | 
											
												
													
														|  | 
 |  | +            } catch (IOException e) {
 | 
											
												
													
														|  | 
 |  | +                throw new RuntimeException(e);
 | 
											
												
													
														|  | 
 |  | +            } catch (SftpException e) {
 | 
											
												
													
														|  |                  throw new RuntimeException(e);
 |  |                  throw new RuntimeException(e);
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |              //关闭连接
 |  |              //关闭连接
 | 
											
												
													
														|  |              sftpClient.disconnect();
 |  |              sftpClient.disconnect();
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          if (name.equals("uploadfile"))
 |  |          if (name.equals("uploadfile"))
 | 
											
												
													
														|  |          {
 |  |          {
 | 
											
												
													
														|  | -            String remoteFilePath="/home/kingdee/cosmic/nginx-appstatic/store/appstatic/";
 |  | 
 | 
											
												
													
														|  | -            SftpClient sftpClient=new SftpClient("192.168.10.69","root","Kd@86262007",22);
 |  | 
 | 
											
												
													
														|  | -            try {
 |  | 
 | 
											
												
													
														|  | -                sftpClient.connect();
 |  | 
 | 
											
												
													
														|  | -                // 创建一个新的远程文件并写入内容
 |  | 
 | 
											
												
													
														|  | -                Path localFile = Files.createTempFile("tempfile", ".txt");
 |  | 
 | 
											
												
													
														|  | -                Files.write(localFile, Collections.singleton("Hello, SFTP!"));
 |  | 
 | 
											
												
													
														|  | -                sftpClient.fileCreat(localFile.toString(),remoteFilePath);  // 清理临时文件
 |  | 
 | 
											
												
													
														|  | -                Files.delete(localFile);
 |  | 
 | 
											
												
													
														|  | -            } catch (IOException e) {
 |  | 
 | 
											
												
													
														|  | -                throw new RuntimeException(e);
 |  | 
 | 
											
												
													
														|  | -            } catch (Exception e) {
 |  | 
 | 
											
												
													
														|  | -                throw new RuntimeException(e);
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -            sftpClient.disconnect();
 |  | 
 | 
											
												
													
														|  | 
 |  | +//            String remoteFilePath="/home/kingdee/cosmic/nginx-appstatic/store/appstatic/";
 | 
											
												
													
														|  | 
 |  | +//            SftpClient sftpClient=new SftpClient("192.168.10.69","root","Kd@86262007",22);
 | 
											
												
													
														|  | 
 |  | +//
 | 
											
												
													
														|  | 
 |  | +//            try {
 | 
											
												
													
														|  | 
 |  | +////                sftpClient.connect();
 | 
											
												
													
														|  | 
 |  | +////                DatFileCreatUtils datFileCreatUtils=new DatFileCreatUtils(tablenumber,bizappnum,fileList,filePath,spiltsign,endsign);
 | 
											
												
													
														|  | 
 |  | +////                Files.write(localFile, Collections.singleton("Hello, SFTP!"));
 | 
											
												
													
														|  | 
 |  | +////                sftpClient.fileCreat(localFile.toString(),remoteFilePath);  // 清理临时文件
 | 
											
												
													
														|  | 
 |  | +////                Files.delete(localFile);
 | 
											
												
													
														|  | 
 |  | +//            } catch (IOException e) {
 | 
											
												
													
														|  | 
 |  | +//                throw new RuntimeException(e);
 | 
											
												
													
														|  | 
 |  | +//            } catch (Exception e) {
 | 
											
												
													
														|  | 
 |  | +//                throw new RuntimeException(e);
 | 
											
												
													
														|  | 
 |  | +//            }
 | 
											
												
													
														|  | 
 |  | +//            sftpClient.disconnect();
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      }
 |  |      }
 |