From 173a20d027af32fec06edf3414f2b96a02f24f10 Mon Sep 17 00:00:00 2001 From: yuxueliang0813 <407010292@qq.com> Date: Tue, 25 Mar 2025 14:25:55 +0800 Subject: [PATCH] =?UTF-8?q?OA=E9=99=84=E4=BB=B6=E5=89=94=E9=99=A4png?= =?UTF-8?q?=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/java/shkd/utils/AttachmentFileUtil.java | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/main/java/shkd/utils/AttachmentFileUtil.java b/main/java/shkd/utils/AttachmentFileUtil.java index e069086..126fc13 100644 --- a/main/java/shkd/utils/AttachmentFileUtil.java +++ b/main/java/shkd/utils/AttachmentFileUtil.java @@ -114,6 +114,23 @@ public class AttachmentFileUtil { return true; } + private static boolean isOAPng(String filename){ + //如果附件名称中是png的文件,并且文件名称是long类型的,或者文件名称为空,则返回true + if(DobeDWUtils.isEmpty(filename)){ + return true; + } + int typeindex = filename.lastIndexOf(".png"); + if(-1 == typeindex){ + return false; + } + try { + Long.parseLong(filename.substring(0, typeindex)); // 尝试将字符串转换为long + return true; // 如果没有异常,则转换成功 + } catch (NumberFormatException e) { + return false; // 如果转换失败(例如,超出范围),则返回false + } + } + /**将文件服务器上某个目录下的所有文件上传至星瀚对应单据附件上 * @param appId 目标单据所属应用标识 * @param entity 目标单据实体标识 @@ -147,10 +164,13 @@ public class AttachmentFileUtil { //遍历目标目录,得到所有文件 for (int i = 0; i < filenames.size(); i++) { destFile = filenames.getJSONObject(i); + fileName = destFile.getString("fileName");//文件名称可能涉及字符集转义,需要注意 + if(isOAPng(fileName)){ + continue; + } attachments.clear(); // service = FileServiceFactory.getAttachmentFileService(); // cache = CacheFactory.getCommonCacheFactory().getTempFileCache(); - fileName = destFile.getString("fileName");//文件名称可能涉及字符集转义,需要注意 attachItem = new HashMap<>(); //附件编号 如果不设置,在前台删除某一个文件时,会把所有编号为空的都删掉 attachItem.put("uid", "nas"+System.currentTimeMillis());