zhangjinkun vor 4 Jahren
Ursprung
Commit
b281e214d5
2 geänderte Dateien mit 68 neuen und 0 gelöschten Zeilen
  1. 66 0
      standardata/src/standarbuyer.go
  2. 2 0
      standardata/src/standarwinner.go

+ 66 - 0
standardata/src/standarbuyer.go

@@ -253,3 +253,69 @@ func buyerMegerBuyerclass(id string, ps map[string]interface{}) map[string]inter
 	data["mobilephone"] = timesMobilePhone
 	return data
 }
+
+func putbuyerreids() {
+	sess := MongoTo.GetMgoConn()
+	defer MongoTo.Close()
+	it := sess.DB("mixdata").C("buyer_enterprise").Find(map[string]interface{}{}).Select(bson.M{"buyer_name": 1}).Iter()
+	index := 0
+	for tmp := make(map[string]interface{}); it.Next(&tmp); index++ {
+		id := mongo.BsonTOStringId(tmp["_id"])
+		buyer_name, _ := tmp["buyer_name"].(string)
+		redis.PutRedis("buyer", 2, buyer_name, id, -1)
+		tmp = map[string]interface{}{}
+		if index%1000 == 0 {
+			log.Println(id, index)
+		}
+	}
+}
+
+func putbuyerreids__s() {
+	sess := MongoTo.GetMgoConn()
+	defer MongoTo.Close()
+	it := sess.DB("mixdata").C("buyer_enterprise").Find(map[string]interface{}{}).Select(bson.M{"buyer_name": 1}).Iter()
+	index := 0
+	for tmp := make(map[string]interface{}); it.Next(&tmp); index++ {
+		buyer_name, _ := tmp["buyer_name"].(string)
+		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)
+			MongoTo.DeleteById("buyer_enterprise", id)
+		}
+		if index%10000 == 0 {
+			log.Println(index)
+		}
+		tmp = map[string]interface{}{}
+	}
+}
+
+func modifybuyer() {
+	sess := MongoTo.GetMgoConn()
+	defer MongoTo.Close()
+	it := sess.DB("mixdata").C("buyer_enterprise").Find(map[string]interface{}{"institute_type": "事业单位"}).Iter()
+	index := 0
+	for tmp := make(map[string]interface{}); it.Next(&tmp); index++ {
+		id := mongo.BsonTOStringId(tmp["_id"])
+		buyer_name, _ := tmp["buyer_name"].(string)
+		bys, _ := MongoTo.Find(
+			"buyer_enterprise",
+			map[string]interface{}{"buyer_name": buyer_name}, nil,
+			bson.M{"institute_type": 1, "buyer_name": 1},
+		)
+		for _, by := range bys {
+			byid := mongo.BsonTOStringId(by["_id"])
+			institute_type, _ := by["institute_type"].(string)
+			if institute_type == "企业" {
+				MongoTo.Save("buyer_tmp", tmp)
+				delete(tmp, "_id")
+				MongoTo.UpdateById("buyer_enterprise", byid, map[string]interface{}{
+					"$set": tmp,
+				})
+				MongoTo.DeleteById("buyer_enterprise", id)
+				log.Println(id)
+			}
+		}
+		tmp = map[string]interface{}{}
+	}
+}

+ 2 - 0
standardata/src/standarwinner.go

@@ -324,6 +324,8 @@ func comHisMegerNewData(name, datatype string, ps []map[string]interface{}) map[
 				}
 			}
 		}
+	} else {
+		return nil
 	}
 
 	//从年报中取网址、邮箱、打电话