瀏覽代碼

Merge branch 'feature/v1.0.35' into feature/v1.0.33

wangchuanjin 2 月之前
父節點
當前提交
02dafa97eb
共有 1 個文件被更改,包括 19 次插入10 次删除
  1. 19 10
      common/src/qfw/util/dataexport/dataexport.go

+ 19 - 10
common/src/qfw/util/dataexport/dataexport.go

@@ -815,7 +815,7 @@ func GetDataExportSelectResultFromMongoDb(bidding mg.MongodbSim, biddingName str
 	sess := bidding.GetMgoConn()
 	defer bidding.DestoryMongoConn(sess)
 	selectMap := map[string]interface{}{
-		"_id": 1, "title": 1, "detail": 1, "area": 1, "city": 1, "publishtime": 1, "projectname": 1, "buyer": 1, "s_winner": 1, "bidamount": 1, "subtype": 1, "toptype": 1, "filetext": 1, "purchasing": 1,
+		"_id": 1, "title": 1, "area": 1, "city": 1, "publishtime": 1, "projectname": 1, "buyer": 1, "s_winner": 1, "bidamount": 1, "subtype": 1, "toptype": 1, "filetext": 1, "purchasing": 1,
 	}
 	if dataType == "2" {
 		for _, key := range []string{"href", "projectcode", "buyerperson", "buyertel", "budget", "bidopentime", "agency", "projectscope", "winnerperson", "winnertel", "bidendtime", "district", "signendtime", "buyeraddr", "filetext", "buyerclass", "s_topscopeclass", "entidlist", "signaturedate"} {
@@ -830,7 +830,16 @@ func GetDataExportSelectResultFromMongoDb(bidding mg.MongodbSim, biddingName str
 	for i, id := range scd.SelectIds {
 		idArr = append(idArr, id)
 		if len(idArr) == 200 || i+1 == len(scd.SelectIds) {
-
+			details := elastic.Get(INDEX, TYPE, fmt.Sprintf(`{"query":{"bool":{"must":[{"terms":{"id":["%s"]}}]}},"_source": ["id",detail"],"size":%d}`, strings.Join(idArr, "\",\""), len(idArr)))
+			idDetail := map[string]string{}
+			if details != nil && len(*details) > 0 {
+				for _, bv := range *details {
+					if detail, _ := bv["detail"].(string); detail != "" {
+						id, _ := bv["id"].(string)
+						idDetail[id] = contentfilterReg.ReplaceAllString(detail, "")
+					}
+				}
+			}
 			log.Println(scd.Id, "GetDataExportSelectResultFromMongoDb===", idArr[0])
 			var (
 				queryIds []interface{}
@@ -843,11 +852,11 @@ func GetDataExportSelectResultFromMongoDb(bidding mg.MongodbSim, biddingName str
 				"$in": queryIds,
 			}}).Iter()
 			for m := make(map[string]interface{}); iter.Next(&m); {
-				m["_id"] = mg.BsonIdToSId(m["_id"])
-				detail, _ := m["detail"].(string)
-				if detail != "" {
-					m["detail"] = contentfilterReg.ReplaceAllString(detail, "")
+				_id := mg.BsonIdToSId(m["_id"])
+				if idDetail[_id] != "" {
+					m["detail"] = idDetail[_id]
 				}
+				m["_id"] = _id
 				count++
 				returnLsit = append(returnLsit, m)
 				m = make(map[string]interface{})
@@ -857,11 +866,11 @@ func GetDataExportSelectResultFromMongoDb(bidding mg.MongodbSim, biddingName str
 					"$in": queryIds,
 				}}).Iter()
 				for m := make(map[string]interface{}); iter_back.Next(&m); {
-					m["_id"] = mg.BsonIdToSId(m["_id"])
-					detail, _ := m["detail"].(string)
-					if detail != "" {
-						m["detail"] = contentfilterReg.ReplaceAllString(detail, "")
+					_id := mg.BsonIdToSId(m["_id"])
+					if idDetail[_id] != "" {
+						m["detail"] = idDetail[_id]
 					}
+					m["_id"] = _id
 					returnLsit = append(returnLsit, m)
 					m = make(map[string]interface{})
 				}