Browse Source

update:优化排版

zoie 3 months ago
parent
commit
d969e253d1
1 changed files with 9 additions and 9 deletions
  1. 9 9
      controllers/TaskData.go

+ 9 - 9
controllers/TaskData.go

@@ -179,7 +179,7 @@ func (c *TaskDataController) TaskData_Pdf(Time_start, Time_end, T_task_id, T_sni
 			if idw > 20 {
 				idWidthMap[sn_id[1]] = idw + 12
 			} else {
-				idWidthMap[sn_id[1]] = 30
+				idWidthMap[sn_id[1]] = 30.3
 			}
 			sort.Slice(List, func(i, j int) bool {
 				return List[i].T_time < List[j].T_time
@@ -363,13 +363,13 @@ func (c *TaskDataController) TaskData_Pdf(Time_start, Time_end, T_task_id, T_sni
 	sort.Slice(T_snid_list2, func(i, j int) bool {
 		return extractSecondElement(T_snid_list2[i]) < extractSecondElement(T_snid_list2[j])
 	})
-	chunks := splitData(T_snid_list2, 450, idWidthMap)
+	chunks := splitData(T_snid_list2, 454.5, idWidthMap)
 	for _, list := range chunks {
 		x = 10
-		w = 120
+		w = 120.7
 		lib.RectFillColor(pdf, "时间", 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
 		x += w
-		w = 30
+		w = 30.3
 		for _, v2 := range list {
 			sn_id2 := strings.Split(v2, ",")
 			id2 := sn_id2[1]
@@ -385,10 +385,10 @@ func (c *TaskDataController) TaskData_Pdf(Time_start, Time_end, T_task_id, T_sni
 			pdf.SetNewY(y, textH)
 			y = pdf.GetY()
 			if y == 20 {
-				w = 120
+				w = 120.7
 				lib.RectFillColor(pdf, "时间", 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
 				x += w
-				w = 30
+				w = 30.3
 				for _, v2 := range list {
 					sn_id2 := strings.Split(v2, ",")
 					id2 := sn_id2[1]
@@ -399,10 +399,10 @@ func (c *TaskDataController) TaskData_Pdf(Time_start, Time_end, T_task_id, T_sni
 				y += 20
 				x = 10
 			}
-			w = 120
+			w = 120.7
 			lib.RectFillColor(pdf, t, 12, x, y, w, 20, 255, 255, 255, lib.AlignCenter, lib.ValignMiddle)
 			x += w
-			w = 30
+			w = 30.3
 			for _, v := range list {
 				sn_id := strings.Split(v, ",")
 				id := sn_id[1]
@@ -457,7 +457,7 @@ func splitData(data []string, threshold float64, idWidthMap map[string]float64)
 		sn_id := strings.Split(item, ",")
 		if len(sn_id) == 2 {
 			wd := idWidthMap[sn_id[1]]
-			if currentSum+wd > threshold {
+			if currentSum+wd > threshold+0.1 {
 				// 当前批次超过阈值,切分
 				result = append(result, currentBatch)
 				// 重置当前批次和当前总和