Ver Fonte

薪酬导入插件

13246659623 há 4 meses atrás
pai
commit
962d458f89

+ 5 - 4
src/main/java/fi/em/formPlugin/SalaryClickPlugin.java

@@ -5,6 +5,7 @@ import kd.bos.context.RequestContext;
 import kd.bos.form.control.Button;
 import kd.bos.form.events.AfterDoOperationEventArgs;
 import kd.bos.form.plugin.AbstractFormPlugin;
+import kd.bos.servicehelper.operation.OperationServiceHelper;
 import kd.bos.url.UrlService;
 
 import java.util.EventObject;
@@ -21,10 +22,10 @@ public class SalaryClickPlugin extends AbstractFormPlugin {
         super.afterBindData(e);
         //新增或可编辑状态
         if(OperationStatus.ADDNEW.equals(getView().getFormShowParameter().getStatus())||OperationStatus.EDIT.equals(getView().getFormShowParameter().getStatus())){
-            RequestContext ctx = RequestContext.get();
-            String clientPath = UrlService.getDomainContextUrlByTenantCode(ctx.getTenantCode());//拿到完整的客户端网址
-            String jspath = clientPath+"/public/thirdjs/salaryupload.js";
-            this.getView().executeClientCommand("loadThirdPartyJS",jspath);
+//            RequestContext ctx = RequestContext.get();
+//            String clientPath = UrlService.getDomainContextUrlByTenantCode(ctx.getTenantCode());//拿到完整的客户端网址
+           // String jspath = clientPath+"/public/thirdjs/salaryupload.js";
+            //this.getView().executeClientCommand("loadThirdPartyJS",jspath);
         }
     }
 }

+ 20 - 12
src/main/java/fi/em/formPlugin/SalaryFileUploadEditPlugin.java

