Преглед изворни кода

编码扩充 - 200行插入一次

yuedefeng пре 5 година
родитељ
комит
2602070114
1 измењених фајлова са 13 додато и 2 уклоњено
  1. 13 2
      src/dashoo.cn/backend/api/controllers/tmpzcgf/tmpzcgf.go

+ 13 - 2
src/dashoo.cn/backend/api/controllers/tmpzcgf/tmpzcgf.go

@@ -680,7 +680,8 @@ func (this *TmpzcgfController) CapacityExpansion() {
 		svc.GetEntities(&goodsAptitudeClassList, whereclass)
 
 		// 扩充的编码
-		for _, goodsAptitudeClass := range goodsAptitudeClassList {
+		var entityList []suppliercertsub.OilSupplierCertSub
+		for classIdx, goodsAptitudeClass := range goodsAptitudeClassList {
 			var entity suppliercertsub.OilSupplierCertSub
 			entity.SupplierId = supplierCertSub.SupplierId
 			entity.SupplierCertId = supplierCertSub.SupplierCertId
@@ -691,7 +692,17 @@ func (this *TmpzcgfController) CapacityExpansion() {
 			entity.Code = goodsAptitudeClass.Code
 			entity.CertSubStatus = supplierCertSub.CertSubStatus
 			entity.Remark = "编码扩充"
-			svc.InsertEntityBytbl(OilSupplierCertSubName, &entity)
+			// 按最多200行insert一次
+			if (classIdx + 1) % 200 == 0 || (classIdx + 1) == len(goodsAptitudeClassList) {
+				// 加入本行数据
+				entityList = append(entityList, entity)
+				//执行insert操作
+				svc.InsertEntityBytbl(OilSupplierCertSubName, &entityList)
+				// 清空数组
+				entityList = entityList[0:0]
+			} else {
+				entityList = append(entityList, entity)
+			}
 		}
 
 		wheredel := "Id = " + strconv.Itoa(supplierCertSub.Id)