瀏覽代碼

Merge branch 'dev4.2' of http://192.168.3.207:10080/qmx/jy into dev4.2

DingChangSheng 4 年之前
父節點
當前提交
3006af877e
共有 2 個文件被更改,包括 183 次插入62 次删除
  1. 181 62
      src/jfw/front/pcIndex.go
  2. 2 0
      src/jfw/front/swordfish.go

+ 181 - 62
src/jfw/front/pcIndex.go

@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"fmt"
 	"jfw/config"
 	"jfw/config"
 	"log"
 	"log"
+	"strconv"
 	"strings"
 	"strings"
 
 
 	"encoding/json"
 	"encoding/json"
@@ -24,16 +25,21 @@ type PcIndex struct {
 	*xweb.Action
 	*xweb.Action
 	newSordfish  xweb.Mapper `xweb:"/"`                        //剑鱼标讯pc首页
 	newSordfish  xweb.Mapper `xweb:"/"`                        //剑鱼标讯pc首页
 	newSordfishC xweb.Mapper `xweb:"/pcindex.html"`            //剑鱼标讯pc首页-统计
 	newSordfishC xweb.Mapper `xweb:"/pcindex.html"`            //剑鱼标讯pc首页-统计
-	newBlog      xweb.Mapper `xweb:"/newBlog"`                 //最新资讯
-	newArticle   xweb.Mapper `xweb:"/newArticle"`              //最新公告信息
 	searchResult xweb.Mapper `xweb:"/list/(\\w+)/(\\w+).html"` //剑鱼标讯分类 地区结果列表
 	searchResult xweb.Mapper `xweb:"/list/(\\w+)/(\\w+).html"` //剑鱼标讯分类 地区结果列表
 	labelUrl     xweb.Mapper `xweb:"/index/labelUrl"`          //首页链接跳转地址
 	labelUrl     xweb.Mapper `xweb:"/index/labelUrl"`          //首页链接跳转地址
+	tesa         xweb.Mapper `xweb:"/index/tesa"`
 }
 }
 
 
 func init() {
 func init() {
 	xweb.AddAction(&PcIndex{})
 	xweb.AddAction(&PcIndex{})
 }
 }
 
 
+func (d *PcIndex) Tesa() {
+	d.WriteBytes([]byte("ok,清除路径:" + "pc/index.html"))
+	// m := GetLabUrl(1)
+	// d.ServeJson(m)
+}
+
 //剑鱼标讯pc首页
 //剑鱼标讯pc首页
 func (m *PcIndex) NewSordfish() error {
 func (m *PcIndex) NewSordfish() error {
 	ispc, _ := m.GetInteger("ispc")
 	ispc, _ := m.GetInteger("ispc")
@@ -60,6 +66,18 @@ func (m *PcIndex) NewSordfish() error {
 		} else {
 		} else {
 			m.T["live_Preheat_Start"] = config.ActiveConfig.Live_Preheat_Start
 			m.T["live_Preheat_Start"] = config.ActiveConfig.Live_Preheat_Start
 			m.T["live_Active_End"] = config.ActiveConfig.Live_Active_End
 			m.T["live_Active_End"] = config.ActiveConfig.Live_Active_End
+			//最新资讯
+			m.T["blog"] = GetNewBlog()
+			//最新公告信息
+			for _, v := range []int{1, 2, 3, 4} { //1拟建 2招标预告 3招标公告 4招标结果
+				m.T[fmt.Sprintf("newArticle_%d", v)] = GetNewArticle(v)
+			}
+			//前端需要跳转的路由
+			for _, v := range []int{1, 2, 3} {
+				m.T[fmt.Sprintf("labUrl_%d", v)] = GetLabUrl(v) //1地域 2信息类型 3热门招标
+			}
+			//信息条数(上线以来..)
+			m.T["infoNum"] = GetInfoNum()
 			content, _ := m.Render4Cache("/pc/index.html", &m.T)
 			content, _ := m.Render4Cache("/pc/index.html", &m.T)
 			redis.Put("other", "jypcindex", string(content), 60*60*2)
 			redis.Put("other", "jypcindex", string(content), 60*60*2)
 			return m.SetBody(content)
 			return m.SetBody(content)
@@ -88,76 +106,158 @@ func (m *PcIndex) NewSordfishC() error {
 	}
 	}
 }
 }
 
 
