fix(测试跟踪): 保存jira缺陷,图片重复提交

--bug=1013360 --user=陈建星 【测试跟踪】GitHub# 13760  缺陷管理 同步jira 问题 https://www.tapd.cn/55049933/s/1174316
This commit is contained in:
chenjianxing 2022-06-06 19:34:01 +08:00 committed by jianxing
parent f0a690772c
commit 3711ab2066
1 changed files with 8 additions and 1 deletions

View File

@ -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<String> 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 {