소스 검색

付款单联查回单修改

turborao 1 주 전
부모
커밋
81290a5383
1개의 변경된 파일69개의 추가작업 그리고 12개의 파일을 삭제
  1. 69 12
      code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/plugin/form/PayBillSearchListPlugin.java

+ 69 - 12
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/plugin/form/PayBillSearchListPlugin.java

@@ -11,14 +11,19 @@ import kd.bos.list.BillList;
 import kd.bos.list.plugin.AbstractListPlugin;
 import kd.bos.logging.Log;
 import kd.bos.logging.LogFactory;
+import kd.bos.orm.ORM;
 import kd.bos.orm.query.QCP;
 import kd.bos.orm.query.QFilter;
+import kd.bos.servicehelper.AttachmentServiceHelper;
 import kd.bos.servicehelper.BusinessDataServiceHelper;
+import kd.bos.servicehelper.operation.SaveServiceHelper;
+import kd.bos.servicehelper.user.UserServiceHelper;
+import kd.bos.url.UrlService;
+import kd.bos.util.StringUtils;
 import kd.fi.cas.util.EmptyUtil;
 import kd.sdk.plugin.Plugin;
 
-import java.util.Arrays;
-import java.util.List;
+import java.util.*;
 
 /**
  * 改造付款单列表查询 查询银行回单、交易明细
@@ -59,16 +64,12 @@ public class PayBillSearchListPlugin extends AbstractListPlugin implements Plugi
             }
         }
         if (operationResult != null && operationResult.isSuccess() && "elecreceipt".equals(operateKey)) {
-            logger.info("-- 付款单联查电子回单开始 --");
+            logger.info("-- 付款单联查电子回单附件开始 --");
             if(EmptyUtil.isNoEmpty(payBillIdList)){
                 String billId = payBillIdList.get(0).toString();
-                Long  elebillId = getElecreceiptID(billId);
-                String formId= "bei_elecreceipt";
-                showParameter.setFormId(formId);
-                showParameter.setPkId(elebillId);
-                showParameter.getOpenStyle().setShowType(ShowType.MainNewTabPage);
-                showParameter.setStatus(OperationStatus.VIEW);
-                this.getView().showForm(showParameter);
+                Map<String,Object>  fileMap = getElecreceiptByFile(billId);
+                if (fileMap == null) return ;
+                this.getView().previewAttachment(fileMap);
             }
         }
     }
@@ -90,16 +91,72 @@ public class PayBillSearchListPlugin extends AbstractListPlugin implements Plugi
      * @param payBillId
      * @return
      */
-    public Long getElecreceiptID(String payBillId){
+    public Map<String,Object> getElecreceiptByFile(String payBillId){
         Long billId = Long.parseLong(payBillId);
         QFilter qf = new QFilter("id", QCP.equals, billId);
         DynamicObject billDyn = BusinessDataServiceHelper.loadSingle("cas_paybill", new QFilter[]{qf});
         String transdetailId = billDyn.getString("detailseqid");
+        if(StringUtils.isEmpty(transdetailId)) return null;
         QFilter qf1 = new QFilter("billno", QCP.equals, transdetailId);
         DynamicObject transdetailDyn = BusinessDataServiceHelper.loadSingle("bei_transdetail", new QFilter[]{qf1});
+        if(EmptyUtil.isEmpty(transdetailDyn)) return null;
         String elecreceiptNo = transdetailDyn.getString("receiptno");
         QFilter qf2 = new QFilter("receiptno", QCP.equals, elecreceiptNo);
         DynamicObject elecreceiptDyn = BusinessDataServiceHelper.loadSingle("bei_elecreceipt", new QFilter[]{qf2});
-        return elecreceiptDyn.getLong("id");
+
+        if(EmptyUtil.isEmpty(elecreceiptDyn)) return null;
+        Map<String, Object> attachmentMap = getAttachmentFile(elecreceiptDyn.getLong("id"));
+
+        if(attachmentMap == null) return null;
+        String filepath = elecreceiptDyn.getString("filepath");
+        /**
+         * 获取持久化附件的预览url
+         * @param path 持久化附件的downloadUrl相对路径
+         * @return 持久化附件的预览url
+         *  入参示例: /tenant_devcore_dev/1402323749146986496/202305/1683569603244172288/5b3c272f9d5a42fdbecddf2d84bcdd56/Wo rd文档.docx
+         */
+        String previewUrl = UrlService.getAttachmentPreviewUrl(filepath);
+        String downloadUrl = UrlService.getAttachmentDownloadUrl(filepath);
+        previewUrl = previewUrl.replace("http://127.0.0.1:8881","https://d-kd.jeyoupharma.com:8022");
+        downloadUrl = downloadUrl.replace("http://127.0.0.1:8881","https://d-kd.jeyoupharma.com:8022");
+
+        Map<String,Object> attMap = new HashMap<>();
+        attMap.put("previewurl",previewUrl);
+        attMap.put("url",downloadUrl);
+        attMap.put("uid",attachmentMap.get("uid"));
+        attMap.put("type", attachmentMap.get("type"));
+        attMap.put("name",attachmentMap.get("name"));
+        attMap.put("size", attachmentMap.get("size"));
+        attMap.put("status","success");
+        attMap.put("visible","1000");
+
+//        attMap.put("downloadUrl", previewUrl);
+//        attMap.put("fileExt", attachmentMap.get("type"));
+//        attMap.put("fileId", attachmentMap.get("uid"));
+//        attMap.put("fileName", attachmentMap.get("name"));
+//        attMap.put("fileSize", attachmentMap.get("size"));
+//        attMap.put("fileTime", attachmentMap.get("createdate"));
+//        attMap.put("filesource", "1");
+//        attMap.put("previewType", "0");
+//        attMap.put("previewUrl", previewUrl);
+//        attMap.put("status", "success");
+
+        return attMap;
+    }
+
+
+    public static Map<String, Object>  getAttachmentFile(Long billId) {
+
+        //创建一条基础资料数据-附件字段
+        //获取单据信息,并查询单据中的附件字段
+        QFilter qf = new QFilter("id", QCP.equals, billId);
+        DynamicObject file =BusinessDataServiceHelper.loadSingle("bei_elecreceipt", "attachmentpanel",new QFilter[]{qf});
+        //获取单据中附件面板信息
+        List<Map<String, Object>> atts = AttachmentServiceHelper.getAttachments("bei_elecreceipt", file.getPkValue().toString(), "attachmentpanel");
+        //遍历文件   电子回单只有一条
+        for (Map<String, Object>  att: atts) {
+            return att;
+        }
+        return null;
     }
 }