|
@@ -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(¶m); 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
|