|
@@ -249,15 +249,16 @@ func Report2pdfAndJpeg(reportUrl string, reportId int) {
|
|
|
}()
|
|
|
reportCode := utils.MD5(strconv.Itoa(reportId))
|
|
|
|
|
|
- filePath := `./static/` + reportCode
|
|
|
+ pdfPath := `./static/` + reportCode + ".pdf"
|
|
|
+ jpegPath := `./static/` + reportCode + ".jpeg"
|
|
|
|
|
|
go func() {
|
|
|
- err := ReportToPdf(reportUrl, filePath+".pdf")
|
|
|
+ err := ReportToPdf(reportUrl, pdfPath)
|
|
|
if err != nil {
|
|
|
utils.FileLog.Info("ReportToPdf failed: , error: \n" + err.Error())
|
|
|
}
|
|
|
|
|
|
- file, err := os.Open(filePath)
|
|
|
+ file, err := os.Open(pdfPath)
|
|
|
if err != nil {
|
|
|
fmt.Println("Error:", err)
|
|
|
return
|
|
@@ -275,13 +276,13 @@ func Report2pdfAndJpeg(reportUrl string, reportId int) {
|
|
|
utils.FileLog.Info("初始化OSS服务失败")
|
|
|
return
|
|
|
}
|
|
|
- resourceUrl, err = ossClient.UploadFile(fileName, filePath, "")
|
|
|
+ resourceUrl, err = ossClient.UploadFile(fileName, pdfPath, "")
|
|
|
if err != nil {
|
|
|
utils.FileLog.Info("文件上传失败, Err: \n" + err.Error())
|
|
|
return
|
|
|
}
|
|
|
defer func() {
|
|
|
- _ = os.Remove(filePath)
|
|
|
+ _ = os.Remove(pdfPath)
|
|
|
}()
|
|
|
|
|
|
// 更新pdf url
|
|
@@ -295,11 +296,11 @@ func Report2pdfAndJpeg(reportUrl string, reportId int) {
|
|
|
}()
|
|
|
|
|
|
go func() {
|
|
|
- err := ReportToJpeg(reportUrl, filePath+".jpeg")
|
|
|
+ err := ReportToJpeg(reportUrl, jpegPath)
|
|
|
if err != nil {
|
|
|
utils.FileLog.Info("ReportToJpeg failed: , error: \n" + err.Error())
|
|
|
}
|
|
|
- file, err := os.Open(filePath)
|
|
|
+ file, err := os.Open(jpegPath)
|
|
|
if err != nil {
|
|
|
utils.FileLog.Info("open file failed: , error: \n" + err.Error())
|
|
|
return
|
|
@@ -317,13 +318,13 @@ func Report2pdfAndJpeg(reportUrl string, reportId int) {
|
|
|
utils.FileLog.Info("初始化OSS服务失败")
|
|
|
return
|
|
|
}
|
|
|
- resourceUrl, err = ossClient.UploadFile(fileName, filePath, "")
|
|
|
+ resourceUrl, err = ossClient.UploadFile(fileName, jpegPath, "")
|
|
|
if err != nil {
|
|
|
utils.FileLog.Info("文件上传失败, Err: \n" + err.Error())
|
|
|
return
|
|
|
}
|
|
|
defer func() {
|
|
|
- _ = os.Remove(filePath)
|
|
|
+ _ = os.Remove(jpegPath)
|
|
|
}()
|
|
|
|
|
|
// 更新jpeg url
|