|
@@ -11,8 +11,22 @@ import (
|
|
|
"github.com/donnie4w/go-logger/logger"
|
|
|
)
|
|
|
|
|
|
+type sysconfig struct {
|
|
|
+ Mgodb string `json:"mgodb"`
|
|
|
+ DbSize int `json:"dbsize"`
|
|
|
+ DbName string `json:"dbname"`
|
|
|
+ TaskTime int64 `json:"tasktime"`
|
|
|
+ LatestId string `json:"latestid"`
|
|
|
+ BuyerInfo map[string]interface{} `json:"buyerinfo"`
|
|
|
+ Enterprise map[string]interface{} `json:"enterprise"`
|
|
|
+ Save map[string]interface{} `json:"save"`
|
|
|
+ Es map[string]interface{} `json:"es"`
|
|
|
+ ProjectAppid []string `json:"project_appid"`
|
|
|
+ SWinnerFilter []string `json:"s_winner_filter"`
|
|
|
+}
|
|
|
+
|
|
|
var (
|
|
|
- Sysconfig map[string]interface{}
|
|
|
+ Sysconfig sysconfig
|
|
|
LatestId string //起始id
|
|
|
MgoTag *mongodb.MongodbSim //标签库连接
|
|
|
MgoSave *mongodb.MongodbSim //数据保存库连接
|
|
@@ -42,13 +56,13 @@ func init() {
|
|
|
logger.SetRollingDaily("./logs", "spider.log")
|
|
|
//mgo datatag
|
|
|
MgoTag = &mongodb.MongodbSim{
|
|
|
- MongodbAddr: qu.ObjToString(Sysconfig["mgodb"]),
|
|
|
- DbName: qu.ObjToString(Sysconfig["dbname"]),
|
|
|
- Size: qu.IntAllDef(Sysconfig["dbsize"], 15),
|
|
|
+ MongodbAddr: qu.ObjToString(Sysconfig.Mgodb),
|
|
|
+ DbName: qu.ObjToString(Sysconfig.DbName),
|
|
|
+ Size: qu.IntAllDef(Sysconfig.DbSize, 15),
|
|
|
}
|
|
|
MgoTag.InitPool()
|
|
|
//mgo save
|
|
|
- save := Sysconfig["save"].(map[string]interface{})
|
|
|
+ save := Sysconfig.Save
|
|
|
SaveColl = qu.ObjToString(save["coll"])
|
|
|
SaveCollProject = qu.ObjToString(save["coll_project"])
|
|
|
MgoSave = &mongodb.MongodbSim{
|
|
@@ -58,7 +72,7 @@ func init() {
|
|
|
}
|
|
|
MgoSave.InitPool()
|
|
|
//mgo buyerinfo
|
|
|
- buyerinfo := Sysconfig["buyerinfo"].(map[string]interface{})
|
|
|
+ buyerinfo := Sysconfig.BuyerInfo
|
|
|
HospColl = qu.ObjToString(buyerinfo["hospcoll"])
|
|
|
BuyerEntColl = qu.ObjToString(buyerinfo["buyerentcoll"])
|
|
|
MgoBuyer = &mongodb.MongodbSim{
|
|
@@ -68,7 +82,7 @@ func init() {
|
|
|
}
|
|
|
MgoBuyer.InitPool()
|
|
|
//mgo enterprise
|
|
|
- enterprise := Sysconfig["enterprise"].(map[string]interface{})
|
|
|
+ enterprise := Sysconfig.Enterprise
|
|
|
EnpsColl = qu.ObjToString(enterprise["coll"])
|
|
|
MgoEnps = &mongodb.MongodbSim{
|
|
|
MongodbAddr: qu.ObjToString(enterprise["addr"]),
|
|
@@ -78,7 +92,7 @@ func init() {
|
|
|
MgoEnps.InitPool()
|
|
|
|
|
|
//es
|
|
|
- es := Sysconfig["es"].(map[string]interface{})
|
|
|
+ es := Sysconfig.Es
|
|
|
Es = &elastic.Elastic{
|
|
|
S_esurl: qu.ObjToString(es["addr"]),
|
|
|
I_size: qu.IntAllDef(es["pool"], 15),
|
|
@@ -87,16 +101,16 @@ func init() {
|
|
|
Index = qu.ObjToString(es["index"])
|
|
|
Itype = qu.ObjToString(es["itype"])
|
|
|
//
|
|
|
- TaskTime = qu.Int64All(Sysconfig["tasktime"])
|
|
|
- LatestId = qu.ObjToString(Sysconfig["latestid"])
|
|
|
+ TaskTime = Sysconfig.TaskTime
|
|
|
+ LatestId = Sysconfig.LatestId
|
|
|
// tmp := map[string]interface{}{
|
|
|
// "buyer": "四川大学华西第二医院",
|
|
|
// "s_winner": "邓州市兴都供销社第八门市部",
|
|
|
// }
|
|
|
// AssembelSave(tmp, true, true)
|
|
|
// qu.Debug(tmp)
|
|
|
- for _, v := range Sysconfig["project_appid"].([]interface{}) {
|
|
|
- projectAppidMap[v.(string)] = true
|
|
|
+ for _, v := range Sysconfig.ProjectAppid {
|
|
|
+ projectAppidMap[v] = true
|
|
|
}
|
|
|
}
|
|
|
func main() {
|