|
@@ -1,6 +1,7 @@
|
|
|
package main
|
|
|
|
|
|
import (
|
|
|
+ "fmt"
|
|
|
"log"
|
|
|
qu "qfw/util"
|
|
|
"time"
|
|
@@ -11,36 +12,27 @@ func dealWithJPData() {
|
|
|
|
|
|
log.Println("开始统计竞品数据...")
|
|
|
defer qu.Catch()
|
|
|
-
|
|
|
start := int(time.Now().Unix())
|
|
|
now:=time.Now() //当前天
|
|
|
gte_time:= time.Date(now.Year(), now.Month(), now.Day()-1, 0, 0, 0, 0, time.Local).Unix()
|
|
|
lt_time := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local).Unix()
|
|
|
|
|
|
- //临时测试-7号
|
|
|
- gte_time = 1617724800
|
|
|
- lt_time = 1617811200
|
|
|
-
|
|
|
q := map[string]interface{}{
|
|
|
"comeintime": map[string]interface{}{
|
|
|
"$gte": gte_time,
|
|
|
"$lt": lt_time,
|
|
|
},
|
|
|
- "site":"中国招标与采购网",
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
sess := jp_mgo.GetMgoConn()
|
|
|
defer jp_mgo.DestoryMongoConn(sess)
|
|
|
-
|
|
|
//细节才需要遍历
|
|
|
it := sess.DB(jp_mgo.DbName).C(jp_c_name).Find(&q).Select(map[string]interface{}{
|
|
|
"site":1,
|
|
|
}).Iter()
|
|
|
- total,_ :=0, int(time.Now().Unix())
|
|
|
+ total,isOK,_ :=0, 0,int(time.Now().Unix())
|
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
|
|
|
- if total%10000==0 {
|
|
|
- //log.Println("current index",total)
|
|
|
+ if qu.ObjToString(tmp["site"]) == "中国招标与采购网" {
|
|
|
+ isOK++
|
|
|
}
|
|
|
tmp = make(map[string]interface{})
|
|
|
}
|
|
@@ -50,14 +42,63 @@ func dealWithJPData() {
|
|
|
//sendErrMailApi("竞品数据异常","数量无")
|
|
|
}
|
|
|
|
|
|
- comeintime:=qu.Int64All(time.Now().Unix())
|
|
|
- date := qu.FormatDateByInt64(&comeintime, qu.DATEFORMAT)
|
|
|
data_mgo.Save("monitor_other", map[string]interface{}{
|
|
|
"name":"竞品",
|
|
|
"num":qu.IntAll(total),
|
|
|
- "comeintime":comeintime,
|
|
|
- "updatedate":date,
|
|
|
+ "comeintime":qu.Int64All(time.Now().Unix()),
|
|
|
+ "date":qu.FormatDateByInt64(>e_time, qu.DATEFORMAT),
|
|
|
})
|
|
|
|
|
|
log.Println("竞品-定时处理完毕...",int(time.Now().Unix())-start,"秒")
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+//测试分析
|
|
|
+func dealWithJPTest(year int,month time.Month, day int) {
|
|
|
+ gte_time:= time.Date(year, month, day, 0, 0, 0, 0, time.Local).Unix()
|
|
|
+ lt_time := time.Date(year, month, day+1, 0, 0, 0, 0, time.Local).Unix()
|
|
|
+ q := map[string]interface{}{
|
|
|
+ "comeintime": map[string]interface{}{
|
|
|
+ "$gte": gte_time,
|
|
|
+ "$lt": lt_time,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ sess := jp_mgo.GetMgoConn()
|
|
|
+ defer jp_mgo.DestoryMongoConn(sess)
|
|
|
+ it := sess.DB(jp_mgo.DbName).C(jp_c_name).Find(&q).Select(map[string]interface{}{
|
|
|
+ "site":1,
|
|
|
+ }).Iter()
|
|
|
+ total,isOK :=0, 0
|
|
|
+ for tmp := make(map[string]interface{}); it.Next(&tmp); total++ {
|
|
|
+ if qu.ObjToString(tmp["site"]) == "中国招标与采购网" {
|
|
|
+ isOK++
|
|
|
+ }
|
|
|
+ tmp = make(map[string]interface{})
|
|
|
+ }
|
|
|
+ fmt.Println(qu.FormatDateByInt64(>e_time, qu.DATEFORMAT),"总量:",total,"竞品:",isOK)
|
|
|
+ comeintime:=qu.Int64All(time.Now().Unix())
|
|
|
+ date := qu.FormatDateByInt64(>e_time, qu.DATEFORMAT)
|
|
|
+ data_mgo.Save("monitor_other", map[string]interface{}{
|
|
|
+ "name":"竞品",
|
|
|
+ "num":qu.IntAll(isOK),
|
|
|
+ "comeintime":comeintime,
|
|
|
+ "date":date,
|
|
|
+ })
|
|
|
}
|