Browse Source

定时任务批量更新

xyxie 1 week ago
parent
commit
7384e9f639
1 changed files with 6 additions and 3 deletions
  1. 6 3
      services/chart_info.go

+ 6 - 3
services/chart_info.go

@@ -382,8 +382,13 @@ func ChartInfoSaveBatch() (err error) {
 	pageSize := 100
 	success := 0
 
+	// 计算需要分多少页
+	pageNum := total / pageSize
+	if total % pageSize != 0 {
+		pageNum += 1
+	}
 	// 循环更新100个图表数据
-	for i := 0; offset < total; i++ {
+	for i := 0; i < pageNum; i++ {
 		// 查询需要更新的图表信息
 		chartInfos, e := models.GetChartInfoListByCondition(condition, []interface{}{chartClassifyIdList}, offset, pageSize)
 		if e != nil {
@@ -407,8 +412,6 @@ func ChartInfoSaveBatch() (err error) {
 			}
 			success += 1
 		}
-
-		offset += pageSize
 	}
 	utils.FileLog.Info("上传图表数据完成, 上传图表数据总数:", success)