|
@@ -1,5 +1,7 @@
|
|
package fi.em.formPlugin;
|
|
package fi.em.formPlugin;
|
|
|
|
|
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
|
+import kd.bos.entity.property.ComboProp;
|
|
import kd.bos.form.events.AfterDoOperationEventArgs;
|
|
import kd.bos.form.events.AfterDoOperationEventArgs;
|
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
|
import org.apache.commons.io.FileUtils;
|
|
import org.apache.commons.io.FileUtils;
|
|
@@ -30,6 +32,8 @@ public class SalaryDownloadFilePlugin extends AbstractFormPlugin {
|
|
String filename= interFaceImgUtils.getFileName();
|
|
String filename= interFaceImgUtils.getFileName();
|
|
//获取文件路径
|
|
//获取文件路径
|
|
String fileurl= interFaceImgUtils.getServerUrl();
|
|
String fileurl= interFaceImgUtils.getServerUrl();
|
|
|
|
+ //文件保存路径
|
|
|
|
+ String fileLocalpath= interFaceImgUtils.getFileLocalPath();
|
|
|
|
|
|
//获取sftp链接对象
|
|
//获取sftp链接对象
|
|
public SftpClient sftpClient=new SftpClient(serverurl,user,password,port);
|
|
public SftpClient sftpClient=new SftpClient(serverurl,user,password,port);
|
|
@@ -41,22 +45,29 @@ public class SalaryDownloadFilePlugin extends AbstractFormPlugin {
|
|
String operateKey = arg.getOperateKey();
|
|
String operateKey = arg.getOperateKey();
|
|
//审核操作代码
|
|
//审核操作代码
|
|
String downloadBut="download";
|
|
String downloadBut="download";
|
|
|
|
+ DynamicObject dynamicObject=this.getModel().getDataEntity(true);
|
|
|
|
+ String nckd_entrytype= dynamicObject.getString("nckd_entrytype");
|
|
if (downloadBut.equals(operateKey)) {
|
|
if (downloadBut.equals(operateKey)) {
|
|
- //获取桌面路径
|
|
|
|
- String path ="C:/Users";
|
|
|
|
- try {
|
|
|
|
- //获取服务器链接
|
|
|
|
- sftpClient.connect();
|
|
|
|
- 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);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ //通用薪酬(一般员工)
|
|
|
|
+ downFileToLocal(nckd_entrytype);
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ //根据分录类型,下载对应的分录模板
|
|
|
|
+ public void downFileToLocal(String nckd_entrytype) {
|
|
|
|
+ //获取下拉列表字段
|
|
|
|
+ ComboProp comboProp = (ComboProp) getModel().getProperty("nckd_entrytype");
|
|
|
|
+ try {
|
|
|
|
+// //通过下拉值获取下拉标题
|
|
|
|
+ String displayName = comboProp.getItemByName(nckd_entrytype);
|
|
|
|
+// //获取服务器链接
|
|
|
|
+ sftpClient.connect();
|
|
|
|
+ sftpClient.downloadFile(fileurl+"/"+displayName+filename,fileLocalpath);
|
|
|
|
+ sftpClient.disconnect();
|
|
|
|
+ this.getView().showMessage("文件生成成功,文件位置为:"+fileLocalpath+"/"+displayName+filename);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|