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

更新 bidding 索引,同时bidding_temp 19905 索引

wcc 1 сар өмнө
parent
commit
0c8efdba5b

+ 6 - 0
createEsIndex/bidding_es.go

@@ -221,6 +221,12 @@ func biddingTask(mapInfo map[string]interface{}) {
 				}
 			}
 			newTmp["stype"] = stype
+			pici := util.Int64All(tmp["pici"])
+			//MongoDB 存在pici 字段
+			if pici > 0 {
+				newTmp["pici"] = pici
+			}
+
 			//
 			//if stype == "bidding" || stype == "bidding_history" || stype == "index-by-id" {
 			//	newTmp["stype"] = stype

+ 1 - 1
createEsIndex/common.toml

@@ -84,7 +84,7 @@
     password = "Top2023_JEB01i@31"
     size = 5
     indexb = "bidding"
-#    indextmp = "bidding_temporary"       ## 临时索引,其他程序需要;目前已不需要
+    indextmp = "bidding_temporary"       ## 临时索引,
     indexp = "projectset"
     indexpd = "projectdetail" ## 项目支持detail的新索引
     biddingdetail = "bidding_detail" ## 标讯详情

+ 4 - 3
createEsIndex/init.go

@@ -55,6 +55,7 @@ func InitLog() {
 	}
 
 	log.Info("InitLog", zap.Any("duration", time.Since(now).Seconds()))
+	log.Info("InitLog", zap.Any("config.db", config.Conf.DB))
 }
 
 func InitMgo() {
@@ -178,9 +179,9 @@ func InitEs() {
 		log.Debug("InitEs", zap.String("IndexP", config.Conf.DB.Es.IndexP))
 	}
 
-	//if config.Conf.DB.Es.IndexTmp == "" {
-	//	log.Error("InitEs", zap.String("IndexTmp 为空", "请检查是否需要配置;该配置主要生产环境需要"))
-	//}
+	if config.Conf.DB.Es.IndexTmp == "" {
+		log.Error("InitEs", zap.String("IndexTmp 为空", "请检查是否需要配置;该配置主要生产环境需要"))
+	}
 	if config.Conf.DB.Es.IndexWinner == "" {
 		log.Error("InitEs", zap.String("IndexWinner", "中标单位 索引为空,请检查"))
 	} else {

+ 12 - 1
createEsIndex/main.go

@@ -453,7 +453,8 @@ func SaveEsMethod() {
 			mgoUpdate := make(map[string]interface{})
 			if stype == "bidding" || stype == "bidding_history" || stype == "index-by-id" {
 				//之前存在pici,就不在添加
-				if pici, ok := v["pici"]; ok {
+				if pici, ok := v["pici"]; ok && util.Int64All(pici) > 0 {
+					log.Info("SaveEsMethod,之前存在pici", zap.Any("MongoDB中老的pici", pici), zap.Any("id", v["id"]), zap.Any("time", time.Now().Unix()))
 					v["pici"] = pici
 				} else {
 					picc := time.Now().Unix()
@@ -462,6 +463,8 @@ func SaveEsMethod() {
 				}
 			}
 
+			log.Info("SaveEsMethod,保存bidding数据到es;单携程保存", zap.Any("pici", v["pici"]), zap.Any("id", v["id"]), zap.Any("time", time.Now().Unix()))
+
 			if len(mgoUpdate) > 0 {
 				updateBiddingPool <- map[string]interface{}{
 					"_id": mongodb.StringTOBsonId(util.ObjToString(v["_id"])),
@@ -488,6 +491,13 @@ func SaveEsMethod() {
 					}
 				}
 				Es2.Save(config.Conf.DB.Es.Indexb2, v)
+				// bidding_temporary,只需要存放 19905 这个集群
+				if config.Conf.DB.Es.IndexTmp != "" {
+					v["id"] = id
+					v["_id"] = ids
+					delete(v, "old_preferid")
+					Es2.Save(config.Conf.DB.Es.IndexTmp, v)
+				}
 			}
 			// 华为云新集群2,迁移原来阿里云数据
 			if config.Conf.DB.Es.Addr3 != "" {
@@ -626,6 +636,7 @@ func SaveAllEsMethod() {
 	for {
 		select {
 		case v := <-saveEsAllPool:
+			log.Info("biddingDataTask,保存爬虫采集临时数据,保存在华为云上", zap.Any("pici", v["pici"]), zap.Any("id", v["id"]), zap.Any("time", time.Now().Unix()))
 			arru[indexu] = v
 			indexu++
 			if indexu == EsBulkSize {