浏览代码

Merge branch 'release' into dev2.0.1

lianbingjie 7 年之前
父节点
当前提交
b7a007ba2a
共有 29 个文件被更改,包括 806 次插入273 次删除
  1. 2 1
      src/jfw/front/front.go
  2. 3 3
      src/jfw/front/supsearch.go
  3. 1 1
      src/jfw/jylabutil/entsearch.go
  4. 2 1
      src/jfw/modules/push/src/config.json
  5. 2 1
      src/jfw/modules/push/src/main.go
  6. 9 4
      src/jfw/modules/push/src/qfw/push/cache.go
  7. 15 6
      src/jfw/modules/push/src/qfw/push/dopush/dopush.go
  8. 228 0
      src/jfw/modules/push/src/qfw/push/dopush/dopush201709127
  9. 421 117
      src/jfw/modules/push/src/qfw/push/dopush/dopushes.go
  10. 11 29
      src/jfw/modules/push/src/qfw/push/dopush/filterdata.go
  11. 12 26
      src/jfw/modules/pushent/src/filterdata/filterdata.go
  12. 7 8
      src/jfw/modules/pushent/src/followpush/push.go
  13. 4 3
      src/jfw/modules/pushent/src/rpcpush/findData.go
  14. 11 25
      src/jfw/modules/pushproject/src/filterdata/filterdata.go
  15. 7 8
      src/jfw/modules/pushproject/src/followpush/push.go
  16. 4 3
      src/jfw/modules/pushproject/src/rpcpush/findData.go
  17. 13 2
      src/web/staticres/css/baidu-ground.css
  18. 二进制
      src/web/staticres/images/baidu/bd-content.jpg
  19. 二进制
      src/web/staticres/images/baidu/bd-header.jpg
  20. 二进制
      src/web/staticres/images/baidu/bd-header1.jpg
  21. 二进制
      src/web/staticres/images/baidu/bg-copy-bg.png
  22. 2 2
      src/web/staticres/js/baidu-tengxun-ground.js
  23. 1 1
      src/web/staticres/js/superSearch.js
  24. 8 7
      src/web/staticres/js/wxEntsesearch.js
  25. 24 18
      src/web/staticres/js/wxSupersearch.js
  26. 1 0
      src/web/templates/active/ext-baidu.html
  27. 5 2
      src/web/templates/pc/biddetail.html
  28. 1 1
      src/web/templates/weixin/search/mainSearch.html
  29. 12 4
      src/web/templates/weixin/wxinfocontent.html

+ 2 - 1
src/jfw/front/front.go

