fix(测试跟踪): 缺陷同步平台附件有误

--bug=1023082 --user=陈建星 【测试跟踪】缺陷管理,ms创建带附件的缺陷在禅道编辑后再同步回ms,附件没了 https://www.tapd.cn/55049933/s/1340797
This commit is contained in:
chenjianxing 2023-02-22 17:36:54 +08:00 committed by jianxing
parent c8813ca967
commit 23788673a9
1 changed files with 5 additions and 5 deletions

View File

@ -1018,7 +1018,7 @@ public class IssuesService {
if (MapUtils.isNotEmpty(attachmentMap)) {
for (String issueId : attachmentMap.keySet()) {
// 查询我们平台的附件
Set<String> jiraAttachmentSet = new HashSet<>();
Set<String> platformAttachmentSet = new HashSet<>();
List<FileAttachmentMetadata> allMsAttachments = getIssueFileAttachmentMetadata(issueId);
Set<String> attachmentsNameSet = allMsAttachments.stream()
.map(FileAttachmentMetadata::getName)
@ -1031,14 +1031,14 @@ public class IssuesService {
for (PlatformAttachment syncAttachment : syncAttachments) {
String fileName = syncAttachment.getFileName();
String fileKey = syncAttachment.getFileKey();
platformAttachmentSet.add(fileName);
if (!attachmentsNameSet.contains(fileName)) {
jiraAttachmentSet.add(fileName);
saveAttachmentModuleRelation(platform, issueId, fileName, fileKey, batchAttachmentModuleRelationMapper);
}
}
// 删除Jira中不存在的附件
deleteSyncAttachment(batchAttachmentModuleRelationMapper, jiraAttachmentSet, allMsAttachments);
deleteSyncAttachment(batchAttachmentModuleRelationMapper, platformAttachmentSet, allMsAttachments);
}
}
}
@ -1081,13 +1081,13 @@ public class IssuesService {
}
private void deleteSyncAttachment(AttachmentModuleRelationMapper batchAttachmentModuleRelationMapper,
Set<String> jiraAttachmentSet,
Set<String> platformAttachmentSet,
List<FileAttachmentMetadata> allMsAttachments) {
try {
// 删除Jira中不存在的附件
if (CollectionUtils.isNotEmpty(allMsAttachments)) {
List<FileAttachmentMetadata> deleteMsAttachments = allMsAttachments.stream()
.filter(msAttachment -> !jiraAttachmentSet.contains(msAttachment.getName()))
.filter(msAttachment -> !platformAttachmentSet.contains(msAttachment.getName()))
.collect(Collectors.toList());
deleteMsAttachments.forEach(fileAttachmentMetadata -> {
List<String> ids = List.of(fileAttachmentMetadata.getId());