Эх сурвалжийг харах

wip:数据导出增加二次匹配

wangkaiyue 2 жил өмнө
parent
commit
f41c24dde9

+ 0 - 2
src/jfw/front/dataExport.go

@@ -213,7 +213,6 @@ func (d *DataExport) SieveData() {
 		if msgCount > 20000 {
 			msgCount = 20000
 		}
-		dataexport.GetMatchKey(scd, list)
 		_res["data"] = map[string]interface{}{
 			"list":  subUrl(list, dataType),
 			"_id":   util.SE.Encode2Hex(_id),
@@ -545,7 +544,6 @@ func (d *DataExport) PreviewData(source, _id string) error {
 	//格式化字段
 	res_screen := dataexport.ScreenData(res, dataType, 20, kws)
 	list := dataexport.FormatExportData(public.Mgo_Ent, &res_screen, config.Sysconfig["webdomain"].(string), dataType, true)
-	dataexport.GetMatchKey(scd, list)
 
 	d.T["data"] = subUrl(list, dataType)
 	d.T["dataType"] = dataType

+ 0 - 1
src/jfw/front/ws_dataExport.go

@@ -205,7 +205,6 @@ func (w *WsDataExport) GetPreview() error {
 	if msgCount > 20000 {
 		msgCount = 20000
 	}
-	dataexport.GetMatchKey(scd, list)
 	_res["data"] = subUrl(list, dataType)
 	_res["dataType"] = dataType
 	_res["total"] = msgCount

+ 0 - 1
src/jfw/modules/app/src/app/front/ws_dataExport.go

@@ -83,7 +83,6 @@ func (w *WsDataExport) GetPreview() error {
 	if msgCount > 20000 {
 		msgCount = 20000
 	}
-	dataexport.GetMatchKey(scd, list)
 	_res["data"] = subUrl(list, dataType)
 	_res["dataType"] = dataType
 	_res["total"] = msgCount

+ 19 - 6
src/jfw/modules/common/src/qfw/util/dataexport/common.go

@@ -38,15 +38,23 @@ func GetLastExportPhoneAndMail(mysqlSess *mysql.Mysql, userId, entUserId string)
 	return
 }
 
-// GetMatchKey key 关键词 逗号分隔 或的关系进行关联  types 匹配类型  data数据
+// GetDataExportMatchKey key 关键词 逗号分隔 或的关系进行关联  types 匹配类型  data数据
 // title 标题,detail 正文,filetext 附件,purchasing 标的物,projectname.pname 项目命,mbuyer 采购单位,mwinner 中标单位,magency 代理机构
-func GetMatchKey(scd *SieveCondition, list *[]map[string]interface{}) {
-	types := scd.SelectType
-	kws := scd.Keyword
-	if len(kws) > 0 && kws[0].Keyword != "" {
+func GetDataExportMatchKey(scd *SieveCondition, list *[]map[string]interface{}) {
+	if list == nil || len(*list) == 0 {
+		return
+	}
+	if scd.Comeinfrom == "pushHistory" { //历史推送数据使用推送匹配关键词
+		if len(scd.Keyword) == len(*list) {
+			for i := 0; i < len(*list); i++ {
+				(*list)[i]["keyword"] = scd.Keyword[i]
+			}
+		}
+	} else if len(scd.Keyword) > 0 && scd.Keyword[0].Keyword != "" { //关键词二次匹配
+		types := scd.SelectType
 		var keys []string
 		//统计关键词
-		for _, vk := range kws {
+		for _, vk := range scd.Keyword {
 			keys = append(keys, strings.Replace(vk.Keyword, "+", ",", -1))
 		}
 		key := strings.Join(keys, ",")
@@ -117,3 +125,8 @@ func KeyWordToDatas(item, key string, keyWord []string) []string {
 	}
 	return keyWord
 }
+
+// 获取关键词匹配字段
+func getKeywordFields() {
+
+}

+ 10 - 2
src/jfw/modules/common/src/qfw/util/dataexport/dataexport.go

@@ -47,6 +47,7 @@ type SieveCondition struct {
 	SelectType       string    `json:"selectType"`       //筛选(正文 or 标题)
 	Subtype          string    `json:"subtype"`          //信息类型
 	SelectIds        []string  `json:"selectId"`         //选择信息导出
+	PushKeyWords     []string  `json:"pushKeyWords"`     //推送历史匹配词
 	Comeinfrom       string    `json:"comeinfrom"`       //查询来源
 	FileExists       string    `json:"fileExists"`       //是否有附件
 	SearchTypeSwitch bool      `json:"searchTypeSwitch"` //是否开启 正文 标题同时搜索只搜正文的开关
@@ -408,6 +409,7 @@ func GetSqlObjFromId(mongo mg.MongodbSim, _id string) *SieveCondition {
 		ComeInTime:       qutil.Int64All((*query)["comeintime"]),
 		Comeinfrom:       qutil.ObjToString((*query)["comeinfrom"]),
 		SelectIds:        getStringArrFromDbResult((*query)["selectIds"]),
+		PushKeyWords:     getStringArrFromDbResult((*query)["pushKeyWords"]),
 		FileExists:       qutil.ObjToString((*query)["fileExists"]),
 		SearchTypeSwitch: searchTypeSwitch,
 		BidField:         qutil.ObjToString((*query)["bid_field"]), // 领域化数据
@@ -506,7 +508,6 @@ func GetDataExportSearchResultByScdId(sim, bid mg.MongodbSim, bidMgoDBName, elas
 	if list == nil || err != nil {
 		return nil, err
 	}
-	GetMatchKey(scd, list)
 	return list, nil
 }
 
@@ -561,6 +562,7 @@ func GetDataExportSelectResult(bidding mg.MongodbSim, biddingName string, scd *S
 	for _, idStr := range scd.SelectIds {
 		queryIds = append(queryIds, mg.StringTOBsonId(idStr))
 	}
+
 	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,
 	}
@@ -664,7 +666,12 @@ func GetDataExportSearchResult(bid mg.MongodbSim, bidMgoDBName, elasticAddress s
 		return nil, errors.New("GetDataExportSearchResult-未获取到查询信息")
 	}
 	if scd.SelectIds != nil {
-		return GetDataExportSelectResult(bid, bidMgoDBName, scd, dataType, checkCount)
+		idSelectDates, idSelectErr := GetDataExportSelectResult(bid, bidMgoDBName, scd, dataType, checkCount)
+		if idSelectErr != nil {
+			return nil, idSelectErr
+		}
+		GetDataExportMatchKey(scd, idSelectDates)
+		return idSelectDates, idSelectErr
 	}
 	//获取查询语句
 	qstr := getDataExportSql(scd)
@@ -701,6 +708,7 @@ func GetDataExportSearchResult(bid mg.MongodbSim, bidMgoDBName, elasticAddress s
 	if checkCount != len(res) && checkCount != -1 {
 		return nil, fmt.Errorf("GetDataExportSearchResult-%s-数据总量校验异常,期望:%d,实际:%d", scd.Id, checkCount, len(res))
 	}
+	GetDataExportMatchKey(scd, &res)
 	return &res, nil
 }
 

+ 8 - 6
src/jfw/modules/publicapply/src/dataexport/service/action.go

@@ -229,22 +229,24 @@ func (des *DataExportStruct) ByPushHistory() {
 		if list == nil || len(list) == 0 {
 			return nil, fmt.Errorf("未匹配到导出数据")
 		}
-		ids := []string{}
+		ids := make([]string, 0, len(list))
+		keyWords := make([]string, 0, len(list)) //数据导出需增加匹配词
 		for _, pushData := range list {
 			if pushData.Id != "" {
 				if tmp := util.CommonDecodeArticle("content", pushData.Id); len(tmp) > 0 {
 					if id := tmp[0]; id != "" {
 						ids = append(ids, id)
+						keyWords = append(keyWords, strings.Join(pushData.Matchkeys, ","))
 					}
 				}
-				//ids = append(ids, util.CommonDecodeArticle("content", pushData.Id))
 			}
 		}
 		saveData := map[string]interface{}{
-			"s_userid":   userId,
-			"comeinfrom": "pushHistory",
-			"comeintime": time.Now().Unix(),
-			"selectIds":  ids,
+			"s_userid":     userId,
+			"comeinfrom":   "pushHistory",
+			"comeintime":   time.Now().Unix(),
+			"selectIds":    ids,
+			"pushKeyWords": keyWords,
 		}
 		_id := db.Mgo.Save(dataexport.ExportTable, saveData)
 		if _id == "" {