소스 검색

下载附件

zhouger 5 달 전
부모
커밋
4f59d5bb4e
1개의 변경된 파일28개의 추가작업 그리고 1개의 파일을 삭제
  1. 28 1
      src/main/java/fi/em/formPlugin/SalaryDownloadFilePlugin.java

+ 28 - 1
src/main/java/fi/em/formPlugin/SalaryDownloadFilePlugin.java

@@ -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,12 +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);
+                }
+            }
         }
     }