From cb2341c4625db72163d7bdf51eb1db70412e3513 Mon Sep 17 00:00:00 2001 From: wanc Date: Thu, 10 Jul 2025 16:45:08 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E5=A2=9E=E5=8A=A0=E8=B4=B9?= =?UTF-8?q?=E7=94=A8=E7=99=BB=E8=AE=B0=E8=AF=86=E5=88=AB=E5=8F=91=E7=A5=A8?= =?UTF-8?q?=E5=90=8E=E4=BF=9D=E5=AD=98=E5=8F=91=E7=A5=A8=E7=99=BB=E8=AE=B0?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E6=8A=8A=E5=8F=91=E7=A5=A8=E5=B8=A6=E5=88=B0?= =?UTF-8?q?=E5=8F=91=E7=A5=A8=E7=99=BB=E8=AE=B0=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dynamic/ReconPayreqNewFormPlugin.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/main/java/shkd/repc/recon/formplugin/dynamic/ReconPayreqNewFormPlugin.java b/main/java/shkd/repc/recon/formplugin/dynamic/ReconPayreqNewFormPlugin.java index 10b5d8f..d658d68 100644 --- a/main/java/shkd/repc/recon/formplugin/dynamic/ReconPayreqNewFormPlugin.java +++ b/main/java/shkd/repc/recon/formplugin/dynamic/ReconPayreqNewFormPlugin.java @@ -13,6 +13,8 @@ import kd.bos.entity.datamodel.ListSelectedRowCollection; import kd.bos.entity.datamodel.events.ChangeData; import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.bos.entity.operate.result.OperationResult; +import kd.bos.fileservice.FileItem; +import kd.bos.fileservice.FileService; import kd.bos.fileservice.FileServiceFactory; import kd.bos.form.*; import kd.bos.form.control.EntryGrid; @@ -44,7 +46,9 @@ import org.agrona.Strings; import shkd.repc.recon.formplugin.ReconPayreqFormPlugin; import shkd.utils.DobeDWUtils; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.InputStream; import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; @@ -439,6 +443,8 @@ public class ReconPayreqNewFormPlugin extends AbstractFormPlugin implements Befo OperationResult operationResult1 = OperationServiceHelper.executeOperate("save", "recon_invoicebill", new DynamicObject[]{recon_invoicebill}, operateOption1); if (!operationResult1.isSuccess()){ logger.error(operationResult1.getMessage()); + } else{ + saveAttachmentToInvoicebill( attachment, operationResult1.getSuccessPkIds().get(0).toString()); } //提交 OperateOption operateOption2 = OperateOption.create(); @@ -558,6 +564,47 @@ public class ReconPayreqNewFormPlugin extends AbstractFormPlugin implements Befo } + + + /**将费用登记发票附件保存至对应发票登记* + * pkid:发票登记ID + * + * **/ + private void saveAttachmentToInvoicebill(Map attachment,String pkid) { + Object attPKId = attachment.get("attPkId"); + AttachmentDto attachmentDto = AttachmentServiceHelper.getAttachmentInfoByAttPk(attPKId); + String resourcePath = attachmentDto.getResourcePath(); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + FileServiceFactory.getAttachmentFileService().download(resourcePath,out,null); + byte[] bytes = out.toByteArray(); + String type = attachment.get("type").toString();//附件类型 + String fileName = attachment.get("name").toString();//附件名称 + InputStream input = new ByteArrayInputStream(bytes); + String uploadPath = "dbjt/" + fileName; + StringBuffer uid = new StringBuffer(); + uid.append("rc-upload-").append(new Date().getTime()).append("-"); + int index = (int) (1 + Math.random() * 10); + String uid1 = uid.toString() + index++; + /****上传****/ + FileService fs = FileServiceFactory.getAttachmentFileService(); + // 构造FileItem + FileItem fi = new FileItem(fileName, uploadPath, input); + String path = fs.upload(fi); + /****绑定****/ + Map uploadFileMap = new HashMap(); + uploadFileMap.put("uid", uid1); + uploadFileMap.put("entityNum", "recon_invoicebill"); + uploadFileMap.put("billPkId", pkid); + uploadFileMap.put("lastModified", new Date().getTime()); + uploadFileMap.put("name", fileName); + uploadFileMap.put("url", path); + uploadFileMap.put("size", bytes.length); + uploadFileMap.put("status", "success"); + List> attachments = new ArrayList<>( ); + attachments.add(uploadFileMap); + AttachmentServiceHelper.upload("recon_invoicebill", pkid, "attachmentpanel", attachments); + } + private void updateAmt(){ DynamicObject dataEntity = this.getModel().getDataEntity(); DynamicObjectCollection invoiceentry = dataEntity.getDynamicObjectCollection("invoiceentry");