浏览代码

Merge remote-tracking branch 'origin/eta/1.8.3' into debug

Roc 8 月之前
父节点
当前提交
49f108cd69
共有 3 个文件被更改,包括 107 次插入73 次删除
  1. 72 72
      services/report.go
  2. 3 1
      services/report_approve.go
  3. 32 0
      services/report_v2.go

+ 72 - 72
services/report.go

@@ -449,78 +449,78 @@ func reportBase64ToImg(imageBase64 string) (resourceUrl string, err error) {
 	return
 }
 
-// UpdateReportVideo 更新报告及其章节音频
-func UpdateReportVideo(reportId int) (err error) {
-	defer func() {
-		if err != nil {
-			utils.FileLog.Error("UpdateReportVideo, reportId:%s, Err:%s", strconv.Itoa(reportId), err.Error())
-			go alarm_msg.SendAlarmMsg("更新报告音频失败, 报告ID: "+strconv.Itoa(reportId)+", Err: "+err.Error(), 3)
-			//go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "更新报告音频失败, 报告ID: " + reportIdStr + ", Err: "+err.Error(), utils.EmailSendToUsers)
-		}
-	}()
-	if reportId == 0 {
-		return
-	}
-	reportInfo, err := models.GetReportByReportId(reportId)
-	if err != nil {
-		return
-	}
-	if reportInfo.HasChapter == 1 {
-		// 更新章节音频
-		chapterList, tmpErr := models.GetPublishedChapterListByReportId(reportInfo.Id)
-		if tmpErr != nil {
-			err = tmpErr
-			return
-		}
-		chapterIdArr := make([]int, 0)
-		for i := 0; i < len(chapterList); i++ {
-			chapterIdArr = append(chapterIdArr, chapterList[i].ReportChapterId)
-		}
-		//go UpdateChaptersVideo(chapterIds)
-		err = UpdateChaptersVideo(chapterIdArr)
-	} else {
-		// 更新报告音频
-		if reportInfo.VideoUrl != "" {
-			return
-		}
-		nowTime := time.Now()
-		updateCols := make([]string, 0)
-		updateCols = append(updateCols, "VideoUrl", "VideoName", "VideoSize", "VideoPlaySeconds")
-		videoUrl, videoName, videoSize, videoPlaySeconds, tmpErr := CreateReportVideo(reportInfo.Title, html.UnescapeString(reportInfo.Content), nowTime.Format(utils.FormatDateTime))
-		reportInfo.VideoUrl = videoUrl
-		reportInfo.VideoName = videoName
-		reportInfo.VideoSize = videoSize
-		reportInfo.VideoPlaySeconds = fmt.Sprintf("%.2f", videoPlaySeconds)
-		tmpErr = reportInfo.UpdateReport(updateCols)
-		if tmpErr != nil {
-			err = tmpErr
-			return
-		}
-	}
-	return
-}
-
-func UpdateEmptyVideoReportVideo() (err error) {
-	list, err := models.GetSyncEmptyVideoReport()
-	if err != nil {
-		return
-	}
-	listLen := len(list)
-	if listLen <= 0 {
-		fmt.Println("无报告需要更新音频")
-		return
-	}
-	fmt.Println("Start 待更新报告音频数: ", listLen)
-	for i := 0; i < listLen; i++ {
-		if err = UpdateReportVideo(list[i].Id); err != nil {
-			fmt.Printf("更新音频失败")
-			fmt.Println(err.Error())
-			return
-		}
-	}
-	fmt.Println("End 报告音频更新完毕")
-	return
-}
+//// UpdateReportVideo 更新报告及其章节音频
+//func UpdateReportVideo(reportId int) (err error) {
+//	defer func() {
+//		if err != nil {
+//			utils.FileLog.Error("UpdateReportVideo, reportId:%s, Err:%s", strconv.Itoa(reportId), err.Error())
+//			go alarm_msg.SendAlarmMsg("更新报告音频失败, 报告ID: "+strconv.Itoa(reportId)+", Err: "+err.Error(), 3)
+//			//go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "更新报告音频失败, 报告ID: " + reportIdStr + ", Err: "+err.Error(), utils.EmailSendToUsers)
+//		}
+//	}()
+//	if reportId == 0 {
+//		return
+//	}
+//	reportInfo, err := models.GetReportByReportId(reportId)
+//	if err != nil {
+//		return
+//	}
+//	if reportInfo.HasChapter == 1 {
+//		// 更新章节音频
+//		chapterList, tmpErr := models.GetPublishedChapterListByReportId(reportInfo.Id)
+//		if tmpErr != nil {
+//			err = tmpErr
+//			return
+//		}
+//		chapterIdArr := make([]int, 0)
+//		for i := 0; i < len(chapterList); i++ {
+//			chapterIdArr = append(chapterIdArr, chapterList[i].ReportChapterId)
+//		}
+//		//go UpdateChaptersVideo(chapterIds)
+//		err = UpdateChaptersVideo(chapterIdArr)
+//	} else {
+//		// 更新报告音频
+//		if reportInfo.VideoUrl != "" {
+//			return
+//		}
+//		nowTime := time.Now()
+//		updateCols := make([]string, 0)
+//		updateCols = append(updateCols, "VideoUrl", "VideoName", "VideoSize", "VideoPlaySeconds")
+//		videoUrl, videoName, videoSize, videoPlaySeconds, tmpErr := CreateReportVideo(reportInfo.Title, html.UnescapeString(reportInfo.Content), nowTime.Format(utils.FormatDateTime))
+//		reportInfo.VideoUrl = videoUrl
+//		reportInfo.VideoName = videoName
+//		reportInfo.VideoSize = videoSize
+//		reportInfo.VideoPlaySeconds = fmt.Sprintf("%.2f", videoPlaySeconds)
+//		tmpErr = reportInfo.UpdateReport(updateCols)
+//		if tmpErr != nil {
+//			err = tmpErr
+//			return
+//		}
+//	}
+//	return
+//}
+//
+//func UpdateEmptyVideoReportVideo() (err error) {
+//	list, err := models.GetSyncEmptyVideoReport()
+//	if err != nil {
+//		return
+//	}
+//	listLen := len(list)
+//	if listLen <= 0 {
+//		fmt.Println("无报告需要更新音频")
+//		return
+//	}
+//	fmt.Println("Start 待更新报告音频数: ", listLen)
+//	for i := 0; i < listLen; i++ {
+//		if err = UpdateReportVideo(list[i].Id); err != nil {
+//			fmt.Printf("更新音频失败")
+//			fmt.Println(err.Error())
+//			return
+//		}
+//	}
+//	fmt.Println("End 报告音频更新完毕")
+//	return
+//}
 
 // checkDayWeekChapterWrite 校验晨周报已写章节与本期应写章节
 func checkDayWeekChapterWrite(chapters []*models.ReportChapter, reportType string) (publishReport bool, tips string, publishIdArr, unPublishIdArr []int, err error) {

+ 3 - 1
services/report_approve.go

@@ -839,7 +839,9 @@ func AfterReportApprovePass(reportType, reportId int) (err error) {
 			err = fmt.Errorf("获取研报信息失败, Err: %s", e.Error())
 			return
 		}
-		_ = CreateVideo(reportInfo)
+		// 重新生成音频,里面还涉及到章节类型的报告
+		go UpdateReportVideo(reportInfo)
+		//_ = CreateVideo(reportInfo)
 		_ = UpdateReportEs(reportInfo.Id, models.ReportStatePublished)
 
 		return

+ 32 - 0
services/report_v2.go

@@ -1338,3 +1338,35 @@ func HandleReportPermission(reportInfo *models.Report) {
 	}
 	handleReportPermission(int64(reportInfo.Id), minClassifyId)
 }
+
+// UpdateReportVideo
+// @Description: 更新报告音频
+// @author: Roc
+// @datetime 2024-07-17 18:11:10
+// @param reportInfo *models.Report
+func UpdateReportVideo(reportInfo *models.Report) {
+	if reportInfo.HasChapter == 1 {
+		reportChapterIdList := make([]int, 0)
+		// 获取报告中的所有章节列表
+		chapterList, err := models.GetChapterListByReportId(reportInfo.Id)
+		if err != nil {
+			return
+		}
+		for _, chapter := range chapterList {
+			if chapter.PublishState == 1 {
+				reportChapterIdList = append(reportChapterIdList, chapter.ReportChapterId)
+			}
+		}
+		if len(reportChapterIdList) > 0 {
+			err = UpdateChaptersVideo(reportChapterIdList)
+			if err != nil {
+				utils.FileLog.Info(fmt.Sprintf("%d报告音频生产失败:%s", reportInfo.Id, err.Error()))
+			}
+		}
+	} else {
+		err := CreateVideo(reportInfo)
+		if err != nil {
+			utils.FileLog.Info(fmt.Sprintf("%d报告音频生产失败:%s", reportInfo.Id, err.Error()))
+		}
+	}
+}