Ver Fonte

feat:冲突

wangshan há 2 anos atrás
pai
commit
b686e5931e

+ 131 - 10
src/jfw/modules/app/src/app/front/ws.go

@@ -10,6 +10,7 @@ import (
 	"context"
 	"encoding/json"
 	"fmt"
+	"github.com/pkg/errors"
 	"jy/src/jfw/modules/app/src/app/jyutil"
 	"log"
 	"reflect"
@@ -21,14 +22,21 @@ import (
 
 // 最后与tags合并后 删除
 var (
-	cacheTime        = 12 * 60 //* 60
-	mobileHref       = "/jyapp/tags/%s/%s"
-	infoTypeRedisKey = "mobile_seo_infoType_home"
-	areaRedisKey     = "mobile_seo_area_home"
-	hotAreaRedisKey  = "mobile_seo_hot_area"
-	biddingListKey   = "mobile_seo_list_%s_%s_%d"
-	hotArea          = "北京,山东,陕西,河南,广东"
-	label            = map[string]string{
+	cacheTime            = 12 * 60 //* 60
+	mobileHref           = "/jyapp/tags/%s/%s"
+	infoTypeRedisKey     = "mobile_seo_infoType_home"
+	areaRedisKey         = "mobile_seo_area_home"
+	hotAreaRedisKey      = "mobile_seo_hot_area"
+	biddingListKey       = "mobile_seo_list_%s_%s_%d"
+	industryRedisKey     = "mobile_seo_industry"
+	industryLessRedisKey = "mobile_seo_industry_less"
+	buyerListRedisKey    = "mobile_seo_buyer_list_%d"
+	winnerListRedisKey   = "mobile_seo_winner_list_%d"
+	buyerListLimit       = 5000
+	winnerListLimit      = 5000
+	listPageSize         = 25
+	hotArea              = "北京,山东,陕西,河南,广东"
+	label                = map[string]string{
 		"area":     "area",
 		"infoType": "it",
 		"industry": "indu",
@@ -305,8 +313,8 @@ func (tg *Tags) GetAllArea() (areaList []map[string][]*AreaInfo, areaToCode map[
 
 // GetIndustry 获取行业和行业下标的物
 func GetIndustry(industryHref string) (interface{}, interface{}) {
-	rediskey := fmt.Sprintf("app_index_getIndustry")
-	rediskey2 := fmt.Sprintf("app_index_getIndustry_less") // 少于5个字的
+	rediskey := fmt.Sprintf(industryRedisKey)
+	rediskey2 := fmt.Sprintf(industryLessRedisKey) // 少于5个字的
 	if l := redis.Get("seoCache", rediskey); l != nil {
 		l2 := redis.Get("seoCache", rediskey2)
 		return l, l2
@@ -658,3 +666,116 @@ func (r *reqLimit) Limit(ctx context.Context) int {
 func (r *reqLimit) Release() {
 	r.doPool <- struct{}{}
 }
+
+// PutListCache
+func PutListCache(redisKey string, redisTimeout int, list []map[string]interface{}) {
+	if b := redis.Put("seoCache", redisKey, list, redisTimeout); !b {
+		log.Printf("保存缓存 redis 异常 key:%s", redisKey)
+	}
+
+}
+
+// GetEntInfoList 采购单位列表/企业列表
+// pageNum:页码
+// identityType :0 采购单位 1 企业
+func GetEntInfoList(pageNum int, identityType int) (list []interface{}) {
+	redisKeyNum := ""
+	redisKey := ""
+	var rs *[]map[string]interface{}
+	switch identityType {
+	case 0:
+		redisKeyNum = fmt.Sprintf(buyerListRedisKey, pageNum)
+		redisKey = buyerListRedisKey
+	case 1:
+		redisKeyNum = fmt.Sprintf(winnerListRedisKey, pageNum)
+		redisKey = winnerListRedisKey
+	}
+	//查缓存
+	if data, err := GetListCache(redisKeyNum); err == nil && len(data) > 0 {
+		return data
+	}
+	// 查数据
+	switch identityType {
+	case 0:
+		rs = selectBuyerInfo(buyerListLimit)
+	case 1:
+		rs = selectEntInfo(winnerListLimit)
+	}
+	if rs == nil || len(*rs) == 0 {
+		return []interface{}{}
+	}
+	for i := 0; i < len(*rs); i++ {
+		(*rs)[i]["id"] = encrypt.EncodeArticleId2ByCheck(qu.ObjToString((*rs)[i]["id"]))
+	}
+	// 存缓存
+	for i := 1; i <= len(*rs)/listPageSize; i++ {
+		tmpKey := fmt.Sprintf(redisKey, i)
+		start := (i - 1) * listPageSize
+		end := i * listPageSize
+		if end > len(*rs) {
+			end = len(*rs)
+		}
+		if i == pageNum {
+			list = qu.MapArrToObjArr((*rs)[start:end])
+		}
+		PutListCache(tmpKey, cacheTime, (*rs)[start:end])
+	}
+	return list
+}
+
+func GetListCache(redisKey string) (list []interface{}, err error) {
+	rs := redis.Get("seoCache", redisKey)
+	if rs == nil {
+		return nil, errors.New("未获取到")
+	}
+	if list, ok := rs.([]interface{}); ok {
+		return list, nil
+	}
+	return nil, errors.New("未获取到缓存信息")
+}
+
+// 获取最新的采购单位
+// limit: 数量
+func selectBuyerInfo(limit int) *[]map[string]interface{} {
+	//
+	//q := `select c. name, c.company_id as id,b.name as buyerclass,p.area as province,ca.city as city   from ( SELECT
+	//        name, company_id, area_code, city_code, name_id
+	//    FROM
+	//        dws_f_ent_baseinfo
+	//    WHERE   company_id!=''and
+	//        (identity_type & (1 << 0)) > 0 order by latest_time desc
+	//    LIMIT ?) c left join dws_f_ent_tags t on( t.name_id=c.name_id) left join code_buyerclass b on (b.code=t.labelvalues) left join code_area p on(p.code=c.area_code)
+	//    left join code_area ca on(ca.code=c.city_code)
+	//      where (identity_type &(1 << 0)) > 0`
+	// todo 测试环境排序字段还没有加 先用下面没有order by 的sql测
+	q := `select c. name, c.company_id as id,b.name as buyerclass,p.area as province,ca.city as city   from ( SELECT
+            name, company_id, area_code, city_code, name_id
+        FROM
+            dws_f_ent_baseinfo
+        WHERE   company_id!=''and
+            (identity_type & (1 << 0)) > 0
+        LIMIT ?) c left join dws_f_ent_tags t on( t.name_id=c.name_id) left join code_buyerclass b on (b.code=t.labelvalues) left join code_area p on(p.code=c.area_code)
+        left join code_area ca on(ca.code=c.city_code)
+          where (identity_type &(1 << 0)) > 0`
+	return public.GlobalCommonMysql.SelectBySql(q, limit)
+}
+
+// 获取最新的中标单位
+// limit: 数量
+func selectEntInfo(limit int) *[]map[string]interface{} {
+	//q := `  select c. name, c.company_id as id,c.address,cb.legal_person,cb.company_status,cb.capital  from ( SELECT
+	//name, company_id,address
+	//FROM
+	//    dws_f_ent_baseinfo
+	//WHERE   company_id!=''and
+	//    (identity_type & (1 << 1)) > 0  order by latest_time desc
+	//    LIMIT ?) c left join company_baseinfo cb on(cb.company_id=c.company_id) `
+	q := `  select c. name, c.company_id as id,c.address,cb.legal_person,cb.company_status,cb.capital  from ( SELECT
+    name, company_id,address
+    FROM
+       dws_f_ent_baseinfo
+    WHERE   company_id!=''and
+       (identity_type & (1 << 1)) > 0
+       LIMIT ?) c left join company_baseinfo cb on(cb.company_id=c.company_id) `
+	return public.GlobalCommonMysql.SelectBySql(q, limit)
+}

+ 9 - 1
src/jfw/modules/app/src/db.json

@@ -59,6 +59,14 @@
 	        "passWord": "=PDT49#80Z!RVv52_z",
 	        "maxOpenConns": 5,
 	        "maxIdleConns": 5
-      	}
+      	},
+      "globalCommon": {
+        "dBName": "global_common_data",
+        "address": "192.168.3.217:4000",
+        "userName": "root",
+        "passWord": "=PDT49#80Z!RVv52_z",
+        "maxOpenConns": 5,
+        "maxIdleConns": 5
+      }
     }
 }

+ 1 - 1
src/jfw/modules/app/src/go.mod

@@ -5,7 +5,7 @@ go 1.18
 require (
 	app.yhyue.com/moapp/jybase v0.0.0-20230727083622-4dfc804ea6cf
 	app.yhyue.com/moapp/jylog v0.0.0-20230522075550-05d7230ca545
-	app.yhyue.com/moapp/jypkg v0.0.0-20230731064332-8e42fae281a1
+	app.yhyue.com/moapp/jypkg v0.0.0-20230802005656-6379ddc03ee0
 	bp.jydev.jianyu360.cn/BaseService/userCenter v1.2.13
 	github.com/SKatiyar/qr v0.0.0-20151201054752-25b6bdf44e67
 	github.com/gogf/gf/v2 v2.3.1

+ 2 - 2
src/jfw/modules/app/src/go.sum

@@ -9,8 +9,8 @@ app.yhyue.com/moapp/jybase v0.0.0-20230727083622-4dfc804ea6cf h1:/Tk5haITmGc5c3/
 app.yhyue.com/moapp/jybase v0.0.0-20230727083622-4dfc804ea6cf/go.mod h1:D40Ae0rQilH8Hc5o2Vtt04Tjh/DNEFpcS3/WkJMPJb8=
 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-20230731064332-8e42fae281a1 h1:9nFmngu21ai/4i/YvOevLQAAJVNk/65E7vbayuyHqBI=
-app.yhyue.com/moapp/jypkg v0.0.0-20230731064332-8e42fae281a1/go.mod h1:VaHDi3twSg4G84k2+UFOe7ZCw5EqUZVAkW2N2dHeMbU=
+app.yhyue.com/moapp/jypkg v0.0.0-20230802005656-6379ddc03ee0 h1:EC5n/8wE9PnSSZxTTuAjDngI9YC41MPsRShbI8Z8v8Y=
+app.yhyue.com/moapp/jypkg v0.0.0-20230802005656-6379ddc03ee0/go.mod h1:VaHDi3twSg4G84k2+UFOe7ZCw5EqUZVAkW2N2dHeMbU=
 app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae h1:6rDDaz6yxvE8viTSzEBwKYOFWq14TMfuBivSazUZMz4=
 app.yhyue.com/moapp/message v0.0.0-20221223100203-6402e389d9ae/go.mod h1:b0zZHev3gmJao1Fo+2Z2KPVjsuLOJVvVxf+kCnu9WkA=
 bp.jydev.jianyu360.cn/BaseService/entManageApplication v0.0.0-20230214091519-89a98c01ab0e h1:h+VEI3o1qC0jeCzkFGTrLI4f27cfa/W/y+0sXokWMgE=

+ 3 - 6
src/jfw/modules/app/src/web/templates/tags/index.html

@@ -5,11 +5,8 @@
   <title>{{.T.pageNum}}/{{.T.totalPage}}</title>
 </head>
 <body>
-{{range $k, $v := .T.biddingList}}
-{{$v.Name}}
-{{range $kk, $vv := $v.List}}
-{{$vv}}
-{{end}}
-{{end}}
+{{.T.industryData}}
+<br>
+{{.T.industryNav}}
 </body>
 </html>