LingxinMeng преди 1 година
родител
ревизия
4bb8524172

+ 1 - 1
aarch64/pjisuv/master/main.go

@@ -53,7 +53,7 @@ func main() {
 	//go commonService.RunTimeWindowConsumerQueue(commonConfig.CloudConfig.Hosts[0].Name)
 
 	// todo 算法比赛临时使用
-	go svc.ForCompetition()
+	go service.ForCompetition()
 
 	// 阻塞主线程,等待其他线程执行。
 	select {}

+ 4 - 4
amd64/web_server/application.yaml

@@ -9,10 +9,10 @@ log:
   dir: ./log/
   prefix: web_server
 mysql:
-#  ip: 36.110.106.156 # 公网IP
-#  sqlfile-dir: D:\code\cicv-data-closedloop\amd64\web_server\sql
-  ip: 10.14.85.241 # 内网IP
-  sqlfile-dir: /root/cicv-data-closedloop/amd64/web_server/sql
+  ip: 36.110.106.156 # 公网IP
+  sqlfile-dir: D:\code\cicv-data-closedloop\amd64\web_server\sql
+#  ip: 10.14.85.241 # 内网IP
+#  sqlfile-dir: /root/cicv-data-closedloop/amd64/web_server/sql
   port: 3306
   username: root
   password: 1qaz2wsx!

BIN
amd64/web_server/background.png


+ 202 - 17
amd64/web_server/handler/h_exam.go

@@ -6,6 +6,7 @@ import (
 	"cicv-data-closedloop/common/config/c_log"
 	commonEntity "cicv-data-closedloop/common/entity"
 	"cicv-data-closedloop/common/util"
+	"fmt"
 	"github.com/gin-gonic/gin"
 	"github.com/signintech/gopdf"
 	"io"
@@ -328,33 +329,217 @@ func Report(c *gin.Context) {
 	// 2 根据数据生成pdf
 	// 3 创建pdf文件
 	{
-		// 1 初始化 pdf 对象
+		// 初始化 pdf 对象
 		pdf := gopdf.GoPdf{}
 		pdf.Start(gopdf.Config{PageSize: *gopdf.PageSizeA4})
-
-		// 2 添加一页
-		pdf.AddPage()
-
-		// 3
-		err := pdf.AddTTFFont("simfang", "D:\\code\\cicv-data-closedloop\\test\\pdf\\ttf\\simfang.ttf")
+		// 添加字体文件到pdf
+		err := pdf.AddTTFFont("simfang", "D:\\code\\cicv-data-closedloop\\amd64\\web_server\\simfang.ttf")
 		if err != nil {
 			log.Print(err.Error())
 			return
 		}
 
-		err = pdf.SetFont("simfang", "", 14)
-		if err != nil {
-			log.Print(err.Error())
-			return
+		leftMargin := 70.0
+		topMargin := 100.0
+		lineHeight := 30.0
+		tableWidth := 400.0
+		pdf.SetLeftMargin(leftMargin) // 设置左边距
+
+		// ------- 封面页 -------
+		pdf.AddPage()
+		{
+			err = pdf.SetFont("simfang", "", 36)
+			if err != nil {
+				fmt.Print(err.Error())
+			}
+			err = pdf.Image("D:\\code\\cicv-data-closedloop\\amd64\\web_server\\background.png", 0, 0, nil) // 背景图片
+			if err != nil {
+				fmt.Print(err.Error())
+			}
+			err = pdf.Image("D:\\code\\cicv-data-closedloop\\amd64\\web_server\\logo.png", 20, 20, &gopdf.Rect{W: 320, H: 100})
+			if err != nil {
+				fmt.Print(err.Error())
+			}
+			{
+				pdf.SetXY(100, 250)
+				_ = pdf.Text("车路云一体化算法挑战赛")
+			}
+			{
+				pdf.SetXY(220, 315) // 200
+				_ = pdf.Text("评分报告")
+			}
+			_ = pdf.SetFont("simfang", "", 14)
+			{
+				pdf.SetXY(200, 525)
+				_ = pdf.Text("赛队编号:01")
+			}
+			{
+				pdf.SetXY(200, 545)
+				_ = pdf.Cell(nil, "评测车型:多功能车平台")
+			}
+			{
+				pdf.SetXY(200, 565)
+				_ = pdf.Cell(nil, "评测地点:天津生态城")
+			}
+			{
+				pdf.SetXY(200, 585)
+				_ = pdf.Cell(nil, "报告时间:2023年10月12日")
+			}
+			{
+				pdf.SetXY(165, 775)
+				_ = pdf.Cell(nil, "国汽(北京)智能网联汽车研究院有限公司")
+			}
 		}
-		err = pdf.Cell(nil, "您好")
-		if err != nil {
-			return
+		// ------- 目录页 -------
+		{
+			pdf.AddPage()
+			currentLine := 0.0
+			{
+				pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
+				currentLine++
+				err = pdf.Text("目录")
+			}
+			{
+				pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
+				currentLine++
+				err = pdf.Text("1. 总体情况\t22")
+			}
 		}
-		err = pdf.WritePdf("D:\\hello.pdf")
-		if err != nil {
-			return
+		// ------- 详情页 -------
+		{
+			pdf.AddPage()
+			currentLine := 0.0
+			// 1. 总体分数情况
+			{
+				{
+					pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
+					currentLine++
+					err = pdf.Text("1. 总体分数情况")
+				}
+				{
+					pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
+					currentLine++
+					err = pdf.Text("整体得分:")
+				}
+				{
+					pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
+					currentLine++
+					err = pdf.Text("线下得分:")
+				}
+				{
+					pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
+					currentLine++
+					err = pdf.Text("整体耗时:")
+				}
+			}
+			// 2. 分数详情
+			{
+				columnNumber := 4.0                         // 列数
+				tableCellWidth := tableWidth / columnNumber // 单元格宽度
+				{
+					pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
+					currentLine++
+					err = pdf.Cell(nil, "2. 分数详情")
+				}
+				// 分数详情表格
+				{
+					{
+						pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
+						err = pdf.Cell(nil, "序号")
+					}
+					{
+						pdf.SetXY(leftMargin+1.0*tableCellWidth, topMargin+currentLine*lineHeight)
+						err = pdf.Cell(nil, "场景名称")
+					}
+					{
+						pdf.SetXY(leftMargin+2.0*tableCellWidth, topMargin+currentLine*lineHeight)
+						err = pdf.Cell(nil, "线上得分")
+					}
+					{
+						pdf.SetXY(leftMargin+3.0*tableCellWidth, topMargin+currentLine*lineHeight)
+						err = pdf.Cell(nil, "线下得分")
+					}
+					currentLine++
+				}
+				{
+					{
+						pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
+						err = pdf.Cell(nil, "1")
+					}
+					{
+						pdf.SetXY(leftMargin+1.0*tableCellWidth, topMargin+currentLine*lineHeight)
+						err = pdf.Cell(nil, "xxx")
+					}
+					{
+						pdf.SetXY(leftMargin+2.0*tableCellWidth, topMargin+currentLine*lineHeight)
+						err = pdf.Cell(nil, "xxx")
+					}
+					{
+						pdf.SetXY(leftMargin+3.0*tableCellWidth, topMargin+currentLine*lineHeight)
+						err = pdf.Cell(nil, "xxx")
+					}
+					currentLine++
+				}
+			}
+			// 3. 线上扣分详情
+			{
+				columnNumber := 3.0                         // 列数
+				tableCellWidth := tableWidth / columnNumber // 单元格宽度
+				{
+					pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
+					currentLine++
+					err = pdf.Cell(nil, "3. 线上扣分详情")
+				}
+				// 场景1
+				{
+					{
+						pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
+						currentLine++
+						err = pdf.Cell(nil, "(1)xxxx场景")
+					}
+					// 场景1 表格
+					{
+						{
+							pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
+							err = pdf.Cell(nil, "序号")
+						}
+						{
+							pdf.SetXY(leftMargin+1.0*tableCellWidth, topMargin+currentLine*lineHeight)
+							err = pdf.Cell(nil, "扣分点")
+						}
+						{
+							pdf.SetXY(leftMargin+2.0*tableCellWidth, topMargin+currentLine*lineHeight)
+							err = pdf.Cell(nil, "扣分说明")
+						}
+						currentLine++
+					}
+					{
+						{
+							pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
+							err = pdf.Cell(nil, "1")
+						}
+						{
+							pdf.SetXY(leftMargin+1.0*tableCellWidth, topMargin+currentLine*lineHeight)
+							err = pdf.Cell(nil, "xxx")
+						}
+						{
+							pdf.SetXY(leftMargin+2.0*tableCellWidth, topMargin+currentLine*lineHeight)
+							err = pdf.Cell(nil, "xxx")
+						}
+						currentLine++
+					}
+				}
+			}
+		}
+		// ------- 附录页 -------
+		pdf.AddPage()
+		{
+			pdf.SetXY(leftMargin, topMargin)
+			_ = pdf.Text("附件:评分规则")
+			pdf.AddExternalLink("http://www.baidu.com/", 27.5, 28, 125, 15)
 		}
+		// 写入本地
+		pdf.WritePdf("D:\\hello.pdf")
 	}
 
 	// 打开要发送的文件

BIN
amd64/web_server/logo.png


BIN
amd64/web_server/simfang.ttf