|
|
@@ -904,6 +904,33 @@ func (c *EvaLogController) Export() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ if courseRunLog.CourseTime == 0 {
|
|
|
+ // 课程正在进行中,计算运行时间并返回详细信息
|
|
|
+ startTime, err := time.ParseInLocation("2006-01-02 15:04:05", courseRunLog.RunDateTime, time.Local)
|
|
|
+ if err != nil {
|
|
|
+ c.Data["json"] = map[string]interface{}{
|
|
|
+ "code": 500,
|
|
|
+ "msg": "解析课程开始时间失败: " + err.Error(),
|
|
|
+ "data": map[string]interface{}{
|
|
|
+ "runStatus": 0,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取当前时间
|
|
|
+ now := time.Now()
|
|
|
+
|
|
|
+ fmt.Printf("目标时间: %v\n", startTime)
|
|
|
+ fmt.Printf("当前时间: %v\n", now)
|
|
|
+
|
|
|
+ // 计算时间差(秒)
|
|
|
+ diff := int(now.Sub(startTime).Seconds()) - courseRunLog.PauseTotalTime
|
|
|
+ courseRunLog.CourseTime = diff
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
// 创建角色ID到角色名称的映射
|
|
|
roleMap := make(map[int]string)
|
|
|
for _, role := range roleInfos {
|
|
|
@@ -922,7 +949,7 @@ func (c *EvaLogController) Export() {
|
|
|
pdf.AddPage()
|
|
|
|
|
|
// 标题
|
|
|
- pdf.CellFormat(277, 10, "课程评价记录报告", "0", 0, "C", false, 0, "")
|
|
|
+ pdf.CellFormat(277, 10, "课程电子考评表", "0", 0, "C", false, 0, "")
|
|
|
pdf.Ln(15)
|
|
|
|
|
|
pdf.SetFont("NotoSansSC", "B", 12)
|
|
|
@@ -932,15 +959,15 @@ func (c *EvaLogController) Export() {
|
|
|
pdf.Ln(8)
|
|
|
|
|
|
pdf.SetFont("NotoSansSC", "B", 12)
|
|
|
- pdf.CellFormat(40, 7, "运行日期时间:", "0", 0, "", false, 0, "")
|
|
|
+ pdf.CellFormat(40, 7, "开课时间:", "0", 0, "", false, 0, "")
|
|
|
pdf.SetFont("NotoSansSC", "", 12)
|
|
|
pdf.CellFormat(50, 7, courseRunLog.RunDateTime, "0", 0, "", false, 0, "")
|
|
|
pdf.Ln(8)
|
|
|
|
|
|
pdf.SetFont("NotoSansSC", "B", 12)
|
|
|
- pdf.CellFormat(40, 7, "课程用时(秒):", "0", 0, "", false, 0, "")
|
|
|
+ pdf.CellFormat(40, 7, "课程用时:", "0", 0, "", false, 0, "")
|
|
|
pdf.SetFont("NotoSansSC", "", 12)
|
|
|
- pdf.CellFormat(50, 7, fmt.Sprintf("%d", courseRunLog.CourseTime), "0", 0, "", false, 0, "")
|
|
|
+ pdf.CellFormat(50, 7, formatSecondsToHMS(courseRunLog.CourseTime), "0", 0, "", false, 0, "")
|
|
|
pdf.Ln(8)
|
|
|
|
|
|
pdf.SetFont("NotoSansSC", "B", 12)
|
|
|
@@ -1021,8 +1048,7 @@ func (c *EvaLogController) Export() {
|
|
|
// 获取当前Y位置
|
|
|
y := pdf.GetY()
|
|
|
|
|
|
- // 计算评价名称所需的高度(支持自动换行)
|
|
|
- lines := pdf.SplitLines([]byte(evaLog.EvaName), colWidths[3])
|
|
|
+ lines := pdf.SplitText(evaLog.EvaName, colWidths[3])
|
|
|
cellHeight := float64(len(lines)) * 6
|
|
|
if cellHeight < 6 {
|
|
|
cellHeight = 6
|
|
|
@@ -1145,3 +1171,11 @@ func getColX(colWidths []float64, colIndex int) float64 {
|
|
|
}
|
|
|
return x
|
|
|
}
|
|
|
+
|
|
|
+// 将秒数格式化为 HH:MM:SS 格式
|
|
|
+func formatSecondsToHMS(seconds int) string {
|
|
|
+ hours := seconds / 3600
|
|
|
+ minutes := (seconds % 3600) / 60
|
|
|
+ secs := seconds % 60
|
|
|
+ return fmt.Sprintf("%02d:%02d:%02d", hours, minutes, secs)
|
|
|
+}
|