wcc 1 year ago
parent
commit
854a3cfa92
2 changed files with 16 additions and 9 deletions
  1. 0 5
      qyxy_std_new/main.go
  2. 16 4
      qyxy_std_new/task.go

+ 0 - 5
qyxy_std_new/main.go

@@ -50,11 +50,6 @@ func main() {
 	}
 	log.Info("main", zap.Any("qyxyEsAddr", qyxyEsAddr))
 
-	if int64(GF.Env.Autoid) == 0 || int64(GF.Env.Seoid) == 0 {
-		log.Error("配置文件错误", zap.String("配置文件", "autoid 或者 seoid 为 0"))
-		os.Exit(-1)
-	}
-
 	UdpClient.Listen(processUdpMsg)
 	log.Info("main", zap.String("Udp服务监听本地端口", localPort))
 

+ 16 - 4
qyxy_std_new/task.go

@@ -89,7 +89,7 @@ func updateStd() {
 	// 创建数据库操作对象
 	badgerDB := &bdb{db}
 	var id int64
-
+	// 获取 autoid
 	auotidOld := badgerDB.Get("autoid")
 	if auotidOld == "" {
 		id = int64(GF.Env.Autoid) //起始 autoid
@@ -99,14 +99,23 @@ func updateStd() {
 		id = int64(aotoid)
 	}
 
+	log.Println("autoid:", id)
+	if id == 0 {
+		log.Fatalln("autoid 为 0,请检查配置")
+	}
+	//获取 seo_id
 	seoIdOld := badgerDB.Get("seoid")
 	if seoIdOld == "" {
 		startSeoId = int64(GF.Env.Seoid) //起始 nseo_id
-		badgerDB.Set("autoid", strconv.Itoa(GF.Env.Seoid))
+		badgerDB.Set("seoid", strconv.Itoa(GF.Env.Seoid))
 	} else {
 		seoid, _ := strconv.Atoi(seoIdOld)
 		startSeoId = int64(seoid)
 	}
+	log.Println("seoid", startSeoId)
+	if startSeoId == 0 {
+		log.Fatalln("seoid 为 0,请检查配置")
+	}
 
 	rand.Seed(time.Now().UnixNano())
 
@@ -156,7 +165,10 @@ func updateStd() {
 				"_id": tmp["_id"],
 			}
 
-			MongoTool.Update("qyxy_std", where, update, true, false)
+			res := MongoTool.Update("qyxy_std", where, update, true, false)
+			if !res {
+				log.Println(tmp["_id"], "数据更新失败,nseo_id", nseo_id)
+			}
 
 			if count%10000 == 0 {
 				log.Println("current,autoid,startSeoId,nseo_id", count, id, startSeoId, nseo_id)
@@ -173,6 +185,6 @@ func updateStd() {
 	badgerDB.Set("autoid", strconv.Itoa(int(id)))
 	badgerDB.Set("seoid", strconv.Itoa(int(startSeoId)))
 
-	log.Println("over ----;", "seo_id:", startSeoId)
+	log.Println("over ----;", "autoid", id, "seoid:", startSeoId)
 
 }