package services import ( "encoding/json" "eta/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]", err) } }() for { utils.Rc.Brpop(utils.CACHE_CREATE_REPORT_IMGPDF_QUEUE, func(b []byte) { fmt.Println("ListenReport2ImgQueue Brpop:" + string(b)) var req Report2ImgQueueReq err := json.Unmarshal(b, &req) if err != nil { fmt.Println("ListenReport2ImgQueue json.Unmarshal Err:" + err.Error()) } CreateReportImgAndPdf(req) }) } }