Browse Source

Merge branch 'release/v4.8.67_wky' of qmx/jy into release/v4.8.67

wangkaiyue 1 year ago
parent
commit
993f785fdb
4 changed files with 113 additions and 23 deletions
  1. 1 1
      src/go.mod
  2. 2 2
      src/go.sum
  3. 108 18
      src/jfw/front/classificationTag.go
  4. 2 2
      src/jfw/front/pcIndex.go

+ 1 - 1
src/go.mod

@@ -4,7 +4,7 @@ go 1.19
 
 require (
 	app.yhyue.com/moapp/jyMarketing v0.0.2-0.20230308011651-df591d32df88
-	app.yhyue.com/moapp/jybase v0.0.0-20230901064756-2fc66b18db40
+	app.yhyue.com/moapp/jybase v0.0.0-20231026082242-8eb41c7bdda6
 	app.yhyue.com/moapp/jylog v0.0.0-20230522075550-05d7230ca545
 	app.yhyue.com/moapp/jypkg v0.0.0-20231017032120-01da044f6c92
 	bp.jydev.jianyu360.cn/BaseService/userCenter v1.2.14

+ 2 - 2
src/go.sum

@@ -5,8 +5,8 @@ app.yhyue.com/moapp/jyMarketing v0.0.2-0.20230308011651-df591d32df88/go.mod h1:J
 app.yhyue.com/moapp/jyPoints v1.1.1/go.mod h1:SvP8p5L3jGrejHiH2LXfgCg/NPlFiKBC5Yd0gsI12FU=
 app.yhyue.com/moapp/jybase v0.0.0-20220427020729-974c1a148186/go.mod h1:qNRA0sHuYqcLoYoP8irpaWnW9YsXixe6obBIkwaXpD0=
 app.yhyue.com/moapp/jybase v0.0.0-20230117032034-ad7c00ffe11a/go.mod h1:zB47XTeJvpcbtBRYgkQuxOICWNexiZfbUO+7aUf6mNs=
-app.yhyue.com/moapp/jybase v0.0.0-20230901064756-2fc66b18db40 h1:/FcBvpf/KW8g6GBfTkypVW1pGbNs+iNhDrUGUi+KNjc=
-app.yhyue.com/moapp/jybase v0.0.0-20230901064756-2fc66b18db40/go.mod h1:Hv9U/7oHRucqH315Tr1+d03NCvS9mOKPfk8pwwlOIwQ=
+app.yhyue.com/moapp/jybase v0.0.0-20231026082242-8eb41c7bdda6 h1:uyaBp5Iuc/Il4+O2n92CyU9LPvHetFzQVC8iS9iLFOc=
+app.yhyue.com/moapp/jybase v0.0.0-20231026082242-8eb41c7bdda6/go.mod h1:Hv9U/7oHRucqH315Tr1+d03NCvS9mOKPfk8pwwlOIwQ=
 app.yhyue.com/moapp/jylog v0.0.0-20230522075550-05d7230ca545 h1:+Lak4m1zgsigQloOsvp8AJ+0XeX/+PGp9QP550xlbBQ=
 app.yhyue.com/moapp/jylog v0.0.0-20230522075550-05d7230ca545/go.mod h1:uFrsdUBFbETiJlEmr4PtJWPsZlUpPj2bHQRhryu6ggk=
 app.yhyue.com/moapp/jypkg v0.0.0-20231017032120-01da044f6c92 h1:ZEe+lUFbCk+MWUnNxTx4L+lsJmiAEIdFsgFyMT4ua+E=

+ 108 - 18
src/jfw/front/classificationTag.go

@@ -9,9 +9,11 @@ import (
 	"app.yhyue.com/moapp/jypkg/public"
 	"encoding/json"
 	"fmt"
+	"github.com/gogf/gf/v2/util/gconv"
 	"jy/src/jfw/config"
 	"log"
 	"strconv"
+	"strings"
 	"sync"
 	"time"
 
@@ -61,18 +63,16 @@ func GetWinnerInfo() (data []*BuyerList) {
 		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
 	}
 
-	for _, v := range *rs {
+	for _, v := range rs {
 		var vs BuyerList
-		id := qu.InterfaceToStr(v["nseo_id"])
 		vs.Name = qu.InterfaceToStr(v["name"])
-		vs.Url = fmt.Sprintf("/qy/%s.html", id)
+		vs.Url = qu.InterfaceToStr(v["url"])
 		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 实用内容推荐
@@ -269,20 +360,19 @@ func HotBuyerList() []*BuyerList {
 	}
 	// 查数据
 	//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
 	}
 	var buyerList []*BuyerList
-	for _, b := range *data {
+	for _, b := range data {
 		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)
 			buyerList = append(buyerList, &BuyerList{
 				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,
 			})
 		}
 	}

+ 2 - 2
src/jfw/front/pcIndex.go

@@ -201,8 +201,6 @@ func (m *PcIndex) NewSordfish(flag string) error {
 			m.T["jycmsLink"] = GetJycmsAreaLink()
 			//推荐标讯专区
 			m.T["recommendBeacon"] = RecommendationBeacon()
-			//热门采购单位
-			m.T["hotBuyers"] = HotBuyerList()
 			//招投标攻略
 			var strategyList []map[string]interface{}
 			for _, item := range jySchool.GuidelineColumn().SeedData {
@@ -217,6 +215,8 @@ func (m *PcIndex) NewSordfish(flag string) error {
 			m.T["strategyList"] = strategyList
 			m.T["hasLogin"] = userId != ""
 			m.T["includedInfo"] = GetIncludedInfo()
+			//热门采购单位
+			m.T["hotBuyers"] = HotBuyerList()
 			m.T["hotWinner"] = GetWinnerInfo()
 			m.T["newbids"] = NewIndexbids(m.Session(), m.Request)
 			m.T["hotkey"] = hotKeyArrLoginEd