Explorar o código

site:中国招标投标公共服务平台detail替换为filetext

maxiaoshan %!s(int64=5) %!d(string=hai) anos
pai
achega
86778b2a27
Modificáronse 1 ficheiros con 24 adicións e 10 borrados
  1. 24 10
      udpcreateindex/src/bidingpurchasing.go

+ 24 - 10
udpcreateindex/src/bidingpurchasing.go

@@ -42,8 +42,19 @@ func biddingPurchaingTask(q map[string]interface{}) {
 			continue
 		}
 		newTmp := map[string]interface{}{} //最终生索引的数据
+		saveArr := []map[string]interface{}{}
 		//oss拼装filetext
 		if filetext := getFileText(tmp); len(filetext) > 0 {
+			if site, _ := tmp["site"].(string); site == "中国招标投标公共服务平台" { //site:中国招标投标公共服务平台 detail替换成filetext 并加入标记filedetail=1
+				tmp["detail"] = filetext
+				saveArr = append(saveArr, map[string]interface{}{"_id": tmp["_id"]})
+				saveArr = append(saveArr, map[string]interface{}{
+					"$set": map[string]interface{}{
+						"filedetail": 1,
+						"detail":     filetext,
+					},
+				})
+			}
 			newTmp["filetext"] = filetext
 		}
 		//purchasing
@@ -128,16 +139,19 @@ func biddingPurchaingTask(q map[string]interface{}) {
 			}
 		}
 		arrEs = append(arrEs, newTmp)
-		arrMgo = append(arrMgo, []map[string]interface{}{ //要更新数据
-			map[string]interface{}{
-				"_id": tmp["_id"],
-			},
-			map[string]interface{}{
-				"$set": map[string]interface{}{
-					"extract_state": 4,
-				},
-			},
-		})
+		if len(saveArr) > 0 {
+			arrMgo = append(arrMgo, saveArr) //要更新数据
+		}
+		// arrMgo = append(arrMgo, []map[string]interface{}{ //要更新数据
+		// 	map[string]interface{}{
+		// 		"_id": tmp["_id"],
+		// 	},
+		// 	map[string]interface{}{
+		// 		"$set": map[string]interface{}{
+		// 			"extract_state": 4,
+		// 		},
+		// 	},
+		// })
 		//批量更新
 		if len(arrMgo) >= savesizei-1 {
 			mgo.UpdateBulkAll(db, c, arrMgo...)