|
@@ -204,14 +204,14 @@ func (nIndex *NewIndex) NewIndex() error {
|
|
|
})
|
|
|
}
|
|
|
//政府采购
|
|
|
- procure, procureName := GetIndexProjectList(8, 10)
|
|
|
+ procure, procureName := GetIndexProjectListRedis(8, 10)
|
|
|
bidTrends = append(bidTrends, map[string]interface{}{
|
|
|
"listData": procure,
|
|
|
"types": procureName,
|
|
|
"url": fmt.Sprintf("%s", BiddingTypeUrl[8]),
|
|
|
})
|
|
|
//项目分包
|
|
|
- projectPage, typesName := GetIndexProjectList(6, 10)
|
|
|
+ projectPage, typesName := GetIndexProjectListRedis(6, 10)
|
|
|
bidTrends = append(bidTrends, map[string]interface{}{
|
|
|
"listData": projectPage,
|
|
|
"types": typesName,
|
|
@@ -222,7 +222,7 @@ func (nIndex *NewIndex) NewIndex() error {
|
|
|
projectZoneType := []int{13, 14, 15, 16}
|
|
|
projectZone := []map[string]interface{}{}
|
|
|
for _, val := range projectZoneType {
|
|
|
- listData, types := GetIndexProjectList(val, 10)
|
|
|
+ listData, types := GetIndexProjectListRedis(val, 10)
|
|
|
projectZone = append(projectZone, map[string]interface{}{
|
|
|
"listData": listData,
|
|
|
"types": types,
|
|
@@ -365,7 +365,24 @@ func GetStrategyList() (strategyList []map[string]interface{}) {
|
|
|
return strategyList
|
|
|
}
|
|
|
|
|
|
-func GetIndexProjectList(typ, pageSize int) (data []map[string]interface{}, types string) {
|
|
|
+func GetIndexProjectList(typ, pageSize int, resArr []map[string]interface{}) (data []map[string]interface{}, types string) {
|
|
|
+ if len(resArr) > 5 {
|
|
|
+ return resArr[:5], types
|
|
|
+ }
|
|
|
+ res, err := g.DB().Query(gctx.New(), fmt.Sprintf(`SELECT bid_id,publish_time,bitmapToArray(sign) FROM new_bid_sign WHERE bitmapContains(sign, %d) ORDER BY publish_time DESC LIMIT %d, %d`, typ, pageSize-10, 10))
|
|
|
+ if err != nil || res.IsEmpty() {
|
|
|
+ return nil, types
|
|
|
+ }
|
|
|
+ finalArr := FillingBiddingBaseFields(gctx.New(), res.List(), types)
|
|
|
+ if len(finalArr) > 5 {
|
|
|
+ finalArr = finalArr[:5]
|
|
|
+ }
|
|
|
+
|
|
|
+ resArr = append(resArr, finalArr...)
|
|
|
+ return GetIndexProjectList(typ, pageSize+10, resArr)
|
|
|
+}
|
|
|
+
|
|
|
+func GetIndexProjectListRedis(typ, pageSize int) (data []map[string]interface{}, types string) {
|
|
|
switch typ {
|
|
|
case 5:
|
|
|
types = "采购意向"
|
|
@@ -388,29 +405,11 @@ func GetIndexProjectList(typ, pageSize int) (data []map[string]interface{}, type
|
|
|
data = common.ObjArrToMapArr(redisArr)
|
|
|
return
|
|
|
}
|
|
|
- res, err := g.DB().Query(gctx.New(), fmt.Sprintf(`SELECT bid_id,publish_time,bitmapToArray(sign) FROM new_bid_sign WHERE bitmapContains(sign, %d) ORDER BY publish_time DESC LIMIT %d, %d`, typ, pageSize-10, 10))
|
|
|
- if err != nil || res.IsEmpty() {
|
|
|
- return nil, types
|
|
|
- }
|
|
|
- /*for _, v := range res.List() {
|
|
|
- v["_id"] = encrypt.EncodeArticleId2ByCheck(common.InterfaceToStr(v["bid_id"]))
|
|
|
- v["publish_time"] = time.Unix(common.Int64All(v["publish_time"]), 0).Format("2006-01-02")
|
|
|
- data = append(data, v)
|
|
|
- }*/
|
|
|
- finalArr := FillingBiddingBaseFields(gctx.New(), res.List(), types)
|
|
|
- if finalArr == nil || len(finalArr) < 5 {
|
|
|
- resArr, _ := GetIndexProjectList(typ, pageSize+10)
|
|
|
- if resArr != nil && len(resArr) > 0 {
|
|
|
- finalArr = append(finalArr, resArr...)
|
|
|
- }
|
|
|
- }
|
|
|
- if len(finalArr) > 5 {
|
|
|
- finalArr = finalArr[:5]
|
|
|
- }
|
|
|
- if finalArr != nil && len(finalArr) > 0 {
|
|
|
- redis.Put(RedisNameNew, redidKey, finalArr, 24*3600)
|
|
|
+ data, _ = GetIndexProjectList(typ, pageSize, []map[string]interface{}{})
|
|
|
+ if data != nil && len(data) > 0 {
|
|
|
+ redis.Put(RedisNameNew, redidKey, data, 24*3600)
|
|
|
}
|
|
|
- return finalArr, types
|
|
|
+ return data, types
|
|
|
}
|
|
|
|
|
|
// 优秀供应商
|