修改
This commit is contained in:
parent
03983189f6
commit
bd801656d1
@ -9,6 +9,7 @@ import (
|
|||||||
"fonchain-fiee/pkg/service/bundle/model"
|
"fonchain-fiee/pkg/service/bundle/model"
|
||||||
"fonchain-fiee/pkg/service/upload"
|
"fonchain-fiee/pkg/service/upload"
|
||||||
"fonchain-fiee/pkg/utils"
|
"fonchain-fiee/pkg/utils"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -73,20 +74,19 @@ func QuestionnaireSurveyCreate(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
templateDir := "./data/满意度调成报告模板.pdf"
|
templateDir := "./data/满意度调成报告模板.pdf"
|
||||||
outputPath := "./data/" + req.UserTel + time.Now().Format("20060102150405") + ".pdf"
|
outputPath := "/data/questionnaire/" + req.UserTel + time.Now().Format("20060102150405") + ".pdf"
|
||||||
fmt.Println("1111111111111111111")
|
|
||||||
err = utils.QuestionnaireSurveyPDF(templateDir, outputPath, &model.QuestionnairePDFData{
|
err = utils.QuestionnaireSurveyPDF(templateDir, outputPath, &model.QuestionnairePDFData{
|
||||||
//CustomerNum: surveyInfo.BundleInfo.,
|
//CustomerNum: surveyInfo.BundleInfo.,
|
||||||
CustomerName: surveyInfo.UserName,
|
CustomerName: surveyInfo.UserName,
|
||||||
BundleName: surveyInfo.BundleInfo.BundleName,
|
BundleName: surveyInfo.BundleInfo.BundleName,
|
||||||
BundleStartDate: surveyInfo.BundleInfo.StartAt,
|
BundleStartDate: surveyInfo.BundleInfo.StartAt,
|
||||||
BundleEndDate: surveyInfo.BundleInfo.ExpiredAt,
|
BundleEndDate: surveyInfo.BundleInfo.ExpiredAt,
|
||||||
VideoNum: string(surveyInfo.BundleInfo.BundleVideoNumber),
|
VideoNum: strconv.FormatInt(int64(surveyInfo.BundleInfo.BundleVideoNumber), 10),
|
||||||
AccountNum: string(surveyInfo.BundleInfo.BundleAccountNumber),
|
AccountNum: strconv.FormatInt(int64(surveyInfo.BundleInfo.BundleAccountNumber), 10),
|
||||||
ImagesNum: string(surveyInfo.BundleInfo.BundleImageNumber),
|
ImagesNum: strconv.FormatInt(int64(surveyInfo.BundleInfo.BundleImageNumber), 10),
|
||||||
DataAnalysisNum: string(surveyInfo.BundleInfo.BundleDataNumber),
|
DataAnalysisNum: strconv.FormatInt(int64(surveyInfo.BundleInfo.BundleDataNumber), 10),
|
||||||
CompetitiveNum: string(surveyInfo.BundleInfo.BundleCompetitiveNumber),
|
CompetitiveNum: strconv.FormatInt(int64(surveyInfo.BundleInfo.BundleCompetitiveNumber), 10),
|
||||||
ValueAddVideoNum: string(surveyInfo.BundleInfo.IncreaseVideoNumber),
|
ValueAddVideoNum: strconv.FormatInt(int64(surveyInfo.BundleInfo.IncreaseVideoNumber), 10),
|
||||||
Score1: int(req.SurveyAnswer.BundleAccountScore),
|
Score1: int(req.SurveyAnswer.BundleAccountScore),
|
||||||
Score2: int(req.SurveyAnswer.BundleAccountScore),
|
Score2: int(req.SurveyAnswer.BundleAccountScore),
|
||||||
Score3: int(req.SurveyAnswer.BundleImageScore),
|
Score3: int(req.SurveyAnswer.BundleImageScore),
|
||||||
@ -102,22 +102,16 @@ func QuestionnaireSurveyCreate(c *gin.Context) {
|
|||||||
Address: address,
|
Address: address,
|
||||||
})
|
})
|
||||||
|
|
||||||
fmt.Println("2222222222222222222")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("生成PDF失败: ", err)
|
|
||||||
service.Error(c, err)
|
service.Error(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Println("333333333333333333")
|
|
||||||
outputUrl, ossErr := upload.PutBos(outputPath, upload.PdfType, true)
|
outputUrl, ossErr := upload.PutBos(outputPath, upload.PdfType, true)
|
||||||
|
|
||||||
fmt.Println("outputUrl======================>>>>", outputUrl)
|
|
||||||
fmt.Println("ossErr======================>>>>", ossErr)
|
|
||||||
if ossErr != nil {
|
if ossErr != nil {
|
||||||
service.Error(c, err)
|
service.Error(c, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Println("outputUrl======================>>>>", outputUrl)
|
|
||||||
//service.Success(c, outputUrl)
|
//service.Success(c, outputUrl)
|
||||||
//return
|
//return
|
||||||
req.SurveyUrl = outputUrl
|
req.SurveyUrl = outputUrl
|
||||||
|
|||||||
@ -605,17 +605,14 @@ func QuestionnaireSurveyPDF(templatePath, outputPath string, data *model.Questio
|
|||||||
pdf := gopdf.GoPdf{}
|
pdf := gopdf.GoPdf{}
|
||||||
pdf.Start(gopdf.Config{PageSize: *gopdf.PageSizeA4})
|
pdf.Start(gopdf.Config{PageSize: *gopdf.PageSizeA4})
|
||||||
|
|
||||||
fmt.Println("pdf111111111111111111111111111")
|
|
||||||
if err := pdf.ImportPagesFromSource(templatePath, "/MediaBox"); err != nil {
|
if err := pdf.ImportPagesFromSource(templatePath, "/MediaBox"); err != nil {
|
||||||
return fmt.Errorf("导入模板失败: %w", err)
|
return fmt.Errorf("导入模板失败: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("pdf222222222222222222222222222")
|
|
||||||
if err := pdf.AddTTFFont("simfang", "./data/simfang.ttf"); err != nil {
|
if err := pdf.AddTTFFont("simfang", "./data/simfang.ttf"); err != nil {
|
||||||
return fmt.Errorf("加载字体失败: %w", err)
|
return fmt.Errorf("加载字体失败: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("pdf333333333333333333333333333")
|
|
||||||
if err := pdf.SetFont("simfang", "", 12); err != nil {
|
if err := pdf.SetFont("simfang", "", 12); err != nil {
|
||||||
return fmt.Errorf("设置字体失败: %w", err)
|
return fmt.Errorf("设置字体失败: %w", err)
|
||||||
}
|
}
|
||||||
@ -624,12 +621,10 @@ func QuestionnaireSurveyPDF(templatePath, outputPath string, data *model.Questio
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("BundleStartDate格式错误: %w", err)
|
return fmt.Errorf("BundleStartDate格式错误: %w", err)
|
||||||
}
|
}
|
||||||
fmt.Println("pdf4444444444444444444444444444444")
|
|
||||||
endTime, err := parseFlexibleDate(data.BundleEndDate)
|
endTime, err := parseFlexibleDate(data.BundleEndDate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("BundleEndDate格式错误: %w", err)
|
return fmt.Errorf("BundleEndDate格式错误: %w", err)
|
||||||
}
|
}
|
||||||
fmt.Println("pdf555555555555555555555555555555")
|
|
||||||
submissionDate, err := parseFlexibleDate(data.SubmissionDate)
|
submissionDate, err := parseFlexibleDate(data.SubmissionDate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("SubmissionDate格式错误: %w", err)
|
return fmt.Errorf("SubmissionDate格式错误: %w", err)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user