diff --git a/apistructs/issue.go b/apistructs/issue.go index 07307d36078..e24ae474fbc 100644 --- a/apistructs/issue.go +++ b/apistructs/issue.go @@ -88,12 +88,17 @@ func (s *Issue) SetRelatedIssueIDs(ids string) error { return nil } idStrs := strings.Split(ids, ",") + dp := map[uint64]bool{} relatedIssueIDs := make([]uint64, 0) for _, id := range idStrs { issueID, err := strconv.Atoi(id) if err != nil { return err } + if dp[uint64(issueID)] { + continue + } + dp[uint64(issueID)] = true relatedIssueIDs = append(relatedIssueIDs, uint64(issueID)) } s.relatedIssueIDs = relatedIssueIDs diff --git a/modules/dop/services/issue/convert.go b/modules/dop/services/issue/convert.go index 8c154ccdc67..d8826f6074c 100644 --- a/modules/dop/services/issue/convert.go +++ b/modules/dop/services/issue/convert.go @@ -361,6 +361,19 @@ func (svc *Issue) decodeFromExcelFile(req apistructs.IssueImportExcelRequest, r allInstance []apistructs.IssuePropertyRelationCreateRequest ) sheets, err := excel.Decode(r) + // filter empty row + sheetLst := make([][][]string, 0) + for _, rows := range sheets { + rowLst := make([][]string, 0) + for _, row := range rows { + if strings.Join(row, "") == "" { + continue + } + rowLst = append(rowLst, row) + } + sheetLst = append(sheetLst, rowLst) + } + sheets = sheetLst if err != nil { return nil, nil, nil, nil, nil, 0, fmt.Errorf("failed to decode excel, err: %v", err) } diff --git a/modules/dop/services/issue/import.go b/modules/dop/services/issue/import.go index bec5b39cc92..6195ef6778b 100644 --- a/modules/dop/services/issue/import.go +++ b/modules/dop/services/issue/import.go @@ -172,6 +172,18 @@ func (svc *Issue) storeExcel2DB(request apistructs.IssueImportExcelRequest, issu falseReason = append(falseReason, "创建任务失败, err:"+err.Error()) continue } + for _, issueRelated := range req.GetRelatedIssueIDs() { + relatedIssue, err := svc.db.GetIssue(int64(issueRelated)) + if err != nil { + continue + } + if relatedIssue.ProjectID == request.ProjectID { + _ = svc.db.CreateIssueRelations(&dao.IssueRelation{ + IssueID: issueRelated, + RelatedIssue: create.ID, + }) + } + } // 添加标签关联关系 labels, err := svc.bdl.ListLabelByNameAndProjectID(req.ProjectID, req.Labels) if err != nil {