浏览代码

钢联数据分批插入

xyxie 1 年之前
父节点
当前提交
b444ce7647
共有 1 个文件被更改,包括 34 次插入0 次删除
  1. 34 0
      services/edb_info_stat.go

+ 34 - 0
services/edb_info_stat.go

@@ -220,6 +220,23 @@ func SetMysteelChemicalEdbInfoUpdateStat(needStat bool) (err error) {
 				tmp.CreateTime = nowTime
 				addList = append(addList, tmp)
 			}
+			if len(addList) >= 500 {
+				err = logStat.Add(addList)
+				if err != nil {
+					err = fmt.Errorf("新增钢联化工明细记录报错,err: %s", err)
+					return
+				}
+				addList = addList[:0]
+			}
+
+			if len(modifyList) >= 500 {
+				err = data_stat.UpdateEdbUpdateStatMulti(modifyList)
+				if err != nil {
+					err = fmt.Errorf("更新钢联化工明细记录报错,err: %s", err)
+					return
+				}
+				modifyList = modifyList[:0]
+			}
 		}
 	}
 
@@ -371,6 +388,23 @@ func SetEdbSourceStat(needStat bool) (err error) {
 			tmp.CreateTime = nowTime
 			addList = append(addList, tmp)
 		}
+		if len(addList) >= 500 {
+			err = logStat.Add(addList)
+			if err != nil {
+				err = fmt.Errorf("新增钢联化工统计表报错,err: %s", err)
+				return
+			}
+			addList = addList[:0]
+		}
+
+		if len(modifyList) >= 500 {
+			err = data_stat.UpdateEdbSourceStatMulti(modifyList)
+			if err != nil {
+				err = fmt.Errorf("更新钢联化工统计表报错,err: %s", err)
+				return
+			}
+			modifyList = modifyList[:0]
+		}
 	}
 
 	//判断当日指标统计数据是否存在,如果存在则更新,不存在则新增