|
@@ -5,20 +5,20 @@ import (
|
|
|
"dbutil/mongo"
|
|
|
"dbutil/redis"
|
|
|
"encoding/json"
|
|
|
- "log"
|
|
|
+ log "github.com/donnie4w/go-logger/logger"
|
|
|
+ "go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
+ "gopkg.in/mgo.v2/bson"
|
|
|
qu "qfw/util"
|
|
|
"time"
|
|
|
"unicode/utf8"
|
|
|
-
|
|
|
- "go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
- "gopkg.in/mgo.v2/bson"
|
|
|
)
|
|
|
|
|
|
//增量处理
|
|
|
func buyerStandarData(db string, query map[string]interface{}) {
|
|
|
defer qu.Catch()
|
|
|
sess := MongoFrom.GetMgoConn()
|
|
|
- defer MongoFrom.Close()
|
|
|
+ defer MongoFrom.DestoryMongoConn(sess)
|
|
|
+
|
|
|
it := sess.DB(db).C(extractcoll).Find(query).Select(bson.M{"repeat": 1, "buyer": 1, "buyertel": 1,
|
|
|
"buyerperson": 1, "buyerclass": 1, "topscopeclass": 1}).Sort("_id").Iter()
|
|
|
index := 0
|
|
@@ -27,8 +27,12 @@ func buyerStandarData(db string, query map[string]interface{}) {
|
|
|
continue
|
|
|
}
|
|
|
buyer := qu.ObjToString(tmp["buyer"])
|
|
|
- if utf8.RuneCountInString(buyer) < 4 {
|
|
|
- continue
|
|
|
+ if utf8.RuneCountInString(buyer) < 5 {
|
|
|
+ if LenReg.MatchString(buyer)&&utf8.RuneCountInString(buyer)==4 {
|
|
|
+
|
|
|
+ }else {
|
|
|
+ continue
|
|
|
+ }
|
|
|
}
|
|
|
infoid := mongo.BsonTOStringId(tmp["_id"])
|
|
|
buyerclass := qu.ObjToString(tmp["buyerclass"])
|
|
@@ -73,7 +77,9 @@ func buyerStandarData(db string, query map[string]interface{}) {
|
|
|
data["mobilephone"] = timesMobilePhone
|
|
|
data["institute_type"] = "企业"
|
|
|
_id := MongoTo.Save(buyerent, data)
|
|
|
- redis.PutRedis("buyer", buyerbd, buyer, _id.(primitive.ObjectID).Hex(), -1)
|
|
|
+ if _id!=nil {
|
|
|
+ redis.PutRedis("buyer", buyerbd, buyer, mongo.BsonTOStringId(_id), -1)
|
|
|
+ }
|
|
|
savetoerr = false
|
|
|
}
|
|
|
}
|
|
@@ -111,17 +117,17 @@ func buyerStandarData(db string, query map[string]interface{}) {
|
|
|
}
|
|
|
}
|
|
|
tmp = map[string]interface{}{}
|
|
|
- if index%1000 == 0 {
|
|
|
- log.Println("buyer index", index)
|
|
|
+ if index%10000 == 0 {
|
|
|
+ log.Debug("buyer index ", index)
|
|
|
}
|
|
|
}
|
|
|
- log.Println("buyer ok index", index)
|
|
|
+ log.Debug("buyer ok index", index)
|
|
|
}
|
|
|
|
|
|
//历史数据处理
|
|
|
func historybuyer(db, fromcoll string) {
|
|
|
defer qu.Catch()
|
|
|
- log.Println("history start")
|
|
|
+ log.Debug("history start")
|
|
|
sess := MongoFrom.GetMgoConn()
|
|
|
defer MongoFrom.Close()
|
|
|
it := sess.DB(db).C(fromcoll).Find(map[string]interface{}{}).Select(bson.M{"repeat": 1, "buyer": 1, "buyertel": 1, "buyerperson": 1, "buyerclass": 1, "topscopeclass": 1}).Sort("_id").Iter()
|
|
@@ -148,7 +154,7 @@ func historybuyer(db, fromcoll string) {
|
|
|
|
|
|
}
|
|
|
topscopeclass, _ := tmp["topscopeclass"].(primitive.A)
|
|
|
- if buyer != "" && utf8.RuneCountInString(buyer) > 3 {
|
|
|
+ if buyer != "" && (utf8.RuneCountInString(buyer) > 4 || (LenReg.MatchString(buyer)&&utf8.RuneCountInString(buyer)==4)) {
|
|
|
buyerperson := qu.ObjToString(tmp["buyerperson"])
|
|
|
buyertel := qu.ObjToString(tmp["buyertel"])
|
|
|
b, _ := redis.ExistRedis("buyer", buyerbd, buyer)
|
|
@@ -195,17 +201,17 @@ func historybuyer(db, fromcoll string) {
|
|
|
}(tmp)
|
|
|
tmp = map[string]interface{}{}
|
|
|
if index%10000 == 0 {
|
|
|
- log.Println("index", index, _id)
|
|
|
+ log.Debug("index", index, _id)
|
|
|
}
|
|
|
}
|
|
|
- log.Println("history ok index", index)
|
|
|
+ log.Debug("history ok index", index)
|
|
|
buyerStandarHistory(qu.ObjToString(sysconfig["mgotodb"]))
|
|
|
}
|
|
|
|
|
|
//查询buyererr标准化历史数据
|
|
|
func buyerStandarHistory(db string) {
|
|
|
defer qu.Catch()
|
|
|
- log.Println("开始标准化数据--buyer", db)
|
|
|
+ log.Debug("开始标准化数据--buyer", db)
|
|
|
sessto := MongoTo.GetMgoConn()
|
|
|
defer MongoTo.Close()
|
|
|
it := sessto.DB(db).C(buyererr).Find(map[string]interface{}{}).Iter()
|
|
@@ -237,15 +243,15 @@ func buyerStandarHistory(db string) {
|
|
|
MongoTo.UpdateById(buyererr, err_id, map[string]interface{}{"$set": map[string]interface{}{"check": num}})
|
|
|
}
|
|
|
} else {
|
|
|
- log.Println("jsonErr", name, err)
|
|
|
+ log.Debug("jsonErr", name, err)
|
|
|
}
|
|
|
}(tmp)
|
|
|
if index%1000 == 0 {
|
|
|
- log.Println("标准化历史数据--buyer", index, err_id, entnum)
|
|
|
+ log.Debug("标准化历史数据--buyer", index, err_id, entnum)
|
|
|
}
|
|
|
tmp = map[string]interface{}{}
|
|
|
}
|
|
|
- log.Println("标准化数据完成--buyer", index, entnum)
|
|
|
+ log.Debug("标准化数据完成--buyer", index, entnum)
|
|
|
}
|
|
|
|
|
|
//企业数据整合(已有标注信息)
|
|
@@ -264,8 +270,12 @@ func buyerMegerBuyerclass(id string, ps map[string]interface{}) map[string]inter
|
|
|
data["buyerclass"] = sb
|
|
|
}
|
|
|
data["updatetime"] = time.Now().Unix()
|
|
|
+
|
|
|
//contact
|
|
|
- contact := tmp["contact"].(primitive.A)
|
|
|
+ contact :=make(primitive.A,0)
|
|
|
+ if tmp["contact"]!=nil {
|
|
|
+ contact = tmp["contact"].(primitive.A)
|
|
|
+ }
|
|
|
contact = append(contact, ps)
|
|
|
//bid_contact
|
|
|
bid_contacts, contacts := bid_contact(contact)
|
|
@@ -295,7 +305,7 @@ func putbuyerreids() {
|
|
|
redis.PutRedis("buyer", 2, buyer_name, id, -1)
|
|
|
tmp = map[string]interface{}{}
|
|
|
if index%1000 == 0 {
|
|
|
- log.Println(id, index)
|
|
|
+ log.Debug(id, index)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -310,11 +320,11 @@ func putbuyerreids__s() {
|
|
|
ts, _ := MongoTo.Find("buyer_enterprise", map[string]interface{}{"buyer_name": buyer_name}, nil, bson.M{"buyer_name": 1})
|
|
|
if len(ts) > 1 {
|
|
|
id := mongo.BsonTOStringId(ts[0]["_id"])
|
|
|
- log.Println(buyer_name, id)
|
|
|
+ log.Debug(buyer_name, id)
|
|
|
MongoTo.DeleteById("buyer_enterprise", id)
|
|
|
}
|
|
|
if index%10000 == 0 {
|
|
|
- log.Println(index)
|
|
|
+ log.Debug(index)
|
|
|
}
|
|
|
tmp = map[string]interface{}{}
|
|
|
}
|
|
@@ -343,7 +353,7 @@ func modifybuyer() {
|
|
|
"$set": tmp,
|
|
|
})
|
|
|
MongoTo.DeleteById("buyer_enterprise", id)
|
|
|
- log.Println(id)
|
|
|
+ log.Debug(id)
|
|
|
}
|
|
|
}
|
|
|
tmp = map[string]interface{}{}
|