fix(测试跟踪): 关联第三方附件报错问题 (#18075)

--bug=1016957,1016945,1016941,1016938 --user=宋昌昌 【测试跟踪】测试用例-关联文件报错 https://www.tapd.cn/55049933/s/1246636

Co-authored-by: song-cc-rock <changchang.song@fit2cloud.com>
This commit is contained in:
MeterSphere Bot 2022-09-20 13:45:17 +08:00 committed by GitHub
parent dfb1651632
commit 15a0da3b73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 8 deletions

View File

@ -253,8 +253,8 @@ public class AttachmentService {
FileAttachmentMetadata fileAttachmentMetadata = new FileAttachmentMetadata();
BeanUtils.copyBean(fileAttachmentMetadata, fileMetadata);
fileAttachmentMetadata.setId(record.getAttachmentId());
fileAttachmentMetadata.setCreator(fileMetadata.getCreateUser());
fileAttachmentMetadata.setFilePath(fileMetadata.getPath());
fileAttachmentMetadata.setCreator(fileMetadata.getCreateUser() == null ? "" : fileMetadata.getCreateUser());
fileAttachmentMetadata.setFilePath(fileMetadata.getPath() == null ? "" : fileMetadata.getPath());
fileAttachmentMetadataBatchMapper.insert(fileAttachmentMetadata);
// 缺陷类型的附件, 关联时需单独同步第三方平台
if (AttachmentType.ISSUE.type().equals(request.getBelongType())) {
@ -296,6 +296,13 @@ public class AttachmentService {
example.createCriteria().andRelationIdEqualTo(request.getBelongId())
.andRelationTypeEqualTo(request.getBelongType())
.andAttachmentIdIn(request.getMetadataRefIds());
List<AttachmentModuleRelation> relations = attachmentModuleRelationMapper.selectByExample(example);
if (CollectionUtils.isNotEmpty(relations)) {
List<String> refIds = relations.stream().map(AttachmentModuleRelation::getFileMetadataRefId).collect(Collectors.toList());
FileAssociationExample associationExample = new FileAssociationExample();
associationExample.createCriteria().andIdIn(refIds);
fileAssociationMapper.deleteByExample(associationExample);
}
FileAttachmentMetadataExample exampleAttachment = new FileAttachmentMetadataExample();
exampleAttachment.createCriteria().andIdIn(request.getMetadataRefIds());
fileAttachmentMetadataMapper.deleteByExample(exampleAttachment);

View File

@ -139,6 +139,7 @@ public class IssuesService {
attachmentService.copyAttachment(attachmentRequest);
} else {
final String issueId = issues.getId();
final String platform = issues.getPlatform();
// 新增, 需保存并同步所有待上传的附件
if (CollectionUtils.isNotEmpty(files)) {
files.forEach(file -> {
@ -174,14 +175,14 @@ public class IssuesService {
FileAttachmentMetadata fileAttachmentMetadata = new FileAttachmentMetadata();
BeanUtils.copyBean(fileAttachmentMetadata, fileMetadata);
fileAttachmentMetadata.setId(relation.getAttachmentId());
fileAttachmentMetadata.setCreator(fileMetadata.getCreateUser());
fileAttachmentMetadata.setFilePath(fileMetadata.getPath());
fileAttachmentMetadata.setCreator(fileMetadata.getCreateUser() == null ? "" : fileMetadata.getCreateUser());
fileAttachmentMetadata.setFilePath(fileMetadata.getPath() == null ? "" : fileMetadata.getPath());
fileAttachmentMetadataBatchMapper.insert(fileAttachmentMetadata);
// 下载文件管理文件, 同步到第三方平台
File refFile = attachmentService.downloadMetadataFile(filemetaId, fileMetadata.getName());
IssuesRequest addIssueRequest = new IssuesRequest();
addIssueRequest.setWorkspaceId(SessionUtils.getCurrentWorkspaceId());
Objects.requireNonNull(IssueFactory.createPlatform(issuesRequest.getPlatform(), addIssueRequest))
Objects.requireNonNull(IssueFactory.createPlatform(platform, addIssueRequest))
.syncIssuesAttachment(issuesRequest, refFile, AttachmentSyncType.UPLOAD);
FileUtils.deleteFile(FileUtils.ATTACHMENT_TMP_DIR + File.separator + fileMetadata.getName());
});

View File

@ -2130,8 +2130,8 @@ public class TestCaseService {
FileAttachmentMetadata fileAttachmentMetadata = new FileAttachmentMetadata();
BeanUtils.copyBean(fileAttachmentMetadata, fileMetadata);
fileAttachmentMetadata.setId(record.getAttachmentId());
fileAttachmentMetadata.setCreator(fileMetadata.getCreateUser());
fileAttachmentMetadata.setFilePath(fileMetadata.getPath());
fileAttachmentMetadata.setCreator(fileMetadata.getCreateUser() == null ? "" : fileMetadata.getCreateUser());
fileAttachmentMetadata.setFilePath(fileMetadata.getPath() == null ? "" : fileMetadata.getPath());
fileAttachmentMetadataBatchMapper.insert(fileAttachmentMetadata);
});
sqlSession.flushStatements();

View File

@ -840,7 +840,7 @@ export default {
}
}
if (!repeatRecord) {
if (this.type === 'add') {
if (this.type === 'add' || this.isCaseEdit) {
//
rows.forEach(row => {
this.relateFiles.push(row.id);