|
@@ -9,9 +9,11 @@ import (
|
|
"app.yhyue.com/moapp/jypkg/public"
|
|
"app.yhyue.com/moapp/jypkg/public"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"fmt"
|
|
"fmt"
|
|
|
|
+ "github.com/gogf/gf/v2/util/gconv"
|
|
"jy/src/jfw/config"
|
|
"jy/src/jfw/config"
|
|
"log"
|
|
"log"
|
|
"strconv"
|
|
"strconv"
|
|
|
|
+ "strings"
|
|
"sync"
|
|
"sync"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
@@ -61,18 +63,16 @@ func GetWinnerInfo() (data []*BuyerList) {
|
|
return cache
|
|
return cache
|
|
}
|
|
}
|
|
// 没取到缓存查数据
|
|
// 没取到缓存查数据
|
|
- //rs := getEntBaseInfo(IdentityTypeWinner, config.HotWinnerConfig.Limit)
|
|
|
|
- rs := GetSeoId(IdentityTypeWinner, config.HotWinnerConfig.Limit)
|
|
|
|
|
|
+ rs := GetHotWinnerBuyer(IdentityTypeWinner, config.HotWinnerConfig.Limit)
|
|
//关联中标企业
|
|
//关联中标企业
|
|
- if rs == nil || len(*rs) == 0 {
|
|
|
|
|
|
+ if rs == nil || len(rs) == 0 {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- for _, v := range *rs {
|
|
|
|
|
|
+ for _, v := range rs {
|
|
var vs BuyerList
|
|
var vs BuyerList
|
|
- id := qu.InterfaceToStr(v["nseo_id"])
|
|
|
|
vs.Name = qu.InterfaceToStr(v["name"])
|
|
vs.Name = qu.InterfaceToStr(v["name"])
|
|
- vs.Url = fmt.Sprintf("/qy/%s.html", id)
|
|
|
|
|
|
+ vs.Url = qu.InterfaceToStr(v["url"])
|
|
data = append(data, &vs)
|
|
data = append(data, &vs)
|
|
}
|
|
}
|
|
// 存缓存
|
|
// 存缓存
|
|
@@ -116,12 +116,103 @@ func getEntBaseInfo(identityType, limit int) *[]map[string]interface{} {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-func GetSeoId(identityType, limit int) *[]map[string]interface{} {
|
|
|
|
- index := qu.If(identityType != 0, "qyxy", "buyer").(string)
|
|
|
|
- seo := qu.If(identityType != 0, "nseo_id", "seo_id").(string)
|
|
|
|
- q := fmt.Sprintf(`{"query": {"bool": {}},"sort": {"updatetime": "desc"},"from": 0,"size": %d,"_source": ["name","%s"]}`, limit, seo)
|
|
|
|
|
|
+func GetHotWinnerBuyer(identityType, limit int) []map[string]interface{} {
|
|
|
|
+ isWinner := identityType == 1
|
|
|
|
+ queryTotal := gconv.Int(gconv.Float64(limit) * 1.5)
|
|
|
|
+ var querySql string
|
|
|
|
+ if isWinner {
|
|
|
|
+ querySql = fmt.Sprintf(`{"query": {"bool": {"must": [{"exists": {"field": "s_winner"}},{"exists": {"field": "entidlist"}}],"must_not":[{"term":{"entidlist":"-"}}]}},"_source":["buyer","s_winner","entidlist"],"size": %d}`, queryTotal)
|
|
|
|
+ } else {
|
|
|
|
+ querySql = fmt.Sprintf(`{"query": {"bool": {"must": [{"exists": {"field": "buyer"}}]}},"_source":["buyer","s_winner","entidlist"],"size": %d}`, queryTotal)
|
|
|
|
+ }
|
|
|
|
+ getData := elastic.GetNoLimit("projectset", "projectset", querySql)
|
|
|
|
+ var finalList []map[string]interface{}
|
|
|
|
+ if getData != nil && len(*getData) > 0 {
|
|
|
|
+ queryMap := make(map[string]bool)
|
|
|
|
+ if isWinner { //采购关联企业 校验正确性
|
|
|
|
+ var queryArr []string
|
|
|
|
+ for _, v := range *getData {
|
|
|
|
+ if len(queryArr) < queryTotal {
|
|
|
|
+ for _, name := range gconv.Strings(v["entidlist"]) {
|
|
|
|
+ if name == "" || name == "-" {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ if queryMap[name] {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ queryArr = append(queryArr, name)
|
|
|
|
+ queryMap[name] = true
|
|
|
|
|
|
- return elastic.Get(index, index, q)
|
|
|
|
|
|
+ if len(queryArr) == queryTotal {
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ finalList = getWinnerSeoIdByName(queryArr...)
|
|
|
|
+ } else {
|
|
|
|
+ var queryArr []string
|
|
|
|
+ for _, v := range *getData {
|
|
|
|
+ buyerName := gconv.String(v["buyer"])
|
|
|
|
+ if queryMap[buyerName] {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ queryArr = append(queryArr, buyerName)
|
|
|
|
+ queryMap[buyerName] = true
|
|
|
|
+ }
|
|
|
|
+ finalList = getBuyerSeoIdByName(queryArr...)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if len(finalList) > limit {
|
|
|
|
+ finalList = finalList[:limit]
|
|
|
|
+ }
|
|
|
|
+ return finalList
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 根据企业名称获取seoid
|
|
|
|
+// query: company_name 根据名字匹配
|
|
|
|
+// query: _id 根据entid匹配
|
|
|
|
+func getWinnerSeoIdByName(winners ...string) (res []map[string]interface{}) {
|
|
|
|
+ if len(winners) == 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ winnerRes := elastic.Get("qyxy", "qyxy", fmt.Sprintf(`{"query":{"terms":{"_id":["%s"]}},"_source":[%s],"size":%d}`, strings.Join(winners, `","`), `"nseo_id","company_name"`, len(winners)))
|
|
|
|
+ if winnerRes != nil && len(*winnerRes) > 0 {
|
|
|
|
+ for _, m := range *winnerRes {
|
|
|
|
+ name := gconv.String(m["company_name"])
|
|
|
|
+ sid := gconv.String(m["nseo_id"])
|
|
|
|
+ if name != "" && sid != "" {
|
|
|
|
+ res = append(res, map[string]interface{}{
|
|
|
|
+ "name": name,
|
|
|
|
+ "seoId": sid,
|
|
|
|
+ "url": fmt.Sprintf("/qy/%s.html", sid),
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 根据采购单位名字获取seoid
|
|
|
|
+func getBuyerSeoIdByName(buyer ...string) (res []map[string]interface{}) {
|
|
|
|
+ if len(buyer) == 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ buyerRes := elastic.GetNoLimit("buyer", "buyer", fmt.Sprintf(`{"query":{"terms":{"buyer_name":["%s"]}},"_source":[%s],"size":%d}`, strings.Join(buyer, `","`), `"seo_id","name"`, len(buyer)))
|
|
|
|
+ if buyerRes != nil && len(*buyerRes) > 0 {
|
|
|
|
+ for _, m := range *buyerRes {
|
|
|
|
+ name := gconv.String(m["name"])
|
|
|
|
+ sid := gconv.String(m["seo_id"])
|
|
|
|
+ if name != "" && sid != "" {
|
|
|
|
+ res = append(res, map[string]interface{}{
|
|
|
|
+ "name": name,
|
|
|
|
+ "seoId": sid,
|
|
|
|
+ "url": fmt.Sprintf("/dw/%s.html", sid),
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
|
|
// ContentRecommendation 实用内容推荐
|
|
// ContentRecommendation 实用内容推荐
|
|
@@ -269,20 +360,19 @@ func HotBuyerList() []*BuyerList {
|
|
}
|
|
}
|
|
// 查数据
|
|
// 查数据
|
|
//data := getEntBaseInfo(IdentityTypeBuyer, config.HotBuyerConfig.Limit)
|
|
//data := getEntBaseInfo(IdentityTypeBuyer, config.HotBuyerConfig.Limit)
|
|
- data := GetSeoId(IdentityTypeBuyer, config.HotBuyerConfig.Limit)
|
|
|
|
- if data == nil || len(*data) == 0 {
|
|
|
|
|
|
+ data := GetHotWinnerBuyer(IdentityTypeBuyer, config.HotBuyerConfig.Limit)
|
|
|
|
+ if data == nil || len(data) == 0 {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
var buyerList []*BuyerList
|
|
var buyerList []*BuyerList
|
|
- for _, b := range *data {
|
|
|
|
|
|
+ for _, b := range data {
|
|
name := qu.ObjToString(b["name"])
|
|
name := qu.ObjToString(b["name"])
|
|
- buyerId := qu.InterfaceToStr(b["seo_id"])
|
|
|
|
- if name != "" && buyerId != "" {
|
|
|
|
|
|
+ url := qu.InterfaceToStr(b["url"])
|
|
|
|
+ if name != "" && url != "" {
|
|
//idEncode := encrypt.EncodeArticleId2ByCheck(buyerId)
|
|
//idEncode := encrypt.EncodeArticleId2ByCheck(buyerId)
|
|
buyerList = append(buyerList, &BuyerList{
|
|
buyerList = append(buyerList, &BuyerList{
|
|
Name: name,
|
|
Name: name,
|
|
- //Url: qu.If(entIsNew, fmt.Sprintf("/entpc/unit_portrayal_id/%s", idEncode), fmt.Sprintf("/swordfish/page_big_pc/unit_portrayal_id/%s", idEncode)).(string),
|
|
|
|
- Url: fmt.Sprintf("/dw/%s.html", buyerId),
|
|
|
|
|
|
+ Url: url,
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|