mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-03 04:28:51 +08:00
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:
parent
dfb1651632
commit
15a0da3b73
@ -253,8 +253,8 @@ public class AttachmentService {
|
|||||||
FileAttachmentMetadata fileAttachmentMetadata = new FileAttachmentMetadata();
|
FileAttachmentMetadata fileAttachmentMetadata = new FileAttachmentMetadata();
|
||||||
BeanUtils.copyBean(fileAttachmentMetadata, fileMetadata);
|
BeanUtils.copyBean(fileAttachmentMetadata, fileMetadata);
|
||||||
fileAttachmentMetadata.setId(record.getAttachmentId());
|
fileAttachmentMetadata.setId(record.getAttachmentId());
|
||||||
fileAttachmentMetadata.setCreator(fileMetadata.getCreateUser());
|
fileAttachmentMetadata.setCreator(fileMetadata.getCreateUser() == null ? "" : fileMetadata.getCreateUser());
|
||||||
fileAttachmentMetadata.setFilePath(fileMetadata.getPath());
|
fileAttachmentMetadata.setFilePath(fileMetadata.getPath() == null ? "" : fileMetadata.getPath());
|
||||||
fileAttachmentMetadataBatchMapper.insert(fileAttachmentMetadata);
|
fileAttachmentMetadataBatchMapper.insert(fileAttachmentMetadata);
|
||||||
// 缺陷类型的附件, 关联时需单独同步第三方平台
|
// 缺陷类型的附件, 关联时需单独同步第三方平台
|
||||||
if (AttachmentType.ISSUE.type().equals(request.getBelongType())) {
|
if (AttachmentType.ISSUE.type().equals(request.getBelongType())) {
|
||||||
@ -296,6 +296,13 @@ public class AttachmentService {
|
|||||||
example.createCriteria().andRelationIdEqualTo(request.getBelongId())
|
example.createCriteria().andRelationIdEqualTo(request.getBelongId())
|
||||||
.andRelationTypeEqualTo(request.getBelongType())
|
.andRelationTypeEqualTo(request.getBelongType())
|
||||||
.andAttachmentIdIn(request.getMetadataRefIds());
|
.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();
|
FileAttachmentMetadataExample exampleAttachment = new FileAttachmentMetadataExample();
|
||||||
exampleAttachment.createCriteria().andIdIn(request.getMetadataRefIds());
|
exampleAttachment.createCriteria().andIdIn(request.getMetadataRefIds());
|
||||||
fileAttachmentMetadataMapper.deleteByExample(exampleAttachment);
|
fileAttachmentMetadataMapper.deleteByExample(exampleAttachment);
|
||||||
|
@ -139,6 +139,7 @@ public class IssuesService {
|
|||||||
attachmentService.copyAttachment(attachmentRequest);
|
attachmentService.copyAttachment(attachmentRequest);
|
||||||
} else {
|
} else {
|
||||||
final String issueId = issues.getId();
|
final String issueId = issues.getId();
|
||||||
|
final String platform = issues.getPlatform();
|
||||||
// 新增, 需保存并同步所有待上传的附件
|
// 新增, 需保存并同步所有待上传的附件
|
||||||
if (CollectionUtils.isNotEmpty(files)) {
|
if (CollectionUtils.isNotEmpty(files)) {
|
||||||
files.forEach(file -> {
|
files.forEach(file -> {
|
||||||
@ -174,14 +175,14 @@ public class IssuesService {
|
|||||||
FileAttachmentMetadata fileAttachmentMetadata = new FileAttachmentMetadata();
|
FileAttachmentMetadata fileAttachmentMetadata = new FileAttachmentMetadata();
|
||||||
BeanUtils.copyBean(fileAttachmentMetadata, fileMetadata);
|
BeanUtils.copyBean(fileAttachmentMetadata, fileMetadata);
|
||||||
fileAttachmentMetadata.setId(relation.getAttachmentId());
|
fileAttachmentMetadata.setId(relation.getAttachmentId());
|
||||||
fileAttachmentMetadata.setCreator(fileMetadata.getCreateUser());
|
fileAttachmentMetadata.setCreator(fileMetadata.getCreateUser() == null ? "" : fileMetadata.getCreateUser());
|
||||||
fileAttachmentMetadata.setFilePath(fileMetadata.getPath());
|
fileAttachmentMetadata.setFilePath(fileMetadata.getPath() == null ? "" : fileMetadata.getPath());
|
||||||
fileAttachmentMetadataBatchMapper.insert(fileAttachmentMetadata);
|
fileAttachmentMetadataBatchMapper.insert(fileAttachmentMetadata);
|
||||||
// 下载文件管理文件, 同步到第三方平台
|
// 下载文件管理文件, 同步到第三方平台
|
||||||
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());
|
||||||
Objects.requireNonNull(IssueFactory.createPlatform(issuesRequest.getPlatform(), 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());
|
||||||
});
|
});
|
||||||
|
@ -2130,8 +2130,8 @@ public class TestCaseService {
|
|||||||
FileAttachmentMetadata fileAttachmentMetadata = new FileAttachmentMetadata();
|
FileAttachmentMetadata fileAttachmentMetadata = new FileAttachmentMetadata();
|
||||||
BeanUtils.copyBean(fileAttachmentMetadata, fileMetadata);
|
BeanUtils.copyBean(fileAttachmentMetadata, fileMetadata);
|
||||||
fileAttachmentMetadata.setId(record.getAttachmentId());
|
fileAttachmentMetadata.setId(record.getAttachmentId());
|
||||||
fileAttachmentMetadata.setCreator(fileMetadata.getCreateUser());
|
fileAttachmentMetadata.setCreator(fileMetadata.getCreateUser() == null ? "" : fileMetadata.getCreateUser());
|
||||||
fileAttachmentMetadata.setFilePath(fileMetadata.getPath());
|
fileAttachmentMetadata.setFilePath(fileMetadata.getPath() == null ? "" : fileMetadata.getPath());
|
||||||
fileAttachmentMetadataBatchMapper.insert(fileAttachmentMetadata);
|
fileAttachmentMetadataBatchMapper.insert(fileAttachmentMetadata);
|
||||||
});
|
});
|
||||||
sqlSession.flushStatements();
|
sqlSession.flushStatements();
|
||||||
|
@ -840,7 +840,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!repeatRecord) {
|
if (!repeatRecord) {
|
||||||
if (this.type === 'add') {
|
if (this.type === 'add' || this.isCaseEdit) {
|
||||||
// 新增
|
// 新增
|
||||||
rows.forEach(row => {
|
rows.forEach(row => {
|
||||||
this.relateFiles.push(row.id);
|
this.relateFiles.push(row.id);
|
||||||
|
Loading…
Reference in New Issue
Block a user