package main

import qu "qfw/util"

func initConfig()  {
	initMgo()
	souceconf:= sysconfig["data_source"].(map[string]interface{})
	s_class_xlsx_name = qu.ObjToString(souceconf["s_class_xlsx_name"])
	s_area_xlsx_name = qu.ObjToString(souceconf["s_area_xlsx_name"])
	s_area_coll = qu.ObjToString(souceconf["s_area_coll"])
	s_product_coll = qu.ObjToString(souceconf["s_product_coll"])
	s_company_coll = qu.ObjToString(souceconf["s_company_coll"])
	s_qybase_coll = qu.ObjToString(souceconf["s_qybase_coll"])
	s_bidding_coll = qu.ObjToString(souceconf["s_bidding_coll"])
	s_company_history_coll = qu.ObjToString(souceconf["s_company_history_coll"])

	outputconf:= sysconfig["data_output"].(map[string]interface{})
	o_area_coll = qu.ObjToString(outputconf["o_area_coll"])
	o_class_coll = qu.ObjToString(outputconf["o_class_coll"])
	o_company_coll = qu.ObjToString(outputconf["o_company_coll"])
	o_company_err_coll = qu.ObjToString(outputconf["o_company_err_coll"])
	o_product_coll = qu.ObjToString(outputconf["o_product_coll"])
	o_bidding_coll = qu.ObjToString(outputconf["o_bidding_coll"])
	o_hospital_coll = qu.ObjToString(outputconf["o_hospital_coll"])
	o_company_history_coll = qu.ObjToString(outputconf["o_company_history_coll"])

}



//初始化Mgo
func initMgo() {
	spiconf := sysconfig["spi_mgodb"].(map[string]interface{})
	spi_mgo = &MongodbSim{
		MongodbAddr: spiconf["addr"].(string),
		DbName:      spiconf["db"].(string),
		Size:        qu.IntAllDef(spiconf["pool"], 5),
	}
	spi_mgo.InitPool()

	qyconf := sysconfig["qy_mgodb"].(map[string]interface{})
	qy_mgo = &MongodbSim{
		MongodbAddr: qyconf["addr"].(string),
		DbName:      qyconf["db"].(string),
		Size:        qu.IntAllDef(qyconf["pool"], 5),
		UserName: 	qyconf["username"].(string),
		Password: 	qyconf["password"].(string),
	}
	qy_mgo.InitPool()

	saveconf := sysconfig["save_mgodb"].(map[string]interface{})
	save_mgo = &MongodbSim{
		MongodbAddr: saveconf["addr"].(string),
		DbName:      saveconf["db"].(string),
		Size:        qu.IntAllDef(saveconf["pool"], 5),
	}
	save_mgo.InitPool()


	sqlconf := sysconfig["mysql"].(map[string]interface{})
	MysqlTool = &Mysql{
		Address: sqlconf["addr"].(string),
		UserName: sqlconf["username"].(string),
		PassWord: sqlconf["password"].(string),
		DBName: sqlconf["db"].(string),
	}
	MysqlTool.Init()
}