LingxinMeng 11 ماه پیش
والد
کامیت
38f1486ec7
3فایلهای تغییر یافته به همراه14 افزوده شده و 48 حذف شده
  1. 9 46
      amd64/score_server/handler/h_exam.go
  2. 4 2
      amd64/score_server/infra/application.yaml
  3. 1 0
      amd64/score_server/infra/i_application.go

+ 9 - 46
amd64/score_server/handler/h_exam.go

@@ -318,6 +318,8 @@ func Page(c *gin.Context) {
 
 // 评分报告pdf下载
 func Report(c *gin.Context) {
+	pdfName := util.NewShortUUID() + ".pdf"
+	pdfPath := infra.ApplicationYaml.Pdf.LocalDir + pdfName
 	param := new(webServerEntity.ExamReportPao)
 	// 映射到结构体
 	if err := c.ShouldBindJSON(&param); err != nil {
@@ -576,39 +578,20 @@ func Report(c *gin.Context) {
 							_ = pdf.CellWithOption(&gopdf.Rect{W: tableWidth, H: lineHeight}, "("+util.ToString(i+1)+")"+detailsDtos2[i].SceneName, alignOptionText)
 							currentLine++
 						}
-						// 场景1 表格
 						{
-							//{
-							//	pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
-							//	_ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "序号", alignOptionTable)
-							//}
-							//{
-							//	pdf.SetXY(leftMargin+1.0*tableCellWidth, topMargin+currentLine*lineHeight)
-							//	_ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "扣分点", alignOptionTable)
-							//}
 							{
 								pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
 								_ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "扣分说明", alignOptionTable)
 							}
 							currentLine++
 						}
-						//for j := 0; j < 1; j++ {
 						{
-							//{
-							//	pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
-							//	_ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, util.ToString(j+1), alignOptionTable)
-							//}
-							//{
-							//	pdf.SetXY(leftMargin+1.0*tableCellWidth, topMargin+currentLine*lineHeight)
-							//	_ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "xxx", alignOptionTable)
-							//}
 							{
 								pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
 								_ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, detailsDtos2[i].Reason, alignOptionTable)
 							}
 							currentLine++
 						}
-						//}
 					}
 				}
 			}
@@ -630,46 +613,26 @@ func Report(c *gin.Context) {
 			{
 				columnNumber := 3.0                         // 列数
 				tableCellWidth := tableWidth / columnNumber // 单元格宽度
-				for i := 5; i < 10; i++ {
-					// 场景1
+				for i := 8; i < 10; i++ {
 					{
 						{
 							pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
 							_ = pdf.CellWithOption(&gopdf.Rect{W: tableWidth, H: lineHeight}, "("+util.ToString(i+1)+")xxxx场景", alignOptionText)
 							currentLine++
 						}
-						// 场景1 表格
 						{
-							{
-								pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
-								_ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "序号", alignOptionTable)
-							}
-							{
-								pdf.SetXY(leftMargin+1.0*tableCellWidth, topMargin+currentLine*lineHeight)
-								_ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "扣分点", alignOptionTable)
-							}
 							{
 								pdf.SetXY(leftMargin+2.0*tableCellWidth, topMargin+currentLine*lineHeight)
 								_ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "扣分说明", alignOptionTable)
 							}
 							currentLine++
 						}
-						for j := 0; j < 2; j++ {
+						{
 							{
-								{
-									pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
-									_ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, util.ToString(j+1), alignOptionTable)
-								}
-								{
-									pdf.SetXY(leftMargin+1.0*tableCellWidth, topMargin+currentLine*lineHeight)
-									_ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "xxx", alignOptionTable)
-								}
-								{
-									pdf.SetXY(leftMargin+2.0*tableCellWidth, topMargin+currentLine*lineHeight)
-									_ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "xxx", alignOptionTable)
-								}
-								currentLine++
+								pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
+								_ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, detailsDtos2[i].Reason, alignOptionTable)
 							}
+							currentLine++
 						}
 					}
 				}
@@ -689,11 +652,11 @@ func Report(c *gin.Context) {
 		//	pdf.AddExternalLink("https://www.baidu.com/", leftMargin, topMargin-lineHeight, 6*14, lineHeight)
 		//}
 		// 写入本地
-		_ = pdf.WritePdf("D:\\hello.pdf")
+		_ = pdf.WritePdf(pdfPath)
 	}
 
 	// 打开要发送的文件
-	file, err := os.Open("D:\\hello.pdf")
+	file, err := os.Open(pdfPath)
 	if err != nil {
 		c.String(http.StatusNotFound, "文件未找到")
 		return

+ 4 - 2
amd64/score_server/infra/application.yaml

@@ -9,8 +9,8 @@ log:
   dir: ./log/
   prefix: score_server
 mysql:
-#  ip: 36.110.106.156 # 公网IP
-#  sqlfile-dir: D:\code\cicv-data-closedloop\amd64\score_server\sql
+  #  ip: 36.110.106.156 # 公网IP
+  #  sqlfile-dir: D:\code\cicv-data-closedloop\amd64\score_server\sql
   ip: 10.14.85.241 # 内网IP
   sqlfile-dir: /root/cicv-data-closedloop/amd64/score_server/sql
   port: 3306
@@ -20,9 +20,11 @@ mysql:
   charset: utf8
 
 pdf:
+  local-dir: /root/cicv-data-closedloop/amd64/score_server/pdf/
   ttf: /root/cicv-data-closedloop/amd64/score_server/simfang.ttf
   background-png: /root/cicv-data-closedloop/amd64/score_server/background.png
   logo-png: /root/cicv-data-closedloop/amd64/score_server/logo.png
+#  local-path: D:\pdf\
 #  ttf: D:\code\cicv-data-closedloop\amd64\score_server\simfang.ttf
 #  background-png: D:\code\cicv-data-closedloop\amd64\score_server\background.png
 #  logo-png: D:\code\cicv-data-closedloop\amd64\score_server\logo.png

+ 1 - 0
amd64/score_server/infra/i_application.go

@@ -28,6 +28,7 @@ type ApplicationYamlStruct struct {
 		SqlfileDir string `yaml:"sqlfile-dir"`
 	} `yaml:"mysql"`
 	Pdf struct {
+		LocalDir      string `yaml:"local-dir"`
 		Ttf           string `yaml:"ttf"`
 		BackgroundPng string `yaml:"background-png"`
 		LogoPng       string `yaml:"logo-png"`