Эх сурвалжийг харах

新增模型字段info_ids

mxs 1 жил өмнө
parent
commit
87990c5263

+ 16 - 16
data_project_wy/history.go

@@ -286,26 +286,26 @@ func HisTransactionDataAddInformation() {
 			set["winner_id"] = winner_ids
 
 			//项目信息补充业态
-			//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"]
-			//	}
-			//}
+			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"]
+				}
+			}
 			delete(tmp, "from") //无用字段删除
 			delete(tmp, "_id")  //无用字段删除
 			tmp["buyer_id"] = buyer_id
 			tmp["agency_id"] = agency_id
-			tmp["winner_id"] = winner_ids
-			if !SaveDataToEs(tmp) { //保存、更新es
-				fmt.Println("数据保存es失败,数据类型  项目project_id", tmp["project_id"])
-			}
-			var err error
-			err = UpdateOrSaveDataToClickHouse(tmp)
-			if err != nil {
-				fmt.Println("数据迁移失败,数据类型 项目project_id", tmp["project_id"], err)
-			}
+			tmp["w-inner_id"] = winner_ids
+			//if !SaveDataToEs(tmp) { //保存、更新es
+			//	fmt.Println("数据保存es失败,数据类型  项目project_id", tmp["project_id"])
+			//}
+			//var err error
+			//err = UpdateOrSaveDataToClickHouse(tmp)
+			//if err != nil {
+			//	fmt.Println("数据迁移失败,数据类型 项目project_id", tmp["project_id"], err)
+			//}
 			//更新
 			update = append(update, map[string]interface{}{"$set": set})
 			lock.Lock()

+ 7 - 9
data_project_wy/main.go

@@ -38,9 +38,9 @@ func tmp() {
 	wg := &sync.WaitGroup{}
 	lock := &sync.Mutex{}
 	query := map[string]interface{}{
-		"zbtime": 0,
+		//"zbtime": 0,
 	}
-	it := sess.DB(MgoPro.DbName).C("projectset_wy_back").Find(&query).Iter()
+	it := sess.DB(MgoPro.DbName).C("projectset_wy").Find(&query).Iter()
 	n := 0
 	arr := [][]map[string]interface{}{}
 	for tmp := make(map[string]interface{}); it.Next(tmp); n++ {
@@ -51,20 +51,18 @@ func tmp() {
 				<-ch
 				wg.Done()
 			}()
-			projectid := gconv.String(tmp["project_id"])
-			data, _ := MgoPro.FindById("projectset_20230904", projectid, map[string]interface{}{"firsttime": 1})
-			firsttime := gconv.Int64((*data)["firsttime"])
+			info_id := gconv.String(tmp["info_id"])
 			update := []map[string]interface{}{
 				{"_id": tmp["_id"]},
 			}
 			set := map[string]interface{}{
-				"zbtime": firsttime,
+				"info_ids": []string{info_id},
 			}
 			update = append(update, map[string]interface{}{"$set": set})
 			lock.Lock()
 			arr = append(arr, update)
-			if len(arr) > 100 {
-				MgoPro.UpdateBulk("projectset_wy_back", arr...)
+			if len(arr) > 500 {
+				MgoPro.UpdateBulk("projectset_wy", arr...)
 				arr = [][]map[string]interface{}{}
 			}
 			lock.Unlock()
@@ -76,7 +74,7 @@ func tmp() {
 	}
 	wg.Wait()
 	if len(arr) > 0 {
-		MgoPro.UpdateBulk("projectset_wy_back", arr...)
+		MgoPro.UpdateBulk("projectset_wy", arr...)
 		arr = [][]map[string]interface{}{}
 	}
 	fmt.Println("迁移结束...")

+ 3 - 0
data_project_wy/task.go

@@ -20,6 +20,7 @@ type Transaction struct {
 	Business_Type     string   `bson:"business_type"`
 	Project_Bidstatus int      `bson:"project_bidstatus"`
 	Info_Id           string   `bson:"info_id"`
+	Info_Ids          []string `bson:"info_ids"`
 	Information_Id    string   `bson:"information_id"`
 	Buyer             string   `bson:"buyer"`
 	Buyer_Id          string   `bson:"buyer_id"`
@@ -208,6 +209,7 @@ func DealTransactionForBid(tmp map[string]interface{}, business_type string, pro
 		Business_Type:     business_type,
 		Project_Bidstatus: project_bidstatus,
 		Info_Id:           id,
+		Info_Ids:          []string{id},
 		Information_Id:    information_id,
 		Buyer:             buyer,
 		Winner:            winners,
@@ -391,6 +393,7 @@ func DealTransactionForPro(data map[string]interface{}) map[string]interface{} {
 		Business_Type:     business_type,
 		Project_Bidstatus: project_bidstatus,
 		Info_Id:           gconv.String(data["sourceinfoid"]),
+		Info_Ids:          ids,
 		Information_Id:    info.Id,
 		Buyer:             buyer,
 		Winner:            winners,