|
@@ -243,7 +243,6 @@ async def main():
|
|
|
# 截取全页面的屏幕截图
|
|
|
await page.screenshot({
|
|
|
'path': "%s",
|
|
|
- 'type': "jpeg",
|
|
|
'fullPage': True,
|
|
|
})
|
|
|
|
|
@@ -296,7 +295,7 @@ func Report2pdfAndJpeg(reportUrl string, reportId int) {
|
|
|
reportCode := utils.MD5(strconv.Itoa(reportId))
|
|
|
|
|
|
pdfPath := `./static/` + reportCode + ".pdf"
|
|
|
- //jpegPath := `./static/` + reportCode + ".jpeg"
|
|
|
+ jpegPath := `./static/` + reportCode + ".jpeg"
|
|
|
|
|
|
go func() {
|
|
|
err := ReportToPdf(reportUrl, pdfPath)
|
|
@@ -344,45 +343,45 @@ func Report2pdfAndJpeg(reportUrl string, reportId int) {
|
|
|
}
|
|
|
}()
|
|
|
|
|
|
- //go func() {
|
|
|
- // err := ReportToJpeg(reportUrl, jpegPath)
|
|
|
- // if err != nil {
|
|
|
- // utils.FileLog.Info("ReportToJpeg failed: , error: \n" + err.Error())
|
|
|
- // }
|
|
|
- // file, err := os.Open(jpegPath)
|
|
|
- // if err != nil {
|
|
|
- // utils.FileLog.Info("open file failed: , error: \n" + err.Error())
|
|
|
- // return
|
|
|
- // }
|
|
|
- //
|
|
|
- // ext := path.Ext(file.Name())
|
|
|
- //
|
|
|
- // randStr := utils.GetRandStringNoSpecialChar(28)
|
|
|
- // fileName := randStr + ext
|
|
|
- // defer file.Close() //关闭上传文件
|
|
|
- //
|
|
|
- // resourceUrl := ``
|
|
|
- // ossClient := NewOssClient()
|
|
|
- // if ossClient == nil {
|
|
|
- // utils.FileLog.Info("初始化OSS服务失败")
|
|
|
- // return
|
|
|
- // }
|
|
|
- // resourceUrl, err = ossClient.UploadFile(fileName, jpegPath, "")
|
|
|
- // if err != nil {
|
|
|
- // utils.FileLog.Info("文件上传失败, Err: \n" + err.Error())
|
|
|
- // return
|
|
|
- // }
|
|
|
- // defer func() {
|
|
|
- // _ = os.Remove(jpegPath)
|
|
|
- // }()
|
|
|
- //
|
|
|
- // // 更新jpeg url
|
|
|
- // ob := new(smart_report.SmartReport)
|
|
|
- // ob.SmartReportId = reportId
|
|
|
- // ob.DetailImgUrl = resourceUrl
|
|
|
- // if err = ob.Update([]string{"DetailImgUrl"}); err != nil {
|
|
|
- // utils.FileLog.Info("更新研报失败, Err: \n" + err.Error())
|
|
|
- // return
|
|
|
- // }
|
|
|
- //}()
|
|
|
+ go func() {
|
|
|
+ err := ReportToJpeg(reportUrl, jpegPath)
|
|
|
+ if err != nil {
|
|
|
+ utils.FileLog.Info("ReportToJpeg failed: , error: \n" + err.Error())
|
|
|
+ }
|
|
|
+ file, err := os.Open(jpegPath)
|
|
|
+ if err != nil {
|
|
|
+ utils.FileLog.Info("open file failed: , error: \n" + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ ext := path.Ext(file.Name())
|
|
|
+
|
|
|
+ randStr := utils.GetRandStringNoSpecialChar(28)
|
|
|
+ fileName := randStr + ext
|
|
|
+ defer file.Close() //关闭上传文件
|
|
|
+
|
|
|
+ resourceUrl := ``
|
|
|
+ ossClient := NewOssClient()
|
|
|
+ if ossClient == nil {
|
|
|
+ utils.FileLog.Info("初始化OSS服务失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resourceUrl, err = ossClient.UploadFile(fileName, jpegPath, "")
|
|
|
+ if err != nil {
|
|
|
+ utils.FileLog.Info("文件上传失败, Err: \n" + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer func() {
|
|
|
+ _ = os.Remove(jpegPath)
|
|
|
+ }()
|
|
|
+
|
|
|
+ // 更新jpeg url
|
|
|
+ ob := new(smart_report.SmartReport)
|
|
|
+ ob.SmartReportId = reportId
|
|
|
+ ob.DetailImgUrl = resourceUrl
|
|
|
+ if err = ob.Update([]string{"DetailImgUrl"}); err != nil {
|
|
|
+ utils.FileLog.Info("更新研报失败, Err: \n" + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }()
|
|
|
}
|