فهرست منبع

智能研报生成长图

hsun 1 سال پیش
والد
کامیت
1c388d523b
4فایلهای تغییر یافته به همراه35 افزوده شده و 8 حذف شده
  1. 6 0
      models/smart_report.go
  2. 7 1
      services/smart_report.go
  3. 17 7
      utils/config.go
  4. 5 0
      utils/constants.go

+ 6 - 0
models/smart_report.go

@@ -92,3 +92,9 @@ type ElasticSmartReport struct {
 	StageStr           string `description:"报告期数"`
 	Frequency          string `description:"频度"`
 }
+
+// Report2ImgQueueReq 报告详情生成长图队列请求体
+type Report2ImgQueueReq struct {
+	ReportType int    `description:"报告类型: 1-研报; 2-智能研报"`
+	ReportCode string `description:"报告唯一编码"`
+}

+ 7 - 1
services/smart_report.go

@@ -48,6 +48,12 @@ func PublishSmartReport(cont context.Context) (err error) {
 			return
 		}
 
+		// 写入队列
+		var queue models.Report2ImgQueueReq
+		queue.ReportType = 2
+		queue.ReportCode = item.ReportCode
+		_ = utils.Rc.LPush(utils.CACHE_CREATE_REPORT_IMGPDF_QUEUE, queue)
+
 		// 生成音频, 更新ES
 		go func() {
 			if item.VideoUrl == "" {
@@ -120,7 +126,7 @@ func SmartReportElasticUpsert(smartReportId int, state int) (err error) {
 	esReport.ClassifyNameSecond = item.ClassifyNameSecond
 	esReport.StageStr = strconv.Itoa(item.Stage)
 	esReport.Frequency = item.Frequency
-	if err = EsAddOrEditSmartReport(utils.EsReportIndexName, strconv.Itoa(item.SmartReportId), esReport); err != nil {
+	if err = EsAddOrEditSmartReport(utils.SmartReportIndexName, strconv.Itoa(item.SmartReportId), esReport); err != nil {
 		return
 	}
 	return

+ 17 - 7
utils/config.go

@@ -4,6 +4,7 @@ import (
 	"fmt"
 	beego "github.com/beego/beego/v2/adapter"
 	"github.com/beego/beego/v2/server/web"
+	"github.com/rdlucklib/rdluck_tools/cache"
 )
 
 var (
@@ -14,6 +15,10 @@ var (
 	MYSQL_URL_DATA string
 	MYSQL_URL_GL   string
 	MYSQL_URL_ETA  string
+
+	REDIS_CACHE string       //缓存地址
+	Rc          *cache.Cache //redis缓存
+	Re          error        //redis错误
 )
 
 var (
@@ -23,8 +28,6 @@ var (
 	BinLogFile string
 )
 
-var SystemType string // 系统类型; hz:弘则;trial:试用平台;custom:客户
-
 var (
 	APPNAME                        string //项目中文名称
 	EmailSendToUsers               string // 邮件提醒人员
@@ -83,9 +86,11 @@ var (
 	ES_PASSWORD string // ES密码
 )
 
+// ES索引配置
 var (
 	EsReportIndexName        string //研报ES索引
 	EsEnglishReportIndexName string //英文研报ES索引
+	SmartReportIndexName     string //智能研报ES索引
 )
 
 // 科大讯飞--语音合成
@@ -144,12 +149,16 @@ func init() {
 	MYSQL_URL_DATA = config["mysql_url_data"]
 	MYSQL_URL_GL = config["mysql_url_gl"]
 	MYSQL_URL_ETA = config["mysql_url_eta"]
-	// 系统类型
-	systemType, err := web.AppConfig.String("system_type")
-	if err != nil {
-		panic(any("配置文件读取system_type错误 " + err.Error()))
+
+	REDIS_CACHE = config["beego_cache"]
+	if len(REDIS_CACHE) <= 0 {
+		panic(any("redis链接参数没有配置"))
+	}
+	Rc, Re = cache.NewCache(REDIS_CACHE) //初始化缓存
+	if Re != nil {
+		fmt.Println(Re)
+		panic(any(Re))
 	}
-	SystemType = systemType
 
 	// 项目中文名称
 	appNameCn, err := web.AppConfig.String("app_name_cn")
@@ -201,6 +210,7 @@ func init() {
 	{
 		EsReportIndexName = config["es_report_index_name"]
 		EsEnglishReportIndexName = config["es_english_report_index_name"]
+		SmartReportIndexName = config["es_smart_report_index_name"]
 	}
 
 	// 科大讯飞

+ 5 - 0
utils/constants.go

@@ -115,3 +115,8 @@ var (
 const (
 	TEMPLATE_MSG_REPORT = iota + 1 //日度点评报告推送
 )
+
+// 缓存key
+const (
+	CACHE_CREATE_REPORT_IMGPDF_QUEUE = "eta_report:report_img_pdf_queue" // 生成报告长图PDF队列
+)