|
@@ -4,12 +4,19 @@ import kd.bos.dataentity.entity.DynamicObject;
|
|
|
import kd.bos.entity.property.ComboProp;
|
|
|
import kd.bos.form.events.AfterDoOperationEventArgs;
|
|
|
import kd.bos.form.plugin.AbstractFormPlugin;
|
|
|
+import kd.bos.orm.query.QCP;
|
|
|
+import kd.bos.orm.query.QFilter;
|
|
|
+import kd.bos.servicehelper.AttachmentServiceHelper;
|
|
|
+import kd.bos.servicehelper.BusinessDataServiceHelper;
|
|
|
+import kd.imc.bdm.common.constant.BotpCallBackLogConstant;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import sys.sc.opplugin.utils.InterFaceImgUtils;
|
|
|
import sys.sc.opplugin.utils.SftpClient;
|
|
|
|
|
|
import javax.swing.filechooser.FileSystemView;
|
|
|
import java.io.File;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author cjz
|
|
@@ -25,13 +32,32 @@ public class SalaryDownloadFilePlugin extends AbstractFormPlugin {
|
|
|
public void afterDoOperation(AfterDoOperationEventArgs arg){
|
|
|
super.afterDoOperation(arg);
|
|
|
String operateKey = arg.getOperateKey();
|
|
|
+ //获取下拉列表字段
|
|
|
+ ComboProp comboProp = (ComboProp) getModel().getProperty("nckd_entrytype");
|
|
|
+
|
|
|
//审核操作代码
|
|
|
String downloadBut="download";
|
|
|
DynamicObject dynamicObject=this.getModel().getDataEntity(true);
|
|
|
String nckd_entrytype= dynamicObject.getString("nckd_entrytype");
|
|
|
+ //通过下拉值获取下拉标题
|
|
|
+ String displayName = comboProp.getItemByName(nckd_entrytype);
|
|
|
if (downloadBut.equals(operateKey)) {
|
|
|
- //通用薪酬(一般员工)
|
|
|
- downFileToLocal(nckd_entrytype);
|
|
|
+// downFileToLocal(nckd_entrytype);
|
|
|
+ QFilter qFilter=new QFilter("number", QCP.equals,"salaryfile");
|
|
|
+ //下载模板表单
|
|
|
+ DynamicObject nckd_file= BusinessDataServiceHelper.loadSingle("nckd_file",new QFilter[]{qFilter});
|
|
|
+ List<Map<String, Object>> list = AttachmentServiceHelper
|
|
|
+ .getAttachments("nckd_file", nckd_file.getPkValue(), "nckd_attachmentpanelap");
|
|
|
+ String myurl = "";
|
|
|
+ //获取下载链接并打开
|
|
|
+ for(int i = 0; i < list.size(); i++) {
|
|
|
+ String filename=list.get(i).get("name").toString();
|
|
|
+ if (filename.equals(displayName+".xls")) {
|
|
|
+ String downLoadUrl = list.get(i).get("url").toString();
|
|
|
+ //调用该url
|
|
|
+ getView().openUrl(downLoadUrl);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -64,9 +90,11 @@ public class SalaryDownloadFilePlugin extends AbstractFormPlugin {
|
|
|
SftpClient sftpClient=new SftpClient(serverurl,user,password,port);
|
|
|
//获取服务器链接
|
|
|
sftpClient.connect();
|
|
|
- sftpClient.downloadFile(filepath,fileLocalpath+File.separator+displayName+filename);
|
|
|
+ sftpClient.downloadFile(filepath,fileLocalpath+"/"+nckd_entrytype+".xls");
|
|
|
+ new File(fileLocalpath+"/"+nckd_entrytype+".xls")
|
|
|
+ .renameTo(new File(fileLocalpath+"/"+displayName+filename));
|
|
|
sftpClient.disconnect();
|
|
|
- this.getView().showMessage("文件下载成功,文件位置:"+fileLocalpath+File.separator+displayName+filename);
|
|
|
+ this.getView().showMessage("文件下载成功,文件位置:"+fileLocalpath+"/"+displayName+filename);
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|