-//首页资讯(博客)
-func (p *PcIndex) NewBlog() {
-	d := func() (r *[]map[string]interface{}) {
-		rediskey := "pcindex_blog"
-		if data, ok := redis.Get("other", rediskey).(*[]map[string]interface{}); ok && data != nil && len(*data) > 0 {
-			r = data
-		} else {
-			r, _ = SearhWebContentblog(map[string]string{
-				"contentType": "jybk",
-			})
-			if r != nil && len(*r) > 4 {
-				*r = (*r)[0:5]
-				for _, v := range *r {
-					delete(v, "praise")
-					delete(v, "s_contenttype")
-					delete(v, "s_source")
-				}
+//首页资讯
+func GetNewBlog() (r *[]map[string]interface{}) {
+	rediskey := "pcindex_blog"
+	if data, ok := redis.Get("other", rediskey).(*[]map[string]interface{}); ok && data != nil && len(*data) > 0 {
+		r = data
+	} else {
+		r, _ = SearhWebContentblog(map[string]string{
+			"contentType": "jybk",
+		})
+		if r != nil && len(*r) > 4 {
+			*r = (*r)[0:5]
+			for _, v := range *r {
+				delete(v, "praise")
+				delete(v, "s_contenttype")
+				delete(v, "s_source")
 			}
 			}
-			redis.Put("other", rediskey, r, 24*60*60)
 		}
 		}
-		return r
-	}()
-	p.ServeJson(map[string]interface{}{
-		"data": d,
-	})
+		redis.Put("other", rediskey, r, 24*60*60)
+	}
+	return r
 }
 }
 
 
 //最新公告信息
 //最新公告信息
-func (p *PcIndex) NewArticle() {
-	data := func() (list []map[string]interface{}) {
-		typ, _ := p.GetInteger("typ")
-		if typ == 0 {
-			typ = 1
+func GetNewArticle(typ int) (list []map[string]interface{}) {
+	if typ == 0 {
+		typ = 1
+	}
+	rediskey := fmt.Sprintf("pcindex_newArticle_%d", typ)
+	subtype := ""
+	switch typ {
+	case 1:
+		//拟建
+		subtype = "拟建"
+	case 2:
+		//招标预告
+		subtype = "预告"
+	case 3:
+		//招标公告
+		subtype = "招标,邀标,询价,竞谈,单一,竞价,变更,其他"
+	case 4:
+		//招标结果
+		subtype = "中标,成交,废标,流标"
+	}
+	if l, ok := redis.Get("other", rediskey).([]interface{}); ok && l != nil && len(l) > 0 {
+		list = util.ObjArrToMapArr(l)
+	} else {
+		_, _, lists := getBidSearchData("", "", "", subtype, "", "", "", 1, false, "", "")
+		if lists != nil && len(*lists) > 5 {
+			*lists = (*lists)[0:6]
+			for _, v := range *lists {
+				v["_id"] = util.EncodeArticleId2ByCheck(v["_id"].(string))
+				delete(v, "toptype")
+				delete(v, "s_subscopeclass")
+				tmpdate := v["publishtime"]
+				v["publishtime"] = util.TimeDiff(time.Unix(util.Int64All(tmpdate.(float64)), 0))
+				if v["budget"] != nil {
+					v["budget"] = ConversionMoeny(v["budget"])
+				} else if v["bidamount"] != nil {
+					v["budget"] = ConversionMoeny(v["bidamount"])
+				}
+			}
+			list = *lists
+			redis.Put("other", rediskey, list, 2*60*60)
 		}
 		}
-		rediskey := fmt.Sprintf("pcindex_newArticle_%d", typ)
-		subtype := ""
-		switch typ {
-		case 1:
-			//拟建
-			subtype = "拟建"
-		case 2:
-			//招标预告
-			subtype = "预告"
-		case 3:
-			//招标公告
-			subtype = "招标,邀标,询价,竞谈,单一,竞价,变更,其他"
-		case 4:
-			//招标结果
-			subtype = "中标,成交,废标,流标"
+	}
+	return list
+}
+
+//前端跳转地址
+func GetLabUrl(typ int) interface{} {
+	if typ == 1 { //地区
+		areaM := map[string]interface{}{}
+		//省份
+		areamap, _ := config.Seoconfig["area"].(map[string]interface{})
+		if areamap != nil && len(areamap) > 0 {
+			for k, v := range areamap {
+				area := v.(map[string]interface{})
+				areaname := util.ObjToString(area["NAME"])
+				areaM[areaname] = k
+			}
 		}
 		}
-		if l, ok := redis.Get("other", rediskey).([]interface{}); ok && l != nil && len(l) > 0 {
-			list = util.ObjArrToMapArr(l)
-		} else {
-			_, _, lists := getBidSearchData("", "", "", subtype, "", "", "", 1, false, "", "")
-			if lists != nil && len(*lists) > 5 {
-				*lists = (*lists)[0:6]
-				for _, v := range *lists {
-					v["_id"] = util.EncodeArticleId2ByCheck(v["_id"].(string))
-					delete(v, "toptype")
-					delete(v, "s_subscopeclass")
+		//城市
+		m := map[string][]map[string]interface{}{}
+		for k, v := range areaM {
+			a, _ := v.(string)
+			m[k] = append(m[k], map[string]interface{}{
+				"city": k,
+				"url":  fmt.Sprintf("/list/area/%s.html", a),
+			})
+		}
+		cityMap := getCityMap()
+		r := public.PushMysql.SelectBySql(`select a.name province,b.name city from
+(select name,cid from province where level =1) a left join province b on a.cid =b.pid`)
+		if r != nil && len(*r) > 0 {
+			for _, v := range *r {
+				province := util.ObjToString(v["province"])
+				city := util.ObjToString(v["city"])
+				m[province] = append(m[province], map[string]interface{}{
+					"city": city,
+				})
+			}
+		}
+		for kk, vv := range m {
+			for _, vvv := range vv {
+				city := util.ObjToString(vvv["city"])
+				if kk != city {
+					vvv["url"] = fmt.Sprintf("/list/city/%s.html", cityMap[city])
 				}
 				}
-				list := *lists
-				redis.Put("other", rediskey, list, 2*60*60)
 			}
 			}
 		}
 		}
-		return list
-	}()
-	p.ServeJson(map[string]interface{}{
-		"list": data,
-	})
+		return m
+	} else if typ == 2 { //信息类型
+		stypeMap := getstypeMap()
+		for _, v := range stypeMap {
+			// stypeMap[k] = fmt.Sprintf("/list/stype/%s.html", v)
+			for _, vv := range v {
+				vv["url"] = fmt.Sprintf("/list/stype/%s.html", vv["url"])
+			}
+		}
+		return stypeMap
+	} else if typ == 3 { //热门招标
+		keysMap := getkeysMap()
+		return keysMap
+	}
+	return nil
+}
+
+//招标搜索数量
+func GetInfoNum() (one map[string]interface{}) {
+	defer util.Catch()
+	redis_obj := redis.Get("other", "pcsw_index")
+	if redis_obj != nil {
+		one = redis_obj.(map[string]interface{})
+		log.Println("newpage from the cache...")
+	} else {
+		rs, err := mongodb.Find("swordfish_index", nil, `{"_id":-1}`, nil, false, 0, 1)
+		if err {
+			one = (*rs)[0]
+			one["i_site"] = util.IntAll(one["i_entsite"]) + util.IntAll(one["i_govsite"])
+			avg := util.IntAll(one["i_bidmonth"])/21 + util.IntAll(one["i_bidmonth"])%21
+			one["i_avg"] = avg
+			one["i_my"] = util.IntAll(one["i_entsite"]) * 35 / 100
+			one["i_hy"] = util.IntAll(one["i_entsite"]) * 15 / 100
+			one["i_zb"] = util.IntAll(one["i_entsite"]) - util.IntAll(one["i_my"]) - util.IntAll(one["i_hy"])
+			one["i_push"] = NumberFormat(util.IntAll(one["i_push"]))
+			one["i_bidmonth"] = NumberFormat(util.IntAll(one["i_bidmonth"]))
+			one["i_site"] = NumberFormat(util.IntAll(one["i_site"]))
+			one["i_bidtoday"] = NumberFormat(util.IntAll(one["i_bidtoday"]))
+			redis.Put("other", "pcsw_index", one, 60*60*2)
+		}
+	}
+	return one
 }
 }
 
 
 //标签查询
 //标签查询
