|
@@ -28,6 +28,10 @@ import (
|
|
|
"app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
)
|
|
|
|
|
|
+const (
|
|
|
+ tagQuery = `{"query":{"bool":{"must":[%s]}},"_source":["_id","title","publishtime","toptype","subtype","type","area","href","bidopentime","winner","buyer","bidamount","budget","s_subscopeclass","projectname"],"sort":[{"dataweight":"desc","publishtime":"desc"}],"from":%d,"size":%d}`
|
|
|
+)
|
|
|
+
|
|
|
type PcIndex struct {
|
|
|
*xweb.Action
|
|
|
newSordfish xweb.Mapper `xweb:"/(old|)"` //剑鱼标讯pc首页
|
|
@@ -387,7 +391,6 @@ func (f *PcIndex) SearchResult(at, name string) error {
|
|
|
// stype = "招标预告,招标公告,招标结果,招标信用信息"
|
|
|
stype = "招标,询价,竞谈,变更,单一,竞价,邀标,成交,中标,废标,流标,结果变更,合同,验收,违规,预告,需求公示,预审,论证意见,预审结果"
|
|
|
}
|
|
|
- query := getLastNewsQuery(area, "", stype, industry, city)
|
|
|
|
|
|
var datas *[]map[string]interface{}
|
|
|
if list == nil || len(list.([]interface{})) == 0 {
|
|
@@ -400,8 +403,9 @@ func (f *PcIndex) SearchResult(at, name string) error {
|
|
|
if count1 < startPage || startPage < 0 {
|
|
|
startPage = 0
|
|
|
}
|
|
|
- datas = elastic.GetPage(INDEX, TYPE, query, bidSearch_sort, `"_id","title","publishtime","toptype","subtype","type","area","href","bidopentime","winner","buyer","bidamount","budget","s_subscopeclass","projectname"`, startPage, limitcount)
|
|
|
- log.Println(len(*datas), "=====", limitcount)
|
|
|
+ query := fmt.Sprintf(tagQuery, getLastNewsQueryTemp(area, "", stype, industry, city), startPage, limitcount)
|
|
|
+ datas = elastic.Get(INDEX, TYPE, query)
|
|
|
+ log.Println(len(*datas), "=====", limitcount, "=====", query)
|
|
|
|
|
|
} else {
|
|
|
//关键词 如果规定时间内未取到数据 则按照老规则取数据 //规则开发一半被砍 暂时注释
|
|
@@ -442,7 +446,88 @@ func (f *PcIndex) SearchResult(at, name string) error {
|
|
|
}
|
|
|
return f.Render("/pc/classifylist.html", &f.T)
|
|
|
}
|
|
|
-
|
|
|
+func getLastNewsQueryTemp(area, publishtime, subtype, industry, city string) string {
|
|
|
+ query := ``
|
|
|
+ if area != "" {
|
|
|
+ query += `{"terms":{"area":[`
|
|
|
+ for k, v := range strings.Split(area, ",") {
|
|
|
+ if k > 0 {
|
|
|
+ query += `,`
|
|
|
+ }
|
|
|
+ query += `"` + v + `"`
|
|
|
+ }
|
|
|
+ query += `]}}`
|
|
|
+ }
|
|
|
+ if publishtime != "" {
|
|
|
+ if len(query) > 0 {
|
|
|
+ query += ","
|
|
|
+ }
|
|
|
+ starttime, endtime := "", ""
|
|
|
+ now := time.Now()
|
|
|
+ if publishtime == "lately-7" { //最近7天
|
|
|
+ starttime = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-7, 0, 0, 0, 0, time.Local).Unix())
|
|
|
+ } else if publishtime == "lately-30" { //最近30天
|
|
|
+ starttime = fmt.Sprint(time.Date(now.Year(), now.Month(), now.Day()-30, 0, 0, 0, 0, time.Local).Unix())
|
|
|
+ } else if publishtime == "thisyear" { //去年
|
|
|
+ starttime = fmt.Sprint(time.Date(now.Year()-1, 1, 1, 0, 0, 0, 0, time.Local).Unix())
|
|
|
+ endtime = fmt.Sprint(time.Date(now.Year()-1, 12, 31, 23, 59, 59, 0, time.Local).Unix())
|
|
|
+ } else {
|
|
|
+ starttime = strings.Split(publishtime, "_")[0]
|
|
|
+ endtime = strings.Split(publishtime, "_")[1]
|
|
|
+ et, _ := strconv.ParseInt(endtime, 0, 64)
|
|
|
+ etTime := time.Unix(et, 0)
|
|
|
+ endtime = fmt.Sprint(time.Date(etTime.Year(), etTime.Month(), etTime.Day()+1, 0, 0, 0, 0, time.Local).Unix())
|
|
|
+ }
|
|
|
+ if starttime != "" && endtime != "" {
|
|
|
+ query += `{"range":{"publishtime":{"$gte":` + starttime + `,"$lt":` + endtime + `}}}`
|
|
|
+ } else if starttime != "" && endtime == "" {
|
|
|
+ query += `{"range":{"publishtime":{"$gte":` + starttime + `}}}`
|
|
|
+ } else if starttime == "" && endtime != "" {
|
|
|
+ query += `{"range":{"publishtime":{"$lt":` + endtime + `}}}`
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if subtype != "" {
|
|
|
+ if len(query) > 0 {
|
|
|
+ query += ","
|
|
|
+ }
|
|
|
+ query += `{"terms":{"subtype":[`
|
|
|
+ for k, v := range strings.Split(subtype, ",") {
|
|
|
+ if k > 0 {
|
|
|
+ query += `,`
|
|
|
+ }
|
|
|
+ query += `"` + v + `"`
|
|
|
+ }
|
|
|
+ query += `]}}`
|
|
|
+ }
|
|
|
+ //
|
|
|
+ if industry != "" {
|
|
|
+ if len(query) > 0 {
|
|
|
+ query += ","
|
|
|
+ }
|
|
|
+ query += `{"terms":{"s_subscopeclass":[`
|
|
|
+ for k, v := range strings.Split(industry, ",") {
|
|
|
+ if k > 0 {
|
|
|
+ query += `,`
|
|
|
+ }
|
|
|
+ query += `"` + v + `"`
|
|
|
+ }
|
|
|
+ query += `]}}`
|
|
|
+ }
|
|
|
+ if city != "" {
|
|
|
+ if len(query) > 0 {
|
|
|
+ query += ","
|
|
|
+ }
|
|
|
+ query += `{"terms":{"city":[`
|
|
|
+ for k, v := range strings.Split(city, ",") {
|
|
|
+ if k > 0 {
|
|
|
+ query += `,`
|
|
|
+ }
|
|
|
+ query += `"` + v + `"`
|
|
|
+ }
|
|
|
+ query += `]}}`
|
|
|
+ }
|
|
|
+ return query
|
|
|
+}
|
|
|
func getCityMap() map[string]interface{} {
|
|
|
m := map[string]interface{}{}
|
|
|
citymp, _ := config.Seoconfig["city"].(map[string]interface{})
|