Explorar o código

报销类单据联查回单
1、批量联查回单,增加jpg格式的回单处理

wanghaiwu hai 2 semanas
pai
achega
74db1f472f

+ 37 - 12
code/jyyy/nckd-jimin-jyyy-fi/src/main/java/nckd/jimin/jyyy/fi/plugin/form/FeiBillFileViewMultListPlugin.java

@@ -109,24 +109,49 @@ public class FeiBillFileViewMultListPlugin  extends AbstractListPlugin implement
             DynamicObject elecreceiptDyn = BusinessDataServiceHelper.loadSingle("bei_elecreceipt", new QFilter[]{qf2});
 
             if(EmptyUtil.isEmpty(elecreceiptDyn)) {
-                return null;
+                continue;
             }
-            Map<String, Object> attachmentMap = getAttachmentFile(elecreceiptDyn.getLong("id"));
 
-            if(attachmentMap == null) {
-                return null;
-            }
+            Long elecreceiptId = elecreceiptDyn.getLong("id");
 
-            Object relativeUrl = attachmentMap.get("relativeUrl");
-            if (relativeUrl == null) {
+            //创建一条基础资料数据-附件字段
+            //获取单据信息,并查询单据中的附件字段
+            QFilter qf = new QFilter("id", QCP.equals, elecreceiptId);
+            DynamicObject file = BusinessDataServiceHelper.loadSingle("bei_elecreceipt", "attachmentpanel", new QFilter[]{qf});
+
+            if(file == null){
                 continue;
             }
-            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-            String path = FilePathUtil.dealPath(relativeUrl.toString(), "attach");
-            InputStream inputStream = FileServiceFactory.getAttachmentFileService().getInputStream(path);
 
-            byte[] bytesAtt = getBytes(inputStream,outputStream);
-            resList.add(bytesAtt);
+            //获取单据中附件面板信息
+            List<Map<String, Object>> atts = AttachmentServiceHelper.getAttachments("bei_elecreceipt", file.getPkValue().toString(), "attachmentpanel");
+            //遍历文件
+            for (Map<String, Object>  attachmentMap: atts) {
+                if(attachmentMap.get("type") != null
+                        && ("pdf".equals(attachmentMap.get("type").toString()) || "jpg".equals(attachmentMap.get("type").toString()))) {
+
+                    if(attachmentMap == null) {
+                        continue;
+                    }
+
+                    Object relativeUrl = attachmentMap.get("relativeUrl");
+                    if (relativeUrl == null) {
+                        continue;
+                    }
+
+                    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+                    String path = FilePathUtil.dealPath(relativeUrl.toString(), "attach");
+                    InputStream inputStream = FileServiceFactory.getAttachmentFileService().getInputStream(path);
+
+                    if("jpg".equals(attachmentMap.get("type").toString())){
+                        ReceiptPrintHelper.imageConvertPdf(path, resList, inputStream);
+                        continue;
+                    }
+
+                    byte[] bytesAtt = getBytes(inputStream,outputStream);
+                    resList.add(bytesAtt);
+                }
+            }
         }
 
         if(resList.size() == 0){