From 8af14e7336fc54b77bdfc35d056b963f2056dc8e Mon Sep 17 00:00:00 2001 From: yuxueliang0813 <407010292@qq.com> Date: Mon, 24 Mar 2025 16:40:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0OA=E9=99=84=E4=BB=B6=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=EF=BC=8C=E5=85=88=E5=88=A0=E9=99=A4=E5=90=88=E5=90=8C?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E5=B7=B2=E6=9C=89=E9=99=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/java/shkd/utils/AttachmentFileUtil.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/main/java/shkd/utils/AttachmentFileUtil.java b/main/java/shkd/utils/AttachmentFileUtil.java index 44d066b..e069086 100644 --- a/main/java/shkd/utils/AttachmentFileUtil.java +++ b/main/java/shkd/utils/AttachmentFileUtil.java @@ -124,6 +124,14 @@ public class AttachmentFileUtil { * @author yuxueliang */ public static boolean saveDirFile2Attchment(String appId, String entity, Object pk, String dirpath, String attachKey, JSONArray filenames) throws Exception { + //先删除合同对应附件面板中已存在的附件,再从nas上传新的附件 + List> contfiles = AttachmentServiceHelper.getAttachments(entity,pk,attachKey); + if(contfiles != null && !contfiles.isEmpty()){ + for (Map attItem : contfiles){ + logger.info(attachKey+"删除附件:"+attItem.get("name")); + AttachmentServiceHelper.remove(entity,pk,attItem.get("uid")); + } + } logger.info("传入的文件夹路径"+dirpath); List> attachments = new ArrayList<>(1); Map attachItem; @@ -178,7 +186,7 @@ public class AttachmentFileUtil { return true; } - /**将文件服务器上某个目录下的所有文件上传至星瀚对应单据附件上 + /**将文件服务器上某个目录下的所有文件上传至星瀚对应单据附件上-由于file server的限制,此方法不可行,无法读取到对应目录 * @param appId 目标单据所属应用标识 * @param entity 目标单据实体标识 * @param pk 目标数据id @@ -247,6 +255,7 @@ public class AttachmentFileUtil { } /**将星瀚nfs上某个目录下的所有文件关联至星瀚对应单据附件上,不需要文件上传 + * 此方法在明确文件路径情况下可行,但是删除时,也会将对应文件删掉,不建议使用 * @param appId 目标单据所属应用标识 * @param entity 目标单据实体标识 * @param pk 目标数据id