|
@@ -347,102 +347,45 @@ func GetDataExportSearchResultUseId(_id, dataType string, count int) (*[]map[str
|
|
|
//获取查询语句
|
|
|
qstr := getDataExportSql(scd)
|
|
|
kws = scd.Keyword
|
|
|
- if count == -1 {
|
|
|
- //数据预览数据查询
|
|
|
- if scd.Comeinfrom == "supersearchPage" && len(scd.Keyword) == 0 && len(scd.Industry) == 0 {
|
|
|
- //空查询
|
|
|
- obj := redis.Get("other", "export_news")
|
|
|
- if obj != nil {
|
|
|
- res = util.ObjArrToMapArr(obj.([]interface{}))
|
|
|
- } else {
|
|
|
- res = *doSearch(qstr, 0, 500, "2")
|
|
|
- if len(res) > 0 {
|
|
|
- redis.Put("other", "export_news", res, 7200)
|
|
|
- }
|
|
|
- }
|
|
|
- return &res, kws
|
|
|
- } else if scd.Comeinfrom == "supersearchPage" {
|
|
|
- //超级搜索非空查询
|
|
|
- count = int(elastic.Count(INDEX, TYPE, qstr))
|
|
|
- searchTextSize := 0
|
|
|
- if len(scd.Keyword) > 0 {
|
|
|
- searchTextSize = len([]rune(scd.Keyword[0].Keyword))
|
|
|
- }
|
|
|
- if searchTextSize > 3 && count < 50 {
|
|
|
- var res *[]map[string]interface{}
|
|
|
- if count > 0 {
|
|
|
- res = doSearch(qstr, 0, count, "")
|
|
|
- }
|
|
|
- secondKWS := jy.HttpEs(scd.Keyword[0].Keyword, "ik_smart", config.Sysconfig["elasticsearch"].(string))
|
|
|
- scd.Keyword[0].Keyword = secondKWS
|
|
|
- scd.SelectType = "title"
|
|
|
- qstr = getDataExportSql(scd)
|
|
|
- res2 := doSearch(qstr, 0, 100-count, "")
|
|
|
- return delRepeatMapArr(res, res2), kws
|
|
|
- }
|
|
|
- }
|
|
|
- //非空查询
|
|
|
- res = *doSearch(qstr, 0, 500, dataType)
|
|
|
-
|
|
|
- } else {
|
|
|
- //数据导出数据查询
|
|
|
- if count > onceSearchCount {
|
|
|
- for t := 0; t < 3; t++ {
|
|
|
- for n := 0; n*onceSearchCount < count; n++ {
|
|
|
- searchWaitGroup.Add(1)
|
|
|
- searchPool <- true
|
|
|
- go func(start int) {
|
|
|
- defer func() {
|
|
|
- searchWaitGroup.Done()
|
|
|
- <-searchPool
|
|
|
- }()
|
|
|
- r := doSearch(qstr, start*onceSearchCount, onceSearchCount, dataType)
|
|
|
- if r != nil {
|
|
|
- res = append(res, *r...)
|
|
|
- log.Println("第", start+1, "页数据加载完成!")
|
|
|
- }
|
|
|
- }(n)
|
|
|
- }
|
|
|
- searchWaitGroup.Wait()
|
|
|
- //校验数量(预览数据查询不需要校验数据量)
|
|
|
- if len(res) == count {
|
|
|
- break
|
|
|
- }
|
|
|
- log.Println("第", t+1, "次加载数据完成,数据总数", len(res), ",由于数据量不够,重新加载!")
|
|
|
- }
|
|
|
+ //数据预览数据查询
|
|
|
+ if scd.Comeinfrom == "supersearchPage" && len(scd.Keyword) == 0 && len(scd.Industry) == 0 {
|
|
|
+ //空查询
|
|
|
+ obj := redis.Get("other", "export_news")
|
|
|
+ if obj != nil {
|
|
|
+ res = util.ObjArrToMapArr(obj.([]interface{}))
|
|
|
} else {
|
|
|
- res = *doSearch(qstr, 0, count, dataType)
|
|
|
- }
|
|
|
-
|
|
|
- //和超级搜索同步
|
|
|
- if scd.Comeinfrom == "supersearchPage" && (len(scd.Keyword) != 0 || len(scd.Industry) != 0) {
|
|
|
- num := len(res)
|
|
|
- searchTextSize := 0
|
|
|
- if len(scd.Keyword) > 0 {
|
|
|
- searchTextSize = len([]rune(scd.Keyword[0].Keyword))
|
|
|
- }
|
|
|
- if searchTextSize > 3 && num < 50 {
|
|
|
- secondKWS := jy.HttpEs(scd.Keyword[0].Keyword, "ik_smart", config.Sysconfig["elasticsearch"].(string))
|
|
|
- scd.Keyword[0].Keyword = secondKWS
|
|
|
- scd.SelectType = "title"
|
|
|
- qstr = getDataExportSql(scd)
|
|
|
- res2 := doSearch(qstr, 0, 100-num, "")
|
|
|
- res = *delRepeatMapArr(&res, res2)
|
|
|
+ res = *doSearch(qstr, 0, 500, "2")
|
|
|
+ if len(res) > 0 {
|
|
|
+ redis.Put("other", "export_news", res, 7200)
|
|
|
}
|
|
|
}
|
|
|
- var EntArr = []string{}
|
|
|
- for _, v := range res {
|
|
|
- //高级字段查询且winner不为空
|
|
|
- if v["s_winner"] != "" && dataType == "2" {
|
|
|
- EntArr = append(EntArr, v["s_winner"].(string))
|
|
|
+ return &res, kws
|
|
|
+ } else if scd.Comeinfrom == "supersearchPage" {
|
|
|
+ //超级搜索非空查询
|
|
|
+ count = int(elastic.Count(INDEX, TYPE, qstr))
|
|
|
+ searchTextSize := 0
|
|
|
+ if len(scd.Keyword) > 0 {
|
|
|
+ searchTextSize = len([]rune(scd.Keyword[0].Keyword))
|
|
|
+ }
|
|
|
+ if searchTextSize > 3 && count < 50 {
|
|
|
+ var res *[]map[string]interface{}
|
|
|
+ if count > 0 {
|
|
|
+ res = doSearch(qstr, 0, count, "")
|
|
|
}
|
|
|
+ secondKWS := jy.HttpEs(scd.Keyword[0].Keyword, "ik_smart", config.Sysconfig["elasticsearch"].(string))
|
|
|
+ scd.Keyword[0].Keyword = secondKWS
|
|
|
+ scd.SelectType = "title"
|
|
|
+ qstr = getDataExportSql(scd)
|
|
|
+ res2 := doSearch(qstr, 0, 100-count, "")
|
|
|
+ return delRepeatMapArr(res, res2), kws
|
|
|
}
|
|
|
- res = *FormatExportData(&res, config.Sysconfig["webdomain"].(string), dataType, false, EntArr)
|
|
|
}
|
|
|
+ //非空查询
|
|
|
+ res = *doSearch(qstr, 0, 500, dataType)
|
|
|
return &res, kws
|
|
|
}
|
|
|
|
|
|
-func FormatExportData(data *[]map[string]interface{}, webdomain string, dataType string, isBreviary bool, EntArr []string) *[]map[string]interface{} {
|
|
|
+func FormatExportData(data *[]map[string]interface{}, webdomain string, dataType string, EntArr []string) *[]map[string]interface{} {
|
|
|
//格式化输出
|
|
|
for _, v := range *data {
|
|
|
//有中标企业 且 高级字段查询
|
|
@@ -465,21 +408,19 @@ func FormatExportData(data *[]map[string]interface{}, webdomain string, dataType
|
|
|
if ev["company_email"] != nil && ev["company_email"] != "无" {
|
|
|
company_email = ev["company_email"].(string)
|
|
|
}
|
|
|
- if isBreviary {
|
|
|
- if legal_person != "" {
|
|
|
- var xx = "*"
|
|
|
- switch len([]rune(legal_person)) {
|
|
|
- case 3:
|
|
|
- xx = "**"
|
|
|
- case 4:
|
|
|
- xx = "***"
|
|
|
- }
|
|
|
- legal_person = string([]rune(legal_person)[:1]) + xx
|
|
|
- }
|
|
|
- company_phone = company_phone[:7] + "****"
|
|
|
- if len(strings.Split(company_email, "@")) > 1 {
|
|
|
- company_email = "******" + strings.Split(company_email, "@")[1]
|
|
|
+ if legal_person != "" {
|
|
|
+ var xx = "*"
|
|
|
+ switch len([]rune(legal_person)) {
|
|
|
+ case 3:
|
|
|
+ xx = "**"
|
|
|
+ case 4:
|
|
|
+ xx = "***"
|
|
|
}
|
|
|
+ legal_person = string([]rune(legal_person)[:1]) + xx
|
|
|
+ }
|
|
|
+ company_phone = company_phone[:7] + "****"
|
|
|
+ if len(strings.Split(company_email, "@")) > 1 {
|
|
|
+ company_email = "******" + strings.Split(company_email, "@")[1]
|
|
|
}
|
|
|
v["legal_person"] = legal_person
|
|
|
v["company_phone"] = company_phone
|
|
@@ -540,26 +481,22 @@ func FormatExportData(data *[]map[string]interface{}, webdomain string, dataType
|
|
|
v["currency"] = "人民币"
|
|
|
}
|
|
|
if v["projectscope"] != "" && v["projectscope"] != nil {
|
|
|
- if isBreviary {
|
|
|
- str := ClearHtml.ReplaceAllString(v["projectscope"].(string), "")
|
|
|
- str = ClearOther.ReplaceAllString(str, "")
|
|
|
- str = strings.Replace(str, " ", "", -1)
|
|
|
- if len([]rune(str)) > 100 {
|
|
|
- str = util.SubString(str, 0, 100) + "..."
|
|
|
- }
|
|
|
- v["projectscope"] = str
|
|
|
+ str := ClearHtml.ReplaceAllString(v["projectscope"].(string), "")
|
|
|
+ str = ClearOther.ReplaceAllString(str, "")
|
|
|
+ str = strings.Replace(str, " ", "", -1)
|
|
|
+ if len([]rune(str)) > 100 {
|
|
|
+ str = util.SubString(str, 0, 100) + "..."
|
|
|
}
|
|
|
+ v["projectscope"] = str
|
|
|
}
|
|
|
if v["detail"] != "" && v["detail"] != nil {
|
|
|
- if isBreviary {
|
|
|
- str := ClearHtml.ReplaceAllString(v["detail"].(string), "")
|
|
|
- str = ClearOther.ReplaceAllString(str, "")
|
|
|
- str = strings.Replace(str, " ", "", -1)
|
|
|
- if len([]rune(str)) > 100 {
|
|
|
- str = util.SubString(str, 0, 100) + "..."
|
|
|
- }
|
|
|
- v["detail"] = str
|
|
|
+ str := ClearHtml.ReplaceAllString(v["detail"].(string), "")
|
|
|
+ str = ClearOther.ReplaceAllString(str, "")
|
|
|
+ str = strings.Replace(str, " ", "", -1)
|
|
|
+ if len([]rune(str)) > 100 {
|
|
|
+ str = util.SubString(str, 0, 100) + "..."
|
|
|
}
|
|
|
+ v["detail"] = str
|
|
|
}
|
|
|
if v["subtype"] == nil && v["toptype"] != nil {
|
|
|
v["subtype"] = v["toptype"]
|