|
@@ -117,6 +117,8 @@ func getDataExportSql(scd *SieveCondition) string {
|
|
|
query_bool_should_and := `{"bool":{"should":[%s],"minimum_should_match": 1 %s}}`
|
|
|
query_price := `{"bool":{"must":[{"range":{"bidamount":{%s}}}]}},{"bool":{"must":[{"range":{"budget":{%s}}}],"must_not":[{"range":{"bidamount":{"gte":-1}}}]}}`
|
|
|
query_bool_must := `{"terms":{"%s":[%s]}}`
|
|
|
+ query_bool_should_wildcard := `{"bool":{"should":[%s]}}`
|
|
|
+ query_wildcard := `{"wildcard":{"%s":"*%s*"}}`
|
|
|
query_bool_must_and := `{"bool":{"must":[%s]%s}}`
|
|
|
query_exists := `{"constant_score":{"filter":{"exists":{"field":"%s"}}}}`
|
|
|
query_bool_must_term := `{"bool": {"must": [{ "term": {"isValidFile": %t }}]}}`
|
|
@@ -225,13 +227,29 @@ func getDataExportSql(scd *SieveCondition) string {
|
|
|
musts = append(musts, fmt.Sprintf(query_bool_must, "s_subscopeclass", `"`+strings.Join(scd.Industry, `","`)+`"`))
|
|
|
}
|
|
|
if len(scd.Buyer) > 0 {
|
|
|
- musts = append(musts, fmt.Sprintf(query_bool_must, "buyer", `"`+strings.Join(scd.Buyer, `","`)+`"`))
|
|
|
+ str := ""
|
|
|
+ for i, v := range scd.Buyer {
|
|
|
+ if i < len(scd.Buyer)-1 {
|
|
|
+ str += fmt.Sprintf(query_wildcard, "buyer", v) + ","
|
|
|
+ } else {
|
|
|
+ str += fmt.Sprintf(query_wildcard, "buyer", v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ musts = append(musts, fmt.Sprintf(query_bool_should_wildcard, str))
|
|
|
}
|
|
|
if len(scd.Buyerclass) > 0 {
|
|
|
musts = append(musts, fmt.Sprintf(query_bool_must, "buyerclass", `"`+strings.Join(scd.Buyerclass, `","`)+`"`))
|
|
|
}
|
|
|
if len(scd.Winner) > 0 {
|
|
|
- musts = append(musts, fmt.Sprintf(query_bool_must, "s_winner", `"`+strings.Join(scd.Winner, `","`)+`"`))
|
|
|
+ str := ""
|
|
|
+ for i, v := range scd.Winner {
|
|
|
+ if i < len(scd.Winner)-1 {
|
|
|
+ str += fmt.Sprintf(query_wildcard, "s_winner", v) + ","
|
|
|
+ } else {
|
|
|
+ str += fmt.Sprintf(query_wildcard, "s_winner", v)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ musts = append(musts, fmt.Sprintf(query_bool_should_wildcard, str))
|
|
|
}
|
|
|
_minPrice := ""
|
|
|
_maxPrice := ""
|
|
@@ -647,7 +665,7 @@ func GetDataExportSelectResult(bidding mg.MongodbSim, biddingName string, scd *S
|
|
|
// "_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,
|
|
|
//}
|
|
|
if dataType == "2" {
|
|
|
- bidField = bidField + `,"href", "projectcode", "buyerperson", "buyertel", "budget", "bidopentime", "agency", "projectscope", "winnerperson", "winnertel", "bidendtime", "district", "signendtime", "buyeraddr"`
|
|
|
+ bidField = bidField + `,"href", "projectcode", "buyerperson", "buyertel", "budget", "bidopentime", "agency", "projectscope", "winnerperson", "winnertel", "bidendtime", "district", "signendtime", "buyeraddr","buyerclass","s_topscopeclass","entidlist"`
|
|
|
//for _, key := range []string{"href", "projectcode", "buyerperson", "buyertel", "budget", "bidopentime", "agency", "projectscope", "winnerperson", "winnertel", "bidendtime", "district", "signendtime", "buyeraddr", "filetext"} {
|
|
|
// selectMap[key] = 1
|
|
|
//}
|
|
@@ -947,58 +965,75 @@ func FormatExportData(entmg mg.MongodbSim, data *[]map[string]interface{}, webdo
|
|
|
if len(encry) > 0 {
|
|
|
isEncry = true
|
|
|
}
|
|
|
- for _, v := range *data {
|
|
|
+ var entCacheMap = map[string]map[string]interface{}{}
|
|
|
+ for index := 0; index < len(*data); index++ {
|
|
|
+ v := (*data)[index]
|
|
|
//有中标企业 且 高级字段查询
|
|
|
if dataType == "2" {
|
|
|
//查询企业公示 法人 公司电话 公司邮箱地址
|
|
|
- s_winner, ok := v["s_winner"].(string) //改为entidlistxx?
|
|
|
- if ok && s_winner != "" {
|
|
|
- if entData, ok := entmg.Find("winner_enterprise", map[string]interface{}{"company_name": s_winner}, nil, `{"company_name":1,"company_email":1,"legal_person":1,"company_phone":1}`, false, -1, -1); ok {
|
|
|
- if entData != nil && *entData != nil && len(*entData) > 0 {
|
|
|
- for _, ev := range *entData {
|
|
|
- if v["s_winner"] == ev["company_name"] {
|
|
|
- legal_person := ""
|
|
|
- if ev["legal_person"] != nil {
|
|
|
- legal_person = ev["legal_person"].(string)
|
|
|
- if isEncry {
|
|
|
- var xx = "*"
|
|
|
- switch len([]rune(legal_person)) {
|
|
|
- case 3:
|
|
|
- xx = "**"
|
|
|
- case 4:
|
|
|
- xx = "***"
|
|
|
- }
|
|
|
- legal_person = string([]rune(legal_person)[:1]) + xx
|
|
|
- }
|
|
|
+ entidlist, ok := v["entidlist"].([]interface{})
|
|
|
+ if ok && len(entidlist) > 0 {
|
|
|
+ var winnerMaps []map[string]interface{}
|
|
|
+ for _, entIdObj := range entidlist {
|
|
|
+ entId := qutil.ObjToString(entIdObj)
|
|
|
+ if entId == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if entCacheMap[entId] != nil {
|
|
|
+ winnerMaps = append(winnerMaps, entCacheMap[entId])
|
|
|
+ } else if entDetail := elastic.Get("qyxy", "qyxy", fmt.Sprintf(`{"query":{"bool":{"must":[{"term":{"id":"%s"}}]}},"size":1,"_source":["company_name","company_email","company_phone","legal_person"]}`, entId)); entDetail != nil && len(*entDetail) > 0 {
|
|
|
+ thisEntMap := map[string]interface{}{}
|
|
|
+ legal_person := ""
|
|
|
+ if (*entDetail)[0]["legal_person"] != nil {
|
|
|
+ legal_person = (*entDetail)[0]["legal_person"].(string)
|
|
|
+ if isEncry {
|
|
|
+ var xx = "*"
|
|
|
+ switch len([]rune(legal_person)) {
|
|
|
+ case 3:
|
|
|
+ xx = "**"
|
|
|
+ case 4:
|
|
|
+ xx = "***"
|
|
|
}
|
|
|
- company_phone := ""
|
|
|
- if ev["company_phone"] != nil {
|
|
|
- company_phone = ev["company_phone"].(string)
|
|
|
- if isEncry {
|
|
|
- if len([]rune(company_phone)) > 7 {
|
|
|
- company_phone = company_phone[:7] + "****"
|
|
|
- } else {
|
|
|
- company_phone = "****"
|
|
|
- }
|
|
|
- }
|
|
|
+ legal_person = string([]rune(legal_person)[:1]) + xx
|
|
|
+ }
|
|
|
+ }
|
|
|
+ company_phone := ""
|
|
|
+ if (*entDetail)[0]["company_phone"] != nil {
|
|
|
+ company_phone = (*entDetail)[0]["company_phone"].(string)
|
|
|
+ if isEncry {
|
|
|
+ if len([]rune(company_phone)) > 7 {
|
|
|
+ company_phone = company_phone[:7] + "****"
|
|
|
+ } else {
|
|
|
+ company_phone = "****"
|
|
|
}
|
|
|
- company_email := ""
|
|
|
- if ev["company_email"] != nil && ev["company_email"] != "无" {
|
|
|
- company_email = ev["company_email"].(string)
|
|
|
- if isEncry {
|
|
|
- if len(strings.Split(company_email, "@")) > 1 {
|
|
|
- company_email = "******" + "@" + strings.Split(company_email, "@")[1]
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ company_email := ""
|
|
|
+ if (*entDetail)[0]["company_email"] != nil && (*entDetail)[0]["company_email"] != "无" {
|
|
|
+ company_email = (*entDetail)[0]["company_email"].(string)
|
|
|
+ if isEncry {
|
|
|
+ if len(strings.Split(company_email, "@")) > 1 {
|
|
|
+ company_email = "******" + "@" + strings.Split(company_email, "@")[1]
|
|
|
}
|
|
|
- v["legal_person"] = legal_person
|
|
|
- v["company_phone"] = company_phone
|
|
|
- v["company_email"] = company_email
|
|
|
}
|
|
|
}
|
|
|
+ company_name := ""
|
|
|
+ if (*entDetail)[0]["company_name"] != nil {
|
|
|
+ company_name = (*entDetail)[0]["company_name"].(string)
|
|
|
+ }
|
|
|
+ thisEntMap["legal_person"] = legal_person
|
|
|
+ thisEntMap["company_phone"] = company_phone
|
|
|
+ thisEntMap["company_email"] = company_email
|
|
|
+ thisEntMap["company_name"] = company_name
|
|
|
+ entCacheMap[entId] = thisEntMap
|
|
|
+ winnerMaps = append(winnerMaps, thisEntMap)
|
|
|
}
|
|
|
}
|
|
|
+ if len(winnerMaps) > 0 {
|
|
|
+ v["winnerMaps"] = winnerMaps
|
|
|
+ }
|
|
|
}
|
|
|
+ delete(v, "entidlist")
|
|
|
}
|
|
|
//====================字段补漏=========================
|
|
|
if v["toptype"] == "结果" && dataType == "2" && !(v["agency"] != nil && v["budget"] != nil && v["buyerperson"] != nil && v["buyertel"] != nil) {
|
|
@@ -1052,7 +1087,7 @@ func FormatExportData(entmg mg.MongodbSim, data *[]map[string]interface{}, webdo
|
|
|
date := v["bidendtime"]
|
|
|
v["bidendtime"] = FormatDateWithObj(&date, Date_Short_Layout)
|
|
|
}
|
|
|
- if v["_id"] != nil {
|
|
|
+ if v["_id"] != nil && !isEncry {
|
|
|
encodeId := CommonEncodeArticle("content", v["_id"].(string))
|
|
|
v["url"] = webdomain + "/article/content/" + encodeId + ".html"
|
|
|
v["url_jump"] = webdomain + "/front/reloadTo/article/content/" + encodeId + ".html"
|
|
@@ -1114,7 +1149,7 @@ func doSearch(sql string, start, count int, dataType string) *[]map[string]inter
|
|
|
if dataType != "" {
|
|
|
dataexport_field := `"_id","title","detail","area","city","publishtime","projectname","buyer","s_winner","bidamount","subtype","toptype","filetext","purchasing"`
|
|
|
if dataType == "2" {
|
|
|
- dataexport_field += `,"href","projectcode","buyerperson","buyertel","budget","bidopentime","agency","projectscope","winnerperson","winnertel","bidendtime","district","signendtime","buyeraddr"`
|
|
|
+ dataexport_field += `,"href","projectcode","buyerperson","buyertel","budget","bidopentime","agency","projectscope","winnerperson","winnertel","bidendtime","district","signendtime","buyeraddr","buyerclass","s_topscopeclass","entidlist"`
|
|
|
}
|
|
|
sql = sql[:len(sql)-1] + `,"_source":[` + dataexport_field + "]}"
|
|
|
}
|