fix(测试跟踪): 同步TAPD缺陷失败

This commit is contained in:
chenjianxing 2022-12-20 16:11:23 +08:00 committed by jianxing
parent 7dbef8d2a6
commit aa8c7db3fc
1 changed files with 22 additions and 16 deletions

View File

@ -1081,21 +1081,25 @@ public class IssuesService {
private void deleteSyncAttachment(AttachmentModuleRelationMapper batchAttachmentModuleRelationMapper,
Set<String> jiraAttachmentSet,
List<FileAttachmentMetadata> allMsAttachments) {
// 删除Jira中不存在的附件
if (CollectionUtils.isNotEmpty(allMsAttachments)) {
List<FileAttachmentMetadata> deleteMsAttachments = allMsAttachments.stream()
.filter(msAttachment -> !jiraAttachmentSet.contains(msAttachment.getName()))
.collect(Collectors.toList());
deleteMsAttachments.forEach(fileAttachmentMetadata -> {
List<String> ids = List.of(fileAttachmentMetadata.getId());
AttachmentModuleRelationExample example = new AttachmentModuleRelationExample();
example.createCriteria().andAttachmentIdIn(ids).andRelationTypeEqualTo(AttachmentType.ISSUE.type());
// 删除MS附件及关联数据
attachmentService.deleteAttachmentByIds(ids);
attachmentService.deleteFileAttachmentByIds(ids);
batchAttachmentModuleRelationMapper.deleteByExample(example);
});
}
try {
// 删除Jira中不存在的附件
if (CollectionUtils.isNotEmpty(allMsAttachments)) {
List<FileAttachmentMetadata> deleteMsAttachments = allMsAttachments.stream()
.filter(msAttachment -> !jiraAttachmentSet.contains(msAttachment.getName()))
.collect(Collectors.toList());
deleteMsAttachments.forEach(fileAttachmentMetadata -> {
List<String> ids = List.of(fileAttachmentMetadata.getId());
AttachmentModuleRelationExample example = new AttachmentModuleRelationExample();
example.createCriteria().andAttachmentIdIn(ids).andRelationTypeEqualTo(AttachmentType.ISSUE.type());
// 删除MS附件及关联数据
attachmentService.deleteAttachmentByIds(ids);
attachmentService.deleteFileAttachmentByIds(ids);
batchAttachmentModuleRelationMapper.deleteByExample(example);
});
}
} catch (Exception e) {
LogUtil.error(e);
}
}
private void saveAttachmentModuleRelation(Platform platform, String issueId,
@ -1871,7 +1875,9 @@ public class IssuesService {
xpackIssueService.syncThirdPartyIssues(project, syncRequest);
syncAllPluginIssueAttachment(project, syncRequest);
if (platformPluginService.isPluginPlatform(project.getPlatform())) {
syncAllPluginIssueAttachment(project, syncRequest);
}
} catch (Exception e) {
LogUtil.error(e);
MSException.throwException(e);