|
@@ -62,7 +62,7 @@ func (l *BuyerListLogic) BuyerList(in *bxbuyer.BuyerListReq) (*bxbuyer.BuyerList
|
|
|
if model.CheckEmpty(in) {
|
|
|
res := model.GetL2CacheData("other", model.BuyerListQueryLock, model.P_redis_key, func() interface{} {
|
|
|
//聚合查询获取最近一个月中标单位数量最多的采购单位
|
|
|
- agg := model.GetAggs("projectset", "projectset", fmt.Sprintf(`{"query":{"bool":{"must":[{"range":{"jgtime":{"gt":%d}}}]}},"aggs":{"buyerTop":{"terms":{"field":"buyer","size":%d}}}}`, time.Now().AddDate(-3, 0, -1).Unix(), IC.C.BuyerSearchLimit))
|
|
|
+ agg := model.GetAggs("projectset", "projectset", fmt.Sprintf(`{"query":{"bool":{"must":[{"range":{"jgtime":{"gt":%d}}}]}},"aggs":{"buyerTop":{"terms":{"field":"buyer","size":%d}}}}`, time.Now().AddDate(0, 0, -1).Unix(), IC.C.BuyerSearchLimit*2))
|
|
|
var ta TopAgg
|
|
|
err := gconv.Struct(gconv.String(agg["buyerTop"]), &ta)
|
|
|
if err != nil {
|
|
@@ -73,9 +73,16 @@ func (l *BuyerListLogic) BuyerList(in *bxbuyer.BuyerListReq) (*bxbuyer.BuyerList
|
|
|
names = append(names, bucket.Key)
|
|
|
}
|
|
|
//根据采购单位名称查询列表展示字段
|
|
|
- rs := elastic.Get(model.BuyerIndex, model.BuyerIndex, fmt.Sprintf(`{"query":{"bool":{"must":[{"terms":{"buyer_name":["%s"]}}]}},"source":["seo_id","name","province","city","buyerclass"]}`, strings.Join(names, `","`)))
|
|
|
+ rs := elastic.Get(model.BuyerIndex, model.BuyerIndex, fmt.Sprintf(`{"query":{"bool":{"must":[{"terms":{"buyer_name":["%s"]}}]}},"_source":["seo_id","name","province","city","buyerclass"],"size":%d}`, strings.Join(names, `","`), len(names)))
|
|
|
+ if rs == nil || len(*rs) == 0 {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
var saveBuyerList []*bxbuyer.BuyerList
|
|
|
for i := 0; i < len(*rs); i++ {
|
|
|
+ name := MC.ObjToString((*rs)[i]["name"])
|
|
|
+ if !(len(name) > 5 && (strings.HasSuffix(name, "公司") || strings.HasSuffix(name, "学校") || strings.HasSuffix(name, "医院"))) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
saveBuyerList = append(saveBuyerList, &bxbuyer.BuyerList{
|
|
|
SeoId: MC.ObjToString((*rs)[i]["seo_id"]),
|
|
|
Buyer: MC.ObjToString((*rs)[i]["name"]),
|
|
@@ -83,6 +90,9 @@ func (l *BuyerListLogic) BuyerList(in *bxbuyer.BuyerListReq) (*bxbuyer.BuyerList
|
|
|
City: MC.ObjToString((*rs)[i]["city"]),
|
|
|
BuyerClass: MC.ObjToString((*rs)[i]["buyerclass"]),
|
|
|
})
|
|
|
+ if gconv.Int64(len(saveBuyerList)) > IC.C.BuyerSearchLimit {
|
|
|
+ break
|
|
|
+ }
|
|
|
}
|
|
|
return saveBuyerList
|
|
|
}, model.P_redis_time)
|