|
@@ -299,18 +299,41 @@ func SpiderPassCheckListAndDetail_back(list []map[string]interface{}, data map[s
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-func GetLuasInfoBySite(site string) (domain, status, event, platform, area, city, district string, remarktime int64) {
|
|
|
|
|
|
+func GetLuasInfoBySite(site, area, city, district string) (domain, status, event, platform string, remarktime int64) {
|
|
shelveUp := 0
|
|
shelveUp := 0
|
|
eventMap, platformMap := map[int]interface{}{}, map[string]interface{}{}
|
|
eventMap, platformMap := map[int]interface{}{}, map[string]interface{}{}
|
|
eventArr, platformArr := []string{}, []string{}
|
|
eventArr, platformArr := []string{}, []string{}
|
|
- areaMap := map[string]int{}
|
|
|
|
- areaCityMap := map[string]map[string]int{}
|
|
|
|
- cityDistrictMap := map[string]map[string]int{}
|
|
|
|
|
|
+ //areaMap := map[string]int{}
|
|
|
|
+ //areaCityMap := map[string]map[string]int{}
|
|
|
|
+ //cityDistrictMap := map[string]map[string]int{}
|
|
domainMap := map[string]int{}
|
|
domainMap := map[string]int{}
|
|
remarktime = time.Now().Unix()
|
|
remarktime = time.Now().Unix()
|
|
//luas, _ := MgoE.Find("luaconfig", `{"param_common.1":"`+site+`"}`, ``, `{"model":1,"event":1,"state":1,"platform":1,"param_common":1,"comeintime":1}`, false, -1, -1)
|
|
//luas, _ := MgoE.Find("luaconfig", `{"param_common.1":"`+site+`"}`, ``, `{"model":1,"event":1,"state":1,"platform":1,"param_common":1,"comeintime":1}`, false, -1, -1)
|
|
- luas, _ := MgoEB.Find("luaconfig", `{"param_common.1":"`+site+`"}`, ``, `{"model":1,"event":1,"state":1,"platform":1,"param_common":1,"comeintime":1}`, false, -1, -1)
|
|
|
|
|
|
+ luas, _ := MgoEB.Find("luaconfig", `{"site":"`+site+`"}`, ``, `{"model":1,"event":1,"state":1,"platform":1,"param_common":1,"comeintime":1}`, false, -1, -1)
|
|
|
|
+ arr := [][]map[string]interface{}{}
|
|
for _, l := range *luas {
|
|
for _, l := range *luas {
|
|
|
|
+ update := []map[string]interface{}{}
|
|
|
|
+ set := map[string]interface{}{}
|
|
|
|
+ //更新爬虫area、city、district
|
|
|
|
+ if area != "" {
|
|
|
|
+ set["model.area"] = area
|
|
|
|
+ }
|
|
|
|
+ if area == "全国" {
|
|
|
|
+ set["model.city"] = ""
|
|
|
|
+ set["model.district"] = ""
|
|
|
|
+ } else if area != "" {
|
|
|
|
+ if city != "" {
|
|
|
|
+ set["model.city"] = city
|
|
|
|
+ }
|
|
|
|
+ if district != "" {
|
|
|
|
+ set["model.district"] = district
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if len(set) > 0 {
|
|
|
|
+ update = append(update, map[string]interface{}{"_id": l["_id"]})
|
|
|
|
+ update = append(update, map[string]interface{}{"$set": set})
|
|
|
|
+ arr = append(arr, update)
|
|
|
|
+ }
|
|
//remarktime
|
|
//remarktime
|
|
if comeintime := qu.Int64All(l["comeintime"]); comeintime != int64(0) && comeintime < remarktime {
|
|
if comeintime := qu.Int64All(l["comeintime"]); comeintime != int64(0) && comeintime < remarktime {
|
|
remarktime = comeintime
|
|
remarktime = comeintime
|
|
@@ -335,29 +358,29 @@ func GetLuasInfoBySite(site string) (domain, status, event, platform, area, city
|
|
eventMap[event] = true
|
|
eventMap[event] = true
|
|
platformMap[platform] = true
|
|
platformMap[platform] = true
|
|
//area、city、district
|
|
//area、city、district
|
|
- if model, ok := l["model"].(map[string]interface{}); ok && model != nil {
|
|
|
|
- a := qu.ObjToString(model["area"])
|
|
|
|
- c := qu.ObjToString(model["city"])
|
|
|
|
- d := qu.ObjToString(model["district"])
|
|
|
|
- if a != "" {
|
|
|
|
- areaMap[a] = areaMap[a] + 1
|
|
|
|
- if c != "" {
|
|
|
|
- if cityNum := areaCityMap[a]; cityNum != nil {
|
|
|
|
- cityNum[c] = cityNum[c] + 1
|
|
|
|
- } else {
|
|
|
|
- areaCityMap[a] = map[string]int{c: 1}
|
|
|
|
- }
|
|
|
|
- if d != "" {
|
|
|
|
- if distrctNum := cityDistrictMap[c]; distrctNum != nil {
|
|
|
|
- distrctNum[d] = distrctNum[d] + 1
|
|
|
|
- } else {
|
|
|
|
- cityDistrictMap[c] = map[string]int{d: 1}
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ //if model, ok := l["model"].(map[string]interface{}); ok && model != nil {
|
|
|
|
+ // a := qu.ObjToString(model["area"])
|
|
|
|
+ // c := qu.ObjToString(model["city"])
|
|
|
|
+ // d := qu.ObjToString(model["district"])
|
|
|
|
+ // if a != "" {
|
|
|
|
+ // areaMap[a] = areaMap[a] + 1
|
|
|
|
+ // if c != "" {
|
|
|
|
+ // if cityNum := areaCityMap[a]; cityNum != nil {
|
|
|
|
+ // cityNum[c] = cityNum[c] + 1
|
|
|
|
+ // } else {
|
|
|
|
+ // areaCityMap[a] = map[string]int{c: 1}
|
|
|
|
+ // }
|
|
|
|
+ // if d != "" {
|
|
|
|
+ // if distrctNum := cityDistrictMap[c]; distrctNum != nil {
|
|
|
|
+ // distrctNum[d] = distrctNum[d] + 1
|
|
|
|
+ // } else {
|
|
|
|
+ // cityDistrictMap[c] = map[string]int{d: 1}
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
}
|
|
}
|
|
//
|
|
//
|
|
for e, _ := range eventMap {
|
|
for e, _ := range eventMap {
|
|
@@ -377,30 +400,35 @@ func GetLuasInfoBySite(site string) (domain, status, event, platform, area, city
|
|
}
|
|
}
|
|
}
|
|
}
|
|
status = fmt.Sprintf("%d%s%d", shelveUp, "/", len(*luas))
|
|
status = fmt.Sprintf("%d%s%d", shelveUp, "/", len(*luas))
|
|
- //
|
|
|
|
- an, cn, dn := 0, 0, 0
|
|
|
|
- for at, num := range areaMap {
|
|
|
|
- if num > an {
|
|
|
|
- area = at
|
|
|
|
- an = num
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if area != "" {
|
|
|
|
- for ct, num := range areaCityMap[area] {
|
|
|
|
- if num > cn {
|
|
|
|
- city = ct
|
|
|
|
- cn = num
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if city != "" {
|
|
|
|
- for dt, num := range cityDistrictMap[city] {
|
|
|
|
- if num > dn {
|
|
|
|
- district = dt
|
|
|
|
- dn = num
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ //批量更新
|
|
|
|
+ if len(arr) > 0 {
|
|
|
|
+ MgoEB.UpdateBulk("luaconfig", arr...)
|
|
|
|
+ arr = [][]map[string]interface{}{}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //an, cn, dn := 0, 0, 0
|
|
|
|
+ //for at, num := range areaMap {
|
|
|
|
+ // if num > an {
|
|
|
|
+ // area = at
|
|
|
|
+ // an = num
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+ //if area != "" {
|
|
|
|
+ // for ct, num := range areaCityMap[area] {
|
|
|
|
+ // if num > cn {
|
|
|
|
+ // city = ct
|
|
|
|
+ // cn = num
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+ //if city != "" {
|
|
|
|
+ // for dt, num := range cityDistrictMap[city] {
|
|
|
|
+ // if num > dn {
|
|
|
|
+ // district = dt
|
|
|
|
+ // dn = num
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|