|
@@ -25,6 +25,8 @@ import (
|
|
"app.yhyue.com/moapp/jypkg/public"
|
|
"app.yhyue.com/moapp/jypkg/public"
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+const cacheTime = 60 * 60 * 8
|
|
|
|
+
|
|
// 剑鱼标签页
|
|
// 剑鱼标签页
|
|
type Tags struct {
|
|
type Tags struct {
|
|
*xweb.Action
|
|
*xweb.Action
|
|
@@ -40,6 +42,7 @@ var (
|
|
NotificationWait = make(chan int, 1)
|
|
NotificationWait = make(chan int, 1)
|
|
syw, rwm = &sync.RWMutex{}, &sync.RWMutex{}
|
|
syw, rwm = &sync.RWMutex{}, &sync.RWMutex{}
|
|
)
|
|
)
|
|
|
|
+var seoBidField = `"_id","title","publishtime","subtype","area","href","bidamount","budget","s_subscopeclass","projectname"`
|
|
|
|
|
|
func init() {
|
|
func init() {
|
|
xweb.AddAction(&Tags{})
|
|
xweb.AddAction(&Tags{})
|
|
@@ -318,13 +321,13 @@ func (this *Tags) GetSEOArea() (provinceArr, cityArr, districtArr []string, name
|
|
codeArr = map[int64][]int64{} //code 及 pcode的从属关系
|
|
codeArr = map[int64][]int64{} //code 及 pcode的从属关系
|
|
data := []map[string]interface{}{}
|
|
data := []map[string]interface{}{}
|
|
rediskey := fmt.Sprintf("pcseo_area")
|
|
rediskey := fmt.Sprintf("pcseo_area")
|
|
- if l, ok := redis.Get("other", rediskey).([]interface{}); ok && l != nil && len(l) > 0 {
|
|
|
|
|
|
+ if l, ok := redis.Get("seoCache", rediskey).([]interface{}); ok && l != nil && len(l) > 0 {
|
|
data = qu.ObjArrToMapArr(l)
|
|
data = qu.ObjArrToMapArr(l)
|
|
} else {
|
|
} else {
|
|
list := public.BaseMysql.SelectBySql(`select name,code,level,pcode from seo_words.seo_area order by code`)
|
|
list := public.BaseMysql.SelectBySql(`select name,code,level,pcode from seo_words.seo_area order by code`)
|
|
//获取组合成必要参数
|
|
//获取组合成必要参数
|
|
if list != nil && len(*list) > 0 {
|
|
if list != nil && len(*list) > 0 {
|
|
- redis.Put("other", rediskey, *list, 2*60*60)
|
|
|
|
|
|
+ redis.Put("seoCache", rediskey, *list, cacheTime)
|
|
data = *list
|
|
data = *list
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -392,7 +395,7 @@ func (this *Tags) GetkeysMap() []map[string][]map[string]interface{} {
|
|
|
|
|
|
func (this *Tags) GetIndustry(industryHref string) interface{} {
|
|
func (this *Tags) GetIndustry(industryHref string) interface{} {
|
|
rediskey := fmt.Sprintf("pcindex_getIndustry_%s", industryHref)
|
|
rediskey := fmt.Sprintf("pcindex_getIndustry_%s", industryHref)
|
|
- if l := redis.Get("other", rediskey); l != nil {
|
|
|
|
|
|
+ if l := redis.Get("seoCache", rediskey); l != nil {
|
|
return l
|
|
return l
|
|
} else {
|
|
} else {
|
|
data := public.BaseMysql.SelectBySql(`select a.id,a.name,b.id class_id,b.name class_1 from seo_words.seo_industry a inner join seo_words.seo_industry_class b on a.class_1=b.name and a.class_2 !='药品' order by a.class_1`)
|
|
data := public.BaseMysql.SelectBySql(`select a.id,a.name,b.id class_id,b.name class_1 from seo_words.seo_industry a inner join seo_words.seo_industry_class b on a.class_1=b.name and a.class_2 !='药品' order by a.class_1`)
|
|
@@ -421,7 +424,7 @@ func (this *Tags) GetIndustry(industryHref string) interface{} {
|
|
v: industryMap[v],
|
|
v: industryMap[v],
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- redis.Put("other", rediskey, m, 2*60)
|
|
|
|
|
|
+ redis.Put("seoCache", rediskey, m, cacheTime)
|
|
return m
|
|
return m
|
|
}
|
|
}
|
|
return nil
|
|
return nil
|
|
@@ -440,7 +443,7 @@ func IsInArr(arr []string, s string) bool {
|
|
// 获取最新招标信息
|
|
// 获取最新招标信息
|
|
func (this *Tags) GetNewBidInfo() (list []map[string]interface{}) {
|
|
func (this *Tags) GetNewBidInfo() (list []map[string]interface{}) {
|
|
rediskey := fmt.Sprintf("pcindex_newArticle")
|
|
rediskey := fmt.Sprintf("pcindex_newArticle")
|
|
- if l, ok := redis.Get("other", rediskey).([]interface{}); ok && l != nil && len(l) > 0 {
|
|
|
|
|
|
+ if l, ok := redis.Get("seoCache", rediskey).([]interface{}); ok && l != nil && len(l) > 0 {
|
|
list = qu.ObjArrToMapArr(l)
|
|
list = qu.ObjArrToMapArr(l)
|
|
} else {
|
|
} else {
|
|
_, _, lists := bidsearch.GetPcBidSearchData("", "", "", "", "招标预告,招标公告,招标结果,招标信用信息", "", "", "", "", "", "", "", "", 1, false, nil, bidSearch_field_1, "", false, false, "", 50, "")
|
|
_, _, lists := bidsearch.GetPcBidSearchData("", "", "", "", "招标预告,招标公告,招标结果,招标信用信息", "", "", "", "", "", "", "", "", 1, false, nil, bidSearch_field_1, "", false, false, "", 50, "")
|
|
@@ -460,7 +463,7 @@ func (this *Tags) GetNewBidInfo() (list []map[string]interface{}) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
list = *lists
|
|
list = *lists
|
|
- redis.Put("other", rediskey, list, 2*60*60)
|
|
|
|
|
|
+ redis.Put("seoCache", rediskey, list, cacheTime)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return list
|
|
return list
|
|
@@ -469,7 +472,7 @@ func (this *Tags) GetNewBidInfo() (list []map[string]interface{}) {
|
|
// 获取信息类型相关url
|
|
// 获取信息类型相关url
|
|
func (this *Tags) GetStype(href string) (list []map[string]interface{}) {
|
|
func (this *Tags) GetStype(href string) (list []map[string]interface{}) {
|
|
rediskey := fmt.Sprintf("pcseo_stypelist_%s", href)
|
|
rediskey := fmt.Sprintf("pcseo_stypelist_%s", href)
|
|
- if l, ok := redis.Get("other", rediskey).([]interface{}); ok && l != nil && len(l) > 0 {
|
|
|
|
|
|
+ if l, ok := redis.Get("seoCache", rediskey).([]interface{}); ok && l != nil && len(l) > 0 {
|
|
list = qu.ObjArrToMapArr(l)
|
|
list = qu.ObjArrToMapArr(l)
|
|
} else {
|
|
} else {
|
|
m := []map[string]interface{}{}
|
|
m := []map[string]interface{}{}
|
|
@@ -506,7 +509,7 @@ func (this *Tags) GetStype(href string) (list []map[string]interface{}) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
list = m
|
|
list = m
|
|
- redis.Put("other", rediskey, list, 2*60)
|
|
|
|
|
|
+ redis.Put("seoCache", rediskey, list, cacheTime)
|
|
}
|
|
}
|
|
return list
|
|
return list
|
|
}
|
|
}
|
|
@@ -514,7 +517,7 @@ func (this *Tags) GetStype(href string) (list []map[string]interface{}) {
|
|
// 剑鱼博客
|
|
// 剑鱼博客
|
|
func (this *Tags) GetConsult() (list []map[string]interface{}) {
|
|
func (this *Tags) GetConsult() (list []map[string]interface{}) {
|
|
rediskey := fmt.Sprintf("pcseo_jybk")
|
|
rediskey := fmt.Sprintf("pcseo_jybk")
|
|
- if l, ok := redis.Get("other", rediskey).([]interface{}); ok && l != nil && len(l) > 0 {
|
|
|
|
|
|
+ if l, ok := redis.Get("seoCache", rediskey).([]interface{}); ok && l != nil && len(l) > 0 {
|
|
list = qu.ObjArrToMapArr(l)
|
|
list = qu.ObjArrToMapArr(l)
|
|
} else {
|
|
} else {
|
|
|
|
|
|
@@ -529,7 +532,7 @@ func (this *Tags) GetConsult() (list []map[string]interface{}) {
|
|
v["url"] = fmt.Sprintf("/jyblog/%s.html", qu.ObjToString(v["_id"]))
|
|
v["url"] = fmt.Sprintf("/jyblog/%s.html", qu.ObjToString(v["_id"]))
|
|
}
|
|
}
|
|
list = *rs
|
|
list = *rs
|
|
- redis.Put("other", rediskey, list, 2*60*60)
|
|
|
|
|
|
+ redis.Put("seoCache", rediskey, list, cacheTime)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return list
|
|
return list
|
|
@@ -537,8 +540,8 @@ func (this *Tags) GetConsult() (list []map[string]interface{}) {
|
|
|
|
|
|
func (this *Tags) GetLetterMap(pageSize, pageNum int64, letter string) ([]map[string]interface{}, int64) {
|
|
func (this *Tags) GetLetterMap(pageSize, pageNum int64, letter string) ([]map[string]interface{}, int64) {
|
|
m := []map[string]interface{}{}
|
|
m := []map[string]interface{}{}
|
|
- sql := `select id,name,letter from seo_words.seo_resource where letter = ? order by id desc`
|
|
|
|
- cql := `select count(1) from seo_words.seo_resource where letter = ?`
|
|
|
|
|
|
+ sql := `select id,name,letter from seo_words.seo_resource where letter = ? and state=1 order by id desc`
|
|
|
|
+ cql := `select count(1) from seo_words.seo_resource where letter = ? and state=1 `
|
|
offset := (pageNum - 1) * pageSize
|
|
offset := (pageNum - 1) * pageSize
|
|
sql += fmt.Sprintf(" limit %v,%v", offset, pageSize)
|
|
sql += fmt.Sprintf(" limit %v,%v", offset, pageSize)
|
|
data := public.BaseMysql.SelectBySql(sql, letter)
|
|
data := public.BaseMysql.SelectBySql(sql, letter)
|
|
@@ -560,7 +563,7 @@ func (this *Tags) GetLetterMap(pageSize, pageNum int64, letter string) ([]map[st
|
|
|
|
|
|
func (this *Tags) GetHotLabel(length int64) []map[string]interface{} {
|
|
func (this *Tags) GetHotLabel(length int64) []map[string]interface{} {
|
|
rediskey := fmt.Sprintf("pcseo_getHotLabel_%v", length)
|
|
rediskey := fmt.Sprintf("pcseo_getHotLabel_%v", length)
|
|
- if l, ok := redis.Get("other", rediskey).([]interface{}); ok && l != nil && len(l) > 0 {
|
|
|
|
|
|
+ if l, ok := redis.Get("seoCache", rediskey).([]interface{}); ok && l != nil && len(l) > 0 {
|
|
return qu.ObjArrToMapArr(l)
|
|
return qu.ObjArrToMapArr(l)
|
|
} else {
|
|
} else {
|
|
m := []map[string]interface{}{}
|
|
m := []map[string]interface{}{}
|
|
@@ -583,7 +586,7 @@ func (this *Tags) GetHotLabel(length int64) []map[string]interface{} {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- redis.Put("other", rediskey, m, 60)
|
|
|
|
|
|
+ redis.Put("seoCache", rediskey, m, cacheTime)
|
|
return m
|
|
return m
|
|
}
|
|
}
|
|
return nil
|
|
return nil
|
|
@@ -636,8 +639,8 @@ func (this *Tags) GetBidding(industry, area, city, stype, keyword string, reques
|
|
rediskey := fmt.Sprintf("pcseo_getbidding_%s_%s_%s_%s_%s", industry, area, city, stype, keyword)
|
|
rediskey := fmt.Sprintf("pcseo_getbidding_%s_%s_%s_%s_%s", industry, area, city, stype, keyword)
|
|
rediskeyCount := fmt.Sprintf("pcseo_getbidding_count_%s_%s_%s_%s_%s", industry, area, city, stype, keyword)
|
|
rediskeyCount := fmt.Sprintf("pcseo_getbidding_count_%s_%s_%s_%s_%s", industry, area, city, stype, keyword)
|
|
|
|
|
|
- if l, ok := redis.Get("other", rediskey).([]interface{}); ok && l != nil {
|
|
|
|
- count := redis.GetInt("other", rediskeyCount)
|
|
|
|
|
|
+ if l, ok := redis.Get("seoCache", rediskey).([]interface{}); ok && l != nil && false {
|
|
|
|
+ count := redis.GetInt("seoCache", rediskeyCount)
|
|
return qu.ObjArrToMapArr(l), int64(count), false
|
|
return qu.ObjArrToMapArr(l), int64(count), false
|
|
} else {
|
|
} else {
|
|
if area != "" || stype != "" || industry != "" || city != "" || keyword != "" {
|
|
if area != "" || stype != "" || industry != "" || city != "" || keyword != "" {
|
|
@@ -670,66 +673,31 @@ func (this *Tags) GetBidding(industry, area, city, stype, keyword string, reques
|
|
} else {
|
|
} else {
|
|
return nil, 0, true
|
|
return nil, 0, true
|
|
}
|
|
}
|
|
- //
|
|
|
|
- query1 := `{"query": {"bool": {"must":[`
|
|
|
|
- query_start := `{"query": {"bool": {"must":[`
|
|
|
|
- if area != "" {
|
|
|
|
- query1 += `{"term":{"area":"` + area + `"}}`
|
|
|
|
- }
|
|
|
|
- if stype != "" {
|
|
|
|
- if query1 != query_start {
|
|
|
|
- query1 += ","
|
|
|
|
- }
|
|
|
|
- stype = getstype(stype)
|
|
|
|
- query1 += `{"terms":{"subtype":[`
|
|
|
|
- for k, v := range strings.Split(stype, ",") {
|
|
|
|
- if k > 0 {
|
|
|
|
- query1 += `,`
|
|
|
|
- }
|
|
|
|
- query1 += `"` + v + `"`
|
|
|
|
- }
|
|
|
|
- query1 += `]}}`
|
|
|
|
- }
|
|
|
|
- if industry != "" {
|
|
|
|
- if query1 != query_start {
|
|
|
|
- query1 += ","
|
|
|
|
- }
|
|
|
|
- query1 += `{"term":{"s_subscopeclass":"` + industry + `"}}`
|
|
|
|
- }
|
|
|
|
- if city != "" {
|
|
|
|
- if query1 != query_start {
|
|
|
|
- query1 += ","
|
|
|
|
- }
|
|
|
|
- query1 += `{"term":{"city":"` + city + `"}}`
|
|
|
|
- }
|
|
|
|
- if keyword != "" {
|
|
|
|
- if query1 != query_start {
|
|
|
|
- query1 += ","
|
|
|
|
- }
|
|
|
|
- query1 += `{ "bool": {"must": [ { "multi_match": { "query": "` + keyword + `","type": "phrase", "fields": [ "title","detail" ]}}]}}`
|
|
|
|
- }
|
|
|
|
- query1 += `],"should": [],"minimum_should_match": 0}}}`
|
|
|
|
- log.Println("~~~query1:", query1)
|
|
|
|
- query := getLastNewsQuery(area, "", stype, industry, city)
|
|
|
|
|
|
+ now := time.Now()
|
|
|
|
+ starttime := fmt.Sprint(time.Date(now.Year()-1, now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second(), 0, time.Local).Unix())
|
|
|
|
+ endtime := fmt.Sprint(now.Unix())
|
|
|
|
+
|
|
var datas *[]map[string]interface{}
|
|
var datas *[]map[string]interface{}
|
|
var startPage int
|
|
var startPage int
|
|
|
|
+ var count int64
|
|
currentPage := 5
|
|
currentPage := 5
|
|
- limitcount := qu.IntAllDef(config.Seoconfig["tagsLimitCount"], 50)
|
|
|
|
- count := elastic.Count(INDEX, TYPE, query1)
|
|
|
|
|
|
+ limitCount := qu.IntAllDef(config.Seoconfig["tagsLimitCount"], 50)
|
|
if keyword == "" {
|
|
if keyword == "" {
|
|
- r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
|
|
|
- startPage = r.Intn(currentPage * limitcount)
|
|
|
|
|
|
+ query := bidsearch.GetSearchQuery("", industry, "1000", "50000", "", "", "", "", bidsearch.GetBidSearchQuery(area, city, fmt.Sprintf("%s_%s", starttime, endtime), stype, "", ""), "", false, seoBidField)
|
|
|
|
+ count = elastic.Count(INDEX, TYPE, query)
|
|
|
|
+ if count == 0 {
|
|
|
|
+ return nil, 0, false
|
|
|
|
+ }
|
|
|
|
+ startPage = rand.New(rand.NewSource(time.Now().UnixNano())).Intn(currentPage * limitCount)
|
|
count1 := qu.IntAll(count)
|
|
count1 := qu.IntAll(count)
|
|
if count1 < startPage || startPage < 0 {
|
|
if count1 < startPage || startPage < 0 {
|
|
startPage = 0
|
|
startPage = 0
|
|
}
|
|
}
|
|
- datas = elastic.GetPage(INDEX, TYPE, query, bidSearch_sort, bidField, startPage, limitcount)
|
|
|
|
|
|
+ datas = elastic.GetPage(INDEX, TYPE, query, bidSearch_sort, seoBidField, startPage, limitCount)
|
|
} else {
|
|
} else {
|
|
- log.Println(keyword, area, city, industry)
|
|
|
|
- _, _, datas = bidsearch.GetPcBidSearchData(keyword, area, city, "", stype, industry, "", "", "", "", "", "", "", 0, true, []string{"title", "detail"}, bidField, "", false, false, "", limitcount, "")
|
|
|
|
-
|
|
|
|
- if datas != nil && len(*datas) > limitcount {
|
|
|
|
- *datas = (*datas)[0:limitcount]
|
|
|
|
|
|
+ count, _, datas = bidsearch.GetPcBidSearchData(keyword, area, city, fmt.Sprintf("%s_%s", starttime, endtime), stype, industry, "1000", "50000", "", "", "", "", "", 0, true, []string{"title", "detail", "purchasing"}, seoBidField, "", false, false, "", limitCount, "")
|
|
|
|
+ if datas != nil && len(*datas) > limitCount {
|
|
|
|
+ *datas = (*datas)[0:limitCount]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if datas != nil && len(*datas) > 0 {
|
|
if datas != nil && len(*datas) > 0 {
|
|
@@ -749,8 +717,8 @@ func (this *Tags) GetBidding(industry, area, city, stype, keyword string, reques
|
|
industry = strings.Split(industry, "_")[0]
|
|
industry = strings.Split(industry, "_")[0]
|
|
}
|
|
}
|
|
public.BidListConvert(industry, datas)
|
|
public.BidListConvert(industry, datas)
|
|
- redis.Put("other", rediskey, datas, 2*60)
|
|
|
|
- redis.Put("other", rediskeyCount, count, 2*60)
|
|
|
|
|
|
+ redis.Put("seoCache", rediskey, datas, cacheTime) //生产环境配置4G单独redis,超出4G自动清除
|
|
|
|
+ redis.Put("seoCache", rediskeyCount, count, cacheTime) //生产环境配置4G单独redis,超出4G自动清除
|
|
return *datas, count, false
|
|
return *datas, count, false
|
|
}
|
|
}
|
|
}
|
|
}
|