Browse Source

已推送的报告不更新发布时间

kobe6258 7 months ago
parent
commit
126e672b54
2 changed files with 10 additions and 21 deletions
  1. 0 6
      domian/report/report_service.go
  2. 10 15
      models/report/report.go

+ 0 - 6
domian/report/report_service.go

@@ -270,9 +270,6 @@ func InitETAReportList(list []eta.ETAReport) (err error) {
 	logger.Info("同步研报数量%d", len(list))
 	var reports []reportDao.Report
 	for _, etaRp := range list {
-		//authorNames := strings.Split(etaRp.Author, ",")
-		//authorNamesWithOutEmpty := stringUtils.RemoveEmptyStrings(authorNames)
-		//for _, authorName := range authorNamesWithOutEmpty {
 		var coverSrc int
 		var permissions []etaDao.ChartPermission
 		permissions, err = etaDao.GetSecondPermissionsByClassifyID(etaRp.ClassifyID)
@@ -368,9 +365,6 @@ func SyncETAReportList(list []eta.ETAReport) (err error) {
 			//	coverSrc = ids[randomIndex]
 			//}
 		}
-		//authorNames := strings.Split(etaRp.Author, ",")
-		//authorNamesWithOutEmpty := stringUtils.RemoveEmptyStrings(authorNames)
-		//for _, authorName := range authorNamesWithOutEmpty {
 		status := etaStatus(etaRp.State)
 		destRp := convertEtaReport(etaRp, status)
 		destRp.CoverSrc = coverSrc

+ 10 - 15
models/report/report.go

@@ -73,24 +73,19 @@ func InsertOrUpdateReport(list []Report, source string) (result []Report, err er
 	orgIds = silce_utils.RemoveDuplicates(orgIds)
 	db := models.Main()
 	//数据库找到作者的名字
-	//var dbAuthors []string
-	//err = db.Model(&Report{}).Select("distinct author").Where("org_id in ? and source =? ", orgIds, source).Scan(&dbAuthors).Error
 	if err != nil {
 		logger.Error("查询研报失败:%v", err)
 	}
-	//var deleteAuthors []string
-	//for _, dbAuthor := range dbAuthors {
-	//	found := false
-	//	for _, insertAuthor := range authorNames {
-	//		if dbAuthor == insertAuthor {
-	//			found = true
-	//			break
-	//		}
-	//	}
-	//	if !found {
-	//		deleteAuthors = append(deleteAuthors, dbAuthor)
-	//	}
-	//}
+	for i := 0; i < len(list); i++ {
+		var dbReport Report
+		err = db.Model(&Report{}).Select(CommonColumns).Where("org_id = ? and source =? ", list[i].OrgID, source).First(&dbReport).Error
+		if err != nil {
+			logger.Error("查询数据库失败研报失败:%v,发布时间不更新", err)
+		}
+		if dbReport.Status == StatusPublish {
+			list[i].PublishedTime = dbReport.PublishedTime
+		}
+	}
 	//手动事务
 	tx := db.Begin()
 	OnConflictFunc := clause.OnConflict{