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 58df9789ff
commit 700b8a5a06
1 changed files with 8 additions and 1 deletions

View File

@ -433,6 +433,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();
@ -442,6 +443,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);
@ -450,7 +452,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 {