|
@@ -1,59 +1,60 @@
|
|
|
package task
|
|
|
|
|
|
-import (
|
|
|
- "fmt"
|
|
|
- "mongodb"
|
|
|
- "time"
|
|
|
- u "util"
|
|
|
-
|
|
|
- "front"
|
|
|
-)
|
|
|
-
|
|
|
-var timer *time.Ticker
|
|
|
-
|
|
|
-func init() {
|
|
|
- timer = time.NewTicker(1 * time.Second)
|
|
|
-}
|
|
|
-
|
|
|
-func TimeTask() {
|
|
|
- for t := range timer.C {
|
|
|
- hour := t.Hour()
|
|
|
- second := t.Second()
|
|
|
- minutes := t.Minute()
|
|
|
- if hour == 0 && minutes == 0 && second == 0 {
|
|
|
- FlushAuthor()
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-func FlushAuthor() {
|
|
|
- query := map[string]interface{}{
|
|
|
- "flush": map[string]interface{}{"$exists": false},
|
|
|
- "next": map[string]interface{}{"$exists": true},
|
|
|
- "l_uploadtime": map[string]interface{}{
|
|
|
- "$lte": time.Now().AddDate(0, 0, -30).Unix(),
|
|
|
- },
|
|
|
- "$where": "this.createuseremail != this.next",
|
|
|
- }
|
|
|
- //rets := *mgdb.Find("luaconfig", query, bson.M{}, bson.M{}, false, -1, -1)
|
|
|
- rets, _ := u.MgoEB.Find("luaconfig", query, nil, nil, false, -1, -1)
|
|
|
- for _, v := range *rets {
|
|
|
- next, ok := v["next"].(string)
|
|
|
- if ok {
|
|
|
- one, _ := u.MgoEB.FindOne("user", map[string]interface{}{"s_email": next})
|
|
|
- if len(*one) > 0 {
|
|
|
- update := map[string]interface{}{
|
|
|
- "$set": map[string]interface{}{
|
|
|
- "createuser": (*one)["s_name"],
|
|
|
- "createuserid": mongodb.BsonIdToSId((*one)["_id"]),
|
|
|
- "createuseremail": next,
|
|
|
- "flush": "ok",
|
|
|
- },
|
|
|
- }
|
|
|
- front.Wlog("转移爬虫给", v["code"].(string), fmt.Sprint((*one)["s_name"]), next, "系统定时任务", nil)
|
|
|
- //mgdb.Update("luaconfig", bson.M{"_id": v["_id"]}, update, false, false)
|
|
|
- u.MgoEB.UpdateById("luaconfig", v["_id"], update)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+//
|
|
|
+//import (
|
|
|
+// "fmt"
|
|
|
+// "mongodb"
|
|
|
+// "time"
|
|
|
+// u "util"
|
|
|
+//
|
|
|
+// "front"
|
|
|
+//)
|
|
|
+//
|
|
|
+//var timer *time.Ticker
|
|
|
+//
|
|
|
+//func init() {
|
|
|
+// timer = time.NewTicker(1 * time.Second)
|
|
|
+//}
|
|
|
+//
|
|
|
+//func TimeTask() {
|
|
|
+// for t := range timer.C {
|
|
|
+// hour := t.Hour()
|
|
|
+// second := t.Second()
|
|
|
+// minutes := t.Minute()
|
|
|
+// if hour == 0 && minutes == 0 && second == 0 {
|
|
|
+// FlushAuthor()
|
|
|
+// }
|
|
|
+// }
|
|
|
+//}
|
|
|
+//
|
|
|
+//func FlushAuthor() {
|
|
|
+// query := map[string]interface{}{
|
|
|
+// "flush": map[string]interface{}{"$exists": false},
|
|
|
+// "next": map[string]interface{}{"$exists": true},
|
|
|
+// "l_uploadtime": map[string]interface{}{
|
|
|
+// "$lte": time.Now().AddDate(0, 0, -30).Unix(),
|
|
|
+// },
|
|
|
+// "$where": "this.createuseremail != this.next",
|
|
|
+// }
|
|
|
+// //rets := *mgdb.Find("luaconfig", query, bson.M{}, bson.M{}, false, -1, -1)
|
|
|
+// rets, _ := u.MgoEB.Find("luaconfig", query, nil, nil, false, -1, -1)
|
|
|
+// for _, v := range *rets {
|
|
|
+// next, ok := v["next"].(string)
|
|
|
+// if ok {
|
|
|
+// one, _ := u.MgoEB.FindOne("user", map[string]interface{}{"s_email": next})
|
|
|
+// if len(*one) > 0 {
|
|
|
+// update := map[string]interface{}{
|
|
|
+// "$set": map[string]interface{}{
|
|
|
+// "createuser": (*one)["s_name"],
|
|
|
+// "createuserid": mongodb.BsonIdToSId((*one)["_id"]),
|
|
|
+// "createuseremail": next,
|
|
|
+// "flush": "ok",
|
|
|
+// },
|
|
|
+// }
|
|
|
+// front.Wlog("转移爬虫给", v["code"].(string), fmt.Sprint((*one)["s_name"]), next, "系统定时任务", nil)
|
|
|
+// //mgdb.Update("luaconfig", bson.M{"_id": v["_id"]}, update, false, false)
|
|
|
+// u.MgoEB.UpdateById("luaconfig", v["_id"], update)
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//}
|