소스 검색

Merge brant ch 'dev3.4' of http://192.168.3.207:10080/qmx/jy-data-extract into dev3.4

maxiaoshan 5 년 전
부모
커밋
6a260c2de6
1개의 변경된 파일55개의 추가작업 그리고 24개의 파일을 삭제
  1. 55 24
      standardata/src/standaragency.go

+ 55 - 24
standardata/src/standaragency.go

@@ -38,7 +38,7 @@ func agencyStandarData(db string, query map[string]interface{}) {
 		agencytel := qu.ObjToString(tmp["agencytel"])
 		if entid == "" {//redis 未存
 			savetoerr := true
-			if agencyperson != "" || agencytel != "" {
+			if agencytel != "" {
 				v := map[string]interface{}{
 					"contact_person": agencyperson,
 					"phone":          agencytel,
@@ -64,19 +64,34 @@ func agencyStandarData(db string, query map[string]interface{}) {
 				}
 			}
 		} else {
-			if agencyperson != "" || agencytel != "" {
-				v := map[string]interface{}{
-					"contact_person": agencyperson,
-					"phone":          agencytel,
-					"topscopeclass":  comRepTopscopeclass(topscopeclass),
-					"infoid":         infoid,
+			if agencytel != "" {
+				is_exist:=false //电话是否存在
+				for _,v := range ps{
+					if v["phone"]==agencytel{
+						is_exist = true
+						if agencyperson!=""&&v["contact_person"]!=agencyperson {
+							v["contact_person"]=agencyperson
+							v["infoid"] = infoid
+							bs, _ := json.Marshal(ps)//替换数据,更新
+							redis.PutRedis("agency", agencybd, agency, bs, -1)
+						}
+						continue
+					}
+				}
+				if !is_exist {
+					v := map[string]interface{}{
+						"contact_person": agencyperson,
+						"phone":          agencytel,
+						"topscopeclass":  comRepTopscopeclass(topscopeclass),
+						"infoid":         infoid,
+					}
+					MongoTo.UpdateById(agencyent, entid,
+						map[string]interface{}{
+							"$set":  v,
+							"$push": map[string]interface{}{"contact": v},
+						},
+					)
 				}
-				MongoTo.UpdateById(agencyent, entid,
-					map[string]interface{}{
-						"$set":  v,
-						"$push": map[string]interface{}{"contact": v},
-					},
-				)
 			}
 		}
 		tmp = map[string]interface{}{}
@@ -113,27 +128,43 @@ func historyagency(db, fromcoll string) {
 				agencytel := qu.ObjToString(tmp["agencytel"])
 				b, _ := redis.ExistRedis("agency", agencybd, agency)
 				if b {//redis 存在
-					if agencyperson != "" || agencytel != "" {
+					if  agencytel != "" {
 						strs, _ := redis.GetRedisStr("agency", agencybd, agency)
-						ps := []interface{}{}
+						ps := []map[string]interface{}{}
 						err := json.Unmarshal([]byte(strs), &ps)
 						if err == nil {
-							v := map[string]interface{}{
-								"contact_person": agencyperson,
-								"phone":          agencytel,
-								"topscopeclass":  comRepTopscopeclass(topscopeclass),
-								"infoid":         _id,
+							is_exist:=false //电话是否存在
+							for _,v := range ps{
+								if v["phone"]==agencytel{
+									is_exist = true
+									if agencyperson!=""&&v["contact_person"]!=agencyperson {
+										v["contact_person"]=agencyperson
+										v["infoid"] = _id
+										bs, _ := json.Marshal(ps)//替换数据,更新
+										redis.PutRedis("agency", agencybd, agency, bs, -1)
+									}
+									continue
+								}
+							}
+
+							if !is_exist {
+								v := map[string]interface{}{
+									"contact_person": agencyperson,
+									"phone":          agencytel,
+									"topscopeclass":  comRepTopscopeclass(topscopeclass),
+									"infoid":         _id,
+								}
+								ps = append(ps, v)
+								bs, _ := json.Marshal(ps)
+								redis.PutRedis("agency", agencybd, agency, bs, -1)
 							}
-							ps = append(ps, v)
-							bs, _ := json.Marshal(ps)
-							redis.PutRedis("agency", agencybd, agency, bs, -1)
 						} else {
 							log.Println("jsonErr", err)
 						}
 					}
 				} else {
 					val := []map[string]interface{}{}
-					if agencyperson != "" || agencytel != "" {
+					if agencytel != "" {
 						tmp := map[string]interface{}{
 							"contact_person": agencyperson,
 							"phone":          agencytel,