@@ -32,29 +32,37 @@ public class SalaryFileUploadEditPlugin extends AbstractBillPlugIn implements Up
     public void registerListener(EventObject e) {
 
         super.registerListener(e);
-        //按钮面板
-        Toolbar toolbar = this.getControl("tbmain");
-        toolbar.addUploadListener(this);
-        //附件面板
-        AttachmentPanel attachmentPanel = getControl("nckd_attachment_xc");
+        Toolbar attachmentPanel = this.getControl("advcontoolbarap");
         attachmentPanel.addUploadListener(this);
+        Toolbar attachmentPanel1 = this.getControl("nckd_advcontoolbarap1");
+        attachmentPanel1.addUploadListener(this);
+        Toolbar attachmentPanel2 = this.getControl("nckd_advcontoolbarap12");
+        attachmentPanel2.addUploadListener(this);
+        Toolbar attachmentPanel3 = this.getControl("nckd_advcontoolbarap11");
+        attachmentPanel3.addUploadListener(this);
+        Toolbar attachmentPanel4 = this.getControl("nckd_advcontoolbarap13");
+        attachmentPanel4.addUploadListener(this);
     }
 
 
     @Override
     public void afterUpload(UploadEvent evt) {
-        //获取当前操作单据
-        DynamicObject dynamicObject=this.getModel().getDataEntity(true);
-        String nckd_entrytype=dynamicObject.getString("nckd_entrytype");
+        String nckd_entrytype=this.getModel().getValue("nckd_entrytype")+"";
         //解析附件面板
-        AttachmentPanel attachmentPanel=this.getControl("nckd_attachment_xc");
-        List<Map<String,Object>> attachmentData=attachmentPanel.getAttachmentData();
+      //  AttachmentPanel attachmentPanel=this.getControl("nckd_attachment_xc");
+      //  List<Map<String,Object>> attachmentData=attachmentPanel.getAttachmentData();
         //获取最新上传的文件路径
-        String fileurl = (String) attachmentData.get(attachmentData.size()-1).get("url");
+        String fileurl = evt.getUrls()[0]+"";
+        File ff = new File(fileurl);
         //获取文件缓存
         TempFileCache cache = CacheFactory.getCommonCacheFactory().getTempFileCache();
         //从缓存中拿到输入流
-        InputStream inputStream = cache.getInputStream(fileurl);
+        InputStream inputStream = null;
+        try {
+            inputStream = new FileInputStream(ff);
+        } catch (FileNotFoundException e) {
+            throw new RuntimeException(e);
+        }
         String billtype="";
         //根据分录类型获取对应分录标识
         if ("A".equals(nckd_entrytype)) {

+ 20 - 12
src/main/java/fi/em/formPlugin/SalaryFileUploadEditPluginCp.java

@@ -32,29 +32,37 @@ public class SalaryFileUploadEditPluginCp extends AbstractBillPlugIn implements
     public void registerListener(EventObject e) {
 
         super.registerListener(e);
-        //按钮面板
-        Toolbar toolbar = this.getControl("tbmain");
-        toolbar.addUploadListener(this);
-        //附件面板
-        AttachmentPanel attachmentPanel = getControl("nckd_attachment_xc");
+        Toolbar attachmentPanel = this.getControl("advcontoolbarap");
         attachmentPanel.addUploadListener(this);
+        Toolbar attachmentPanel1 = this.getControl("nckd_advcontoolbarap1");
+        attachmentPanel1.addUploadListener(this);
+        Toolbar attachmentPanel2 = this.getControl("nckd_advcontoolbarap12");
+        attachmentPanel2.addUploadListener(this);
+        Toolbar attachmentPanel3 = this.getControl("nckd_advcontoolbarap11");
+        attachmentPanel3.addUploadListener(this);
+        Toolbar attachmentPanel4 = this.getControl("nckd_advcontoolbarap13");
+        attachmentPanel4.addUploadListener(this);
     }
 
 
     @Override
     public void afterUpload(UploadEvent evt) {
-        //获取当前操作单据
-        DynamicObject dynamicObject=this.getModel().getDataEntity(true);
-        String nckd_entrytype=dynamicObject.getString("nckd_entrytype");
+        String nckd_entrytype=this.getModel().getValue("nckd_entrytype")+"";
         //解析附件面板
-        AttachmentPanel attachmentPanel=this.getControl("nckd_attachment_xc");
-        List<Map<String,Object>> attachmentData=attachmentPanel.getAttachmentData();
+        //  AttachmentPanel attachmentPanel=this.getControl("nckd_attachment_xc");
+        //  List<Map<String,Object>> attachmentData=attachmentPanel.getAttachmentData();
         //获取最新上传的文件路径
-        String fileurl = (String) attachmentData.get(attachmentData.size()-1).get("url");
+        String fileurl = evt.getUrls()[0]+"";
+        File ff = new File(fileurl);
         //获取文件缓存
         TempFileCache cache = CacheFactory.getCommonCacheFactory().getTempFileCache();
         //从缓存中拿到输入流
-        InputStream inputStream = cache.getInputStream(fileurl);
+        InputStream inputStream = null;
+        try {
+            inputStream = new FileInputStream(ff);
+        } catch (FileNotFoundException e) {
+            throw new RuntimeException(e);
+        }
         String billtype="";
         //根据分录类型获取对应分录标识
         if ("A".equals(nckd_entrytype)) {

+ 0 - 28
src/main/java/fi/em/formPlugin/SalaryJTClickPlugin.java

@@ -1,28 +0,0 @@
-package fi.em.formPlugin;
-
-import kd.bos.bill.OperationStatus;
-import kd.bos.context.RequestContext;
-import kd.bos.form.plugin.AbstractFormPlugin;
-import kd.bos.url.UrlService;
-
-import java.util.EventObject;
-
-/**
- * @author cjz
- * @date 2024/11/15 11:51
- * @description:薪酬发放计提,调用附件上传按钮
- */
-public class SalaryJTClickPlugin extends AbstractFormPlugin {
-
-    @Override
-    public void afterBindData(EventObject e) {
-        super.afterBindData(e);
-        //新增或可编辑状态
-        if(OperationStatus.ADDNEW.equals(getView().getFormShowParameter().getStatus())||OperationStatus.EDIT.equals(getView().getFormShowParameter().getStatus())){
-            RequestContext ctx = RequestContext.get();
-            String clientPath = UrlService.getDomainContextUrlByTenantCode(ctx.getTenantCode());//拿到完整的客户端网址
-            String jspath = clientPath+"/public/thirdjs/salaryuploadJT.js";
-            this.getView().executeClientCommand("loadThirdPartyJS",jspath);
-        }
-    }
-}