Переглянути джерело

Merge branch 'rag/3.1' into debug

Roc 1 тиждень тому
батько
коміт
3a8f3f8dad

+ 37 - 0
cache/llm.go

@@ -0,0 +1,37 @@
+package cache
+
+import (
+	"eta/eta_mobile/utils"
+	"fmt"
+)
+
+type RagEtaReportOpOp struct {
+	Source          string
+	ReportId        int
+	ReportChapterId int
+}
+
+// RagEtaReportOpToCache
+// @Description: 将eta报告入知识库操作加入缓存
+// @author: Roc
+// @datetime 2025-04-07 15:05:22
+// @param reportId int
+// @param reportChapterId int
+// @param source string
+// @return bool
+func RagEtaReportOpToCache(reportId, reportChapterId int, source string) bool {
+	record := new(RagEtaReportOpOp)
+	record.Source = source
+	record.ReportId = reportId
+	record.ReportChapterId = reportChapterId
+	if utils.Re == nil {
+		err := utils.Rc.LPush(utils.CACHE_ETA_REPORT_KNOWLEDGE, record)
+
+		utils.FileLog.Info(fmt.Sprintf("将eta报告入知识库操作加入缓存 加入缓存 RagEtaReportOpToCache LPush: 操作类型:%s,报告id:%d,章节id:%d", source, reportId, reportChapterId))
+		if err != nil {
+			fmt.Println("RagEtaReportOpToCache LPush Err:" + err.Error())
+		}
+		return true
+	}
+	return false
+}

+ 8 - 0
controllers/report_v2.go

@@ -2,6 +2,7 @@ package controllers
 
 import (
 	"encoding/json"
+	"eta/eta_mobile/cache"
 	"eta/eta_mobile/models"
 	"eta/eta_mobile/models/report"
 	"eta/eta_mobile/models/report_approve"
@@ -1487,6 +1488,10 @@ func (this *ReportController) PublishCancelReport() {
 	go func() {
 		_, _ = models.AddReportStateRecord(recordItem)
 	}()
+
+	// 报告取消发布成功后,需要将相关信息入知识库
+	go cache.RagEtaReportOpToCache(reportInfo.Id, 0, `un_publish`)
+
 	br.Ret = 200
 	br.Success = true
 }
@@ -1815,6 +1820,9 @@ func (this *ReportController) CancelApprove() {
 	//	return
 	//}
 
+	// 报告发布成功后,需要将相关信息入知识库
+	go cache.RagEtaReportOpToCache(reportItem.Id, 0, `un_publish`)
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"

+ 2 - 2
controllers/smart_report/smart_report.go

@@ -393,7 +393,7 @@ func (this *SmartReportController) Detail() {
 		headResource, err := smart_report.GetResourceItemById(resp.HeadResourceId)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "操作失败"
-			br.ErrMsg = "获取资源库版失败, Err: " + err.Error()
+			br.ErrMsg = "获取资源库版失败, Err: " + err.Error()
 			return
 		}
 		if headResource != nil && headResource.ResourceId > 0 {
@@ -406,7 +406,7 @@ func (this *SmartReportController) Detail() {
 		endResource, err := smart_report.GetResourceItemById(resp.EndResourceId)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "操作失败"
-			br.ErrMsg = "获取资源库版失败, Err: " + err.Error()
+			br.ErrMsg = "获取资源库版失败, Err: " + err.Error()
 			return
 		}
 		if endResource != nil && endResource.ResourceId > 0 {

+ 4 - 0
services/report_approve.go

@@ -1,6 +1,7 @@
 package services
 
 import (
+	"eta/eta_mobile/cache"
 	"eta/eta_mobile/models"
 	"eta/eta_mobile/models/report_approve"
 	"eta/eta_mobile/models/smart_report"
@@ -848,6 +849,9 @@ func AfterReportApprovePass(reportType, reportId int) (err error) {
 		//_ = CreateVideo(reportInfo)
 		_ = UpdateReportEs(reportInfo.Id, models.ReportStatePublished)
 
+		// 报告发布成功后,需要将相关信息入知识库
+		go cache.RagEtaReportOpToCache(reportInfo.Id, 0, `publish`)
+
 		return
 	}
 

+ 7 - 0
services/report_v2.go

@@ -4,6 +4,7 @@ import (
 	"archive/zip"
 	"encoding/json"
 	"errors"
+	"eta/eta_mobile/cache"
 	"eta/eta_mobile/models"
 	"eta/eta_mobile/models/report"
 	"eta/eta_mobile/models/report_approve"
@@ -1249,6 +1250,9 @@ func PublishReport(reportId int, reportUrl string, sysUser *system.Admin) (tips
 		go handleReportPermission(int64(reportInfo.Id), minClassifyId)
 	}
 
+	// 报告发布成功后,需要将相关信息入知识库
+	go cache.RagEtaReportOpToCache(reportInfo.Id, 0, `publish`)
+
 	return
 }
 
@@ -1367,6 +1371,9 @@ func PublishChapterReport(reportInfo *models.Report, reportUrl string, sysUser *
 		go Report2pdfAndJpeg(reportPdfUrl, reportId, 1)
 	}
 
+	// 报告发布成功后,需要将相关信息入知识库
+	go cache.RagEtaReportOpToCache(reportInfo.Id, 0, `publish`)
+
 	return
 }
 

+ 5 - 3
utils/constants.go

@@ -223,6 +223,7 @@ const (
 	CACHE_CHART_AUTH                  = "eta:chart:auth:"                   //图表数据授权
 	CACHE_REPORT_SHARE_AUTH           = "eta:report:auth:share:"            //报告短链与报告图表授权映射key
 	CACHE_REPORT_AUTH                 = "eta:report:auth:"                  //报告图表数据授权
+	CACHE_ETA_REPORT_KNOWLEDGE        = "eta:report:knowledge:op:"          //eta报告入知识库处理
 )
 
 // 模板消息推送类型
@@ -483,10 +484,11 @@ const (
 	ZhLangVersion = "zh" // 中文语言版本
 	EnLangVersion = "en" // 英文语言版本
 )
+
 // 图表分类设置精选资源分类
 const (
-	ChartClassifyIsSelected = 1 // 图表分类设置精选资源分类
-	ChartClassifyResourceStatusUp = 1 // 图表分类上架状态
-	ChartClassifyResourceStatusDown = 2 // 图表分类下架状态
+	ChartClassifyIsSelected            = 1 // 图表分类设置精选资源分类
+	ChartClassifyResourceStatusUp      = 1 // 图表分类上架状态
+	ChartClassifyResourceStatusDown    = 2 // 图表分类下架状态
 	ChartClassifyResourceStatusDefault = 0 // 图表分类默认状态
 )