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