This commit is contained in:
JNG 2026-03-11 20:01:48 +08:00
parent 03983189f6
commit bd801656d1
2 changed files with 8 additions and 19 deletions

View File

@ -9,6 +9,7 @@ import (
"fonchain-fiee/pkg/service/bundle/model"
"fonchain-fiee/pkg/service/upload"
"fonchain-fiee/pkg/utils"
"strconv"
"time"
"github.com/gin-gonic/gin"
@ -73,20 +74,19 @@ func QuestionnaireSurveyCreate(c *gin.Context) {
return
}
templateDir := "./data/满意度调成报告模板.pdf"
outputPath := "./data/" + req.UserTel + time.Now().Format("20060102150405") + ".pdf"
fmt.Println("1111111111111111111")
outputPath := "/data/questionnaire/" + req.UserTel + time.Now().Format("20060102150405") + ".pdf"
err = utils.QuestionnaireSurveyPDF(templateDir, outputPath, &model.QuestionnairePDFData{
//CustomerNum: surveyInfo.BundleInfo.,
CustomerName: surveyInfo.UserName,
BundleName: surveyInfo.BundleInfo.BundleName,
BundleStartDate: surveyInfo.BundleInfo.StartAt,
BundleEndDate: surveyInfo.BundleInfo.ExpiredAt,
VideoNum: string(surveyInfo.BundleInfo.BundleVideoNumber),
AccountNum: string(surveyInfo.BundleInfo.BundleAccountNumber),
ImagesNum: string(surveyInfo.BundleInfo.BundleImageNumber),
DataAnalysisNum: string(surveyInfo.BundleInfo.BundleDataNumber),
CompetitiveNum: string(surveyInfo.BundleInfo.BundleCompetitiveNumber),
ValueAddVideoNum: string(surveyInfo.BundleInfo.IncreaseVideoNumber),
VideoNum: strconv.FormatInt(int64(surveyInfo.BundleInfo.BundleVideoNumber), 10),
AccountNum: strconv.FormatInt(int64(surveyInfo.BundleInfo.BundleAccountNumber), 10),
ImagesNum: strconv.FormatInt(int64(surveyInfo.BundleInfo.BundleImageNumber), 10),
DataAnalysisNum: strconv.FormatInt(int64(surveyInfo.BundleInfo.BundleDataNumber), 10),
CompetitiveNum: strconv.FormatInt(int64(surveyInfo.BundleInfo.BundleCompetitiveNumber), 10),
ValueAddVideoNum: strconv.FormatInt(int64(surveyInfo.BundleInfo.IncreaseVideoNumber), 10),
Score1: int(req.SurveyAnswer.BundleAccountScore),
Score2: int(req.SurveyAnswer.BundleAccountScore),
Score3: int(req.SurveyAnswer.BundleImageScore),
@ -102,22 +102,16 @@ func QuestionnaireSurveyCreate(c *gin.Context) {
Address: address,
})
fmt.Println("2222222222222222222")
if err != nil {
fmt.Println("生成PDF失败: ", err)
service.Error(c, err)
return
}
fmt.Println("333333333333333333")
outputUrl, ossErr := upload.PutBos(outputPath, upload.PdfType, true)
fmt.Println("outputUrl======================>>>>", outputUrl)
fmt.Println("ossErr======================>>>>", ossErr)
if ossErr != nil {
service.Error(c, err)
return
}
fmt.Println("outputUrl======================>>>>", outputUrl)
//service.Success(c, outputUrl)
//return
req.SurveyUrl = outputUrl

View File

@ -605,17 +605,14 @@ func QuestionnaireSurveyPDF(templatePath, outputPath string, data *model.Questio
pdf := gopdf.GoPdf{}
pdf.Start(gopdf.Config{PageSize: *gopdf.PageSizeA4})
fmt.Println("pdf111111111111111111111111111")
if err := pdf.ImportPagesFromSource(templatePath, "/MediaBox"); err != nil {
return fmt.Errorf("导入模板失败: %w", err)
}
fmt.Println("pdf222222222222222222222222222")
if err := pdf.AddTTFFont("simfang", "./data/simfang.ttf"); err != nil {
return fmt.Errorf("加载字体失败: %w", err)
}
fmt.Println("pdf333333333333333333333333333")
if err := pdf.SetFont("simfang", "", 12); err != nil {
return fmt.Errorf("设置字体失败: %w", err)
}
@ -624,12 +621,10 @@ func QuestionnaireSurveyPDF(templatePath, outputPath string, data *model.Questio
if err != nil {
return fmt.Errorf("BundleStartDate格式错误: %w", err)
}
fmt.Println("pdf4444444444444444444444444444444")
endTime, err := parseFlexibleDate(data.BundleEndDate)
if err != nil {
return fmt.Errorf("BundleEndDate格式错误: %w", err)
}
fmt.Println("pdf555555555555555555555555555555")
submissionDate, err := parseFlexibleDate(data.SubmissionDate)
if err != nil {
return fmt.Errorf("SubmissionDate格式错误: %w", err)