Explorar el Código

修改查询条件

hace 6 años
padre
commit
b831da21e8
Se han modificado 2 ficheros con 30 adiciones y 28 borrados
  1. 16 16
      udpprojectset/src/main.go
  2. 14 12
      udpprojectset/src/projectmeger.go

+ 16 - 16
udpprojectset/src/main.go

@@ -196,11 +196,11 @@ func task(data []byte, mapInfo map[string]interface{}) {
 	sess := MQFW.GetMgoConn()
 	defer MQFW.DestoryMongoConn(sess)
 	//数据正序处理
-	it := sess.DB(MQFW.DbName).C(extractColl).Find(&q).Sort("publishtime").Iter()
+	it := sess.DB(MQFW.DbName).C(extractColl).Find(map[string]interface{}{}).Sort("publishtime").Iter()
 	count, index := 0, 0
 	pici := time.Now().Unix()
 	wg := &sync.WaitGroup{}
-	idmap := &sync.Map{}
+	//idmap := &sync.Map{}
 	for tmp := make(map[string]interface{}); it.Next(tmp); {
 		if index%10000 == 0 {
 			log.Println(index, tmp["_id"])
@@ -228,13 +228,13 @@ func task(data []byte, mapInfo map[string]interface{}) {
 		}
 		if !b {
 			wg.Add(1)
-			idmap.Store(tmp["_id"], true) //增加判重逻辑,重复id不再生成
+			//idmap.Store(tmp["_id"], true) //增加判重逻辑,重复id不再生成
 			MultiThread <- true
 			go func(tmp map[string]interface{}, thisid string) {
 				defer func() {
 					<-MultiThread
 					wg.Done()
-					idmap.Delete(tmp["_id"])
+					//idmap.Delete(tmp["_id"])
 				}()
 				info := PreThisInfo(tmp)
 				if info != nil {
@@ -251,18 +251,18 @@ func task(data []byte, mapInfo map[string]interface{}) {
 		}
 		tmp = make(map[string]interface{})
 	}
-	for {
-		time.Sleep(5 * time.Second)
-		n := 0
-		idmap.Range(func(key interface{}, v interface{}) bool {
-			n++
-			log.Println(key, v)
-			return true
-		})
-		if n < 1 {
-			break
-		}
-	}
+	//	for {
+	//		time.Sleep(5 * time.Second)
+	//		n := 0
+	//		idmap.Range(func(key interface{}, v interface{}) bool {
+	//			n++
+	//			log.Println(key, v)
+	//			return true
+	//		})
+	//		if n < 1 {
+	//			break
+	//		}
+	//	}
 	wg.Wait()
 	log.Println("task over...", index, count)
 	//发送udp,调用生成项目索引

+ 14 - 12
udpprojectset/src/projectmeger.go

@@ -65,7 +65,7 @@ func startProjectMerge(thisinfo *Info, tmp map[string]interface{}) {
 			bNormalScore = true
 		} else {
 			extInfoTag("invalid", qu.BsonIdToSId(tmp["_id"])) //无效信息,打标记
-			go IS.Add("invalid")                              //数据统计使用
+			//go IS.Add("invalid")                              //数据统计使用
 			return
 		}
 	} else {
@@ -189,8 +189,8 @@ func noBuyer(p PCBV, thisinfo *Info, tmp map[string]interface{}) {
 			sflag = "invalid"
 		}
 	}
-	extInfoTag(sflag, thisinfo.Id)
-	go IS.Add(sflag) //数据统计使用
+	//extInfoTag(sflag, thisinfo.Id)
+	//go IS.Add(sflag) //数据统计使用
 }
 
 //3选2打分
@@ -580,19 +580,21 @@ func lockPNCBMap(thisinfo *Info) {
 		}
 		if ok {
 			break
+		} else {
+			time.Sleep(100 * time.Millisecond)
 		}
 	}
 }
 
 //pncbMap解锁
 func unlockPNCBMap(thisinfo *Info) {
-	if len(thisinfo.PNKey) > 3 {
-		PNKeyMap.Delete(thisinfo.PNKey)
-	}
-	if len(thisinfo.PCKey) > 3 {
-		PCKeyMap.Delete(thisinfo.PCKey)
-	}
-	if len(thisinfo.PBKey) > 3 {
-		PBKeyMap.Delete(thisinfo.PBKey)
-	}
+	//if len(thisinfo.PNKey) > 3 {
+	PNKeyMap.Delete(thisinfo.PNKey)
+	//}
+	//if len(thisinfo.PCKey) > 3 {
+	PCKeyMap.Delete(thisinfo.PCKey)
+	//}
+	//if len(thisinfo.PBKey) > 3 {
+	PBKeyMap.Delete(thisinfo.PBKey)
+	//}
 }