|
@@ -40,8 +40,8 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
"$gte": GId,
|
|
"$gte": GId,
|
|
"$lte": LtId,
|
|
"$lte": LtId,
|
|
},
|
|
},
|
|
- }).Select(bson.M{"winner": 1, "winnertel": 1, "winnerperson": 1,
|
|
|
|
- "topscopeclass": 1, "winneraddr": 1}).Iter()
|
|
|
|
|
|
+ }).Select(bson.M{"agency": 1, "agencytel": 1, "agencyperson": 1,
|
|
|
|
+ "topscopeclass": 1, "agencyaddr": 1}).Iter()
|
|
if cursor == nil {
|
|
if cursor == nil {
|
|
log.Println(cursor)
|
|
log.Println(cursor)
|
|
return
|
|
return
|
|
@@ -57,7 +57,7 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
//遍历bidding表保存到redis
|
|
//遍历bidding表保存到redis
|
|
// key:_id value:json结构体
|
|
// key:_id value:json结构体
|
|
for cursor.Next(&tmp) {
|
|
for cursor.Next(&tmp) {
|
|
- if tmp["winner"] == nil || tmp["winner"] == "" {
|
|
|
|
|
|
+ if tmp["agency"] == nil || tmp["agency"] == "" {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
bytes, _ := json.Marshal(tmp)
|
|
bytes, _ := json.Marshal(tmp)
|
|
@@ -79,10 +79,10 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
//重复增量操作
|
|
//重复增量操作
|
|
//redis查询是否存在
|
|
//redis查询是否存在
|
|
rdb := RedisPool.Get()
|
|
rdb := RedisPool.Get()
|
|
- if reply, err := redis.String(rdb.Do("GET", tmp["winner"])); err != nil {
|
|
|
|
|
|
+ if reply, err := redis.String(rdb.Do("GET", tmp["agency"])); err != nil {
|
|
//redis不存在,存到临时表,定时任务处理
|
|
//redis不存在,存到临时表,定时任务处理
|
|
FClient.DbName = Config["mgodb_extract_kf"]
|
|
FClient.DbName = Config["mgodb_extract_kf"]
|
|
- if tmpid := FClient.Save("winner_new", tmp); tmpid == nil {
|
|
|
|
|
|
+ if tmpid := FClient.Save("agency_new", tmp); tmpid == nil {
|
|
log.Println("存量 FClient.Save err", tmpid)
|
|
log.Println("存量 FClient.Save err", tmpid)
|
|
}
|
|
}
|
|
//log.Println("get redis id err:定时任务处理", err, tmp)
|
|
//log.Println("get redis id err:定时任务处理", err, tmp)
|
|
@@ -100,7 +100,7 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
FClient.DbName = Config["mgodb_extract_kf"]
|
|
FClient.DbName = Config["mgodb_extract_kf"]
|
|
oldTmp := FClient.FindById(Config["mgo_qyk_c"], reply)
|
|
oldTmp := FClient.FindById(Config["mgo_qyk_c"], reply)
|
|
if oldTmp == nil {
|
|
if oldTmp == nil {
|
|
- log.Println("存量 redis id 不存在",reply,tmp["winner"])
|
|
|
|
|
|
+ log.Println("存量 redis id 不存在",reply,tmp["agency"])
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
tmpTopscopeclass := []string{}
|
|
tmpTopscopeclass := []string{}
|
|
@@ -140,7 +140,8 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
oldTmp["industry"] = tmpTopscopeclass
|
|
oldTmp["industry"] = tmpTopscopeclass
|
|
esId := oldTmp["_id"].(primitive.ObjectID).Hex()
|
|
esId := oldTmp["_id"].(primitive.ObjectID).Hex()
|
|
//更新行业类型
|
|
//更新行业类型
|
|
- if tmp["winnerperson"] == nil || tmp["winnerperson"] == "" || Reg_xing.MatchString(util.ObjToString(tmp["winnerperson"])) {
|
|
|
|
|
|
+ if tmp["agencyperson"] == nil || tmp["agencyperson"] == "" ||
|
|
|
|
+ Reg_xing.MatchString(util.ObjToString(tmp["agencyperson"])) {
|
|
oldTmp["updatatime"] = time.Now().Unix()
|
|
oldTmp["updatatime"] = time.Now().Unix()
|
|
//mongo更新
|
|
//mongo更新
|
|
FClient.DbName = Config["mgodb_extract_kf"]
|
|
FClient.DbName = Config["mgodb_extract_kf"]
|
|
@@ -150,7 +151,7 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
|
|
|
|
//es更新
|
|
//es更新
|
|
delete(oldTmp, "_id")
|
|
delete(oldTmp, "_id")
|
|
- if _, err := EsConn.Update().Index(Config["elasticsearch_index"]).Type(Config["elasticsearch_type"]).Id(esId).Doc(oldTmp).Refresh(true).Do(); err != nil {
|
|
|
|
|
|
+ if _, err := EsConn.Update().Index(Config["elasticsearch_agency_index"]).Type(Config["elasticsearch_agency_type"]).Id(esId).Doc(oldTmp).Refresh(true).Do(); err != nil {
|
|
log.Println("update es err:", err)
|
|
log.Println("update es err:", err)
|
|
}
|
|
}
|
|
//删除存量redis
|
|
//删除存量redis
|
|
@@ -158,15 +159,15 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
//联系方式合并
|
|
//联系方式合并
|
|
- var tmpperson, winnertel string
|
|
|
|
- tmpperson = tmp["winnerperson"].(string)
|
|
|
|
- if tmp["winnertel"] == nil || tmp["winnertel"] == "" {
|
|
|
|
- winnertel = ""
|
|
|
|
|
|
+ var tmpperson, agencytel string
|
|
|
|
+ tmpperson = tmp["agencyperson"].(string)
|
|
|
|
+ if tmp["agencytel"] == nil || tmp["agencytel"] == "" {
|
|
|
|
+ agencytel = ""
|
|
} else {
|
|
} else {
|
|
- if Reg_xing.MatchString(util.ObjToString(tmp["winnertel"])) || !Reg_tel.MatchString(util.ObjToString(tmp["winnertel"])) {
|
|
|
|
- winnertel = ""
|
|
|
|
|
|
+ if Reg_xing.MatchString(util.ObjToString(tmp["agencytel"])) || !Reg_tel.MatchString(util.ObjToString(tmp["agencytel"])) {
|
|
|
|
+ agencytel = ""
|
|
} else {
|
|
} else {
|
|
- winnertel = util.ObjToString(tmp["winnertel"])
|
|
|
|
|
|
+ agencytel = util.ObjToString(tmp["agencytel"])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
contactMaps := make([]interface{}, 0)
|
|
contactMaps := make([]interface{}, 0)
|
|
@@ -175,7 +176,7 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
tmpContact["infoid"] = redisId
|
|
tmpContact["infoid"] = redisId
|
|
tmpContact["contact_person"] = tmpperson
|
|
tmpContact["contact_person"] = tmpperson
|
|
tmpContact["contact_type"] = "项目联系人"
|
|
tmpContact["contact_type"] = "项目联系人"
|
|
- tmpContact["phone"] = winnertel
|
|
|
|
|
|
+ tmpContact["phone"] = agencytel
|
|
tmpContact["topscopeclass"] = strings.Join(tmpTopscopeclass, ";")
|
|
tmpContact["topscopeclass"] = strings.Join(tmpTopscopeclass, ";")
|
|
tmpContact["updatetime"] = time.Now().Unix()
|
|
tmpContact["updatetime"] = time.Now().Unix()
|
|
contactMaps = append(contactMaps, tmpContact)
|
|
contactMaps = append(contactMaps, tmpContact)
|
|
@@ -186,7 +187,7 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
for _, vv := range v {
|
|
for _, vv := range v {
|
|
if vvv, ok := vv.(map[string]interface{}); ok {
|
|
if vvv, ok := vv.(map[string]interface{}); ok {
|
|
if vvv["contact_person"] == tmpperson && vvv["contact_type"] == "项目联系人" &&
|
|
if vvv["contact_person"] == tmpperson && vvv["contact_type"] == "项目联系人" &&
|
|
- vvv["phone"] == winnertel && vvv["topscopeclass"] == strings.Join(tmpTopscopeclass, ";") {
|
|
|
|
|
|
+ vvv["phone"] == agencytel && vvv["topscopeclass"] == strings.Join(tmpTopscopeclass, ";") {
|
|
isNotUpdate = true
|
|
isNotUpdate = true
|
|
vvv["updatetime"] = time.Now().Unix()
|
|
vvv["updatetime"] = time.Now().Unix()
|
|
}
|
|
}
|
|
@@ -196,9 +197,9 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
if !isNotUpdate {
|
|
if !isNotUpdate {
|
|
vvv := make(map[string]interface{})
|
|
vvv := make(map[string]interface{})
|
|
vvv["infoid"] = redisId
|
|
vvv["infoid"] = redisId
|
|
- vvv["contact_person"] = tmp["winnerperson"]
|
|
|
|
|
|
+ vvv["contact_person"] = tmp["agencyperson"]
|
|
vvv["contact_type"] = "项目联系人"
|
|
vvv["contact_type"] = "项目联系人"
|
|
- vvv["phone"] = winnertel
|
|
|
|
|
|
+ vvv["phone"] = agencytel
|
|
vvv["topscopeclass"] = strings.Join(tmpTopscopeclass, ";")
|
|
vvv["topscopeclass"] = strings.Join(tmpTopscopeclass, ";")
|
|
vvv["updatetime"] = time.Now().Unix()
|
|
vvv["updatetime"] = time.Now().Unix()
|
|
contactMaps = append(contactMaps, vvv)
|
|
contactMaps = append(contactMaps, vvv)
|
|
@@ -214,7 +215,7 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
}
|
|
}
|
|
//es更新
|
|
//es更新
|
|
delete(oldTmp, "_id")
|
|
delete(oldTmp, "_id")
|
|
- if _, err := EsConn.Update().Index(Config["elasticsearch_index"]).Type(Config["elasticsearch_type"]).Id(esId).Doc(oldTmp).Refresh(true).Do(); err != nil {
|
|
|
|
|
|
+ if _, err := EsConn.Update().Index(Config["elasticsearch_agency_index"]).Type(Config["elasticsearch_agency_type"]).Id(esId).Doc(oldTmp).Refresh(true).Do(); err != nil {
|
|
log.Println("存量 EsConn err :", err)
|
|
log.Println("存量 EsConn err :", err)
|
|
}
|
|
}
|
|
//最后删除redis
|
|
//最后删除redis
|
|
@@ -231,15 +232,15 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
for cursor.Next(&tmp) {
|
|
for cursor.Next(&tmp) {
|
|
overid = tmp["_id"].(primitive.ObjectID).Hex()
|
|
overid = tmp["_id"].(primitive.ObjectID).Hex()
|
|
log.Println(tmp["_id"])
|
|
log.Println(tmp["_id"])
|
|
- if tmp["winner"] == nil || tmp["winner"] == "" {
|
|
|
|
|
|
+ if tmp["agency"] == nil || tmp["agency"] == "" {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
//redis查询是否存在
|
|
//redis查询是否存在
|
|
rdb := RedisPool.Get()
|
|
rdb := RedisPool.Get()
|
|
- if reply, err := redis.String(rdb.Do("GET", tmp["winner"])); err != nil {
|
|
|
|
|
|
+ if reply, err := redis.String(rdb.Do("GET", tmp["agency"])); err != nil {
|
|
//redis不存在存到临时表,定时任务处理
|
|
//redis不存在存到临时表,定时任务处理
|
|
FClient.DbName = Config["mgodb_extract_kf"]
|
|
FClient.DbName = Config["mgodb_extract_kf"]
|
|
- if tmpid := FClient.Save("winner_new", tmp); tmpid == nil {
|
|
|
|
|
|
+ if tmpid := FClient.Save("agency_new", tmp); tmpid == nil {
|
|
log.Println("FClient.Save err", tmpid)
|
|
log.Println("FClient.Save err", tmpid)
|
|
}
|
|
}
|
|
//log.Println("get redis id err:定时任务处理", err, tmp)
|
|
//log.Println("get redis id err:定时任务处理", err, tmp)
|
|
@@ -297,7 +298,7 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
oldTmp["industry"] = tmpTopscopeclass
|
|
oldTmp["industry"] = tmpTopscopeclass
|
|
esId := oldTmp["_id"].(primitive.ObjectID).Hex()
|
|
esId := oldTmp["_id"].(primitive.ObjectID).Hex()
|
|
//更新行业类型
|
|
//更新行业类型
|
|
- if tmp["winnerperson"] == nil || tmp["winnerperson"] == "" || Reg_xing.MatchString(util.ObjToString(tmp["winnerperson"])) {
|
|
|
|
|
|
+ if tmp["agencyperson"] == nil || tmp["agencyperson"] == "" || Reg_xing.MatchString(util.ObjToString(tmp["agencyperson"])) {
|
|
oldTmp["updatatime"] = time.Now().Unix()
|
|
oldTmp["updatatime"] = time.Now().Unix()
|
|
//mongo更新
|
|
//mongo更新
|
|
FClient.DbName = Config["mgodb_extract_kf"]
|
|
FClient.DbName = Config["mgodb_extract_kf"]
|
|
@@ -307,21 +308,21 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
|
|
|
|
//es更新
|
|
//es更新
|
|
delete(oldTmp, "_id")
|
|
delete(oldTmp, "_id")
|
|
- if _, err := EsConn.Update().Index(Config["elasticsearch_index"]).Type(Config["elasticsearch_type"]).Id(esId).Doc(oldTmp).Refresh(true).Do(); err != nil {
|
|
|
|
|
|
+ if _, err := EsConn.Update().Index(Config["elasticsearch_agency_index"]).Type(Config["elasticsearch_agency_type"]).Id(esId).Doc(oldTmp).Refresh(true).Do(); err != nil {
|
|
log.Println("update es err:", err)
|
|
log.Println("update es err:", err)
|
|
}
|
|
}
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
//联系方式合并
|
|
//联系方式合并
|
|
- var tmpperson, winnertel string
|
|
|
|
- tmpperson = tmp["winnerperson"].(string)
|
|
|
|
- if tmp["winnertel"] == nil || tmp["winnertel"] == "" {
|
|
|
|
- winnertel = ""
|
|
|
|
|
|
+ var tmpperson, agencytel string
|
|
|
|
+ tmpperson = tmp["agencyperson"].(string)
|
|
|
|
+ if tmp["agencytel"] == nil || tmp["agencytel"] == "" {
|
|
|
|
+ agencytel = ""
|
|
} else {
|
|
} else {
|
|
- if Reg_xing.MatchString(util.ObjToString(tmp["winnertel"])) || !Reg_tel.MatchString(util.ObjToString(tmp["winnertel"])) {
|
|
|
|
- winnertel = ""
|
|
|
|
|
|
+ if Reg_xing.MatchString(util.ObjToString(tmp["agencytel"])) || !Reg_tel.MatchString(util.ObjToString(tmp["agencytel"])) {
|
|
|
|
+ agencytel = ""
|
|
} else {
|
|
} else {
|
|
- winnertel = util.ObjToString(tmp["winnertel"])
|
|
|
|
|
|
+ agencytel = util.ObjToString(tmp["agencytel"])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
contactMaps := make([]interface{}, 0)
|
|
contactMaps := make([]interface{}, 0)
|
|
@@ -330,7 +331,7 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
tmpContact["infoid"] = overid
|
|
tmpContact["infoid"] = overid
|
|
tmpContact["contact_person"] = tmpperson
|
|
tmpContact["contact_person"] = tmpperson
|
|
tmpContact["contact_type"] = "项目联系人"
|
|
tmpContact["contact_type"] = "项目联系人"
|
|
- tmpContact["phone"] = winnertel
|
|
|
|
|
|
+ tmpContact["phone"] = agencytel
|
|
tmpContact["topscopeclass"] = strings.Join(tmpTopscopeclass, ";")
|
|
tmpContact["topscopeclass"] = strings.Join(tmpTopscopeclass, ";")
|
|
tmpContact["updatetime"] = time.Now().Unix()
|
|
tmpContact["updatetime"] = time.Now().Unix()
|
|
contactMaps = append(contactMaps, tmpContact)
|
|
contactMaps = append(contactMaps, tmpContact)
|
|
@@ -341,7 +342,7 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
for _, vv := range v {
|
|
for _, vv := range v {
|
|
if vvv, ok := vv.(map[string]interface{}); ok {
|
|
if vvv, ok := vv.(map[string]interface{}); ok {
|
|
if vvv["contact_person"] == tmpperson && vvv["contact_type"] == "项目联系人" &&
|
|
if vvv["contact_person"] == tmpperson && vvv["contact_type"] == "项目联系人" &&
|
|
- vvv["phone"] == winnertel && vvv["topscopeclass"] == strings.Join(tmpTopscopeclass, ";") {
|
|
|
|
|
|
+ vvv["phone"] == agencytel && vvv["topscopeclass"] == strings.Join(tmpTopscopeclass, ";") {
|
|
isNotUpdate = true
|
|
isNotUpdate = true
|
|
vvv["updatetime"] = time.Now().Unix()
|
|
vvv["updatetime"] = time.Now().Unix()
|
|
}
|
|
}
|
|
@@ -351,9 +352,9 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
if !isNotUpdate {
|
|
if !isNotUpdate {
|
|
vvv := make(map[string]interface{})
|
|
vvv := make(map[string]interface{})
|
|
vvv["infoid"] = overid
|
|
vvv["infoid"] = overid
|
|
- vvv["contact_person"] = tmp["winnerperson"]
|
|
|
|
|
|
+ vvv["contact_person"] = tmp["agencyperson"]
|
|
vvv["contact_type"] = "项目联系人"
|
|
vvv["contact_type"] = "项目联系人"
|
|
- vvv["phone"] = winnertel
|
|
|
|
|
|
+ vvv["phone"] = agencytel
|
|
vvv["topscopeclass"] = strings.Join(tmpTopscopeclass, ";")
|
|
vvv["topscopeclass"] = strings.Join(tmpTopscopeclass, ";")
|
|
vvv["updatetime"] = time.Now().Unix()
|
|
vvv["updatetime"] = time.Now().Unix()
|
|
contactMaps = append(contactMaps, vvv)
|
|
contactMaps = append(contactMaps, vvv)
|
|
@@ -369,7 +370,7 @@ func TaskAgency(mapinfo *map[string]interface{}) {
|
|
}
|
|
}
|
|
//es更新
|
|
//es更新
|
|
delete(oldTmp, "_id")
|
|
delete(oldTmp, "_id")
|
|
- if _, err := EsConn.Update().Index(Config["elasticsearch_index"]).Type(Config["elasticsearch_type"]).Id(esId).Doc(oldTmp).Refresh(true).Do(); err != nil {
|
|
|
|
|
|
+ if _, err := EsConn.Update().Index(Config["elasticsearch_agency_index"]).Type(Config["elasticsearch_agency_type"]).Id(esId).Doc(oldTmp).Refresh(true).Do(); err != nil {
|
|
log.Println("EsConn err :", err)
|
|
log.Println("EsConn err :", err)
|
|
}
|
|
}
|
|
}
|
|
}
|