|
@@ -5,10 +5,10 @@ import (
|
|
|
"context"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
+ "jyBXBase/entity"
|
|
|
"jyBXBase/rpc/bxbase"
|
|
|
IC "jyBXBase/rpc/init"
|
|
|
"jyBXBase/rpc/internal/config"
|
|
|
- "jyBXBase/rpc/util"
|
|
|
"log"
|
|
|
"sort"
|
|
|
"strings"
|
|
@@ -145,10 +145,10 @@ func (n *NewestInfo) GetPushHistory() (res []*bxbase.NewestList) {
|
|
|
}
|
|
|
if len(es_ids) > 0 {
|
|
|
t = time.Now()
|
|
|
- list := elastic.Get(search_index, search_type, fmt.Sprintf(query, strings.Join(es_ids, `","`), len(es_ids)))
|
|
|
+ esList := elastic.Get(search_index, search_type, fmt.Sprintf(query, strings.Join(es_ids, `","`), len(es_ids)))
|
|
|
log.Println("elastic 招标信息耗时:", time.Since(t))
|
|
|
- if list != nil {
|
|
|
- for _, v := range *list {
|
|
|
+ if esList != nil && len(*esList) > 0 {
|
|
|
+ for _, v := range *esList {
|
|
|
_id := MC.ObjToString(v["_id"])
|
|
|
bn := infos[_id]
|
|
|
bn.Title = MC.ObjToString(v["title"])
|
|
@@ -172,10 +172,10 @@ func (n *NewestInfo) GetPushHistory() (res []*bxbase.NewestList) {
|
|
|
}
|
|
|
if len(mgo_ids) > 0 {
|
|
|
t = time.Now()
|
|
|
- list, ok := IC.MgoBidding.Find("bidding", map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_ids}}, nil, mongodb_fields, false, -1, -1)
|
|
|
+ mgoList, ok := IC.MgoBidding.Find("bidding", map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_ids}}, nil, mongodb_fields, false, -1, -1)
|
|
|
log.Println("mongodb bidding 招标信息耗时:", time.Since(t))
|
|
|
- if ok && *list != nil {
|
|
|
- for _, v := range *list {
|
|
|
+ if ok && *mgoList != nil && len(*mgoList) > 0 {
|
|
|
+ for _, v := range *mgoList {
|
|
|
_id := mongodb.BsonIdToSId(v["_id"])
|
|
|
bn := infos[_id]
|
|
|
bn.Title = MC.ObjToString(v["title"])
|
|
@@ -199,10 +199,10 @@ func (n *NewestInfo) GetPushHistory() (res []*bxbase.NewestList) {
|
|
|
}
|
|
|
if len(mgo_back_ids) > 0 {
|
|
|
t = time.Now()
|
|
|
- list, ok := IC.MgoBidding.Find("bidding_back", map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_back_ids}}, nil, mongodb_fields, false, -1, -1)
|
|
|
+ mgoBKList, ok := IC.MgoBidding.Find("bidding_back", map[string]interface{}{"_id": map[string]interface{}{"$in": mgo_back_ids}}, nil, mongodb_fields, false, -1, -1)
|
|
|
log.Println("mongodb bidding_back 招标信息耗时:", time.Since(t))
|
|
|
- if ok && *list != nil {
|
|
|
- for _, v := range *list {
|
|
|
+ if ok && *mgoBKList != nil && len(*mgoBKList) > 0 {
|
|
|
+ for _, v := range *mgoBKList {
|
|
|
_id := mongodb.BsonIdToSId(v["_id"])
|
|
|
bn := infos[_id]
|
|
|
bn.Title = MC.ObjToString(v["title"])
|
|
@@ -367,14 +367,14 @@ func DataSortInRedis(r *bxbase.NewsetBiddingResp, status int, positionId int64)
|
|
|
// 延长缓存
|
|
|
// 获取最新数据 -- 延长缓存时间7天---待调整: 1、判断是否需要更新;2、判断订阅信息是否存在,如果存在是否是最新推送,3、订阅信息查推送缓存(只有个人版有缓存:pushcache_2_a )
|
|
|
func ExtendNewListCache(n *NewSet, in *bxbase.NewestBiddingReq, list []*bxbase.NewestList) {
|
|
|
- if flag := util.ReqLimitInit.Limit(context.Background()); flag != 1 {
|
|
|
+ if flag := entity.ReqLimitInit.Limit(context.Background()); flag != 1 {
|
|
|
if flag == -2 {
|
|
|
log.Println("等待队列已满")
|
|
|
} else if flag == -1 {
|
|
|
log.Println("等待超时")
|
|
|
}
|
|
|
} else {
|
|
|
- defer util.ReqLimitInit.Release()
|
|
|
+ defer entity.ReqLimitInit.Release()
|
|
|
if n.RedisKeyModel.Key != "" {
|
|
|
now := time.Now()
|
|
|
if n.RedisKeyModel.CacheUpdateKey != "" {
|
|
@@ -388,13 +388,13 @@ func ExtendNewListCache(n *NewSet, in *bxbase.NewestBiddingReq, list []*bxbase.N
|
|
|
isDoing bool
|
|
|
)
|
|
|
//防止穿透
|
|
|
- util.ReqLimitLock.Lock()
|
|
|
+ entity.ReqLimitLock.Lock()
|
|
|
isDoing, _ = redis.Exists("new", fmt.Sprintf("p1_indexMessage_new_recovery_%d", in.PositionId))
|
|
|
- util.ReqLimitLock.Unlock()
|
|
|
+ entity.ReqLimitLock.Unlock()
|
|
|
if !isDoing {
|
|
|
- util.ReqLimitLock.Lock()
|
|
|
+ entity.ReqLimitLock.Lock()
|
|
|
redis.Put("new", fmt.Sprintf("p1_indexMessage_new_recovery_%d", in.PositionId), "1", 15*time.Now().Minute()) //十五分钟
|
|
|
- util.ReqLimitLock.Unlock()
|
|
|
+ entity.ReqLimitLock.Unlock()
|
|
|
switch n.RedisStatus {
|
|
|
case StatusLoginUser:
|
|
|
//十五分钟内 更新过一次 不再更新
|