Browse Source

数据监控 ods_datamonitoring_bidding 添加更新时间字段

wcc 1 năm trước cách đây
mục cha
commit
1b030e4b2a
1 tập tin đã thay đổi với 3 bổ sung84 xóa
  1. 3 84
      bidding_listen/main.go

+ 3 - 84
bidding_listen/main.go

@@ -196,6 +196,7 @@ func saveBidding(tmp map[string]interface{}) {
 	}
 
 	insert["project_id"] = ""
+	insert["updatetime"] = time.Now().Format("2006-01-02 15:04:05")
 
 	//查询MongoDB project 信息
 	wherep := map[string]interface{}{
@@ -213,47 +214,6 @@ func saveBidding(tmp map[string]interface{}) {
 		}
 	}
 
-	//
-	//esquery := es.NewBoolQuery().Filter(es.NewTermQuery("ids", id))
-	//// 执行查询
-	//searchResult, err := EsClient.Search().
-	//	Index(GF.EsP.Index).
-	//	Query(esquery).
-	//	Source(es.NewFetchSourceContext(true).Include("id", "pici")).
-	//	Do(context.Background())
-	//
-	//if err != nil {
-	//	log.Info("saveBidding", zap.Any("EsClient.Search.Error", err))
-	//}
-	//
-	//if searchResult.Hits.TotalHits.Value > 0 {
-	//	// 处理查询结果
-	//	// 处理查询结果并转换为map
-	//	for _, hit := range searchResult.Hits.Hits {
-	//		//fmt.Printf("Found document with id %s\n", hit.Id)
-	//		// 处理你的文档数据...
-	//		result := make(map[string]interface{})
-	//		err = json.Unmarshal(hit.Source, &result)
-	//		if err != nil {
-	//			log.Info("dealBidding", zap.Any("Unmarshal err", err))
-	//		}
-	//		if len(result) > 0 {
-	//			insert["project_id"] = result["id"]
-	//
-	//			if project_pici, ok := result["pici"].(float64); ok {
-	//				timeString := time.Unix(int64(project_pici), 0).Format("2006-01-02 15:04:05")
-	//				insert["project_pici"] = timeString
-	//			}
-	//			if project_pici, ok := result["pici"].(float64); ok {
-	//				timeString := time.Unix(int64(project_pici), 0).Format("2006-01-02 15:04:05")
-	//				insert["es_project_pici"] = timeString
-	//			}
-	//		}
-	//	}
-	//} else {
-	//	insert["project_id"] = ""
-	//}
-
 	if len(insert) > 0 {
 		insertId := Mysql.Insert(GF.Mysql.Table, insert)
 		if insertId <= 0 {
@@ -339,6 +299,7 @@ func updateProject(tmp map[string]interface{}) {
 		"id": tmp["id"],
 	}
 
+	timenow := time.Now().Format("2006-01-02 15:04:05")
 	//查询MongoDB project 信息
 	wherep := map[string]interface{}{
 		"ids": id,
@@ -352,6 +313,7 @@ func updateProject(tmp map[string]interface{}) {
 			time, _ := convertToTime(p["pici"])
 			update["project_pici"] = time.Format("2006-01-02 15:04:05")
 			update["es_project_pici"] = time.Format("2006-01-02 15:04:05")
+			update["updatetime"] = timenow
 		}
 	}
 
@@ -362,47 +324,4 @@ func updateProject(tmp map[string]interface{}) {
 		}
 	}
 
-	//esquery := es.NewBoolQuery().Filter(es.NewTermQuery("ids", tmp["bidding_id"]))
-	//// 执行查询
-	//searchResult, err := EsClient.Search().
-	//	Index(GF.EsP.Index).
-	//	Query(esquery).
-	//	Do(context.Background())
-	//
-	//if err != nil {
-	//	log.Info("updateProject", zap.Any("EsClient.Search.Error", err))
-	//}
-	//
-	//if searchResult.Hits.TotalHits.Value > 0 {
-	//	// 处理查询结果
-	//	// 处理查询结果并转换为map
-	//	for _, hit := range searchResult.Hits.Hits {
-	//		//fmt.Printf("Found document with id %s\n", hit.Id)
-	//		// 处理你的文档数据...
-	//		result := make(map[string]interface{})
-	//		err = json.Unmarshal(hit.Source, &result)
-	//		if err != nil {
-	//			log.Info("dealBidding", zap.Any("Unmarshal err", err))
-	//		}
-	//		if len(result) > 0 {
-	//			update := map[string]interface{}{
-	//				"project_id": result["id"],
-	//			}
-	//			log.Info("updateProject", zap.Any("bidding_id", tmp["bidding_id"]))
-	//			if project_pici, ok := result["pici"].(float64); ok {
-	//				timeString := time.Unix(int64(project_pici), 0).Format("2006-01-02 15:04:05")
-	//				update["project_pici"] = timeString
-	//				update["es_project_pici"] = timeString
-	//			}
-	//
-	//			where := map[string]interface{}{
-	//				"id": tmp["id"],
-	//			}
-	//			res := Mysql.Update(GF.Mysql.Table, where, update)
-	//			if !res {
-	//				log.Info("updateProject", zap.Any("update", update), zap.Any("where", where))
-	//			}
-	//		}
-	//	}
-	//}
 }