fix(测试跟踪): MS附件同步至Azure问题
--bug=1017812 --user=宋昌昌 【接口测试】github#18391,Azure Devops 平台创建缺陷,上传附件未同步上传到缺陷平台里 https://www.tapd.cn/55049933/s/1284499
This commit is contained in:
parent
58a4b55e2f
commit
46614a75d3
|
@ -100,6 +100,7 @@ public class AttachmentService {
|
||||||
File uploadFile = new File(fileAttachmentMetadata.getFilePath() + "/" + fileAttachmentMetadata.getName());
|
File uploadFile = new File(fileAttachmentMetadata.getFilePath() + "/" + fileAttachmentMetadata.getName());
|
||||||
IssuesRequest issuesRequest = new IssuesRequest();
|
IssuesRequest issuesRequest = new IssuesRequest();
|
||||||
issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||||
|
issuesRequest.setProjectId(SessionUtils.getCurrentProjectId());
|
||||||
Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest))
|
Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest))
|
||||||
.syncIssuesAttachment(updateRequest, uploadFile, AttachmentSyncType.UPLOAD);
|
.syncIssuesAttachment(updateRequest, uploadFile, AttachmentSyncType.UPLOAD);
|
||||||
}
|
}
|
||||||
|
@ -120,6 +121,7 @@ public class AttachmentService {
|
||||||
File deleteFile = new File(fileAttachmentMetadata.getFilePath() + "/" + fileAttachmentMetadata.getName());
|
File deleteFile = new File(fileAttachmentMetadata.getFilePath() + "/" + fileAttachmentMetadata.getName());
|
||||||
IssuesRequest issuesRequest = new IssuesRequest();
|
IssuesRequest issuesRequest = new IssuesRequest();
|
||||||
issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||||
|
issuesRequest.setProjectId(SessionUtils.getCurrentProjectId());
|
||||||
Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest))
|
Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest))
|
||||||
.syncIssuesAttachment(updateRequest, deleteFile, AttachmentSyncType.DELETE);
|
.syncIssuesAttachment(updateRequest, deleteFile, AttachmentSyncType.DELETE);
|
||||||
}
|
}
|
||||||
|
@ -178,6 +180,7 @@ public class AttachmentService {
|
||||||
File refFile = downloadMetadataFile(metadataRefId, fileMetadata.getName());
|
File refFile = downloadMetadataFile(metadataRefId, fileMetadata.getName());
|
||||||
IssuesRequest issuesRequest = new IssuesRequest();
|
IssuesRequest issuesRequest = new IssuesRequest();
|
||||||
issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||||
|
issuesRequest.setProjectId(SessionUtils.getCurrentProjectId());
|
||||||
Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest))
|
Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest))
|
||||||
.syncIssuesAttachment(updateRequest, refFile, AttachmentSyncType.UPLOAD);
|
.syncIssuesAttachment(updateRequest, refFile, AttachmentSyncType.UPLOAD);
|
||||||
FileUtils.deleteFile(FileUtils.ATTACHMENT_TMP_DIR + File.separator + fileMetadata.getName());
|
FileUtils.deleteFile(FileUtils.ATTACHMENT_TMP_DIR + File.separator + fileMetadata.getName());
|
||||||
|
@ -275,6 +278,7 @@ public class AttachmentService {
|
||||||
File refFile = downloadMetadataFile(metadataRefId, fileMetadata.getName());
|
File refFile = downloadMetadataFile(metadataRefId, fileMetadata.getName());
|
||||||
IssuesRequest issuesRequest = new IssuesRequest();
|
IssuesRequest issuesRequest = new IssuesRequest();
|
||||||
issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||||
|
issuesRequest.setProjectId(SessionUtils.getCurrentProjectId());
|
||||||
Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest))
|
Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest))
|
||||||
.syncIssuesAttachment(updateRequest, refFile, AttachmentSyncType.UPLOAD);
|
.syncIssuesAttachment(updateRequest, refFile, AttachmentSyncType.UPLOAD);
|
||||||
FileUtils.deleteFile(FileUtils.ATTACHMENT_TMP_DIR + File.separator + fileMetadata.getName());
|
FileUtils.deleteFile(FileUtils.ATTACHMENT_TMP_DIR + File.separator + fileMetadata.getName());
|
||||||
|
@ -299,6 +303,7 @@ public class AttachmentService {
|
||||||
File deleteFile = new File(FileUtils.ATTACHMENT_TMP_DIR + File.separator + fileAttachmentMetadata.getName());
|
File deleteFile = new File(FileUtils.ATTACHMENT_TMP_DIR + File.separator + fileAttachmentMetadata.getName());
|
||||||
IssuesRequest issuesRequest = new IssuesRequest();
|
IssuesRequest issuesRequest = new IssuesRequest();
|
||||||
issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
issuesRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||||
|
issuesRequest.setProjectId(SessionUtils.getCurrentProjectId());
|
||||||
Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest))
|
Objects.requireNonNull(IssueFactory.createPlatform(issues.getPlatform(), issuesRequest))
|
||||||
.syncIssuesAttachment(updateRequest, deleteFile, AttachmentSyncType.DELETE);
|
.syncIssuesAttachment(updateRequest, deleteFile, AttachmentSyncType.DELETE);
|
||||||
});
|
});
|
||||||
|
@ -326,7 +331,7 @@ public class AttachmentService {
|
||||||
List<AttachmentModuleRelation> attachmentModuleRelations = attachmentModuleRelationMapper.selectByExample(example);
|
List<AttachmentModuleRelation> attachmentModuleRelations = attachmentModuleRelationMapper.selectByExample(example);
|
||||||
List<String> attachmentIds = attachmentModuleRelations.stream().map(AttachmentModuleRelation::getAttachmentId)
|
List<String> attachmentIds = attachmentModuleRelations.stream().map(AttachmentModuleRelation::getAttachmentId)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
return attachmentIds;
|
return attachmentIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRefIdByAttachmentId(String attachmentId) {
|
public String getRefIdByAttachmentId(String attachmentId) {
|
||||||
|
|
|
@ -143,12 +143,21 @@ public class IssuesService {
|
||||||
customFieldIssuesService.addFields(issuesRequest.getId(), issuesRequest.getAddFields());
|
customFieldIssuesService.addFields(issuesRequest.getId(), issuesRequest.getAddFields());
|
||||||
customFieldIssuesService.editFields(issuesRequest.getId(), issuesRequest.getEditFields());
|
customFieldIssuesService.editFields(issuesRequest.getId(), issuesRequest.getEditFields());
|
||||||
if (StringUtils.isNotEmpty(issuesRequest.getCopyIssueId())) {
|
if (StringUtils.isNotEmpty(issuesRequest.getCopyIssueId())) {
|
||||||
|
final String platformId = issues.getPlatformId();
|
||||||
// 复制新增, 同步缺陷的MS附件
|
// 复制新增, 同步缺陷的MS附件
|
||||||
AttachmentRequest attachmentRequest = new AttachmentRequest();
|
AttachmentRequest attachmentRequest = new AttachmentRequest();
|
||||||
attachmentRequest.setCopyBelongId(issuesRequest.getCopyIssueId());
|
attachmentRequest.setCopyBelongId(issuesRequest.getCopyIssueId());
|
||||||
attachmentRequest.setBelongId(issues.getId());
|
attachmentRequest.setBelongId(issues.getId());
|
||||||
attachmentRequest.setBelongType(AttachmentType.ISSUE.type());
|
attachmentRequest.setBelongType(AttachmentType.ISSUE.type());
|
||||||
attachmentService.copyAttachment(attachmentRequest);
|
attachmentService.copyAttachment(attachmentRequest);
|
||||||
|
|
||||||
|
// MS附件同步到其他平台, Jira, Zentao已经在创建缺陷时处理, AzureDevops单独处理
|
||||||
|
if (StringUtils.equals(issuesRequest.getPlatform(), IssuesManagePlatform.AzureDevops.toString())) {
|
||||||
|
AttachmentRequest request = new AttachmentRequest();
|
||||||
|
request.setBelongId(issuesRequest.getCopyIssueId());
|
||||||
|
request.setBelongType(AttachmentType.ISSUE.type());
|
||||||
|
uploadAzureCopyAttachment(request, issuesRequest.getPlatform(), platformId);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final String issueId = issues.getId();
|
final String issueId = issues.getId();
|
||||||
final String platform = issues.getPlatform();
|
final String platform = issues.getPlatform();
|
||||||
|
@ -194,6 +203,7 @@ public class IssuesService {
|
||||||
File refFile = attachmentService.downloadMetadataFile(filemetaId, fileMetadata.getName());
|
File refFile = attachmentService.downloadMetadataFile(filemetaId, fileMetadata.getName());
|
||||||
IssuesRequest addIssueRequest = new IssuesRequest();
|
IssuesRequest addIssueRequest = new IssuesRequest();
|
||||||
addIssueRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
addIssueRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||||
|
addIssueRequest.setProjectId(SessionUtils.getCurrentProjectId());
|
||||||
Objects.requireNonNull(IssueFactory.createPlatform(platform, addIssueRequest))
|
Objects.requireNonNull(IssueFactory.createPlatform(platform, addIssueRequest))
|
||||||
.syncIssuesAttachment(issuesRequest, refFile, AttachmentSyncType.UPLOAD);
|
.syncIssuesAttachment(issuesRequest, refFile, AttachmentSyncType.UPLOAD);
|
||||||
FileUtils.deleteFile(FileUtils.ATTACHMENT_TMP_DIR + File.separator + fileMetadata.getName());
|
FileUtils.deleteFile(FileUtils.ATTACHMENT_TMP_DIR + File.separator + fileMetadata.getName());
|
||||||
|
@ -1107,4 +1117,21 @@ public class IssuesService {
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
return filterIssues;
|
return filterIssues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void uploadAzureCopyAttachment(AttachmentRequest attachmentRequest, String platform, String platformId) {
|
||||||
|
List<String> attachmentIds = attachmentService.getAttachmentIdsByParam(attachmentRequest);
|
||||||
|
if (CollectionUtils.isNotEmpty(attachmentIds)) {
|
||||||
|
attachmentIds.forEach(attachmentId -> {
|
||||||
|
FileAttachmentMetadata fileAttachmentMetadata = attachmentService.getFileAttachmentMetadataByFileId(attachmentId);
|
||||||
|
File file = new File(fileAttachmentMetadata.getFilePath() + "/" + fileAttachmentMetadata.getName());
|
||||||
|
IssuesRequest createRequest = new IssuesRequest();
|
||||||
|
createRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
|
||||||
|
createRequest.setProjectId(SessionUtils.getCurrentProjectId());
|
||||||
|
IssuesPlatform azurePlatform = Objects.requireNonNull(IssueFactory.createPlatform(platform, createRequest));
|
||||||
|
IssuesUpdateRequest uploadRequest = new IssuesUpdateRequest();
|
||||||
|
uploadRequest.setPlatformId(platformId);
|
||||||
|
azurePlatform.syncIssuesAttachment(uploadRequest, file, AttachmentSyncType.UPLOAD);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue