فهرست منبع

新增buyerclass

mxs 1 سال پیش
والد
کامیت
a381f1c833
3فایلهای تغییر یافته به همراه50 افزوده شده و 42 حذف شده
  1. 17 10
      data_project_wy/history.go
  2. 19 20
      data_project_wy/main.go
  3. 14 12
      data_project_wy/task.go

+ 17 - 10
data_project_wy/history.go

@@ -256,7 +256,7 @@ func HisTransactionDataFromProject() {
 func HisTransactionDataAddInformation() {
 	sess := MgoPro.GetMgoConn()
 	defer MgoPro.DestoryMongoConn(sess)
-	ch := make(chan bool, 20)
+	ch := make(chan bool, 5)
 	wg := &sync.WaitGroup{}
 	lock := &sync.Mutex{}
 	query := map[string]interface{}{
@@ -276,9 +276,16 @@ func HisTransactionDataAddInformation() {
 		//"_id": map[string]interface{}{
 		//	"$lte": mongodb.StringTOBsonId("661f798b5a4e6cc01349dad0"),
 		//},
+
+		//历史projectset_wy
 		"project_id": map[string]interface{}{
 			"$lte": "662143800000000000000000",
 		},
+
+		//历史projectset_wy_back
+		//"update_time": map[string]interface{}{
+		//	"$lt": 1714959573,
+		//},
 	}
 	count := MgoPro.Count("projectset_wy", query)
 	fmt.Println("count:", count)
@@ -311,14 +318,14 @@ func HisTransactionDataAddInformation() {
 
 			if from := gconv.String(tmp["from"]); from == "project" {
 				//项目信息补充业态
-				project_id := gconv.String(tmp["project_id"])
-				pro, _ := MgoPro.FindById("projectset_20230904", project_id, map[string]interface{}{"property_form": 1})
-				if len(*pro) > 0 && (*pro)["property_form"] != nil {
-					//更新
-					set["property_form"] = (*pro)["property_form"]
-					//保存
-					tmp["property_form"] = (*pro)["property_form"]
-				}
+				//project_id := gconv.String(tmp["project_id"])
+				//pro, _ := MgoPro.FindById("projectset_20230904", project_id, map[string]interface{}{"property_form": 1})
+				//if len(*pro) > 0 && (*pro)["property_form"] != nil {
+				//	//更新
+				//	set["property_form"] = (*pro)["property_form"]
+				//	//保存
+				//	tmp["property_form"] = (*pro)["property_form"]
+				//}
 
 				//查询情报信息
 				ids := gconv.Strings(tmp["info_ids"])
@@ -352,7 +359,7 @@ func HisTransactionDataAddInformation() {
 				fmt.Println("数据保存es失败,数据类型  项目project_id", tmp["project_id"])
 			}
 			var err error
-			err = UpdateOrSaveDataToClickHouse(tmp)
+			err = UpdateOrSaveDataToClickHouse(tmp) //保存、更新clickhouse
 			if err != nil {
 				fmt.Println("数据迁移失败,数据类型 项目project_id", tmp["project_id"], err)
 			}

+ 19 - 20
data_project_wy/main.go

@@ -38,7 +38,7 @@ func tmp() {
 	wg := &sync.WaitGroup{}
 	lock := &sync.Mutex{}
 	query := map[string]interface{}{
-		"project_bidstatus": 4,
+		//"project_bidstatus": 4,
 		//"_id": map[string]interface{}{
 		//	"$gte": mongodb.StringTOBsonId("66213b290f6ba3eb160617ad"),
 		//},
@@ -47,7 +47,7 @@ func tmp() {
 	fmt.Println("count:", count)
 	it := sess.DB(MgoPro.DbName).C("projectset_wy").Find(&query).Iter()
 	n := 0
-	//arr := [][]map[string]interface{}{}
+	arr := [][]map[string]interface{}{}
 	for tmp := make(map[string]interface{}); it.Next(tmp); n++ {
 		ch <- true
 		wg.Add(1)
@@ -57,15 +57,14 @@ func tmp() {
 				wg.Done()
 			}()
 			project_id := gconv.String(tmp["project_id"])
-			count := MgoPro.Count("projectset_wy_back", map[string]interface{}{"project_id": project_id})
-			if count > 0 {
-				fmt.Println(project_id)
-				MgoPro.Del("projectset_wy_back", map[string]interface{}{"project_id": tmp["project_id"]})
+			data, _ := MgoB.FindById("bidding", project_id, map[string]interface{}{"buyerclass": 1})
+			buyerclass := gconv.String((*data)["buyerclass"])
+			update := []map[string]interface{}{
+				{"_id": tmp["_id"]},
+			}
+			set := map[string]interface{}{
+				"buyerclass": buyerclass,
 			}
-			//update := []map[string]interface{}{
-			//	{"_id": tmp["_id"]},
-			//}
-			//set := map[string]interface{}{}
 			//info_id := gconv.String(tmp["info_id"])
 			//data, _ := MgoPro.FindById("projectset", info_id, map[string]interface{}{"bidstatus": 1})
 			//if gconv.String((*data)["bidstatus"]) == "拟建" {
@@ -73,14 +72,14 @@ func tmp() {
 			//} else {
 			//	return
 			//}
-			//update = append(update, map[string]interface{}{"$set": set})
+			update = append(update, map[string]interface{}{"$set": set})
 			//
 			lock.Lock()
-			//arr = append(arr, update)
-			//if len(arr) > 500 {
-			//	MgoPro.UpdateBulk("projectset_wy_back", arr...)
-			//	arr = [][]map[string]interface{}{}
-			//}
+			arr = append(arr, update)
+			if len(arr) > 500 {
+				MgoPro.UpdateBulk("projectset_wy", arr...)
+				arr = [][]map[string]interface{}{}
+			}
 			lock.Unlock()
 		}(tmp)
 		if n%10000 == 0 {
@@ -89,9 +88,9 @@ func tmp() {
 		tmp = map[string]interface{}{}
 	}
 	wg.Wait()
-	//if len(arr) > 0 {
-	//	MgoPro.UpdateBulk("projectset_wy_back", arr...)
-	//	arr = [][]map[string]interface{}{}
-	//}
+	if len(arr) > 0 {
+		MgoPro.UpdateBulk("projectset_wy", arr...)
+		arr = [][]map[string]interface{}{}
+	}
 	fmt.Println("迁移结束...")
 }

+ 14 - 12
data_project_wy/task.go

@@ -22,6 +22,7 @@ type Transaction struct {
 	Info_Id           string   `bson:"info_id"`
 	Info_Ids          []string `bson:"info_ids"`
 	Information_Id    string   `bson:"information_id"`
+	BuyerClass        string   `bson:"buyerclass"`
 	Buyer             string   `bson:"buyer"`
 	Buyer_Id          string   `bson:"buyer_id"`
 	Winner            []string `bson:"winner"`
@@ -83,6 +84,7 @@ func IncTransactionDataFromBid() {
 		"area":          1,
 		"city":          1,
 		"district":      1,
+		"buyerclass":    1,
 		//
 		"owner":                 1,
 		"s_topscopeclass":       1,
@@ -160,6 +162,7 @@ func IncTransactionDataFromBid() {
 func DealTransactionForBid(tmp map[string]interface{}, business_type string, project_bidstatus int) map[string]interface{} {
 	//基本信息封装
 	id := mongodb.BsonIdToSId(tmp["_id"])
+	buyerclass := gconv.String(tmp["buyerclass"])
 	buyer := gconv.String(tmp["buyer"])
 	if buyer == "" {
 		buyer = gconv.String(tmp["owner"])
@@ -186,11 +189,10 @@ func DealTransactionForBid(tmp map[string]interface{}, business_type string, pro
 	}
 
 	//TODO 情报库信息(待补充)
-	information_id := ""
-	starttime, endtime := int64(0), int64(0)
+	info := Infomation{}
 	//if project_bidstatus == 4 {//补充情报信息
 	//	//bidId = "65fbf3f566cf0db42a2a99d2"
-	//	info := FindInfomationData(id) //情报信息查询
+	//	info = FindInfomationData(id) //情报信息查询
 	//	information_id = info.Id
 	//	starttime = info.Starttime
 	//	endtime = info.Endtime
@@ -201,9 +203,7 @@ func DealTransactionForBid(tmp map[string]interface{}, business_type string, pro
 	if winner != "" {
 		winners = strings.Split(winner, ",")
 	}
-	buyer_id, agency_id := "", ""
-	winner_ids := []string{}
-	//buyer_id, agency_id, winner_ids := FindEntInfoData(id, buyer, agency, winners)
+	buyer_id, agency_id, winner_ids := FindEntInfoData(id, buyer, agency, winners)
 	//物业信息
 	t := &Transaction{
 		Project_Id:        id,
@@ -215,7 +215,8 @@ func DealTransactionForBid(tmp map[string]interface{}, business_type string, pro
 		Project_Bidstatus: project_bidstatus,
 		Info_Id:           id,
 		Info_Ids:          []string{id},
-		Information_Id:    information_id,
+		Information_Id:    info.Id,
+		BuyerClass:        buyerclass,
 		Buyer:             buyer,
 		Winner:            winners,
 		Agency:            agency,
@@ -230,8 +231,8 @@ func DealTransactionForBid(tmp map[string]interface{}, business_type string, pro
 		District:          gconv.String(tmp["district"]),
 		ZbTime:            gconv.Int64(tmp["publishtime"]),
 		JgTime:            int64(0),
-		StartTime:         starttime,
-		EndTime:           endtime,
+		StartTime:         info.Starttime,
+		EndTime:           info.Endtime,
 		Create_Time:       time.Now().Unix(),
 		Update_Time:       time.Now().Unix(),
 		//
@@ -278,6 +279,7 @@ func IncTransactionDataFromPro() {
 		"zbtime":        1,
 		"jgtime":        1,
 		"bidstatus":     1,
+		"buyerclass":    1,
 		//
 		"firsttime":             1,
 		"pici":                  1,
@@ -337,6 +339,7 @@ func IncTransactionDataFromPro() {
 func DealTransactionForPro(data map[string]interface{}) map[string]interface{} {
 	//基本信息封装
 	id := mongodb.BsonIdToSId(data["_id"])
+	buyerclass := gconv.String(data["buyerclass"])
 	buyer := gconv.String(data["buyer"])
 	winner := gconv.String(data["s_winner"])
 	agency := gconv.String(data["agency"])
@@ -388,9 +391,7 @@ func DealTransactionForPro(data map[string]interface{}) map[string]interface{} {
 	if winner != "" {
 		winners = strings.Split(winner, ",")
 	}
-	buyer_id, agency_id := "", ""
-	winner_ids := []string{}
-	//buyer_id, agency_id, winner_ids = FindEntInfoData(id, buyer, agency, winners)
+	buyer_id, agency_id, winner_ids := FindEntInfoData(id, buyer, agency, winners)
 	//物业信息
 	t := &Transaction{
 		Project_Id:        id,
@@ -403,6 +404,7 @@ func DealTransactionForPro(data map[string]interface{}) map[string]interface{} {
 		Info_Id:           gconv.String(data["sourceinfoid"]),
 		Info_Ids:          ids,
 		Information_Id:    info.Id,
+		BuyerClass:        buyerclass,
 		Buyer:             buyer,
 		Winner:            winners,
 		Agency:            agency,