package main import "time" var ( //项目 saveProjectBaseInfoPool = make(chan map[string]interface{}, 5000) saveProjectBaseInfoSp = make(chan bool, 1) dwd_f_bid_project_baseinfo_field = []string{"s_projectid", "s_projectcode", "s_projectname", "s_projectname", "s_area_code", "s_city_code", "s_district_code", "s_bidstatus", "s_buyer_id", "s_agency_id", "s_bidtype", "d_bidopentime", "d_firsttime", "d_zbtime", "d_jgtime", "d_lasttime", "f_budget", "f_bidamount", "i_multipackage", "d_updatetime", "d_createtime"} ) //项目基础信息 func dwd_f_bid_project_baseinfo1() { arru := make([]map[string]interface{}, saveSize) indexu := 0 for { select { case v := <-saveProjectBaseInfoPool: arru[indexu] = v indexu++ if indexu == saveSize { saveProjectBaseInfoSp <- true go func(arru []map[string]interface{}) { defer func() { <-saveProjectBaseInfoSp }() MysqlTool.InsertBulk("dwd_f_bid_project_baseinfo", dwd_f_bid_project_baseinfo_field, arru...) }(arru) arru = make([]map[string]interface{}, saveSize) indexu = 0 } case <-time.After(1000 * time.Millisecond): if indexu > 0 { saveProjectBaseInfoSp <- true go func(arru []map[string]interface{}) { defer func() { <-saveProjectBaseInfoSp }() MysqlTool.InsertBulk("dwd_f_bid_project_baseinfo", BaseField, arru...) }(arru[:indexu]) arru = make([]map[string]interface{}, saveSize) indexu = 0 } } } }