@@ -145,7 +145,8 @@ func (f *Front) Mobtopics() error {
 
 //移动端专题推广
 func (f *Front) Extension(page string) error {
-	if page == "" {
+	//今日头条和百度推广用的同一个页面,如以后有变动,需拆分成两个。
+	if page != "tengxun" {
 		page = "baidu"
 	}
 	return f.Render("/active/ext-" + page + ".html")

+ 3 - 3
src/jfw/front/supsearch.go

@@ -234,9 +234,9 @@ func (p *Pcsearch) PcSearchIndex() error {
 	if selectTypesess != nil && selectTypesess != "" {
 		selectType = selectTypesess.(string)
 	}
-	if selectType == "" {
-		selectType = "all"
-	}
+	//if selectType == "" {
+	selectType = "title"
+	//}
 	var count int64
 	var list *[]map[string]interface{}
 	var status = 1

+ 1 - 1
src/jfw/jylabutil/entsearch.go

@@ -45,7 +45,7 @@ func GetProjectByEntName(entname string, area string, lower, upper float64, page
 		"projectset", "projectset",
 		``, mastquery,
 		`"s_winner","biddingcontent"`,
-		`{"createtime":-1}`, ``, (pagenum-1)*pagesize, pagesize,
+		`{"jgtime":-1,"createtime":-1}`, ``, (pagenum-1)*pagesize, pagesize,
 	)
 	return list
 }

+ 2 - 1
src/jfw/modules/push/src/config.json

@@ -60,5 +60,6 @@
     "weixinRpcServer": "192.168.3.14:10084",
     "wxcontent": "剑鱼推送",
     "wxgroup": "%s信息",
-    "wxtitle": "您有新的%s信息!"
+    "wxtitle": "您有新的%s信息!",
+	"maxSearch":10000
 }

+ 2 - 1
src/jfw/modules/push/src/main.go

@@ -10,7 +10,7 @@ import (
 	//"net/rpc"
 	"qfw/push"
 	"qfw/push/bid"
-	//	"qfw/push/dopush"
+	"qfw/push/dopush"
 	//"qfw/push/listdb"
 	_ "net/http/pprof"
 	"qfw/push/rpcpush"
@@ -35,6 +35,7 @@ func init() {
 	}
 	bid.MaxPushSize = util.IntAll(push.PushConfig["maxPushSize"])
 	rpcpush.PushInfoScopeDays = util.IntAll(push.PushConfig["pushInfoScopeDays"])
+	dopush.MaxSearch = util.IntAllDef(push.PushConfig["maxSearch"], 10000)
 	mongodb.InitMongodbPool(util.IntAll(push.PushConfig["mgoSize"]), push.PushConfig["mgoAddr"].(string), "qfw")
 	redis.InitRedis(push.PushConfig["redisServers"].(string))
 	elastic.InitElasticSize(push.PushConfig["elasticsearch"].(string), util.IntAllDef(push.PushConfig["elasticPoolSize"], 20))

+ 9 - 4
src/jfw/modules/push/src/qfw/push/cache.go

@@ -17,10 +17,15 @@ import (
 )
 
 type MemberInterest struct {
-	Id           string   //mongoid
-	Province     string   //省份
-	ProvinceVal  uint64   //可选多个省份的处理
-	Interest     []string //用户兴趣
+	Id           string                     //mongoid
+	Province     string                     //省份
+	Key_notkey   map[string]string          //关键词-排除词
+	Key_area     map[string]map[string]bool //关键词-信息范围
+	Key_infotype map[string]map[string]bool //关键词-信息类型
+	Infotypes    []string                   //信息类型
+	ProvinceVal  uint64                     //可选多个省份的处理
+	Interest     []string                   //用户兴趣
+	NotInterest  []string                   //用户不感兴趣
 	Openid       string
 	InterestDate int64
 	PushMode     int //增加推送方式 11两位,分别代表邮箱、微信

+ 15 - 6
src/jfw/modules/push/src/qfw/push/dopush/dopush.go

@@ -11,6 +11,7 @@ import (
 	//	"qfw/util/mongodb"
 	//	qrpc "qfw/util/rpc"
 	//"regexp"
+	"sort"
 	"strconv"
 	"strings"
 	"time"
@@ -32,8 +33,15 @@ func (s sortList) Swap(i, j int) {
 	s[i], s[j] = s[j], s[i]
 }
 
-func DealSend(k *push.MemberInterest, v *list.List, now time.Time, MaxPushSize int, ratemode int, infoTypeName string) {
+func DealSend(k *push.MemberInterest, l *list.List, now time.Time, MaxPushSize int, ratemode int, infoTypeName string) {
 	defer util.Catch()
+	//排序
+	sl := make(sortList, 0)
+	for ks := l.Front(); ks != nil; ks = ks.Next() {
+		k2 := *(ks.Value.(*map[string]interface{}))
+		sl = append(sl, &k2)
+	}
+	sort.Sort(sl)
 	bmail := false
 	mailContent := ""
 	if k.PushMode&2 > 0 && len(k.Email) > 0 {
@@ -46,15 +54,16 @@ func DealSend(k *push.MemberInterest, v *list.List, now time.Time, MaxPushSize i
 	TitleArray := []string{}
 	o_pushinfo := map[string]map[string]interface{}{}
 	publishTitle := map[string]bool{}
-	FilterData.Start(k.Openid)
-	defer FilterData.End()
+	filterData := &FilterData{}
+	filterData.Start(k.Openid)
+	defer filterData.End()
 	//邮件附件
 	var fmdatas = []map[string]interface{}{}
-	for ks := v.Front(); ks != nil; ks = ks.Next() {
-		k2 := *(ks.Value.(*map[string]interface{}))
+	for _, ks := range sl {
+		k2 := *ks
 		title := strings.Replace(k2["title"].(string), "\n", "", -1)
 		if !publishTitle[title] {
-			if FilterData.IsExists(util.BsonIdToSId(k2["_id"])) {
+			if filterData.IsExists(util.BsonIdToSId(k2["_id"])) {
 				continue
 			}
 			publishTitle[title] = true

+ 228 - 0
src/jfw/modules/push/src/qfw/push/dopush/dopush201709127

@@ -0,0 +1,228 @@
+package dopush
+
+import (
+	"container/list"
+	"encoding/json"
+	"fmt"
+	"log"
+	"qfw/push"
+	"qfw/util"
+	"qfw/util/elastic"
+	"qfw/util/mongodb"
+	"strings"
+	"time"
+
+	"gopkg.in/mgo.v2/bson"
+)
+
+const (
+	//industry
+	ShowField = `"_id","title","publishtime","toptype","subtype","type","area","href","areaval","infoformat",` +
+		`"projectname","buyer","winner","buyer","budget","bidamount","bidopentime","subscopeclass"`
+	FindField      = `"title"`
+	SmartFindField = `"title","projectscope"`
+	SortQuery      = `{"publishtime":"desc"}`
+	DB             = "bidding"
+	IDRange        = `{"range":{"id":{"gt":"%s","lte":"%s"}}},{"range":{"publishtime":{"gt": %d}}}`
+	MaxId          = `{"query":{"filtered":{"filter":{"bool":{"must":{"range":{"id":{"gt":"%s"}}}}}}},"_source":["_id","comeintime"],"sort":{"id":"desc"},"from":0,"size":1}`
+	PushTitle      = `[<span class='area'>%s</span>]%s`
+	Infoformat     = `{"term":{"infoformat":%d}}`
+)
+
+var (
+	InfoMap = map[int]string{
+		1: "招标",
+		2: "拟建项目",
+	}
+	pushpool = make(chan bool, 8)
+)
+
+//开始推送
+func DoPush(k *push.MemberInterest, idrange []string, MaxPushSize int, Now time.Time, ratemode int) {
+	defer util.Catch()
+	defer func() {
+		<-pushpool
+	}()
+	//是否含有拟建项目
+	//for i := 1; i < 3; i++ {
+	//idrangeTmp := append(idrange, fmt.Sprintf(Infoformat, i))
+	var pushArray = []map[string]interface{}{}
+	f := FindField
+	if k.Smartset == 1 {
+		f = SmartFindField
+	}
+	res := elastic.GetResForJY(DB, DB, k.AllKeys, strings.Join(idrange, ","), f, SortQuery, ShowField, 0, MaxPushSize)
+	if res != nil && *res != nil && len(*res) > 0 {
+		listInfos := list.New()
+		for _, v := range *res {
+			vh := v["highlight"].(map[string][]string)
+			if len(vh) == 2 {
+				v["highlight"] = 3
+			} else {
+				if vh["title"] != nil {
+					v["highlight"] = 1
+				} else {
+					v["highlight"] = 2
+				}
+			}
+			province := util.ObjToString(v["area"])
+			v["otitle"] = v["title"]
+			if "A" != province {
+				v["title"] = fmt.Sprintf(PushTitle, province, v["title"])
+			}
+			var info = v
+			pushArray = append(pushArray, info)
+			listInfos.PushBack(&info)
+		}
+		var rtflog = false
+		h := time.Now().Hour()
+		openid := k.Openid
+		if k.Ratemode == 3 {
+			if k.Rmstart <= h && h < k.Rmend {
+				rtflog = true
+				//把暂存数据取出合并后发送,并删除此用户暂存库中的数据
+				inofsdata := mongodb.FindOne("tempush", &bson.M{"s_openid": openid})
+				if inofsdata != nil {
+					if (*inofsdata)["tmpinfos"] != nil {
+						infos := (*inofsdata)["tmpinfos"].([]interface{})
+						for _, tif := range infos {
+							tifMap := tif.(map[string]interface{})
+							listInfos.PushBack(&tifMap)
+						}
+					}
+				}
+				mongodb.Del("tempush", &bson.M{"s_openid": openid})
+			} else {
+				//自定义时间外的数据暂存数据库tempush中
+				mongodb.Update("tempush", &bson.M{"s_openid": openid}, &bson.M{
+					"$pushAll": bson.M{
+						"tmpinfos": &pushArray,
+					},
+				}, true, false)
+			}
+		} else {
+			rtflog = true
+		}
+		if rtflog {
+			DealSend(k, listInfos, Now, MaxPushSize, k.Ratemode, InfoMap[1])
+		}
+
+		//}
+	}
+}
+
+func PushInfoByEs(MaxPushSize int, Config *map[string]interface{}, i_ratemode int) (res bool) {
+	defer util.Catch()
+	st, _ := time.ParseInLocation(util.Date_Full_Layout, (*Config)["StartTime"].(string), time.Local)
+	lastTime := st.Unix()
+	_id := util.ObjToString((*Config)["lastid"])
+	log.Println("开始执行任务-i_ratemode-id-lasttime:", i_ratemode, _id, lastTime)
+	Now := time.Now()
+	session := mongodb.GetMgoConn()
+	defer mongodb.DestoryMongoConn(session)
+	idrange := []string{}
+	//获取本次查询的最大id
+	resId := elastic.Get(DB, DB, fmt.Sprintf(MaxId, _id))
+	lastid := ""
+	var comeintime interface{}
+	if resId != nil && *resId != nil && len(*resId) == 1 {
+		lastid = util.ObjToString((*resId)[0]["_id"])
+		comeintime = (*resId)[0]["comeintime"]
+	} else {
+		log.Println("未查找到数据...", fmt.Sprintf(MaxId, _id))
+		return false
+	}
+	//filter全局查询
+	idrange = append(idrange, fmt.Sprintf(IDRange, _id, lastid, lastTime-7*86400))
+	//遍历用户
+	q := map[string]interface{}{
+		"i_appid":  2,
+		"i_ispush": map[string]interface{}{"$ne": 0},
+	}
+	if i_ratemode == 1 {
+		q["o_jy.i_ratemode"] = map[string]interface{}{"$in": []int{1, 3}}
+	} else {
+		q["o_jy.i_ratemode"] = i_ratemode
+	}
+	//	smopenid := util.ObjToString((*Config)["fixPush"])
+	//	if smopenid != "" {
+	//		q["s_m_openid"] = smopenid
+	//	}
+	query := session.DB("qfw").C("user").Find(&q).Select(&map[string]interface{}{
+		"_id":          1,
+		"o_jy":         1,
+		"s_m_openid":   1,
+		"i_dataexport": 1,
+		"i_smartset":   1,
+	}).Iter()
+	//遍历所有用户放到数组
+	allPushUsers := []map[string]interface{}{}
+	for tmp := make(map[string]interface{}); query.Next(tmp); {
+		allPushUsers = append(allPushUsers, tmp)
+		tmp = make(map[string]interface{})
+	}
+	log.Println("本次推送", len(allPushUsers), "人")
+	//遍历用户数组
+	for _, tmp := range allPushUsers {
+		log.Println("openid:", tmp["s_m_openid"])
+		util.Try(func() {
+			_id := fmt.Sprintf("%x", string(tmp["_id"].(bson.ObjectId)))
+			o_msgset := tmp["o_jy"].(map[string]interface{})
+			var allkeysTemp []elastic.KeyConfig
+			_bs, err := json.Marshal(o_msgset["a_key"])
+			if err == nil {
+				json.Unmarshal(_bs, &allkeysTemp)
+			}
+			allkeys := []elastic.KeyConfig{}
+			if len(allkeysTemp) > 0 {
+				//一个字或者配置文件中的词,不推送
+				for _, vs := range allkeysTemp {
+					isFilter := false
+					vskey := strings.Replace(strings.Join(vs.Keys, ""), " ", "", -1)
+					if len([]rune(vskey)) == 1 {
+						continue
+					}
+					for _, fv := range push.FilterConfig {
+						if fv == vskey {
+							isFilter = true
+							break
+						}
+					}
+					if !isFilter {
+						allkeys = append(allkeys, vs)
+					}
+				}
+			}
+			////////////////
+			if len(allkeys) > 0 {
+				a_key := []string{}
+				for _, vs := range allkeys {
+					a_key = append(a_key, strings.Join(vs.Keys, "+"))
+				}
+				user := push.MemberInterest{
+					Id:         _id,
+					Interest:   a_key,
+					PushMode:   util.IntAllDef(o_msgset["i_mode"], 1),
+					Email:      util.ObjToString(o_msgset["s_email"]),
+					Openid:     util.ObjToString(tmp["s_m_openid"]),
+					Ratemode:   util.IntAllDef(o_msgset["i_ratemode"], 1),
+					Rmstart:    util.IntAllDef(o_msgset["i_rmstart"], 1),
+					Rmend:      util.IntAllDef(o_msgset["i_rmend"], 1),
+					AllKeys:    allkeys,
+					Smartset:   util.IntAllDef(tmp["i_smartset"], 0),
+					Dataexport: util.IntAllDef(tmp["i_dataexport"], 0),
+				}
+				pushpool <- true
+				go DoPush(&user, idrange, MaxPushSize, Now, i_ratemode)
+			}
+
+		}, func(e interface{}) {
+			log.Println(e)
+		})
+	}
+	log.Println("推送结束..", comeintime, lastid)
+	allPushUsers = []map[string]interface{}{}
+	(*Config)["StartTime"] = util.FormatDateWithObj(&comeintime, util.Date_Full_Layout)
+	(*Config)["lastid"] = lastid
+	return true
+}

+ 421 - 117
src/jfw/modules/push/src/qfw/push/dopush/dopushes.go

@@ -4,20 +4,21 @@ import (
 	"container/list"
 	"encoding/json"
 	"fmt"
+	"gopkg.in/mgo.v2/bson"
 	"log"
 	"qfw/push"
+	"qfw/push/dfa"
 	"qfw/util"
 	"qfw/util/elastic"
 	"qfw/util/mongodb"
 	"strings"
+	"sync"
 	"time"
-
-	"gopkg.in/mgo.v2/bson"
 )
 
 const (
 	//industry
-	ShowField = `"_id","title","publishtime","toptype","subtype","type","area","href","areaval","infoformat",` +
+	ShowField = `"_id","title","projectscope","publishtime","toptype","subtype","type","area","href","areaval","infoformat",` +
 		`"projectname","buyer","winner","buyer","budget","bidamount","bidopentime","subscopeclass"`
 	FindField      = `"title"`
 	SmartFindField = `"title","projectscope"`
@@ -27,6 +28,7 @@ const (
 	MaxId          = `{"query":{"filtered":{"filter":{"bool":{"must":{"range":{"id":{"gt":"%s"}}}}}}},"_source":["_id","comeintime"],"sort":{"id":"desc"},"from":0,"size":1}`
 	PushTitle      = `[<span class='area'>%s</span>]%s`
 	Infoformat     = `{"term":{"infoformat":%d}}`
+	FilterQuery    = `{"query": {"filtered": {"filter": {"bool": {"must": [%s]}}}}}`
 )
 
 var (
@@ -34,93 +36,50 @@ var (
 		1: "招标",
 		2: "拟建项目",
 	}
-	pushpool = make(chan bool, 8)
+	searchpool        = make(chan bool, 8)
+	pushpool          = make(chan bool, 50)
+	eachpool          = make(chan bool, 100)
+	searchWaitGroup   = &sync.WaitGroup{}
+	eachInfoWaitGroup = &sync.WaitGroup{}
+	userMapLock       = &sync.Mutex{}
+	biddingDatas      *[]map[string]interface{}
+	allUsers          *map[string]*push.MemberInterest
+	MaxSearch         = 10000 //缓存中总共加载这么多条
+	OnceMax           = 400   //ES一次查询这么多条
 )
 
-//开始推送
-func DoPush(k *push.MemberInterest, idrange []string, MaxPushSize int, Now time.Time, ratemode int) {
-	defer util.Catch()
-	defer func() {
-		<-pushpool
-	}()
-	//是否含有拟建项目
-	//for i := 1; i < 3; i++ {
-	//idrangeTmp := append(idrange, fmt.Sprintf(Infoformat, i))
-	var pushArray = []map[string]interface{}{}
-	f := FindField
-	if k.Smartset == 1 {
-		f = SmartFindField
-	}
-	res := elastic.GetResForJY(DB, DB, k.AllKeys, strings.Join(idrange, ","), f, SortQuery, ShowField, 0, MaxPushSize)
-	if res != nil && *res != nil && len(*res) > 0 {
-		listInfos := list.New()
-		for _, v := range *res {
-			vh := v["highlight"].(map[string][]string)
-			if len(vh) == 2 {
-				v["highlight"] = 3
-			} else {
-				if vh["title"] != nil {
-					v["highlight"] = 1
-				} else {
-					v["highlight"] = 2
-				}
-			}
-			province := util.ObjToString(v["area"])
-			v["otitle"] = v["title"]
-			if "A" != province {
-				v["title"] = fmt.Sprintf(PushTitle, province, v["title"])
-			}
-			var info = v
-			pushArray = append(pushArray, info)
-			listInfos.PushBack(&info)
-		}
-		var rtflog = false
-		h := time.Now().Hour()
-		openid := k.Openid
-		if k.Ratemode == 3 {
-			if k.Rmstart <= h && h < k.Rmend {
-				rtflog = true
-				//把暂存数据取出合并后发送,并删除此用户暂存库中的数据
-				inofsdata := mongodb.FindOne("tempush", &bson.M{"s_openid": openid})
-				if inofsdata != nil {
-					if (*inofsdata)["tmpinfos"] != nil {
-						infos := (*inofsdata)["tmpinfos"].([]interface{})
-						for _, tif := range infos {
-							tifMap := tif.(map[string]interface{})
-							listInfos.PushBack(&tifMap)
-						}
-					}
-				}
-				mongodb.Del("tempush", &bson.M{"s_openid": openid})
-			} else {
-				//自定义时间外的数据暂存数据库tempush中
-				mongodb.Update("tempush", &bson.M{"s_openid": openid}, &bson.M{
-					"$pushAll": bson.M{
-						"tmpinfos": &pushArray,
-					},
-				}, true, false)
-			}
-		} else {
-			rtflog = true
-		}
-		if rtflog {
-			DealSend(k, listInfos, Now, MaxPushSize, k.Ratemode, InfoMap[1])
-		}
+type Pjob struct {
+	InterestDfa    *dfa.DFA
+	NotInterestDfa *dfa.DFA
+	Key_user       *map[string]*[]*push.MemberInterest
+	Notkey_user    *map[string]*[]*push.MemberInterest
+}
 
-		//}
+//所有用户的关键词和排除词
+func (p *Pjob) CreateDaf() {
+	//关键词
+	p.InterestDfa = &dfa.DFA{}
+	interestWords := make([]string, 0)
+	for k, _ := range *p.Key_user {
+		interestWords = append(interestWords, k)
+	}
+	p.InterestDfa.AddWord(interestWords...)
+	//排除关键词
+	p.NotInterestDfa = &dfa.DFA{}
+	notInterestWords := make([]string, 0)
+	for k, _ := range *p.Notkey_user {
+		notInterestWords = append(notInterestWords, k)
 	}
+	p.NotInterestDfa.AddWord(notInterestWords...)
 }
 
-func PushInfoByEs(MaxPushSize int, Config *map[string]interface{}, i_ratemode int) (res bool) {
+func PushInfoByEs(MaxPushSize int, Config *map[string]interface{}, i_ratemode int) bool {
 	defer util.Catch()
 	st, _ := time.ParseInLocation(util.Date_Full_Layout, (*Config)["StartTime"].(string), time.Local)
 	lastTime := st.Unix()
 	_id := util.ObjToString((*Config)["lastid"])
 	log.Println("开始执行任务-i_ratemode-id-lasttime:", i_ratemode, _id, lastTime)
 	Now := time.Now()
-	session := mongodb.GetMgoConn()
-	defer mongodb.DestoryMongoConn(session)
-	idrange := []string{}
 	//获取本次查询的最大id
 	resId := elastic.Get(DB, DB, fmt.Sprintf(MaxId, _id))
 	lastid := ""
@@ -129,11 +88,31 @@ func PushInfoByEs(MaxPushSize int, Config *map[string]interface{}, i_ratemode in
 		lastid = util.ObjToString((*resId)[0]["_id"])
 		comeintime = (*resId)[0]["comeintime"]
 	} else {
-		log.Println("未查找到数据...", fmt.Sprintf(MaxId, _id))
+		log.Println("获取本次查询的最大id的时候,未查找到数据...", fmt.Sprintf(MaxId, _id))
 		return false
 	}
-	//filter全局查询
-	idrange = append(idrange, fmt.Sprintf(IDRange, _id, lastid, lastTime-7*86400))
+	a_p, s_p := InitUserCache(i_ratemode)
+	if a_p == nil {
+		log.Println("未查找到需要推送的用户...")
+		return false
+	}
+	if !InitBiddingCache(_id, lastid, lastTime) {
+		log.Println("加载数据到内存中的时候,未查找到数据...")
+		return false
+	}
+	//
+	DoPush(a_p, s_p, MaxPushSize, Now, i_ratemode)
+	log.Println("推送结束..", comeintime, lastid)
+	biddingDatas = nil
+	allUsers = nil
+	(*Config)["StartTime"] = util.FormatDateWithObj(&comeintime, util.Date_Full_Layout)
+	(*Config)["lastid"] = lastid
+	return true
+}
+
+//初始化用户缓存
+func InitUserCache(i_ratemode int) (*Pjob, *Pjob) {
+	defer util.Catch()
 	//遍历用户
 	q := map[string]interface{}{
 		"i_appid":  2,
@@ -144,26 +123,34 @@ func PushInfoByEs(MaxPushSize int, Config *map[string]interface{}, i_ratemode in
 	} else {
 		q["o_jy.i_ratemode"] = i_ratemode
 	}
-	//	smopenid := util.ObjToString((*Config)["fixPush"])
-	//	if smopenid != "" {
-	//		q["s_m_openid"] = smopenid
+	//18 o8-2pwHj1s_tv3nnRxrH9cD2ngkk
+	//14 ouCYjwzKpn-3orDpb0CA3Po1RLHw
+	//	q = map[string]interface{}{
+	//		"i_appid": 2,
+	//		"s_m_openid": map[string]interface{}{
+	//			"$in": []string{"o8-2pwHj1s_tv3nnRxrH9cD2ngkk"},
+	//		},
 	//	}
+	session := mongodb.GetMgoConn()
+	defer mongodb.DestoryMongoConn(session)
 	query := session.DB("qfw").C("user").Find(&q).Select(&map[string]interface{}{
-		"_id":          1,
-		"o_jy":         1,
-		"s_m_openid":   1,
-		"i_dataexport": 1,
-		"i_smartset":   1,
+		"_id":           1,
+		"o_jy":          1,
+		"s_m_openid":    1,
+		"i_dataexport":  1,
+		"i_smartset":    1,
+		"i_supersearch": 1,
 	}).Iter()
+	allUsers = &map[string]*push.MemberInterest{}
 	//遍历所有用户放到数组
-	allPushUsers := []map[string]interface{}{}
-	for tmp := make(map[string]interface{}); query.Next(tmp); {
-		allPushUsers = append(allPushUsers, tmp)
-		tmp = make(map[string]interface{})
-	}
-	log.Println("本次推送", len(allPushUsers), "人")
+	a_key_user := make(map[string]*[]*push.MemberInterest)
+	a_notkey_user := make(map[string]*[]*push.MemberInterest)
+	//开启智能订阅的用户
+	s_key_user := make(map[string]*[]*push.MemberInterest)
+	s_notkey_user := make(map[string]*[]*push.MemberInterest)
 	//遍历用户数组
-	for _, tmp := range allPushUsers {
+	n := 0
+	for tmp := make(map[string]interface{}); query.Next(tmp); n++ {
 		log.Println("openid:", tmp["s_m_openid"])
 		util.Try(func() {
 			_id := fmt.Sprintf("%x", string(tmp["_id"].(bson.ObjectId)))
@@ -195,34 +182,351 @@ func PushInfoByEs(MaxPushSize int, Config *map[string]interface{}, i_ratemode in
 			}
 			////////////////
 			if len(allkeys) > 0 {
-				a_key := []string{}
+				keys := []string{}                           //关键词
+				notkeys := []string{}                        //排除词
+				key_notkey := map[string]string{}            //关键词所对应的排除词
+				key_area := map[string]map[string]bool{}     //关键词所对应的信息范围
+				key_infotype := map[string]map[string]bool{} //关键词所对应的信息类型
 				for _, vs := range allkeys {
-					a_key = append(a_key, strings.Join(vs.Keys, "+"))
+					key := strings.Join(vs.Keys, "+")
+					keys = append(keys, key)
+					notkey := strings.Join(vs.NotKeys, "+")
+					notkeys = append(notkeys, notkey)
+					//建立与排除词的对应关系
+					key_notkey[key] = notkey
+					//建立与信息范围的对应关系
+					for _, area := range vs.Areas {
+						if key_area[key] == nil {
+							key_area[key] = map[string]bool{}
+						}
+						key_area[key][area] = true
+					}
+					//建立与信息类型的对应关系
+					for _, infotype := range vs.InfoTypes {
+						if key_infotype[key] == nil {
+							key_infotype[key] = map[string]bool{}
+						}
+						key_infotype[key][infotype] = true
+					}
 				}
-				user := push.MemberInterest{
-					Id:         _id,
-					Interest:   a_key,
-					PushMode:   util.IntAllDef(o_msgset["i_mode"], 1),
-					Email:      util.ObjToString(o_msgset["s_email"]),
-					Openid:     util.ObjToString(tmp["s_m_openid"]),
-					Ratemode:   util.IntAllDef(o_msgset["i_ratemode"], 1),
-					Rmstart:    util.IntAllDef(o_msgset["i_rmstart"], 1),
-					Rmend:      util.IntAllDef(o_msgset["i_rmend"], 1),
-					AllKeys:    allkeys,
-					Smartset:   util.IntAllDef(tmp["i_smartset"], 0),
-					Dataexport: util.IntAllDef(tmp["i_dataexport"], 0),
+				smartset := util.IntAllDef(tmp["i_smartset"], 0)
+				user := &push.MemberInterest{
+					Id:           _id,
+					Interest:     keys,
+					NotInterest:  notkeys,
+					Key_notkey:   key_notkey,
+					Key_area:     key_area,
+					Key_infotype: key_infotype,
+					PushMode:     util.IntAllDef(o_msgset["i_mode"], 1),
+					Email:        util.ObjToString(o_msgset["s_email"]),
+					Openid:       util.ObjToString(tmp["s_m_openid"]),
+					Ratemode:     util.IntAllDef(o_msgset["i_ratemode"], 1),
+					Rmstart:      util.IntAllDef(o_msgset["i_rmstart"], 1),
+					Rmend:        util.IntAllDef(o_msgset["i_rmend"], 1),
+					AllKeys:      allkeys,
+					Smartset:     smartset,
+					Dataexport:   util.IntAllDef(tmp["i_dataexport"], 0),
+				}
+				(*allUsers)[user.Openid] = user
+				MakeKeyUser(keys, user, &a_key_user)
+				MakeKeyUser(notkeys, user, &a_notkey_user)
+				if smartset == 1 {
+					MakeKeyUser(keys, user, &s_key_user)
+					MakeKeyUser(notkeys, user, &s_notkey_user)
 				}
-				pushpool <- true
-				go DoPush(&user, idrange, MaxPushSize, Now, i_ratemode)
 			}
-
 		}, func(e interface{}) {
 			log.Println(e)
 		})
+		tmp = make(map[string]interface{})
 	}
-	log.Println("推送结束..", comeintime, lastid)
-	allPushUsers = []map[string]interface{}{}
-	(*Config)["StartTime"] = util.FormatDateWithObj(&comeintime, util.Date_Full_Layout)
-	(*Config)["lastid"] = lastid
+	log.Println("本次查询用户总数:", n)
+	if len(*allUsers) == 0 {
+		return nil, nil
+	}
+	a_p := &Pjob{
+		Key_user:    &a_key_user,
+		Notkey_user: &a_notkey_user,
+	}
+	a_p.CreateDaf()
+	//
+	s_p := &Pjob{
+		Key_user:    &s_key_user,
+		Notkey_user: &s_notkey_user,
+	}
+	s_p.CreateDaf()
+	return a_p, s_p
+}
+
+//把用户挂在词下面
+func MakeKeyUser(keys []string, user *push.MemberInterest, key_user *map[string]*[]*push.MemberInterest) {
+	m := map[string]bool{}
+	for _, v := range keys {
+		if v == "" || m[v] {
+			continue
+		}
+		m[v] = true
+		var arr *[]*push.MemberInterest
+		if nil == (*key_user)[v] {
+			arr = &[]*push.MemberInterest{}
+			(*key_user)[v] = arr
+		} else {
+			arr = (*key_user)[v]
+			(*key_user)[v] = arr
+		}
+		*arr = append(*arr, user)
+	}
+}
+
+//加载数据到内存中
+func InitBiddingCache(_id, lastid string, lastTime int64) bool {
+	//filter全局查询
+	c_query := fmt.Sprintf(FilterQuery, fmt.Sprintf(IDRange, _id, lastid, lastTime-7*86400))
+	//testquery := `{"terms":{"_id":["59cefaa12cf26913ca07fd56"]}}`
+	//testquery := ``
+	//c_query = fmt.Sprintf(FilterQuery, testquery)
+	count := int(elastic.Count(DB, DB, c_query))
+	log.Println("本次推送共查到数据", count, "条")
+	if count == 0 {
+		return false
+	}
+	if count > MaxSearch {
+		count = MaxSearch
+		log.Println("目前数据多于", MaxSearch, ",只加载了", MaxSearch, "条!")
+	}
+	if OnceMax > count {
+		OnceMax = count
+	}
+	var res []map[string]interface{}
+	totalPage := int((count + OnceMax - 1) / OnceMax)
+	log.Println("数据一共", totalPage, "页!")
+	//如果res长度和cout相差5条,重试
+	for t := 1; t <= 3; t++ {
+		res = []map[string]interface{}{}
+		for i := 0; i < totalPage; i++ {
+			searchpool <- true
+			searchWaitGroup.Add(1)
+			go func(start int) {
+				defer func() {
+					searchWaitGroup.Done()
+					<-searchpool
+				}()
+				r := elastic.GetAllByNgram(DB, DB, c_query, "", SortQuery, ShowField, start*OnceMax, OnceMax, 0, false)
+				res = append(res, *r...)
+				log.Println("第", start+1, "页数据加载完成!")
+			}(i)
+		}
+		searchWaitGroup.Wait()
+		if len(res) >= count-5 {
+			break
+		}
+		log.Println("第", t, "次加载数据完成,数据总数", len(res), ",由于数据量不够,重新加载!")
+	}
+	resLenght := len(res)
+	if resLenght == 0 {
+		return false
+	}
+	biddingDatas = &res
+	log.Println(resLenght, "条数据已经加载完成!")
 	return true
 }
+
+//开始推送
+func DoPush(a_p *Pjob, s_p *Pjob, MaxPushSize int, Now time.Time, ratemode int) {
+	defer util.Catch()
+	userMap := EachAllBidInfo(a_p, s_p)
+	log.Println("本次推送", len(*userMap), "人")
+	for temp_k, temp_list := range *userMap {
+		pushpool <- true
+		go func(k *push.MemberInterest, listInfos *list.List) {
+			defer func() {
+				<-pushpool
+			}()
+			var rtflog = false
+			h := time.Now().Hour()
+			openid := k.Openid
+			if k.Ratemode == 3 {
+				inofsdata := mongodb.FindOne("tempush", &bson.M{"s_openid": openid})
+				if k.Rmstart <= h && h < k.Rmend {
+					rtflog = true
+					//把暂存数据取出合并后发送,并删除此用户暂存库中的数据
+					if inofsdata != nil {
+						if (*inofsdata)["tmpinfos"] != nil {
+							infos := (*inofsdata)["tmpinfos"].([]interface{})
+							for _, tif := range infos {
+								tifMap := tif.(map[string]interface{})
+								listInfos.PushBack(&tifMap)
+							}
+						}
+					}
+					mongodb.Del("tempush", &bson.M{"s_openid": openid})
+				} else {
+					//自定义时间外的数据暂存数据库tempush中
+					var pushArray = []interface{}{}
+					for e := listInfos.Front(); e != nil; e = e.Next() {
+						k2 := *(e.Value.(*map[string]interface{}))
+						pushArray = append(pushArray, k2)
+						if len(pushArray) >= MaxPushSize {
+							break
+						}
+					}
+					pLength := len(pushArray)
+					upSet := new(bson.M)
+					//直接替换
+					if inofsdata == nil || pLength >= MaxPushSize {
+						upSet = &bson.M{"$set": &bson.M{"tmpinfos": &pushArray}}
+					} else { //保留最新的50条
+						infos, _ := (*inofsdata)["tmpinfos"].([]interface{})
+						rLength := len(infos)
+						if rLength > 0 && rLength+pLength > MaxPushSize {
+							start := rLength + pLength - MaxPushSize
+							var relationinfoTemp []interface{}
+							if start < rLength {
+								relationinfoTemp = append(relationinfoTemp, infos[start:]...)
+							}
+							relationinfoTemp = append(relationinfoTemp, pushArray...)
+							upSet = &bson.M{"$set": &bson.M{"tmpinfos": &relationinfoTemp}}
+						} else { //追加
+							upSet = &bson.M{"$pushAll": &bson.M{"tmpinfos": &pushArray}}
+						}
+					}
+					mongodb.Update("tempush", &bson.M{"s_openid": openid}, upSet, true, false)
+				}
+			} else {
+				rtflog = true
+			}
+			if rtflog {
+				DealSend(k, listInfos, Now, MaxPushSize, k.Ratemode, InfoMap[1])
+			}
+		}(temp_k, temp_list)
+
+		//		for temp_k, temp_list := range *userMap {
+		//			arrayids := []interface{}{}
+		//			for e := temp_list.Front(); e != nil; e = e.Next() {
+		//				k2 := *(e.Value.(*map[string]interface{}))
+		//				arrayids = append(arrayids, k2["_id"])
+		//			}
+		//			log.Println(temp_k.Openid, arrayids)
+		//			if len(arrayids) < 5 {
+		//				log.Println("==========", temp_k.Openid, arrayids)
+		//			}
+		//		}
+	}
+}
+
+//遍历数据并执行推送操作
+func EachAllBidInfo(a_p *Pjob, s_p *Pjob) *map[*push.MemberInterest]*list.List {
+	defer util.Catch()
+	userMap := &map[*push.MemberInterest]*list.List{}
+	var count int
+	for _, temp := range *biddingDatas {
+		eachpool <- true
+		eachInfoWaitGroup.Add(1)
+		count++
+		go func(info map[string]interface{}) {
+			defer func() {
+				eachInfoWaitGroup.Done()
+				<-eachpool
+			}()
+			title := util.ObjToString(info["title"])
+			if title == "" {
+				return
+			}
+			area := util.ObjToString(info["area"])
+			toptype := util.ObjToString(info["toptype"])
+			//订阅词
+			keys := a_p.InterestDfa.Analy(title)
+			//排除词
+			notkeys := a_p.NotInterestDfa.Analy(title)
+			users := GetFinalUser(keys, notkeys, a_p.Key_user, area, toptype, true)
+			//开启智能匹配的用户,匹配projectscope
+			if s_p != nil {
+				projectscope := util.ObjToString(info["projectscope"])
+				if projectscope != "" {
+					keys = s_p.InterestDfa.Analy(projectscope)
+					notkeys = s_p.NotInterestDfa.Analy(projectscope)
+					s_users := GetFinalUser(keys, notkeys, s_p.Key_user, area, toptype, false)
+					for _, s_u := range *s_users {
+						if (*users)[s_u.Openid] != nil {
+							continue
+						}
+						(*users)[s_u.Openid] = s_u
+					}
+				}
+			}
+			if len(*users) > 0 {
+				province := util.ObjToString(info["area"])
+				info["otitle"] = info["title"]
+				if "A" != province {
+					info["title"] = fmt.Sprintf(PushTitle, province, info["title"])
+				}
+				EachInfoToUser(users, &info, userMap)
+			}
+		}(temp)
+		if count%500 == 0 {
+			log.Println("当前信息索引:", count)
+		}
+	}
+	eachInfoWaitGroup.Wait()
+	log.Println("数据遍历完成!")
+	return userMap
+}
+
+//获取最终的用户,排除词、信息范围、信息类型之后的
+//返回匹配上的用户和没有匹配到的用户
+func GetFinalUser(keys, notkeys []string, key_user *map[string]*[]*push.MemberInterest, area, toptype string, flag bool) *map[string]*push.MemberInterest {
+	keyMap := map[string]bool{}
+	for _, v := range keys {
+		keyMap[v] = true
+	}
+	notkeyMap := map[string]bool{}
+	for _, v := range notkeys {
+		notkeyMap[v] = true
+	}
+	y_users := map[string]*push.MemberInterest{} //匹配到用户
+	//遍历所有用户
+	for k, us := range *key_user {
+		if !keyMap[k] { //改关键词没有匹配到的用户
+			continue
+		}
+		for _, u := range *us {
+			//获取该词下面所有的用户
+			//遍历我的排除词,如果存在的话,排除自己
+			if notkeyMap[u.Key_notkey[k]] {
+				continue
+			}
+			//遍历我的信息范围,看该信息是不是在我的信息范围中
+			if len(u.Key_area[k]) > 0 && !u.Key_area[k][area] {
+				continue
+			}
+			//遍历我的信息类型,看该信息是不是在我的信息类型中
+			if len(u.Key_infotype[k]) > 0 && !u.Key_infotype[k][toptype] {
+				continue
+			}
+			y_users[u.Openid] = u
+		}
+	}
+	//获取最终没有匹配到的用户,进行正文或者范围匹配
+	users := map[string]*push.MemberInterest{}
+	for k, v := range *allUsers {
+		if y_users[k] == nil {
+			continue
+		}
+		users[v.Openid] = v
+	}
+	return &users
+}
+
+//遍历用户加入到此条信息上
+func EachInfoToUser(users *map[string]*push.MemberInterest, info *map[string]interface{}, userMap *map[*push.MemberInterest]*list.List) {
+	defer userMapLock.Unlock()
+	userMapLock.Lock()
+	for _, v := range *users {
+		s := (*userMap)[v]
+		if s == nil {
+			s = list.New()
+			(*userMap)[v] = s
+		}
+		s.PushBack(info)
+	}
+}

+ 11 - 29
src/jfw/modules/push/src/qfw/push/dopush/filterdata.go

@@ -4,31 +4,19 @@ import (
 	"encoding/json"
 	"log"
 	"qfw/util/redis"
-	"sync"
 )
 
-var FilterData *filterDataEntity
-
-type filterDataEntity struct {
-	Lock   *sync.Mutex
+type FilterData struct {
 	Array  []string
 	OpenId string
 }
 
-func init() {
-	FilterData = &filterDataEntity{
-		Lock:  new(sync.Mutex),
-		Array: []string{},
-	}
-}
-
 //获取数据
-func (fde *filterDataEntity) Start(openid string) {
-	fde.Lock.Lock()
+func (fd *FilterData) Start(openid string) {
 	if openid == "" {
 		return
 	}
-	fde.OpenId = openid
+	fd.OpenId = openid
 	data := redis.Get("push", "push_"+openid)
 	if data == nil {
 		return
@@ -43,33 +31,27 @@ func (fde *filterDataEntity) Start(openid string) {
 		log.Println("byte数组转成string数组出错!")
 		return
 	}
-	fde.Array = array
+	fd.Array = array
 }
 
 //判断数据是否存在
-func (fde *filterDataEntity) IsExists(_id string) bool {
+func (fd *FilterData) IsExists(_id string) bool {
 	if _id == "" {
 		return false
 	}
-	for _, v := range fde.Array {
+	for _, v := range fd.Array {
 		if _id == v {
 			return true
 		}
 	}
-	fde.Array = append(fde.Array, _id)
+	fd.Array = append(fd.Array, _id)
 	return false
 }
 
 //添加数据
-func (fde *filterDataEntity) End() {
-	if fde.OpenId != "" {
-		if len(fde.Array) > 0 {
-			redis.Put("push", "push_"+fde.OpenId, fde.Array, -1)
-		} else {
-			redis.Del("push", "push_"+fde.OpenId)
-		}
+func (fd *FilterData) End() {
+	if fd.OpenId == "" || len(fd.Array) == 0 {
+		return
 	}
-	fde.Array = []string{}
-	fde.OpenId = ""
-	fde.Lock.Unlock()
+	redis.Put("push", "push_"+fd.OpenId, fd.Array, -1)
 }

+ 12 - 26
src/jfw/modules/pushent/src/filterdata/filterdata.go

@@ -6,26 +6,18 @@ import (
 	"qfw/util/redis"
 )
 
-var FilterData *filterDataEntity
-
-type filterDataEntity struct {
+type FilterData struct {
 	Array  []string
 	OpenId string
 }
 
-func init() {
-	FilterData = &filterDataEntity{
-		Array: []string{},
-	}
-}
-
 //获取数据
-func (fde *filterDataEntity) Start(openid string) {
+func (fd *FilterData) Start(openid string) {
 	if openid == "" {
 		return
 	}
-	fde.OpenId = openid
-	data := redis.Get("push", "push_ent_"+openid)
+	fd.OpenId = openid
+	data := redis.Get("push", "push_"+openid)
 	if data == nil {
 		return
 	}
@@ -39,33 +31,27 @@ func (fde *filterDataEntity) Start(openid string) {
 		log.Println("byte数组转成string数组出错!")
 		return
 	}
-	fde.Array = array
+	fd.Array = array
 }
 
 //判断数据是否存在
-func (fde *filterDataEntity) IsExists(_id string) bool {
+func (fd *FilterData) IsExists(_id string) bool {
 	if _id == "" {
 		return false
 	}
-	for _, v := range fde.Array {
+	for _, v := range fd.Array {
 		if _id == v {
 			return true
 		}
 	}
-	//log.Println(fde.Array)
-	fde.Array = append(fde.Array, _id)
+	fd.Array = append(fd.Array, _id)
 	return false
 }
 
 //添加数据
-func (fde *filterDataEntity) End(flag int) {
-	if fde.OpenId != "" && flag == 0 {
-		if len(fde.Array) > 0 {
-			redis.Put("push", "push_ent_"+fde.OpenId, fde.Array, -1)
-		} else {
-			redis.Del("push", "push_ent_"+fde.OpenId)
-		}
+func (fd *FilterData) End() {
+	if fd.OpenId == "" || len(fd.Array) == 0 {
+		return
 	}
-	fde.Array = []string{}
-	fde.OpenId = ""
+	redis.Put("push", "push_"+fd.OpenId, fd.Array, -1)
 }

+ 7 - 8
src/jfw/modules/pushent/src/followpush/push.go

@@ -113,8 +113,9 @@ func FindData(fid interface{}, title, sname, openid, idrange string, bsave, bpus
 				} else {
 					Pushlock.Lock()
 					defer Pushlock.Unlock()
-					filterdata.FilterData.Start(openid)
-					defer filterdata.FilterData.End(0)
+					filterData := &filterdata.FilterData{}
+					filterData.Start(openid)
+					defer filterData.End()
 					//1.组织信息、
 					//a_relationinfo s_id s_title s_projectname  s_projectcode  l_publishtime s_url
 					var ids []string
@@ -131,7 +132,7 @@ func FindData(fid interface{}, title, sname, openid, idrange string, bsave, bpus
 						tmp["s_subtype"] = util.ObjToString(info["subtype"])
 						tmp["s_entname"] = util.ObjToString(info["winner"])
 						tmp["s_url"] = util.ObjToString(info["href"])
-						if filterdata.FilterData.IsExists(sid) {
+						if filterData.IsExists(sid) {
 							continue
 						}
 						ids = append(ids, sid)
@@ -161,14 +162,12 @@ func FindData(fid interface{}, title, sname, openid, idrange string, bsave, bpus
 									if rLength > 0 && rLength+pLength > KEEPCOUNT { //保留100条
 										start := rLength + pLength - KEEPCOUNT
 										var relationinfoTemp []interface{}
-										var pushArrayTemp []interface{}
-										for _, v := range *pushArray {
-											pushArrayTemp = append(pushArrayTemp, v)
-										}
 										if start < rLength {
 											relationinfoTemp = append(relationinfoTemp, relationinfo[start:]...)
 										}
-										relationinfoTemp = append(relationinfoTemp, pushArrayTemp...)
+										for _, v := range *pushArray {
+											relationinfoTemp = append(relationinfoTemp, v)
+										}
 										setMap["a_relationinfo"] = relationinfoTemp
 									} else { //追加
 										(*updateMap)["$pushAll"] = bson.M{"a_relationinfo": pushArray}

+ 4 - 3
src/jfw/modules/pushent/src/rpcpush/findData.go

@@ -20,9 +20,10 @@ func RpcFindFollow(entname, followid, thisid, openid string, flag int) *followpu
 		go func() {
 			followpush.Pushlock.Lock()
 			defer followpush.Pushlock.Unlock()
-			filterdata.FilterData.Start(openid)
-			defer filterdata.FilterData.End(0)
-			filterdata.FilterData.IsExists(thisid)
+			filterData := &filterdata.FilterData{}
+			filterData.Start(openid)
+			defer filterData.End()
+			filterData.IsExists(thisid)
 		}()
 	}
 	res := followpush.FindData(ff, thisid, entname, openid, "", bsave, false)

+ 11 - 25
src/jfw/modules/pushproject/src/filterdata/filterdata.go

@@ -6,25 +6,17 @@ import (
 	"qfw/util/redis"
 )
 
-var FilterData *filterDataEntity
-
-type filterDataEntity struct {
+type FilterData struct {
 	Array  []string
 	OpenId string
 }
 
-func init() {
-	FilterData = &filterDataEntity{
-		Array: []string{},
-	}
-}
-
 //获取数据
-func (fde *filterDataEntity) Start(openid string) {
+func (fd *FilterData) Start(openid string) {
 	if openid == "" {
 		return
 	}
-	fde.OpenId = openid
+	fd.OpenId = openid
 	data := redis.Get("push", "push_"+openid)
 	if data == nil {
 		return
@@ -39,33 +31,27 @@ func (fde *filterDataEntity) Start(openid string) {
 		log.Println("byte数组转成string数组出错!")
 		return
 	}
-	fde.Array = array
+	fd.Array = array
 }
 
 //判断数据是否存在
-func (fde *filterDataEntity) IsExists(_id string) bool {
+func (fd *FilterData) IsExists(_id string) bool {
 	if _id == "" {
 		return false
 	}
-	for _, v := range fde.Array {
+	for _, v := range fd.Array {
 		if _id == v {
 			return true
 		}
 	}
-	//log.Println(fde.Array)
-	fde.Array = append(fde.Array, _id)
+	fd.Array = append(fd.Array, _id)
 	return false
 }
 
 //添加数据
-func (fde *filterDataEntity) End(flag int) {
-	if fde.OpenId != "" && flag == 0 {
-		if len(fde.Array) > 0 {
-			redis.Put("push", "push_"+fde.OpenId, fde.Array, -1)
-		} else {
-			redis.Del("push", "push_"+fde.OpenId)
-		}
+func (fd *FilterData) End() {
+	if fd.OpenId == "" || len(fd.Array) == 0 {
+		return
 	}
-	fde.Array = []string{}
-	fde.OpenId = ""
+	redis.Put("push", "push_"+fd.OpenId, fd.Array, -1)
 }

+ 7 - 8
src/jfw/modules/pushproject/src/followpush/push.go

@@ -118,8 +118,9 @@ func FindData(fid interface{}, title, sname, scode, openid, idrange string, bsav
 				} else {
 					Pushlock.Lock()
 					defer Pushlock.Unlock()
-					filterdata.FilterData.Start(openid)
-					defer filterdata.FilterData.End(0)
+					filterData := &filterdata.FilterData{}
+					filterData.Start(openid)
+					defer filterData.End()
 					//1.组织信息、
 					//a_relationinfo s_id s_title s_projectname  s_projectcode  l_publishtime s_url
 					var ids []string
@@ -140,7 +141,7 @@ func FindData(fid interface{}, title, sname, scode, openid, idrange string, bsav
 						tmp["s_projectname"] = util.ObjToString(info["projectname"])
 						tmp["s_projectcode"] = util.ObjToString(info["projectcode"])
 						tmp["s_url"] = util.ObjToString(info["href"])
-						if filterdata.FilterData.IsExists(sid) {
+						if filterData.IsExists(sid) {
 							continue
 						}
 						ids = append(ids, sid)
@@ -173,10 +174,6 @@ func FindData(fid interface{}, title, sname, scode, openid, idrange string, bsav
 										firstInfo, _ := relationinfo[0].(map[string]interface{})
 										firstInfoId, _ := firstInfo["s_id"].(string)
 										var relationinfoTemp []interface{}
-										var pushArrayTemp []interface{}
-										for _, v := range *pushArray {
-											pushArrayTemp = append(pushArrayTemp, v)
-										}
 										//保留本身
 										if s_id == firstInfoId && !bpush {
 											relationinfoTemp = relationinfo[:1]
@@ -188,7 +185,9 @@ func FindData(fid interface{}, title, sname, scode, openid, idrange string, bsav
 												relationinfoTemp = append(relationinfoTemp, relationinfo[start:]...)
 											}
 										}
-										relationinfoTemp = append(relationinfoTemp, pushArrayTemp...)
+										for _, v := range *pushArray {
+											relationinfoTemp = append(relationinfoTemp, v)
+										}
 										setMap["a_relationinfo"] = relationinfoTemp
 									} else { //追加
 										(*updateMap)["$pushAll"] = bson.M{"a_relationinfo": pushArray}

+ 4 - 3
src/jfw/modules/pushproject/src/rpcpush/findData.go

@@ -20,9 +20,10 @@ func RpcFindFollow(projectname, projectcode, followid, thisid, openid string, fl
 		go func() {
 			followpush.Pushlock.Lock()
 			defer followpush.Pushlock.Unlock()
-			filterdata.FilterData.Start(openid)
-			defer filterdata.FilterData.End(0)
-			filterdata.FilterData.IsExists(thisid)
+			filterData := &filterdata.FilterData{}
+			filterData.Start(openid)
+			defer filterData.End()
+			filterData.IsExists(thisid)
 		}()
 	}
 	res := followpush.FindData(ff, thisid, projectname, projectcode, openid, "", bsave, false)

+ 13 - 2
src/web/staticres/css/baidu-ground.css

@@ -9,7 +9,7 @@
 
 #container .header .textCopy {
   position: absolute;
-  top: 5.7rem;
+  top: 5.4rem;
   left: 50%;
   margin-left: -2rem;
   width: 4.05rem;
@@ -40,7 +40,7 @@
 #container .header .ewm {
   position: absolute;
   left: 50%;
-  bottom: .23rem;
+  bottom: .13rem;
   margin-left: -2rem;
 }
 
@@ -90,3 +90,14 @@
   background-color: rgba(0, 0, 0, 0.4);
   border-radius: .1rem;
 }
+.ftext{
+	position:absolute;
+	left: 31%;
+    top: 60.3%;
+}
+.ftext a{
+	color:#fff111;
+	font-size:.3rem;
+	font-weight: bold;
+	text-decoration: underline !important;
+}

二进制
src/web/staticres/images/baidu/bd-content.jpg


二进制
src/web/staticres/images/baidu/bd-header.jpg


二进制
src/web/staticres/images/baidu/bd-header1.jpg


二进制
src/web/staticres/images/baidu/bg-copy-bg.png


+ 2 - 2
src/web/staticres/js/baidu-tengxun-ground.js

@@ -1,8 +1,8 @@
 $(function() {
 
 	//复制粘贴
-	$('.textCopy .fz').on('click', function() {  
-		copy($(this).next('font'));
+	$('.textCopy').on('click', function() {  
+		copy($(this).find('.text'));
 	});
 
 	//弹出框

+ 1 - 1
src/web/staticres/js/superSearch.js

@@ -539,7 +539,7 @@ function getInputTime(){
 //---取VIP数据---
 function getVIPData(){
 	var tlflag = false;
-	if($("#zbSeatchT [name='keywords']").val()==""&&$("#zbSeatchT [name='searchvalue']").val()==""){
+	if($("#zbSeatchT [name='keywords']").val()==""&&$("#zbSeatchT [name='searchvalue']").val()==""&&$("#zbSeatchT [name='industry']").val()==""){
 		return true;
 	}
 	var tabflag = false;

+ 8 - 7
src/web/staticres/js/wxEntsesearch.js

@@ -375,10 +375,9 @@ var EntSearch = {
             EntSearch.noDataCache = false;
             EntSearch.hasNoData();
 		}else if(sessionStorage.entSearch_listCache) {
-            EntSearch.reqParam.pageNum = sessionStorage.entsearch_pageNumCache;
             EntSearch.noMoreCache = sessionStorage.entSearch_noMoreCache;
             EntSearch.appendListHtml(sessionStorage.entSearch_listCache);
-            EntSearch.initDropload(EntSearch.noMoreCache!="true");
+            EntSearch.initDropload(EntSearch.noMoreCache!="true",sessionStorage.entSearch_pageNumCache);
             var moneyFromCache = sessionStorage.entSearch_moneyFromCache;
             var moneyToCache = sessionStorage.entSearch_moneyToCache;
             $("#entsearchPage #money_from").val(moneyFromCache);
@@ -434,14 +433,14 @@ var EntSearch = {
 		sessionStorage.removeItem("entSearch_moneyToCache");
 		sessionStorage.removeItem("entSearch_noMoreCache");
 		sessionStorage.removeItem("entSearch_noDataCache");
-		sessionStorage.removeItem("entsearch_pageNumCache");
+		sessionStorage.removeItem("entSearch_pageNumCache");
 		sessionStorage.removeItem("entSearch_scopeCache");
 		sessionStorage.removeItem("entSearch_scrollTop");
 		sessionStorage.removeItem("searchpageName");
 	},
-	initDropload: function (hasNextPage){
+	initDropload: function (hasNextPage,pgNum){
         //上拉分页
-		EntSearch.reqParam["pageNum"] = 2;
+		EntSearch.reqParam["pageNum"] = parseInt(pgNum);
         EntSearch.dropload = $('#entsearchPage #wrapper').dropload({
             scrollArea: window,
             loadDownFn: function (me) {
@@ -470,7 +469,9 @@ var EntSearch = {
 							EntSearch.noMoreData();
 							return;
                         }
-                        me.resetload();
+						setTimeout(function(){
+	                        me.resetload();
+						},100);
 						EntSearch.reqParam["pageNum"]++;
                     },
                     error: function (xhr, type) {
@@ -675,7 +676,7 @@ var EntSearch = {
 				        EntSearch.noDataCache = false;
 	                    EntSearch.appendListHtml(html);
 	                    EntSearch.shaixuanHide();
-						EntSearch.initDropload(r.hasNextPage);
+						EntSearch.initDropload(r.hasNextPage,2);
 	                }else{
 	                    EntSearch.hasNoData();
 					}

+ 24 - 18
src/web/staticres/js/wxSupersearch.js

@@ -55,13 +55,13 @@ var SuperSearch = {
 		}
 		this.initFlag = true;
 		//localsession存储标题/全文搜索 和 列表/表格展示
-		if(localStorage){
-			if(localStorage.selectType=="allSearch"){
-				$("#supersearchPage #search_all").addClass("on").siblings().removeClass("on");
-			}else if(localStorage.selectType=="titleSearch"){
+		//if(localStorage){
+		//	if(localStorage.selectType=="allSearch"){
+		//		$("#supersearchPage #search_all").addClass("on").siblings().removeClass("on");
+		//	}else if(localStorage.selectType=="titleSearch"){
 				$("#supersearchPage #search_title").addClass("on").siblings().removeClass("on");
-			}
-		}
+		//	}
+		//}
 		//筛选菜单展示or隐藏
 		$("#supersearchPage .wxhead").find(".screen").click(function(){
 			if(SuperSearch.requesting){
@@ -109,12 +109,12 @@ var SuperSearch = {
 		});
 		//提交查询
 		$("#supersearchPage .query").click(function(){
-			SuperSearch.formSubmit();
+			SuperSearch.formSubmit("N");
 		});
 		$("#supersearchPage .jyshxbottom .jydqsure").click(function(){
 			$("#supersearchPage .point").addClass("hidden");
 			if($(this).hasClass("on")){
-				SuperSearch.formSubmit();
+				SuperSearch.formSubmit("N");
 			}
 		});
 		//清除筛选
@@ -528,8 +528,8 @@ var SuperSearch = {
 		SuperSearch.setSessionStorage();
 		window.location.href="/jylab/laboratory/cjss?v=superSearch";
 	},
-	initDropload: function(hasNextPage){
-		SuperSearch.reqParam["pageNum"] = 2;
+	initDropload: function(hasNextPage,pgNum){
+		SuperSearch.reqParam["pageNum"] = parseInt(pgNum);
 		SuperSearch.dropload = $('#supersearchPage #wrapper').dropload({
 			scrollArea: window,
 			loadDownFn: function(me){
@@ -559,7 +559,7 @@ var SuperSearch = {
 							SuperSearch.noMoreData();
 							return;
 						}
-						me.resetload();
+	                    me.resetload();
 						SuperSearch.reqParam["pageNum"]++;//翻页请求
 					},
 					error: function(xhr, type){
@@ -577,6 +577,7 @@ var SuperSearch = {
 		if(!sessionStorage){
 			return;
         }
+		sessionStorage.removeItem("superSearch_noMoreCache");
 		sessionStorage.removeItem("superSearch_listContent");
 		sessionStorage.removeItem("superSearch_tableContent");
 		sessionStorage.removeItem("superSearch_subtype");
@@ -769,7 +770,7 @@ var SuperSearch = {
 			}
 		}
 	},
-	formSubmit: function (){    //提交表单,获取数据
+	formSubmit: function (nw){    //提交表单,获取数据
 		if(!SuperSearch.beforeSubmit()){
 			return;
 		}
@@ -781,6 +782,10 @@ var SuperSearch = {
 		SuperSearch.reqParam.pageNum=1;
 		SuperSearch.noMoreCache = false;
 		SuperSearch.requesting = true;
+		if(nw=="N"){
+			SuperSearch.reqParam.selectType ="title";
+			$("#supersearchPage #search_title").addClass("on").siblings().removeClass("on");
+		}
 		$.ajax({
 			type: "post",
 			url: "/swordfish/searchlist/paging",
@@ -805,7 +810,7 @@ var SuperSearch = {
 					SuperSearch.replayListHtml(SuperSearch.getHtml(data["list"],1));
 					SuperSearch.show();
 					$(window).scrollTop(0);
-					SuperSearch.initDropload(data.hasNextPage);
+					SuperSearch.initDropload(data.hasNextPage,2);
 				}
 			},
 			error: function(xhr,type){
@@ -1172,7 +1177,7 @@ var SuperSearch = {
 		$("#supersearchPage .inputDiv li").unbind("click").click(function () {
 			$("#supersearchPage input[name=super_searchinput]").val($(this).text());
 			SuperSearch.canSearch();
-			SuperSearch.formSubmit();				 //查询
+			SuperSearch.formSubmit("N");				 //查询
 		});
 	},
 	//全文搜索
@@ -1180,7 +1185,7 @@ var SuperSearch = {
 	    $("#supersearchPage #search_all").addClass("on").siblings().removeClass("on");
 	    //记录
 	    if(localStorage){
-	        localStorage.selectType="allSearch";
+	        //localStorage.selectType="allSearch";
 	    }
 	    //将所选标签值作为参数传递
 	    SuperSearch.formSubmit();
@@ -1190,7 +1195,7 @@ var SuperSearch = {
 	    $("#supersearchPage #search_title").addClass("on").siblings().removeClass("on");
 	    //记录
 	    if(localStorage){
-	        localStorage.selectType="titleSearch";
+	       // localStorage.selectType="titleSearch";
 	    }
 	    //将所选标签值作为参数传递
 	    SuperSearch.formSubmit();
@@ -1225,6 +1230,7 @@ var SuperSearch = {
 	},
 	setSessionStorage: function (){
 	    if(sessionStorage){
+			sessionStorage.superSearch_noMoreCache = SuperSearch.noMoreCache;
 	        sessionStorage.superSearch_listContent=$("#supersearchPage #list").html();
 	        sessionStorage.superSearch_tableContent=$("#supersearchPage #table .data .content").html();
 	        sessionStorage.superSearch_subtype=SuperSearch.reqParam.subtype;
@@ -1261,6 +1267,7 @@ var SuperSearch = {
 	    if(sessionStorage.superSearch_listContent==""){
 			SuperSearch.hasNoData();
 	    }else{
+			SuperSearch.noMoreCache = sessionStorage.superSearch_noMoreCache;
 			SuperSearch.showNull = false;
 			var ListContent=$(sessionStorage.superSearch_listContent);
 			ListContent.on("click", function(event){
@@ -1271,7 +1278,7 @@ var SuperSearch = {
 			    SuperSearch.myredirect(h,sid,sds,industry);
 			});
 			$("#supersearchPage #list").html(ListContent);
-		
+			SuperSearch.initDropload(SuperSearch.noMoreCache!="true",sessionStorage.superSearch_pageNum);
 			var TableContent=$(sessionStorage.superSearch_tableContent);
 			TableContent.on("click",function(event){
 			    var h =  $(this).attr("s");
@@ -1383,7 +1390,6 @@ var SuperSearch = {
 	    }else{
 			$("#supersearchPage .money-dialog .btn").addClass("active");
 		}
-	    SuperSearch.reqParam.pageNum=sessionStorage.superSearch_pageNum;
 		var shaxuanclass = sessionStorage.superSearch_shaxuan;
 		if(shaxuanclass){
 			$("#supersearchPage #selLable").addClass("hidden");

+ 1 - 0
src/web/templates/active/ext-baidu.html

@@ -19,6 +19,7 @@
 			<font class="fz"><img src="/images/baidu/bd-fz.png"/></font>
 			<font class="text">剑鱼招标订阅</font>
 		</div>
+		<div class="ftext"><a href="weixin://">复制后 , 点此进入微信</a></div>
 		<div class="ewm">
 			<img src="/images/baidu/bd-hedaer-ew.png"/>
 		</div>

+ 5 - 2
src/web/templates/pc/biddetail.html

@@ -283,7 +283,7 @@ if(refer.indexOf("NJ")>0){
 			<div class="preb-enno"><img src="/images/wx/enclosure.png"/>附件(1个)</div>
 		</div>
 		{{end}}
-		<div class="pdf-div"></div>
+		<div class="pdf-div hidden"></div>
 		<div class="original-text">
 			<a href="{{.T.obj.url}}" target="_blank" class="com-original hidden">
 				<img src="/images/pc_15.png">查看原文
@@ -498,7 +498,6 @@ $(function(){
 			}else{
 				arr["url"]="/fs"+arr["url"].substring(arr["url"].lastIndexOf("/"));
 			}
-			$(".preb-enclosure").removeClass("hidden");
 			var pdfshow = '<div class="approve">'+arr["filename"]+'</div><div id="preb-pdf'+j+'"></div>';
 			$(".pdf-div").html(pdfshow);
 			var pdfhtml = "";
@@ -511,6 +510,10 @@ $(function(){
 	
 	//
 	{{end}}
+	if({{.T.obj.subtype}}=="拟建"||{{.T.obj.toptype}}=="拟建"){
+		$(".preb-enclosure").removeClass("hidden");
+		$(".pdf-div").removeClass("hidden");
+	}
 	//
 	{{if .T.obj.infoformat}}
 	{{if eq .T.obj.infoformat 2}}

+ 1 - 1
src/web/templates/weixin/search/mainSearch.html

@@ -527,7 +527,7 @@
             window.event.returnValue = false;
 			//超级搜索
 			if(SuperSearch.isMyPage){
-				SuperSearch.formSubmit();
+				SuperSearch.formSubmit("N");
 			}else if(EntSearch.isMyPage){//企业搜索
 	            EntSearch.formSubmit();
 			}

+ 12 - 4
src/web/templates/weixin/wxinfocontent.html

@@ -374,6 +374,9 @@ pre {
 .adv-wxcontent-bottom  img{
 	width:100%;
 }
+.pre-dow{
+	margin-bottom:10px;
+}
 </style>
 </head>
 <body>
@@ -401,7 +404,6 @@ pre {
 					type = "";
 				}
 			}
-			
 			if(type != ""){
 				document.write("<span class='type'>"+type+"</span>");
 			}
@@ -517,7 +519,7 @@ pre {
 	<pre id="h_content">{{.T.obj.detail}}</pre>
 	{{if .T.obj.projectinfo.attachments}}
 		<div class="pre-enclosure hidden"><img src="/images/wx/enclosure.png"/>附件(1个)</div>
-		<div class="pre-dow">
+		<div class="pre-dow hidden">
 		
 		</div>
 	{{end}}
@@ -895,6 +897,7 @@ $(function(){
 	//	}
 	//})-->
 	//
+	
 	{{if .T.obj.projectinfo.attachments}}
 	var attachments = {{.T.obj.projectinfo.attachments}}
 	var j = 0;
@@ -905,7 +908,6 @@ $(function(){
 		arr = attachments[m]
 		//for(var i in arr){
 			if(arr["filename"]&&arr["filename"].slice(-3).toLowerCase()=="pdf"){
-				$(".pre-enclosure").removeClass("hidden");
 				var pdfhtml = "";
 				if(j == lh){
 					pdfhtml = '<div class="pre-encont" style="border-bottom:0px;">'
@@ -921,6 +923,10 @@ $(function(){
 		//}
 		$(".pre-dow").append(pdfhtml);
 	}
+	if({{.T.obj.subtype}}=="拟建"||{{.T.obj.toptype}}=="拟建"){
+		$(".pre-enclosure").removeClass("hidden");
+		$(".pre-dow").removeClass("hidden");
+	}
 	$(".pre-enclosure").html('<img src="/images/wx/enclosure.png"/>附件('+j+'个)');
 	$(".filename").css("width",$(window).width()*0.68+"px");
 	{{end}}
@@ -1010,7 +1016,9 @@ $(function(){
     if(winner_con != "" && content.toLowerCase().indexOf(winner_con.toLowerCase()) > -1){
         content = keyWordHighlight(content,winner_con,"<span class='keyword myfollowent'>$1</span>");
     }
-
+	if(content.length>10&&content.substring(0,6).toLowerCase() =="<tbody"&&content.substring(content.length-8).toLowerCase()=="</tbody>"){
+		content ='<table>'+content+'</table>'
+	}
 	var wordsArray = new Array();
 	s_words=decodeURIComponent(getParameter("keywords"))
 	if(s_words.indexOf('_')>0){