|
@@ -314,16 +314,16 @@ func Page(c *gin.Context) {
|
|
|
|
|
|
// 评分报告pdf下载
|
|
// 评分报告pdf下载
|
|
func Report(c *gin.Context) {
|
|
func Report(c *gin.Context) {
|
|
- //param := new(webServerEntity.ExamReportPao)
|
|
|
|
- //// 映射到结构体
|
|
|
|
- //if err := c.ShouldBindJSON(¶m); err != nil {
|
|
|
|
- // c_log.GlobalLogger.Error("项目启动接收请求参数报错:", err)
|
|
|
|
- // c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
|
- // Code: 500,
|
|
|
|
- // Msg: "请求体解析失败。",
|
|
|
|
- // })
|
|
|
|
- // return
|
|
|
|
- //}
|
|
|
|
|
|
+ param := new(webServerEntity.ExamReportPao)
|
|
|
|
+ // 映射到结构体
|
|
|
|
+ if err := c.ShouldBindJSON(¶m); err != nil {
|
|
|
|
+ c_log.GlobalLogger.Error("项目启动接收请求参数报错:", err)
|
|
|
|
+ c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
|
+ Code: 500,
|
|
|
|
+ Msg: "请求体解析失败。",
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
// 1 根据ID查询数据
|
|
// 1 根据ID查询数据
|
|
// 2 根据数据生成pdf
|
|
// 2 根据数据生成pdf
|
|
// 3 创建pdf文件
|
|
// 3 创建pdf文件
|
|
@@ -347,6 +347,7 @@ func Report(c *gin.Context) {
|
|
//alignOptionText := gopdf.CellOption{Align: gopdf.Left | gopdf.Middle}
|
|
//alignOptionText := gopdf.CellOption{Align: gopdf.Left | gopdf.Middle}
|
|
//alignOptionText2 := gopdf.CellOption{Align: gopdf.Center | gopdf.Middle}
|
|
//alignOptionText2 := gopdf.CellOption{Align: gopdf.Center | gopdf.Middle}
|
|
alignOptionTable := gopdf.CellOption{Align: gopdf.Center | gopdf.Middle, Border: gopdf.Left | gopdf.Right | gopdf.Bottom | gopdf.Top}
|
|
alignOptionTable := gopdf.CellOption{Align: gopdf.Center | gopdf.Middle, Border: gopdf.Left | gopdf.Right | gopdf.Bottom | gopdf.Top}
|
|
|
|
+ alignOptionTable2 := gopdf.CellOption{Align: gopdf.Left | gopdf.Middle}
|
|
|
|
|
|
// ------- 封面页 -------
|
|
// ------- 封面页 -------
|
|
pdf.AddPage()
|
|
pdf.AddPage()
|
|
@@ -363,21 +364,53 @@ func Report(c *gin.Context) {
|
|
_ = pdf.Text("评分报告")
|
|
_ = pdf.Text("评分报告")
|
|
}
|
|
}
|
|
_ = pdf.SetFont("simfang", "", 14)
|
|
_ = pdf.SetFont("simfang", "", 14)
|
|
|
|
+ currentLine := 0.0
|
|
|
|
+ tableCellWidth := 100.0
|
|
|
|
+ tableLeftMartin := 190.0
|
|
|
|
+ tableTopMartin := 500.0
|
|
{
|
|
{
|
|
- pdf.SetXY(200, 525)
|
|
|
|
- _ = pdf.Text("赛队编号:01")
|
|
|
|
|
|
+ {
|
|
|
|
+ pdf.SetXY(tableLeftMartin, tableTopMartin+currentLine*lineHeight)
|
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: 100, H: lineHeight}, "赛队编号:", alignOptionTable2)
|
|
|
|
+ }
|
|
|
|
+ {
|
|
|
|
+ pdf.SetXY(tableLeftMartin+1.0*tableCellWidth, tableTopMartin+currentLine*lineHeight)
|
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: 100, H: lineHeight}, param.TeamName, alignOptionTable2)
|
|
|
|
+ }
|
|
|
|
+ currentLine++
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- pdf.SetXY(200, 545)
|
|
|
|
- _ = pdf.Cell(nil, "评测车型:多功能车平台")
|
|
|
|
|
|
+ {
|
|
|
|
+ pdf.SetXY(tableLeftMartin, tableTopMartin+currentLine*lineHeight)
|
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: 100, H: lineHeight}, "评测车型:", alignOptionTable2)
|
|
|
|
+ }
|
|
|
|
+ {
|
|
|
|
+ pdf.SetXY(tableLeftMartin+1.0*tableCellWidth, tableTopMartin+currentLine*lineHeight)
|
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: 100, H: lineHeight}, "多功能车平台", alignOptionTable2)
|
|
|
|
+ }
|
|
|
|
+ currentLine++
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- pdf.SetXY(200, 565)
|
|
|
|
- _ = pdf.Cell(nil, "评测地点:天津生态城")
|
|
|
|
|
|
+ {
|
|
|
|
+ pdf.SetXY(tableLeftMartin, tableTopMartin+currentLine*lineHeight)
|
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: 100, H: lineHeight}, "评测地点:", alignOptionTable2)
|
|
|
|
+ }
|
|
|
|
+ {
|
|
|
|
+ pdf.SetXY(tableLeftMartin+1.0*tableCellWidth, tableTopMartin+currentLine*lineHeight)
|
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: 100, H: lineHeight}, "天津生态城", alignOptionTable2)
|
|
|
|
+ }
|
|
|
|
+ currentLine++
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- pdf.SetXY(200, 585)
|
|
|
|
- _ = pdf.Cell(nil, "报告时间:2023年10月12日")
|
|
|
|
|
|
+ {
|
|
|
|
+ pdf.SetXY(tableLeftMartin, tableTopMartin+currentLine*lineHeight)
|
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: 100, H: lineHeight}, "报告时间:", alignOptionTable2)
|
|
|
|
+ }
|
|
|
|
+ {
|
|
|
|
+ pdf.SetXY(tableLeftMartin+1.0*tableCellWidth, tableTopMartin+currentLine*lineHeight)
|
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: 100, H: lineHeight}, time.Now().Format("2006年01月02日"), alignOptionTable2)
|
|
|
|
+ }
|
|
|
|
+ currentLine++
|
|
}
|
|
}
|
|
{
|
|
{
|
|
pdf.SetXY(165, 775)
|
|
pdf.SetXY(165, 775)
|