Bläddra i källkod

更新 项目分包、省级项目 规则

wcc 1 år sedan
förälder
incheckning
c8161a316d
3 ändrade filer med 68 tillägg och 17 borttagningar
  1. 11 11
      website_columns/config.toml
  2. 39 1
      website_columns/main.go
  3. 18 5
      website_columns/utils.go

+ 11 - 11
website_columns/config.toml

@@ -1,17 +1,17 @@
 [mongob]  ## bidding 链接
-    host = "127.0.0.1:27083"
-    db = "qfw"
-    coll = "bidding"        ## 标讯数据标
-    username = "SJZY_RWbid_ES"
-    password = "SJZY@B4i4D5e6S"
-    direct = true
+#    host = "127.0.0.1:27083"
+#    db = "qfw"
+#    coll = "bidding"        ## 标讯数据标
+#    username = "SJZY_RWbid_ES"
+#    password = "SJZY@B4i4D5e6S"
+#    direct = true
 
     ## 测试环境
-#    host = "192.168.3.206:27002"
-#    db = "qfw_data"
-#    coll = "bidding"        ## 标讯数据标
-#    username = "root"
-#    password = "root"
+    host = "192.168.3.206:27002"
+    db = "qfw_data"
+    coll = "bidding"        ## 标讯数据标
+    username = "root"
+    password = "root"
 
 
 [mongop] ##  项目信息

+ 39 - 1
website_columns/main.go

@@ -58,7 +58,7 @@ func dealBidding() {
 	now := time.Now()
 	ctx, _ := context.WithTimeout(context.Background(), 99999*time.Hour)
 	coll := sess.M.C.Database(GF.MongoB.DB).Collection(GF.MongoB.Coll)
-	find := options.Find().SetBatchSize(1000).SetSort(bson.D{bson.E{"comeintime", 1}}).SetProjection(bson.M{"comeintime": 1, "toptype": 1, "subtype": 1, "buyerclass": 1, "title": 1, "detail": 1, "package": 1, "funds": 1, "spidercode": 1})
+	find := options.Find().SetBatchSize(1000).SetSort(bson.D{bson.E{"comeintime", 1}}).SetProjection(bson.M{"comeintime": 1, "toptype": 1, "subtype": 1, "buyerclass": 1, "title": 1, "detail": 1, "package": 1, "funds": 1, "spidercode": 1, "area": 1, "city": 1, "publishtime": 1})
 	if startTime != 0 && GF.Cron.End != 0 {
 		q = map[string]interface{}{
 			"comeintime": map[string]interface{}{
@@ -126,6 +126,18 @@ func dealBidding() {
 						"nav_column": reb,
 					}},
 				}
+
+				// 改动栏目的数据,存储临时表;刷存量数据使用
+				//if util.IntAll(rea["项目分包"]) == 1 || util.IntAll(rea["省级项目"]) == 1 {
+				//	insert := map[string]interface{}{
+				//		"bid_id":      mongodb.BsonIdToSId(tmp["_id"]),
+				//		"area":        tmp["area"],
+				//		"city":        tmp["city"],
+				//		"publishtime": time.Unix(util.Int64All(tmp["publishtime"]), 0).Format("2006-01-02 15:04:05"),
+				//		"nav_column":  reb,
+				//	}
+				//	MgoB.InsertOrUpdate(MgoB.DbName, "wcc_column_tmp", insert)
+				//}
 				//MgoB.Update(GF.MongoB.Coll, where, map[string]interface{}{"$set": update}, true, false)
 			}
 		}(tmp)
@@ -141,6 +153,7 @@ func dealBidding() {
 
 	//处理热门标讯数据/热门项目
 	getHot()
+	//dealHotDataAll()
 
 	log.Info("dealBidding", zap.Int("over ", count))
 }
@@ -360,3 +373,28 @@ func updateMethod() {
 		}
 	}
 }
+
+// dealHotDataAll 处理存量热门数据标签
+func dealHotDataAll() {
+	hotData, _ := MgoB.Find("bidding_hots", nil, nil, nil, false, -1, -1)
+	for _, data := range *hotData {
+		biddingID := util.ObjToString(data["bidding_id"])
+		bidding, _ := MgoB.FindById("bidding", biddingID, nil)
+		biddingData := *bidding
+		if biddingData == nil {
+			continue
+		}
+		biddingData["hot_data"] = 1
+		rea := TagBidding(biddingData)
+		reb := calculateFlag(rea, columns) //拿到十进制数字,标签栏目结果
+
+		updatePool <- []map[string]interface{}{
+			{"_id": mongodb.StringTOBsonId(biddingID)},
+			{"$set": bson.M{
+				"nav_column": reb,
+			}},
+		}
+	}
+
+	log.Info("dealHotDataAll", zap.Int("over", len(*hotData)))
+}

+ 18 - 5
website_columns/utils.go

@@ -109,7 +109,7 @@ func TagBidding(tmp map[string]interface{}) (res map[string]interface{}) {
 
 	//项目分包标签;总承包;1-9包;
 	// 定义正则表达式,匹配标段1到标段9,标段一到标段九,第一包到第九包,A包到D包,分包、包件号、发包、标包等关键词
-	pattern := `(标段[1-9一二三四五六七八九]|包段[1-9一二三四五六七八九]|第[1-9一二三四五六七八九]包|[a-kA-K]包|分包|包件号|发包|标包|总承包)`
+	pattern := `(专业分包|总承包)`
 	regex := regexp.MustCompile(pattern)
 	if regex.MatchString(title) || regex.MatchString(util.ObjToString(tmp["projectname"])) {
 		res["项目分包"] = 1
@@ -174,15 +174,28 @@ func TagBidding(tmp map[string]interface{}) (res map[string]interface{}) {
 			break
 		}
 	}
-
-	fundsWors2 := []string{"省级财政资金"}
-	for _, v := range fundsWors2 {
+	//省级项目 title 判断
+	titleWors2 := []string{"省级财政资金", "省级财政"}
+	for _, v := range titleWors2 {
 		if strings.Contains(title, v) {
 			res["省级项目"] = 1
 			break
 		}
 	}
-
+	//省级项目 funds 判断
+	if res["省级项目"] == nil {
+		if !strings.Contains(funds, "《") && !strings.Contains(funds, "》") {
+			if strings.Contains(funds, "省级") {
+				fundsWords2 := []string{"资金", "补助", "公益金"}
+				for _, v := range fundsWords2 {
+					if strings.Contains(funds, v) {
+						res["省级项目"] = 1
+						break
+					}
+				}
+			}
+		}
+	}
 	return
 }