From 3711ab20668b14ace2b181ded0dfd2e8a6814748 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 6 Jun 2022 19:34:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E4=BF=9D=E5=AD=98jira=E7=BC=BA=E9=99=B7=EF=BC=8C=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E9=87=8D=E5=A4=8D=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1013360 --user=陈建星 【测试跟踪】GitHub# 13760 缺陷管理 同步jira 问题 https://www.tapd.cn/55049933/s/1174316 --- .../java/io/metersphere/track/issue/JiraPlatform.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java index 7f3c30e380..4ee493d800 100644 --- a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java @@ -434,6 +434,7 @@ public class JiraPlatform extends AbstractIssuePlatform { JSONObject param = buildUpdateParam(request, getIssueType(project.getIssueConfig()), project.getJiraKey()); jiraClientV2.updateIssue(request.getPlatformId(), JSONObject.toJSONString(param)); + Set attachmentNames = new HashSet<>(); // 更新附件 JiraIssue jiraIssue = jiraClientV2.getIssues(request.getPlatformId()); JSONObject fields = jiraIssue.getFields(); @@ -443,6 +444,7 @@ public class JiraPlatform extends AbstractIssuePlatform { for (int i = 0; i < attachments.size(); i++) { JSONObject attachment = attachments.getJSONObject(i); String filename = attachment.getString("filename"); + attachmentNames.add(filename); if (!request.getDescription().contains(filename)) { String fileId = attachment.getString("id"); jiraClientV2.deleteAttachment(fileId); @@ -451,7 +453,12 @@ public class JiraPlatform extends AbstractIssuePlatform { } // 上传新附件 - imageFiles.forEach(img -> jiraClientV2.uploadAttachment(request.getPlatformId(), img)); + imageFiles.forEach(img -> { + if (!attachmentNames.contains(img.getName())) { + // 旧附件没有才上传新附件 + jiraClientV2.uploadAttachment(request.getPlatformId(), img); + } + }); if (request.getTransitions() != null) { try {