123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package services
- import (
- "encoding/json"
- "eta_gn/eta_report/utils"
- "fmt"
- )
- func InitTask() {
- // 监听生成报告长图及pdf
- //go ListenReport2ImgQueue()
- }
- // Report2ImgQueueReq 报告生成长图请求体
- type Report2ImgQueueReq struct {
- ReportType int `description:"报告类型: 1-研报; 2-智能研报"`
- ReportCode string `description:"报告唯一编码"`
- }
- // ListenReport2ImgQueue 监听生成报告长图及pdf
- func ListenReport2ImgQueue() {
- defer func() {
- if err := recover(); err != nil {
- fmt.Println("[ListenReport2ImgQueue] recover: ", err)
- utils.FileLog.Info(fmt.Sprintf("[ListenReport2ImgQueue] recover: %v", err))
- }
- }()
- for {
- if utils.Re != nil {
- fmt.Println("[ListenReport2ImgQueue] Re err: ", utils.Re.Error())
- utils.FileLog.Info(fmt.Sprintf("[ListenReport2ImgQueue] Re err: %s", utils.Re.Error()))
- continue
- }
- utils.Rc.Brpop(utils.CACHE_CREATE_REPORT_IMGPDF_QUEUE, func(b []byte) {
- var req Report2ImgQueueReq
- if e := json.Unmarshal(b, &req); e != nil {
- t := fmt.Sprintf("[ListenReport2ImgQueue] Unmarshal err: %s, b: %s", e.Error(), string(b))
- fmt.Println(t)
- utils.FileLog.Info(t)
- return
- }
- CreateReportImgAndPdf(req)
- })
- }
- }
|