|
@@ -6,7 +6,6 @@ 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"
|
|
@@ -341,25 +340,20 @@ func Report(c *gin.Context) {
|
|
|
|
|
|
leftMargin := 70.0
|
|
|
topMargin := 100.0
|
|
|
- lineHeight := 30.0
|
|
|
- tableWidth := 400.0
|
|
|
+ lineHeight := 25.0
|
|
|
+ tableWidth := 450.0
|
|
|
+ paragraphSpacing := 10.0
|
|
|
pdf.SetLeftMargin(leftMargin)
|
|
|
+
|
|
|
+
|
|
|
+ alignOptionTable := gopdf.CellOption{Align: gopdf.Center | gopdf.Middle, Border: gopdf.Left | gopdf.Right | gopdf.Bottom | gopdf.Top}
|
|
|
|
|
|
|
|
|
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("车路云一体化算法挑战赛")
|
|
@@ -390,22 +384,26 @@ func Report(c *gin.Context) {
|
|
|
_ = pdf.Cell(nil, "国汽(北京)智能网联汽车研究院有限公司")
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- {
|
|
|
- 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")
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
{
|
|
|
pdf.AddPage()
|
|
|
currentLine := 0.0
|
|
@@ -419,17 +417,22 @@ func Report(c *gin.Context) {
|
|
|
{
|
|
|
pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
|
currentLine++
|
|
|
- err = pdf.Text("整体得分:")
|
|
|
+ _ = pdf.Text("整体得分:")
|
|
|
+ }
|
|
|
+ {
|
|
|
+ pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
|
+ currentLine++
|
|
|
+ _ = pdf.Text("线上得分:")
|
|
|
}
|
|
|
{
|
|
|
pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
|
currentLine++
|
|
|
- err = pdf.Text("线下得分:")
|
|
|
+ _ = pdf.Text("线下得分:")
|
|
|
}
|
|
|
{
|
|
|
pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
|
currentLine++
|
|
|
- err = pdf.Text("整体耗时:")
|
|
|
+ _ = pdf.Text("整体耗时:")
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -437,106 +440,119 @@ func Report(c *gin.Context) {
|
|
|
columnNumber := 4.0
|
|
|
tableCellWidth := tableWidth / columnNumber
|
|
|
{
|
|
|
- pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
|
+ pdf.SetXY(leftMargin, paragraphSpacing+topMargin+currentLine*lineHeight)
|
|
|
currentLine++
|
|
|
- err = pdf.Cell(nil, "2. 分数详情")
|
|
|
+ _ = pdf.Cell(nil, "2. 分数详情")
|
|
|
}
|
|
|
|
|
|
{
|
|
|
{
|
|
|
pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
|
- err = pdf.Cell(nil, "序号")
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "序号", alignOptionTable)
|
|
|
}
|
|
|
{
|
|
|
pdf.SetXY(leftMargin+1.0*tableCellWidth, topMargin+currentLine*lineHeight)
|
|
|
- err = pdf.Cell(nil, "场景名称")
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "场景名称", alignOptionTable)
|
|
|
}
|
|
|
{
|
|
|
pdf.SetXY(leftMargin+2.0*tableCellWidth, topMargin+currentLine*lineHeight)
|
|
|
- err = pdf.Cell(nil, "线上得分")
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "线上得分", alignOptionTable)
|
|
|
}
|
|
|
{
|
|
|
pdf.SetXY(leftMargin+3.0*tableCellWidth, topMargin+currentLine*lineHeight)
|
|
|
- err = pdf.Cell(nil, "线下得分")
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "线下得分", alignOptionTable)
|
|
|
}
|
|
|
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++
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- {
|
|
|
- columnNumber := 3.0
|
|
|
- tableCellWidth := tableWidth / columnNumber
|
|
|
- {
|
|
|
- pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
|
- currentLine++
|
|
|
- err = pdf.Cell(nil, "3. 线上扣分详情")
|
|
|
- }
|
|
|
-
|
|
|
- {
|
|
|
- {
|
|
|
- pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
|
- currentLine++
|
|
|
- err = pdf.Cell(nil, "(1)xxxx场景")
|
|
|
- }
|
|
|
-
|
|
|
+ for i := 0; i < 10; i++ {
|
|
|
{
|
|
|
{
|
|
|
pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
|
- err = pdf.Cell(nil, "序号")
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, util.ToString(i+1), alignOptionTable)
|
|
|
}
|
|
|
{
|
|
|
pdf.SetXY(leftMargin+1.0*tableCellWidth, topMargin+currentLine*lineHeight)
|
|
|
- err = pdf.Cell(nil, "扣分点")
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "xxx", alignOptionTable)
|
|
|
}
|
|
|
{
|
|
|
pdf.SetXY(leftMargin+2.0*tableCellWidth, topMargin+currentLine*lineHeight)
|
|
|
- err = pdf.Cell(nil, "扣分说明")
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "xxx", alignOptionTable)
|
|
|
+ }
|
|
|
+ {
|
|
|
+ pdf.SetXY(leftMargin+3.0*tableCellWidth, topMargin+currentLine*lineHeight)
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "xxx", alignOptionTable)
|
|
|
}
|
|
|
currentLine++
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ {
|
|
|
+ columnNumber := 3.0
|
|
|
+ tableCellWidth := tableWidth / columnNumber
|
|
|
+ {
|
|
|
+ pdf.SetXY(leftMargin, paragraphSpacing+topMargin+currentLine*lineHeight)
|
|
|
+ currentLine++
|
|
|
+ err = pdf.Cell(nil, "3. 线上扣分详情")
|
|
|
+ }
|
|
|
+ for i := 0; i < 10; i++ {
|
|
|
+
|
|
|
{
|
|
|
{
|
|
|
pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
|
- err = pdf.Cell(nil, "1")
|
|
|
+ currentLine++
|
|
|
+ err = pdf.Cell(nil, "("+util.ToString(i+1)+")xxxx场景")
|
|
|
}
|
|
|
+
|
|
|
{
|
|
|
- pdf.SetXY(leftMargin+1.0*tableCellWidth, topMargin+currentLine*lineHeight)
|
|
|
- err = pdf.Cell(nil, "xxx")
|
|
|
+ {
|
|
|
+ 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++
|
|
|
}
|
|
|
- {
|
|
|
- pdf.SetXY(leftMargin+2.0*tableCellWidth, topMargin+currentLine*lineHeight)
|
|
|
- err = pdf.Cell(nil, "xxx")
|
|
|
+ for j := 0; j < 4; 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++
|
|
|
+ }
|
|
|
}
|
|
|
- currentLine++
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ {
|
|
|
+ pdf.SetXY(leftMargin, paragraphSpacing+topMargin+currentLine*lineHeight)
|
|
|
+ currentLine++
|
|
|
+ err = pdf.Cell(nil, "4. 作品优化建议")
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
pdf.AddPage()
|
|
|
{
|
|
|
pdf.SetXY(leftMargin, topMargin)
|
|
|
_ = pdf.Text("附件:评分规则")
|
|
|
- pdf.AddExternalLink("http://www.baidu.com/", 27.5, 28, 125, 15)
|
|
|
+ pdf.AddExternalLink("https://www.baidu.com/", leftMargin, topMargin-lineHeight, 6*14, lineHeight)
|
|
|
}
|
|
|
|
|
|
pdf.WritePdf("D:\\hello.pdf")
|