zwxi 10 ماه پیش
والد
کامیت
4565f5b98b
2فایلهای تغییر یافته به همراه11 افزوده شده و 9 حذف شده
  1. 1 0
      controllers/report.go
  2. 10 9
      services/smart_report.go

+ 1 - 0
controllers/report.go

@@ -366,6 +366,7 @@ func (this *ReportController) PublishReport() {
 			go func() {
 				_, _ = models.AddReportStateRecord(recordItem)
 			}()
+
 		}
 	}
 	// 发布晨周报部分章节未发布的提示

+ 10 - 9
services/smart_report.go

@@ -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