|
@@ -2,20 +2,128 @@ package front
|
|
|
|
|
|
import (
|
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
|
- elastic "app.yhyue.com/moapp/jybase/es"
|
|
|
"app.yhyue.com/moapp/jybase/redis"
|
|
|
"app.yhyue.com/moapp/jypkg/public"
|
|
|
- "encoding/json"
|
|
|
"fmt"
|
|
|
+ "github.com/gogf/gf/v2/frame/g"
|
|
|
+ "github.com/gogf/gf/v2/os/gctx"
|
|
|
+ "github.com/gogf/gf/v2/util/gconv"
|
|
|
"jy/src/jfw/config"
|
|
|
- "strings"
|
|
|
- "time"
|
|
|
)
|
|
|
|
|
|
-type subzone struct {
|
|
|
- industry, province string
|
|
|
+// HotIndustryAndRegion 热门行业/地区年度招标趋势
|
|
|
+func HomeBiddingTrends() config.IndustryTrend {
|
|
|
+ return config.IndustryTrendConfig
|
|
|
}
|
|
|
|
|
|
+type (
|
|
|
+ KeyWordSiteRoot struct {
|
|
|
+ SiteCodeMap map[string]*KeyWordSiteNode //省份直辖市简称对照
|
|
|
+ SiteArr []*KeyWordSiteNode
|
|
|
+ }
|
|
|
+
|
|
|
+ KeyWordSiteNode struct {
|
|
|
+ Code string `json:"code" doc:"代码"`
|
|
|
+ Alias string `json:"alias" doc:"名称"`
|
|
|
+ AreaKeyWord string `json:"areaKeyword" doc:"省份关键词"`
|
|
|
+ CityKeyWord string `json:"cityKeyword" doc:"城市关键词"`
|
|
|
+ CitySpecialKeyWord string `json:"citySpecialKeyword" doc:"直辖市关键词"`
|
|
|
+ }
|
|
|
+
|
|
|
+ KeyWordSiteShow struct {
|
|
|
+ Code string `json:"code" doc:"代码"`
|
|
|
+ Name string `json:"name" doc:"名称"`
|
|
|
+ //KeyWord string `json:"keyWord" doc:"对应关键词"`
|
|
|
+ }
|
|
|
+ argument struct {
|
|
|
+ Name string
|
|
|
+ Url string
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
+var (
|
|
|
+ siteCodeMap map[string]*KeyWordSiteNode
|
|
|
+ specialArea = map[string]bool{"北京": true, "上海": true, "天津": true, "重庆": true}
|
|
|
+)
|
|
|
+
|
|
|
+func init() {
|
|
|
+ siteCodeMap = make(map[string]*KeyWordSiteNode)
|
|
|
+ res, err := g.DB().Query(gctx.New(), `SELECT * FROM seo_siteKeywords_splicing order by site_code asc`)
|
|
|
+ if err == nil && len(res.List()) > 0 {
|
|
|
+ for _, m := range res.List() {
|
|
|
+ node := &KeyWordSiteNode{
|
|
|
+ Code: fmt.Sprintf("S%s", gconv.String(m["site_code"])),
|
|
|
+ Alias: gconv.String(m["alias"]),
|
|
|
+ AreaKeyWord: gconv.String(m["area"]),
|
|
|
+ CityKeyWord: gconv.String(m["city"]),
|
|
|
+ CitySpecialKeyWord: gconv.String(m["city_special"]),
|
|
|
+ }
|
|
|
+ siteCodeMap[node.Code] = node
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 政府招标
|
|
|
+func GovernmentTender() {
|
|
|
+ areaM := make(map[string]string)
|
|
|
+ //省份
|
|
|
+ areaMap, _ := config.Seoconfig["area"].(map[string]interface{})
|
|
|
+ if areaMap != nil && len(areaMap) > 0 {
|
|
|
+ for k, v := range areaMap {
|
|
|
+ area := v.(map[string]interface{})
|
|
|
+ name := common.ObjToString(area["NAME"])
|
|
|
+ if name != "全国" {
|
|
|
+ areaM[name] = k
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var (
|
|
|
+ data []argument
|
|
|
+ upperLimit int
|
|
|
+ )
|
|
|
+ siteCode := make(map[string]bool)
|
|
|
+ for acronym, name := range areaM {
|
|
|
+ upperLimit++
|
|
|
+ if upperLimit > 12 {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ if len(siteCode) < len(siteCodeMap) {
|
|
|
+ for code, node := range siteCodeMap {
|
|
|
+ if !siteCode[code] {
|
|
|
+ tagName := common.If(specialArea[name], node.CitySpecialKeyWord, node.AreaKeyWord).(string)
|
|
|
+ data = append(data, argument{
|
|
|
+ fmt.Sprintf("%s%s", name, tagName),
|
|
|
+ fmt.Sprintf("/list/area/%s_%s", acronym, code),
|
|
|
+ })
|
|
|
+ siteCode[code] = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for code, node := range siteCodeMap {
|
|
|
+ var tagName string
|
|
|
+ if specialArea[name] {
|
|
|
+ tagName = fmt.Sprintf("%s%s", name, node.CitySpecialKeyWord)
|
|
|
+ } else {
|
|
|
+ tagName = fmt.Sprintf("%s%s", name, node.AreaKeyWord)
|
|
|
+ }
|
|
|
+ data = append(data, argument{
|
|
|
+ tagName,
|
|
|
+ fmt.Sprintf("/list/area/%s_%s", acronym, code),
|
|
|
+ })
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+const (
|
|
|
+ PSearch_DecMust = `"bidstatus": ["中标","成交","合同","单一"]`
|
|
|
+ query_bool_must = `{"terms": {%s}}`
|
|
|
+)
|
|
|
+
|
|
|
var (
|
|
|
industryMap map[string][]string
|
|
|
)
|
|
@@ -28,34 +136,15 @@ type industryRes struct {
|
|
|
name string
|
|
|
areas []areaRes
|
|
|
}
|
|
|
+
|
|
|
type areaRes struct {
|
|
|
name string
|
|
|
data []map[string]interface{}
|
|
|
}
|
|
|
|
|
|
-func init() {
|
|
|
- IndustryInit()
|
|
|
- BiddingTrendInit()
|
|
|
-}
|
|
|
|
|
|
-// HotIndustryAndRegion 热门行业/地区年度招标趋势
|
|
|
-func HomeBiddingTrends() ServiceRes {
|
|
|
- var sRes ServiceRes
|
|
|
- for _, industry := range config.ServiceArea.Industry {
|
|
|
- var ind industryRes
|
|
|
- ind.name = industry
|
|
|
- for _, area := range config.ServiceArea.Area {
|
|
|
- var aRes areaRes
|
|
|
- aRes.name = area
|
|
|
- redisData, _ := redis.Get(RedisNameNew, fmt.Sprintf("biddingTrend_%s_%s", industry, area)).([]interface{})
|
|
|
- if redisData != nil && len(redisData) > 0 {
|
|
|
- aRes.data = common.ObjArrToMapArr(redisData)
|
|
|
- }
|
|
|
- ind.areas = append(ind.areas, aRes)
|
|
|
- }
|
|
|
- sRes.industry = append(sRes.industry, ind)
|
|
|
- }
|
|
|
- return sRes
|
|
|
+type subzone struct {
|
|
|
+ industry, province string
|
|
|
}
|
|
|
|
|
|
type marketBuckets struct {
|
|
@@ -72,6 +161,11 @@ func getQuarter(st int64) int {
|
|
|
return (currentMonth-1)/3 + 1
|
|
|
}
|
|
|
|
|
|
+func init() {
|
|
|
+ IndustryInit()
|
|
|
+ BiddingTrendInit()
|
|
|
+}
|
|
|
+
|
|
|
func BiddingTrend(st int64, et int64) {
|
|
|
currentQuarter := getQuarter(st)
|
|
|
for _, industry := range config.ServiceArea.Industry {
|
|
@@ -175,23 +269,6 @@ func BiddingTrendInit() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-func Quarter() time.Time {
|
|
|
- currentTime := time.Now()
|
|
|
-
|
|
|
- // 获取当前季度
|
|
|
- currentQuarter := (currentTime.Month()-1)/3 + 1
|
|
|
-
|
|
|
- // 计算当前季度的开始时间
|
|
|
- startMonth := (currentQuarter-1)*3 + 1
|
|
|
- quarterStart := time.Date(currentTime.Year(), startMonth, 1, 0, 0, 0, 0, currentTime.Location())
|
|
|
- return quarterStart
|
|
|
-}
|
|
|
-
|
|
|
-const (
|
|
|
- PSearch_DecMust = `"bidstatus": ["中标","成交","合同","单一"]`
|
|
|
- query_bool_must = `{"terms": {%s}}`
|
|
|
-)
|
|
|
-
|
|
|
// GetCommonQuerySql 公共筛选
|
|
|
func GetCommonQuerySql(st, et int64, area, industry string) string {
|
|
|
var musts, bools []string
|
|
@@ -213,6 +290,20 @@ func GetCommonQuerySql(st, et int64, area, industry string) string {
|
|
|
return fmt.Sprintf(`{"query":{"bool":{"must":[%s],"should":[%s],"minimum_should_match": %d}},"aggs":{"project_count": {"filter": {"match_all":{}}}},"size":0}`, strings.Join(musts, ","), strings.Join(bools, ","), common.If(len(bools) > 0, 1, 0).(int))
|
|
|
}
|
|
|
|
|
|
+func Quarter() time.Time {
|
|
|
+ currentTime := time.Now()
|
|
|
+
|
|
|
+ // 获取当前季度
|
|
|
+ currentQuarter := (currentTime.Month()-1)/3 + 1
|
|
|
+
|
|
|
+ // 计算当前季度的开始时间
|
|
|
+ startMonth := (currentQuarter-1)*3 + 1
|
|
|
+ quarterStart := time.Date(currentTime.Year(), startMonth, 1, 0, 0, 0, 0, currentTime.Location())
|
|
|
+ return quarterStart
|
|
|
+}
|
|
|
+*/
|
|
|
+
|
|
|
+// 热门采购数据
|
|
|
func PurchasingData() []string {
|
|
|
redisData, _ := redis.Get(RedisNameNew, "hotPurchasingData").([]interface{})
|
|
|
if len(redisData) > 0 {
|
|
@@ -224,7 +315,7 @@ func PurchasingData() []string {
|
|
|
for _, m := range *data {
|
|
|
keyWords = append(keyWords, common.InterfaceToStr(m["keyword"]))
|
|
|
}
|
|
|
- redis.Put(RedisNameNew, "hotPurchasingData", keyWords, 24*3600)
|
|
|
+ redis.Put(RedisNameNew, "hotPurchasingData", keyWords, 24*3600*30)
|
|
|
}
|
|
|
|
|
|
return keyWords
|