@@ -480,3 +580,22 @@ func getstype(stype string) string {
 	}
 	}
 	return stype
 	return stype
 }
 }
+
+//
+func NumberFormat(i int) string {
+	str := strconv.Itoa(i)
+	length := len(str)
+	if length < 4 {
+		return str
+	}
+	arr := strings.Split(str, ".") //用小数点符号分割字符串,为数组接收
+	length1 := len(arr[0])
+	if length1 < 4 {
+		return str
+	}
+	count := (length1 - 1) / 3
+	for i := 0; i < count; i++ {
+		arr[0] = arr[0][:length1-(i+1)*3] + "," + arr[0][length1-(i+1)*3:]
+	}
+	return strings.Join(arr, ".") //将一系列字符串连接为一个字符串,之间用sep来分隔。
+}

+ 2 - 0
src/jfw/front/swordfish.go

@@ -2091,6 +2091,8 @@ func SearhWebContentblog(querymap map[string]string) (*[]map[string]interface{},
 			res[i]["l_createdate"] = util.TimeDiff(time.Unix(util.Int64All(tmpdate.(float64)), 0))
 			res[i]["l_createdate"] = util.TimeDiff(time.Unix(util.Int64All(tmpdate.(float64)), 0))
 			tmpdate1, _ := res[i]["releasetime"]
 			tmpdate1, _ := res[i]["releasetime"]
 			res[i]["releasetime"] = util.TimeDiff(time.Unix(util.Int64All(tmpdate1.(float64)), 0))
 			res[i]["releasetime"] = util.TimeDiff(time.Unix(util.Int64All(tmpdate1.(float64)), 0))
+			reltime := time.Unix(util.Int64All(tmpdate1.(float64)), 0)
+			res[i]["time"] = reltime.Format(util.Date_Short_Layout) //首页展示
 			res[i]["s_pic"] = config.Seoconfig["jyadd"].(string) + res[i]["s_pic"].(string)
 			res[i]["s_pic"] = config.Seoconfig["jyadd"].(string) + res[i]["s_pic"].(string)
 			res[i]["s_pic1"] = config.Seoconfig["jyadd"].(string) + res[i]["s_pic1"].(string)
 			res[i]["s_pic1"] = config.Seoconfig["jyadd"].(string) + res[i]["s_pic1"].(string)
 			res[i]["_id"] = se.EncodeString(res[i]["_id"].(string))
 			res[i]["_id"] = se.EncodeString(res[i]["_id"].(string))