package main import ( "mongodb" qu "qfw/util" es "qfw/util/elastic" ) var ( Sysconfig map[string]interface{} //配置文件 Mgo *mongodb.MongodbSim Dbname string Dbcoll string Savecoll string Es *es.Elastic Index string Itype string OtherIndex string OtherItype string EsFields []string Fields []string AddressMap map[string]*City AddressOldMap map[string]*City QyStypeMap map[string]string CompanyStatusMap map[string]string TaskTime int //Updatetime int64 ) var EsSaveCache = make(chan map[string]interface{}, 1000) var SP = make(chan bool, 5) var EsSaveAllCache = make(chan map[string]interface{}, 1000) var SPAll = make(chan bool, 5) func init() { //config qu.ReadConfig(&Sysconfig) //mgo Dbname = Sysconfig["dbname"].(string) Dbcoll = Sysconfig["dbcoll"].(string) Savecoll = Sysconfig["savecoll"].(string) Mgo = &mongodb.MongodbSim{ MongodbAddr: Sysconfig["mgodb"].(string), Size: qu.IntAllDef(Sysconfig["dbsize"], 5), DbName: Dbname, //UserName: Sysconfig["uname"].(string), //Password: Sysconfig["upwd"].(string), } Mgo.InitPool() //es econf := Sysconfig["elastic"].(map[string]interface{}) Index = econf["index"].(string) Itype = econf["itype"].(string) OtherIndex = econf["otherindex"].(string) OtherItype = econf["otheritype"].(string) Es = &es.Elastic{ S_esurl: econf["addr"].(string), I_size: qu.IntAllDef(econf["pool"], 12), } Es.InitElasticSize() Fields = qu.ObjArrToStringArr(econf["fields"].([]interface{})) EsFields = qu.ObjArrToStringArr(econf["esfields"].([]interface{})) //启动es保存 go SaveEs() //过滤后数据 go SaveAllEs() //所有数据 //初始化其他信息 TaskTime = qu.IntAll(Sysconfig["tasktime"]) //Updatetime = qu.Int64All(Sysconfig["updatetime"]) InitAddress() InitQyStype() InitCompanyStatus() } func main() { //go TimeTask() //QyxyStandard() HistoryQyxyStandard() ch := make(chan bool, 1) <-ch }