Ver Fonte

后:老数据导入优化

dubch há 5 anos atrás
pai
commit
1af23ad845

+ 8 - 1
src/dashoo.cn/backend/api/business/tmpzcgf/tmpzcgfSession.go

@@ -280,6 +280,8 @@ func (s *TmpzcgtSession) InsertCertSub() error {
 		}
 		n := math.Ceil(float64(total) / 5000)
 
+		s.DBE.Query("ALTER TABLE `OilSupplierCertSub` drop INDEX index_typecode;")
+		s.DBE.Query("ALTER TABLE `OilSupplierCertSub` drop INDEX index_code;")
 		s.DBE.Query("ALTER TABLE `OilSupplierCertSub` DISABLE KEYS;")
 		s.DBE.Query("SET unique_checks=0;")
 		s.DBE.Query("SET autocommit=0;")
@@ -311,11 +313,13 @@ func (s *TmpzcgtSession) InsertCertSub() error {
 				ORDER BY t.auto_id ` +
 				" limit " + start + "," +  end
 			_, err = s.DBE.Query(sql)
+			s.DBE.Query("COMMIT;")
 		}
-		s.DBE.Query("COMMIT;")
 		s.DBE.Query("SET autocommit=1;")
 		s.DBE.Query("SET unique_checks=1;")
 		s.DBE.Query("ALTER TABLE `OilSupplierCertSub` ENABLE KEYS;")
+		s.DBE.Query("ALTER TABLE `OilSupplierCertSub` ADD INDEX index_typecode ( `SupplierTypeCode` );")
+		s.DBE.Query("ALTER TABLE `OilSupplierCertSub` ADD INDEX index_code ( `Code` );")
 	}
 	return err
 }
@@ -331,6 +335,7 @@ func (s *TmpzcgtSession) UpdateCertSub() error {
 	var err error
 
 	s.DBE.Query("ALTER TABLE `OilSupplierCertSub` ADD INDEX index_oldid ( `OldId` );")
+	s.DBE.Query("SET autocommit=0;")
 	for _, cert := range certList {
 		sql := " UPDATE OilSupplierCertSub b SET b.SupplierId = '" + strconv.Itoa(cert.SupplierId) + "'," +
 			" b.SupplierCertId='"+ strconv.Itoa(cert.Id) + "',"+
@@ -340,7 +345,9 @@ func (s *TmpzcgtSession) UpdateCertSub() error {
 		   // "and b.Type = '1' and b.CreateBy='导入1'"
 
 		_, err = s.DBE.Query(sql)
+		s.DBE.Query("COMMIT;")
 	}
+	s.DBE.Query("SET autocommit=1;")
 	s.DBE.Query("alter table OilSupplierCertSub drop index index_oldid ;")
 	return err
 }

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

@@ -420,7 +420,7 @@ func (this *TmpzcgfController) UpdateCertSubclassID() {
 	where := "1=1"
 	svc.GetEntities(&goodsAptitudeClassList, where)
 	for _, item := range goodsAptitudeClassList {
-		sql := "UPDATE OilSupplierCertSub SET SubClassId = " + strconv.Itoa(item.Id)  + " WHERE SupplierTypeCode = '01' and Type in (1, 3) and CreateBy='导入1' and Code = '" + item.Code + "'"
+		sql := "UPDATE OilSupplierCertSub SET SubClassId = " + strconv.Itoa(item.Id)  + " WHERE SupplierTypeCode = '01' and Code = '" + item.Code + "'"
 		svc.DBE.Query(sql)
 	}
 
@@ -428,7 +428,7 @@ func (this *TmpzcgfController) UpdateCertSubclassID() {
 	where1 := "1=1"
 	svc.GetEntities(&basisBuildList, where1)
 	for _, item := range basisBuildList {
-		sql := "UPDATE OilSupplierCertSub SET SubClassId = " + strconv.Itoa(item.Id)  + " WHERE SupplierTypeCode = '02' and Type in (1, 3) and CreateBy='导入1' and Code = '" + item.Code + "'"
+		sql := "UPDATE OilSupplierCertSub SET SubClassId = " + strconv.Itoa(item.Id)  + " WHERE SupplierTypeCode = '02' and Code = '" + item.Code + "'"
 		svc.DBE.Query(sql)
 	}
 
@@ -436,7 +436,7 @@ func (this *TmpzcgfController) UpdateCertSubclassID() {
 	where2 := "1=1"
 	svc.GetEntities(&technologyServiceClassList, where2)
 	for _, item := range technologyServiceClassList {
-		sql := "UPDATE OilSupplierCertSub SET SubClassId = " + strconv.Itoa(item.Id)  + " WHERE SupplierTypeCode = '03' and Type in (1, 3) and CreateBy='导入1' and Code = '" + item.Code + "'"
+		sql := "UPDATE OilSupplierCertSub SET SubClassId = " + strconv.Itoa(item.Id)  + " WHERE SupplierTypeCode = '03' and Code = '" + item.Code + "'"
 		svc.DBE.Query(sql)
 	}
 
@@ -873,8 +873,8 @@ func (this *TmpzcgfController) InsertAll() {
 		this.UpdateOilSupplierCertAppend()
 		this.UpdateOilSupplierCertAppendSub() // 更新增项的准入范围
 		this.UpdateCertSubclassID()
-		// this.CapacityExpansion() // 编码扩充 --弃用
-		// 历史数据导入-由于运行到此处中断,上面的代码临时注释
+		//this.CapacityExpansion() // 编码扩充 --弃用
+		//历史数据导入-由于运行到此处中断,上面的代码临时注释
 		this.InsterAnnualAudit()
 		this.UpdateAnnualAudit()
 		this.InsterOilPaymentInfo()