|
@@ -2,10 +2,12 @@ package handler
|
|
|
|
|
|
import (
|
|
import (
|
|
webServerEntity "cicv-data-closedloop/amd64/web_server/entity"
|
|
webServerEntity "cicv-data-closedloop/amd64/web_server/entity"
|
|
|
|
+ "cicv-data-closedloop/amd64/web_server/infra"
|
|
"cicv-data-closedloop/common/config/c_db"
|
|
"cicv-data-closedloop/common/config/c_db"
|
|
"cicv-data-closedloop/common/config/c_log"
|
|
"cicv-data-closedloop/common/config/c_log"
|
|
commonEntity "cicv-data-closedloop/common/entity"
|
|
commonEntity "cicv-data-closedloop/common/entity"
|
|
"cicv-data-closedloop/common/util"
|
|
"cicv-data-closedloop/common/util"
|
|
|
|
+ "encoding/json"
|
|
"fmt"
|
|
"fmt"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/signintech/gopdf"
|
|
"github.com/signintech/gopdf"
|
|
@@ -26,9 +28,8 @@ var (
|
|
heartBeatTimeThreshold = 5 * time.Second // 心跳时间
|
|
heartBeatTimeThreshold = 5 * time.Second // 心跳时间
|
|
InitialPositionX = 456292.00 // todo 需要比赛确认起点
|
|
InitialPositionX = 456292.00 // todo 需要比赛确认起点
|
|
InitialPositionY = 4397957.00 // todo 需要比赛确认起点
|
|
InitialPositionY = 4397957.00 // todo 需要比赛确认起点
|
|
- // todo 比赛阶段
|
|
|
|
- trialBegin = time.Date(2024, time.June, 16, 13, 00, 00, 0, time.Local)
|
|
|
|
- trialEnd = time.Date(2024, time.June, 19, 23, 59, 59, 0, time.Local)
|
|
|
|
|
|
+ trialBegin = time.Date(2024, time.June, 16, 13, 00, 00, 0, time.Local)
|
|
|
|
+ trialEnd = time.Date(2024, time.June, 19, 23, 59, 59, 0, time.Local)
|
|
)
|
|
)
|
|
|
|
|
|
// 考试心跳
|
|
// 考试心跳
|
|
@@ -280,7 +281,7 @@ func End(c *gin.Context) {
|
|
}
|
|
}
|
|
|
|
|
|
// 分页查询
|
|
// 分页查询
|
|
-// todo 如果日期为默认值,则返回空""
|
|
|
|
|
|
+// 如果日期为默认值,则返回空""
|
|
func Page(c *gin.Context) {
|
|
func Page(c *gin.Context) {
|
|
param := new(webServerEntity.ExamPagePao)
|
|
param := new(webServerEntity.ExamPagePao)
|
|
_ = c.ShouldBindJSON(¶m)
|
|
_ = c.ShouldBindJSON(¶m)
|
|
@@ -357,6 +358,31 @@ func Report(c *gin.Context) {
|
|
})
|
|
})
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ // 查询打分详情
|
|
|
|
+ var detailsResult []string
|
|
|
|
+ selectSql, err := util.ReadFile(c_db.SqlFilesMap["exam-select-details-by-id.sql"])
|
|
|
|
+ if err != nil {
|
|
|
|
+ c_log.GlobalLogger.Error("读取sql文件报错:", err)
|
|
|
|
+ c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
|
+ Code: 500,
|
|
|
|
+ Msg: "读取sql文件报错。",
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ // 可以传参数
|
|
|
|
+ if err = c_db.MysqlDb.Select(&detailsResult, selectSql, param.Id); err != nil {
|
|
|
|
+ c_log.GlobalLogger.Error("数据库查询报错:", err)
|
|
|
|
+ c.JSON(http.StatusBadRequest, commonEntity.Response{
|
|
|
|
+ Code: 500,
|
|
|
|
+ Msg: "数据库查询报错。",
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ details := detailsResult[0]
|
|
|
|
+ // 解析详情为数组
|
|
|
|
+ var detailsDtos []webServerEntity.DetailsDto
|
|
|
|
+ _ = json.Unmarshal([]byte(details), &detailsDtos)
|
|
|
|
+
|
|
layout := "2006-01-02 15:04:05"
|
|
layout := "2006-01-02 15:04:05"
|
|
beginTime, _ := time.Parse(layout, param.BeginTime)
|
|
beginTime, _ := time.Parse(layout, param.BeginTime)
|
|
endTime, _ := time.Parse(layout, param.EndTime)
|
|
endTime, _ := time.Parse(layout, param.EndTime)
|
|
@@ -368,7 +394,7 @@ func Report(c *gin.Context) {
|
|
pdf := gopdf.GoPdf{}
|
|
pdf := gopdf.GoPdf{}
|
|
pdf.Start(gopdf.Config{PageSize: *gopdf.PageSizeA4})
|
|
pdf.Start(gopdf.Config{PageSize: *gopdf.PageSizeA4})
|
|
// 添加字体文件到pdf
|
|
// 添加字体文件到pdf
|
|
- err := pdf.AddTTFFont("simfang", "D:\\code\\cicv-data-closedloop\\amd64\\web_server\\simfang.ttf")
|
|
|
|
|
|
+ err := pdf.AddTTFFont("simfang", infra.ApplicationYaml.Pdf.Ttf)
|
|
if err != nil {
|
|
if err != nil {
|
|
log.Print(err.Error())
|
|
log.Print(err.Error())
|
|
return
|
|
return
|
|
@@ -388,8 +414,8 @@ func Report(c *gin.Context) {
|
|
pdf.AddPage()
|
|
pdf.AddPage()
|
|
{
|
|
{
|
|
err = pdf.SetFont("simfang", "", 36)
|
|
err = pdf.SetFont("simfang", "", 36)
|
|
- err = pdf.Image("D:\\code\\cicv-data-closedloop\\amd64\\web_server\\background.png", 0, 0, nil) // 背景图片
|
|
|
|
- err = pdf.Image("D:\\code\\cicv-data-closedloop\\amd64\\web_server\\logo.png", 20, 20, &gopdf.Rect{W: 320, H: 100})
|
|
|
|
|
|
+ err = pdf.Image(infra.ApplicationYaml.Pdf.BackgroundPng, 0, 0, nil) // 背景图片
|
|
|
|
+ err = pdf.Image(infra.ApplicationYaml.Pdf.LogoPng, 20, 20, &gopdf.Rect{W: 320, H: 100})
|
|
{
|
|
{
|
|
pdf.SetXY(100, 250)
|
|
pdf.SetXY(100, 250)
|
|
_ = pdf.Text("车路云一体化算法挑战赛")
|
|
_ = pdf.Text("车路云一体化算法挑战赛")
|
|
@@ -505,8 +531,11 @@ func Report(c *gin.Context) {
|
|
}
|
|
}
|
|
// 2. 分数详情
|
|
// 2. 分数详情
|
|
{
|
|
{
|
|
- columnNumber := 4.0 // 列数
|
|
|
|
- tableCellWidth := tableWidth / columnNumber // 单元格宽度
|
|
|
|
|
|
+ //columnNumber := 4.0 // 列数
|
|
|
|
+ //tableCellWidth := tableWidth / columnNumber // 单元格宽度
|
|
|
|
+ tableCellWidth1 := 50.0
|
|
|
|
+ tableCellWidth2 := 300.0
|
|
|
|
+ tableCellWidth3 := 70.0
|
|
{
|
|
{
|
|
pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
_ = pdf.CellWithOption(&gopdf.Rect{W: tableWidth, H: lineHeight}, "2. 分数详情", alignOptionText)
|
|
_ = pdf.CellWithOption(&gopdf.Rect{W: tableWidth, H: lineHeight}, "2. 分数详情", alignOptionText)
|
|
@@ -516,39 +545,31 @@ func Report(c *gin.Context) {
|
|
{
|
|
{
|
|
{
|
|
{
|
|
pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
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.CellWithOption(&gopdf.Rect{W: tableCellWidth1, H: lineHeight}, "序号", alignOptionTable)
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- pdf.SetXY(leftMargin+2.0*tableCellWidth, topMargin+currentLine*lineHeight)
|
|
|
|
- _ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "线上得分", alignOptionTable)
|
|
|
|
|
|
+ pdf.SetXY(leftMargin+tableCellWidth1, topMargin+currentLine*lineHeight)
|
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth2, H: lineHeight}, "场景名称", alignOptionTable)
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- pdf.SetXY(leftMargin+3.0*tableCellWidth, topMargin+currentLine*lineHeight)
|
|
|
|
- _ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "线下得分", alignOptionTable)
|
|
|
|
|
|
+ pdf.SetXY(leftMargin+tableCellWidth1+tableCellWidth2, topMargin+currentLine*lineHeight)
|
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth3, H: lineHeight}, "线上得分", alignOptionTable)
|
|
}
|
|
}
|
|
currentLine++
|
|
currentLine++
|
|
}
|
|
}
|
|
- for i := 0; i < 10; i++ {
|
|
|
|
|
|
+ for i := 0; i < len(detailsDtos); i++ {
|
|
{
|
|
{
|
|
{
|
|
{
|
|
pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
- _ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, util.ToString(i+1), alignOptionTable)
|
|
|
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth1, H: lineHeight}, util.ToString(i+1), alignOptionTable)
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- pdf.SetXY(leftMargin+1.0*tableCellWidth, topMargin+currentLine*lineHeight)
|
|
|
|
- _ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "xxx", alignOptionTable)
|
|
|
|
|
|
+ pdf.SetXY(leftMargin+tableCellWidth1, topMargin+currentLine*lineHeight)
|
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth2, H: lineHeight}, detailsDtos[i].SceneName, alignOptionTable)
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- pdf.SetXY(leftMargin+2.0*tableCellWidth, topMargin+currentLine*lineHeight)
|
|
|
|
- _ = 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)
|
|
|
|
|
|
+ pdf.SetXY(leftMargin+tableCellWidth1+tableCellWidth2, topMargin+currentLine*lineHeight)
|
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth3, H: lineHeight}, util.ToString(detailsDtos[i].TotalScore+detailsDtos[i].DeductedScore), alignOptionTable)
|
|
}
|
|
}
|
|
currentLine++
|
|
currentLine++
|
|
}
|
|
}
|
|
@@ -557,66 +578,82 @@ func Report(c *gin.Context) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// ------- 详情页 第二页 -------
|
|
// ------- 详情页 第二页 -------
|
|
|
|
+ var detailsDtos2 []webServerEntity.DetailsDto // 扣分的场景
|
|
|
|
+ for _, detailsDto := range detailsDtos {
|
|
|
|
+ if detailsDto.Reason != "" {
|
|
|
|
+ detailsDtos2 = append(detailsDtos2, detailsDto)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ size := len(detailsDtos2)
|
|
{
|
|
{
|
|
pdf.AddPage()
|
|
pdf.AddPage()
|
|
currentLine := 0.0
|
|
currentLine := 0.0
|
|
// 3. 线上扣分详情
|
|
// 3. 线上扣分详情
|
|
{
|
|
{
|
|
- columnNumber := 3.0 // 列数
|
|
|
|
- tableCellWidth := tableWidth / columnNumber // 单元格宽度
|
|
|
|
|
|
+ //columnNumber := 3.0 // 列数
|
|
|
|
+ //tableCellWidth := tableWidth / columnNumber // 单元格宽度
|
|
|
|
+ tableCellWidth := 450.0 // 单元格宽度
|
|
{
|
|
{
|
|
pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
_ = pdf.CellWithOption(&gopdf.Rect{W: tableWidth, H: lineHeight}, "3. 线上扣分详情", alignOptionText)
|
|
_ = pdf.CellWithOption(&gopdf.Rect{W: tableWidth, H: lineHeight}, "3. 线上扣分详情", alignOptionText)
|
|
currentLine++
|
|
currentLine++
|
|
}
|
|
}
|
|
- for i := 0; i < 5; i++ {
|
|
|
|
|
|
+ for i := 0; i < 8; i++ {
|
|
// 场景1
|
|
// 场景1
|
|
{
|
|
{
|
|
{
|
|
{
|
|
pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
- _ = pdf.CellWithOption(&gopdf.Rect{W: tableWidth, H: lineHeight}, "("+util.ToString(i+1)+")xxxx场景", alignOptionText)
|
|
|
|
|
|
+ _ = pdf.CellWithOption(&gopdf.Rect{W: tableWidth, H: lineHeight}, "("+util.ToString(i+1)+")"+detailsDtos2[i].SceneName, alignOptionText)
|
|
currentLine++
|
|
currentLine++
|
|
}
|
|
}
|
|
// 场景1 表格
|
|
// 场景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.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)
|
|
_ = pdf.CellWithOption(&gopdf.Rect{W: tableCellWidth, H: lineHeight}, "扣分说明", alignOptionTable)
|
|
}
|
|
}
|
|
currentLine++
|
|
currentLine++
|
|
}
|
|
}
|
|
- for j := 0; j < 2; j++ {
|
|
|
|
|
|
+ //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}, 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++
|
|
}
|
|
}
|
|
|
|
+ //}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //if size <= 8 {
|
|
|
|
+ // // 4 作品优化建议
|
|
|
|
+ // {
|
|
|
|
+ // pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
|
|
+ // _ = pdf.CellWithOption(&gopdf.Rect{W: tableWidth, H: lineHeight}, "4. 作品优化建议", alignOptionText)
|
|
|
|
+ // currentLine++
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
}
|
|
}
|
|
// ------- 详情页 第三页 -------
|
|
// ------- 详情页 第三页 -------
|
|
- size := 10
|
|
|
|
- if size > 5 {
|
|
|
|
|
|
+
|
|
|
|
+ if size > 8 {
|
|
pdf.AddPage()
|
|
pdf.AddPage()
|
|
currentLine := 0.0
|
|
currentLine := 0.0
|
|
// 3. 线上扣分详情
|
|
// 3. 线上扣分详情
|
|
@@ -667,22 +704,22 @@ func Report(c *gin.Context) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // 4 作品优化建议
|
|
|
|
- {
|
|
|
|
- pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
|
|
- _ = pdf.CellWithOption(&gopdf.Rect{W: tableWidth, H: lineHeight}, "4. 作品优化建议", alignOptionText)
|
|
|
|
- currentLine++
|
|
|
|
- }
|
|
|
|
|
|
+ //// 4 作品优化建议
|
|
|
|
+ //{
|
|
|
|
+ // pdf.SetXY(leftMargin, topMargin+currentLine*lineHeight)
|
|
|
|
+ // _ = pdf.CellWithOption(&gopdf.Rect{W: tableWidth, H: lineHeight}, "4. 作品优化建议", alignOptionText)
|
|
|
|
+ // currentLine++
|
|
|
|
+ //}
|
|
}
|
|
}
|
|
- // ------- 附录页 -------
|
|
|
|
- pdf.AddPage()
|
|
|
|
- {
|
|
|
|
- pdf.SetXY(leftMargin, topMargin)
|
|
|
|
- _ = pdf.Text("附件:评分规则")
|
|
|
|
- pdf.AddExternalLink("https://www.baidu.com/", leftMargin, topMargin-lineHeight, 6*14, lineHeight)
|
|
|
|
- }
|
|
|
|
- // 写入本地
|
|
|
|
- pdf.WritePdf("D:\\hello.pdf")
|
|
|
|
|
|
+ //// ------- 附录页 -------
|
|
|
|
+ //pdf.AddPage()
|
|
|
|
+ //{
|
|
|
|
+ // pdf.SetXY(leftMargin, topMargin)
|
|
|
|
+ // _ = pdf.Text("附件:评分规则")
|
|
|
|
+ // pdf.AddExternalLink("https://www.baidu.com/", leftMargin, topMargin-lineHeight, 6*14, lineHeight)
|
|
|
|
+ //}
|
|
|
|
+ //// 写入本地
|
|
|
|
+ //pdf.WritePdf("D:\\hello.pdf")
|
|
}
|
|
}
|
|
|
|
|
|
// 打开要发送的文件
|
|
// 打开要发送的文件
|