|
@@ -19,11 +19,11 @@ func agencyStandarData(db string, query map[string]interface{}) {
|
|
defer qu.Catch()
|
|
defer qu.Catch()
|
|
sess := MongoFrom.GetMgoConn()
|
|
sess := MongoFrom.GetMgoConn()
|
|
defer MongoFrom.Close()
|
|
defer MongoFrom.Close()
|
|
- it := sess.DB(db).C(extractcoll).Find(query).Select(bson.M{"repeat": 1,"agency": 1, "agencytel": 1, "agencyperson": 1, "topscopeclass": 1,
|
|
|
|
|
|
+ it := sess.DB(db).C(extractcoll).Find(query).Select(bson.M{"repeat": 1, "agency": 1, "agencytel": 1, "agencyperson": 1, "topscopeclass": 1,
|
|
"agencyaddr": 1}).Sort("_id").Iter()
|
|
"agencyaddr": 1}).Sort("_id").Iter()
|
|
index := 0
|
|
index := 0
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); index++ {
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); index++ {
|
|
- if qu.IntAll(tmp["repeat"]) > 0 { //重复数据跳过
|
|
|
|
|
|
+ if qu.IntAll(tmp["repeat"]) > 0 { //重复数据跳过
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
agency := qu.ObjToString(tmp["agency"])
|
|
agency := qu.ObjToString(tmp["agency"])
|
|
@@ -36,7 +36,7 @@ func agencyStandarData(db string, query map[string]interface{}) {
|
|
ps := []map[string]interface{}{}
|
|
ps := []map[string]interface{}{}
|
|
agencyperson := qu.ObjToString(tmp["agencyperson"])
|
|
agencyperson := qu.ObjToString(tmp["agencyperson"])
|
|
agencytel := qu.ObjToString(tmp["agencytel"])
|
|
agencytel := qu.ObjToString(tmp["agencytel"])
|
|
- if entid == "" {//redis 未存
|
|
|
|
|
|
+ if entid == "" { //redis 未存
|
|
savetoerr := true
|
|
savetoerr := true
|
|
if agencytel != "" {
|
|
if agencytel != "" {
|
|
v := map[string]interface{}{
|
|
v := map[string]interface{}{
|
|
@@ -65,14 +65,14 @@ func agencyStandarData(db string, query map[string]interface{}) {
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if agencytel != "" {
|
|
if agencytel != "" {
|
|
- is_exist:=false //电话是否存在
|
|
|
|
- for _,v := range ps{
|
|
|
|
- if v["phone"]==agencytel{
|
|
|
|
|
|
+ is_exist := false //电话是否存在
|
|
|
|
+ for _, v := range ps {
|
|
|
|
+ if v["phone"] == agencytel {
|
|
is_exist = true
|
|
is_exist = true
|
|
- if agencyperson!=""&&v["contact_person"]!=agencyperson {
|
|
|
|
- v["contact_person"]=agencyperson
|
|
|
|
|
|
+ if agencyperson != "" && v["contact_person"] != agencyperson {
|
|
|
|
+ v["contact_person"] = agencyperson
|
|
v["infoid"] = infoid
|
|
v["infoid"] = infoid
|
|
- bs, _ := json.Marshal(ps)//替换数据,更新
|
|
|
|
|
|
+ bs, _ := json.Marshal(ps) //替换数据,更新
|
|
redis.PutRedis("agency", agencybd, agency, bs, -1)
|
|
redis.PutRedis("agency", agencybd, agency, bs, -1)
|
|
}
|
|
}
|
|
continue
|
|
continue
|
|
@@ -87,7 +87,7 @@ func agencyStandarData(db string, query map[string]interface{}) {
|
|
}
|
|
}
|
|
MongoTo.UpdateById(agencyent, entid,
|
|
MongoTo.UpdateById(agencyent, entid,
|
|
map[string]interface{}{
|
|
map[string]interface{}{
|
|
- "$set": v,
|
|
|
|
|
|
+ "$set": map[string]interface{}{"updatetime": time.Now().Unix()},
|
|
"$push": map[string]interface{}{"contact": v},
|
|
"$push": map[string]interface{}{"contact": v},
|
|
},
|
|
},
|
|
)
|
|
)
|
|
@@ -108,7 +108,7 @@ func historyagency(db, fromcoll string) {
|
|
log.Println("history start")
|
|
log.Println("history start")
|
|
sess := MongoFrom.GetMgoConn()
|
|
sess := MongoFrom.GetMgoConn()
|
|
defer MongoFrom.Close()
|
|
defer MongoFrom.Close()
|
|
- it := sess.DB(db).C(fromcoll).Find(map[string]interface{}{}).Select(bson.M{"repeat": 1,"agency": 1, "agencytel": 1, "agencyperson": 1, "topscopeclass": 1,
|
|
|
|
|
|
+ it := sess.DB(db).C(fromcoll).Find(map[string]interface{}{}).Select(bson.M{"repeat": 1, "agency": 1, "agencytel": 1, "agencyperson": 1, "topscopeclass": 1,
|
|
"agencyaddr": 1}).Sort("_id").Iter()
|
|
"agencyaddr": 1}).Sort("_id").Iter()
|
|
index := 0
|
|
index := 0
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); index++ {
|
|
for tmp := make(map[string]interface{}); it.Next(&tmp); index++ {
|
|
@@ -127,20 +127,20 @@ func historyagency(db, fromcoll string) {
|
|
agencyperson := qu.ObjToString(tmp["agencyperson"])
|
|
agencyperson := qu.ObjToString(tmp["agencyperson"])
|
|
agencytel := qu.ObjToString(tmp["agencytel"])
|
|
agencytel := qu.ObjToString(tmp["agencytel"])
|
|
b, _ := redis.ExistRedis("agency", agencybd, agency)
|
|
b, _ := redis.ExistRedis("agency", agencybd, agency)
|
|
- if b {//redis 存在
|
|
|
|
- if agencytel != "" {
|
|
|
|
|
|
+ if b { //redis 存在
|
|
|
|
+ if agencytel != "" {
|
|
strs, _ := redis.GetRedisStr("agency", agencybd, agency)
|
|
strs, _ := redis.GetRedisStr("agency", agencybd, agency)
|
|
ps := []map[string]interface{}{}
|
|
ps := []map[string]interface{}{}
|
|
err := json.Unmarshal([]byte(strs), &ps)
|
|
err := json.Unmarshal([]byte(strs), &ps)
|
|
if err == nil {
|
|
if err == nil {
|
|
- is_exist:=false //电话是否存在
|
|
|
|
- for _,v := range ps{
|
|
|
|
- if v["phone"]==agencytel{
|
|
|
|
|
|
+ is_exist := false //电话是否存在
|
|
|
|
+ for _, v := range ps {
|
|
|
|
+ if v["phone"] == agencytel {
|
|
is_exist = true
|
|
is_exist = true
|
|
- if agencyperson!=""&&v["contact_person"]!=agencyperson {
|
|
|
|
- v["contact_person"]=agencyperson
|
|
|
|
|
|
+ if agencyperson != "" && v["contact_person"] != agencyperson {
|
|
|
|
+ v["contact_person"] = agencyperson
|
|
v["infoid"] = _id
|
|
v["infoid"] = _id
|
|
- bs, _ := json.Marshal(ps)//替换数据,更新
|
|
|
|
|
|
+ bs, _ := json.Marshal(ps) //替换数据,更新
|
|
redis.PutRedis("agency", agencybd, agency, bs, -1)
|
|
redis.PutRedis("agency", agencybd, agency, bs, -1)
|
|
}
|
|
}
|
|
continue
|
|
continue
|