xuzhiheng 1 yıl önce
ebeveyn
işleme
503c9e19b5
3 değiştirilmiş dosya ile 152 ekleme ve 150 silme
  1. 114 113
      CMPlatform/service/private_service.go
  2. 30 31
      CMPlatform/util/utiltag.go
  3. 8 6
      customerdata/task.go

+ 114 - 113
CMPlatform/service/private_service.go

@@ -1,16 +1,9 @@
 package service
 
 import (
-	"app.yhyue.com/moapp/jybase/common"
-	"app.yhyue.com/moapp/jybase/encrypt"
-	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
-	"app.yhyue.com/moapp/jybase/log"
-	"app.yhyue.com/moapp/jybase/mail"
 	"cmplatform/util"
 	"encoding/json"
 	"fmt"
-	"go.mongodb.org/mongo-driver/bson"
-	"go.uber.org/zap"
 	"io"
 	"net/http"
 	"regexp"
@@ -18,6 +11,14 @@ import (
 	"strings"
 	"time"
 	"unicode/utf8"
+
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
+	"app.yhyue.com/moapp/jybase/log"
+	"app.yhyue.com/moapp/jybase/mail"
+	"go.mongodb.org/mongo-driver/bson"
+	"go.uber.org/zap"
 )
 
 var (
@@ -36,127 +37,127 @@ type Private struct {
 
 func (f *Private) Keydatademo(world string) {
 	tmp := make(map[string]interface{})
-	destr := encrypt.SE.DecodeString(world)
+	// destr := encrypt.SE.DecodeString(world)
 	typeStr := f.GetString("type")
 
-	log.Debug(destr)
-	if len(destr) > 10 {
-		// ctime := destr[:10]
-		// ctimeint := common.Int64All(ctime)
-		// if time.Now().Sub(time.Unix(ctimeint, 0)).Hours()/24 < Subday {
-		var tagfield *map[string]interface{}
-		if typeStr == "private" {
-			tagfield, _ = util.Mgo.FindOneByField("cuserdepartrule", bson.M{"s_dataid": world}, bson.M{"i_extfieldstype": 1, "i_estotal": 1, "s_userid": 1})
-			customer, _ := util.Mgo.FindById("cuser", common.ObjToString((*tagfield)["s_userid"]), bson.M{"s_name": 1})
-			(*tagfield)["s_customer"] = (*customer)["s_name"]
+	// log.Debug(destr)
+	// if len(destr) > 10 {
+	// ctime := destr[:10]
+	// ctimeint := common.Int64All(ctime)
+	// if time.Now().Sub(time.Unix(ctimeint, 0)).Hours()/24 < Subday {
+	var tagfield *map[string]interface{}
+	if typeStr == "private" {
+		tagfield, _ = util.Mgo.FindOneByField("cuserdepartrule", bson.M{"s_dataid": world}, bson.M{"i_extfieldstype": 1, "i_estotal": 1, "s_userid": 1})
+		customer, _ := util.Mgo.FindById("cuser", common.ObjToString((*tagfield)["s_userid"]), bson.M{"s_name": 1})
+		(*tagfield)["s_customer"] = (*customer)["s_name"]
+	} else {
+		tagfield, _ = util.Mgo.FindOneByField("tags_common", bson.M{"s_dataid": world}, bson.M{"i_extfieldstype": 1, "i_estotal": 1, "s_customer": 1})
+	}
+	if (*tagfield) != nil && len(*tagfield) > 0 {
+		if common.Int64All((*tagfield)["i_extfieldstype"]) == util.Standard {
+			tmp["fieldtype"] = util.Standardstr
+		} else if common.Int64All((*tagfield)["i_extfieldstype"]) == util.Advanced {
+			tmp["fieldtype"] = util.Advancedstr
 		} else {
-			tagfield, _ = util.Mgo.FindOneByField("tags_common", bson.M{"s_dataid": world}, bson.M{"i_extfieldstype": 1, "i_estotal": 1, "s_customer": 1})
+			f.ServeJson(map[string]string{
+				"err": "参数失效",
+			})
+			return
 		}
-		if (*tagfield) != nil && len(*tagfield) > 0 {
-			if common.Int64All((*tagfield)["i_extfieldstype"]) == util.Standard {
-				tmp["fieldtype"] = util.Standardstr
-			} else if common.Int64All((*tagfield)["i_extfieldstype"]) == util.Advanced {
-				tmp["fieldtype"] = util.Advancedstr
-			} else {
-				f.ServeJson(map[string]string{
-					"err": "参数失效",
-				})
-				return
-			}
-			tmp["total"] = common.Int64All((*tagfield)["i_estotal"])
-			tmp["customername"] = common.ObjToString((*tagfield)["s_customer"])
-			datas, _ := util.Mgo.Find("tagsdata", bson.M{"s_dataid": world, "esIndex": util.TotalIndex}, `{"publishtime":-1}`, nil, false, -1, -1)
-			if (*datas) != nil && len(*datas) > 0 {
-				matchskey := make(map[string]bool)
-				matchsprovince := make(map[string]bool)
-				matchscity := make(map[string]bool)
-				rdata := make([]map[string]interface{}, 0)
-				for _, v := range *datas {
-					for _, mv := range strings.Split(common.ObjToString(v["s_matchkey"]), ",") {
-						matchskey[mv] = true
-					}
-					if v["area"] != nil {
-						matchsprovince[common.ObjToString(v["area"])] = true
-					}
-					if v["city"] != nil {
-						matchscity[common.ObjToString(v["city"])] = true
-					}
-					delete(v, "_id")
-					delete(v, "s_dataid")
-					delete(v, "i_createtime")
+		tmp["total"] = common.Int64All((*tagfield)["i_estotal"])
+		tmp["customername"] = common.ObjToString((*tagfield)["s_customer"])
+		datas, _ := util.Mgo.Find("tagsdata", bson.M{"s_dataid": world, "esIndex": util.TotalIndex}, `{"publishtime":-1}`, nil, false, -1, -1)
+		if (*datas) != nil && len(*datas) > 0 {
+			matchskey := make(map[string]bool)
+			matchsprovince := make(map[string]bool)
+			matchscity := make(map[string]bool)
+			rdata := make([]map[string]interface{}, 0)
+			for _, v := range *datas {
+				for _, mv := range strings.Split(common.ObjToString(v["s_matchkey"]), ",") {
+					matchskey[mv] = true
+				}
+				if v["area"] != nil {
+					matchsprovince[common.ObjToString(v["area"])] = true
+				}
+				if v["city"] != nil {
+					matchscity[common.ObjToString(v["city"])] = true
+				}
+				delete(v, "_id")
+				delete(v, "s_dataid")
+				delete(v, "i_createtime")
 
-					if v["bidamount"] != nil {
-						v["bidamount"] = common.Float64All(fmt.Sprintf("%f", common.Float64All(v["bidamount"])/10000))
-					}
-					if v["budget"] != nil {
-						v["budget"] = common.Float64All(fmt.Sprintf("%f", common.Float64All(v["budget"])/10000))
-					}
-					if v["publishtime"] != nil {
-						v["publishtime"] = time.Unix(common.Int64All(v["publishtime"]), 0).Format("2006-01-02")
-					}
-					if v["bidopentime"] != nil {
-						v["bidopentime"] = time.Unix(common.Int64All(v["bidopentime"]), 0).Format("2006-01-02")
-					}
-					if utf8.RuneCountInString(common.ObjToString(v["title"])) > 60 {
-						title := string([]rune(common.ObjToString(v["title"]))[:60])
-						v["title"] = title + "..."
-					}
-					if utf8.RuneCountInString(common.ObjToString(v["detail"])) > 150 {
-						detail := string([]rune(common.ObjToString(v["detail"]))[:150])
-						v["detail"] = detail + "..."
+				if v["bidamount"] != nil {
+					v["bidamount"] = common.Float64All(fmt.Sprintf("%f", common.Float64All(v["bidamount"])/10000))
+				}
+				if v["budget"] != nil {
+					v["budget"] = common.Float64All(fmt.Sprintf("%f", common.Float64All(v["budget"])/10000))
+				}
+				if v["publishtime"] != nil {
+					v["publishtime"] = time.Unix(common.Int64All(v["publishtime"]), 0).Format("2006-01-02")
+				}
+				if v["bidopentime"] != nil {
+					v["bidopentime"] = time.Unix(common.Int64All(v["bidopentime"]), 0).Format("2006-01-02")
+				}
+				if utf8.RuneCountInString(common.ObjToString(v["title"])) > 60 {
+					title := string([]rune(common.ObjToString(v["title"]))[:60])
+					v["title"] = title + "..."
+				}
+				if utf8.RuneCountInString(common.ObjToString(v["detail"])) > 150 {
+					detail := string([]rune(common.ObjToString(v["detail"]))[:150])
+					v["detail"] = detail + "..."
+				}
+				if common.Int64All((*tagfield)["i_extfieldstype"]) == util.Advanced {
+					legal_person := strings.TrimSpace(common.ObjToString(v["legal_person"]))
+					if utf8.RuneCountInString(legal_person) > 1 {
+						legal_person := []rune(legal_person)
+						v["legal_person"] = string(legal_person[:1]) + "**"
 					}
-					if common.Int64All((*tagfield)["i_extfieldstype"]) == util.Advanced {
-						legal_person := strings.TrimSpace(common.ObjToString(v["legal_person"]))
-						if utf8.RuneCountInString(legal_person) > 1 {
-							legal_person := []rune(legal_person)
-							v["legal_person"] = string(legal_person[:1]) + "**"
-						}
 
-						cemail := strings.TrimSpace(common.ObjToString(v["company_email"]))
-						if emailreg.MatchString(cemail) {
-							v["company_email"] = "********" + cemail[strings.Index(cemail, "@"):]
-						} else {
-							v["company_email"] = ""
-						}
-						company_phone := strings.TrimSpace(common.ObjToString(v["company_phone"]))
-						if telreg.MatchString(company_phone) || phonereg.MatchString(company_phone) {
-							company_phone = company_phone[:len(company_phone)-5] + "****"
-							v["company_phone"] = company_phone
-						} else {
-							v["company_phone"] = ""
-						}
+					cemail := strings.TrimSpace(common.ObjToString(v["company_email"]))
+					if emailreg.MatchString(cemail) {
+						v["company_email"] = "********" + cemail[strings.Index(cemail, "@"):]
+					} else {
+						v["company_email"] = ""
 					}
-					deletefields(common.IntAll((*tagfield)["i_extfieldstype"]), &v)
-					rdata = append(rdata, v)
-				}
-				tmp["keylist"] = []string{}
-				for k := range matchskey {
-					if k == "" {
-						continue
+					company_phone := strings.TrimSpace(common.ObjToString(v["company_phone"]))
+					if telreg.MatchString(company_phone) || phonereg.MatchString(company_phone) {
+						company_phone = company_phone[:len(company_phone)-5] + "****"
+						v["company_phone"] = company_phone
+					} else {
+						v["company_phone"] = ""
 					}
-					tmp["keylist"] = append(tmp["keylist"].([]string), k)
 				}
-				tmp["provincelist"] = []string{}
-				for k := range matchsprovince {
-					if k == "" {
-						continue
-					}
-					tmp["provincelist"] = append(tmp["provincelist"].([]string), k)
+				deletefields(common.IntAll((*tagfield)["i_extfieldstype"]), &v)
+				rdata = append(rdata, v)
+			}
+			tmp["keylist"] = []string{}
+			for k := range matchskey {
+				if k == "" {
+					continue
 				}
-				tmp["citylist"] = []string{}
-				for k := range matchscity {
-					if k == "" {
-						continue
-					}
-					tmp["citylist"] = append(tmp["citylist"].([]string), k)
+				tmp["keylist"] = append(tmp["keylist"].([]string), k)
+			}
+			tmp["provincelist"] = []string{}
+			for k := range matchsprovince {
+				if k == "" {
+					continue
 				}
-				tmp["data"] = rdata
-				f.ServeJson(tmp)
-				return
+				tmp["provincelist"] = append(tmp["provincelist"].([]string), k)
+			}
+			tmp["citylist"] = []string{}
+			for k := range matchscity {
+				if k == "" {
+					continue
+				}
+				tmp["citylist"] = append(tmp["citylist"].([]string), k)
 			}
+			tmp["data"] = rdata
+			f.ServeJson(tmp)
+			return
 		}
-		// }
 	}
+	// }
+	// }
 	f.ServeJson(map[string]string{
 		"err": "参数失效",
 	})

+ 30 - 31
CMPlatform/util/utiltag.go

@@ -15,7 +15,6 @@ import (
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/encrypt"
 	elastic "app.yhyue.com/moapp/jybase/es"
-	"app.yhyue.com/moapp/jybase/redis"
 	"go.mongodb.org/mongo-driver/bson"
 )
 
@@ -137,7 +136,7 @@ func searchDataArr(index, esquery, sdataid, userId string, i_maxnum int64, tags
 		err    error
 		counts = int64(0)
 		// times  = 0
-		times2 = 0
+		// times2 = 0
 	)
 	// for {
 	// 	listLen := redis.GetInt("session", "es_status")
@@ -153,35 +152,35 @@ func searchDataArr(index, esquery, sdataid, userId string, i_maxnum int64, tags
 	// 	times += 2
 	// 	time.Sleep(2 * time.Second)
 	// }
-	for {
-		listLens := int(redis.LLEN("datag", "jyqyfw_es_query"))
-		if listLens < 2 {
-			// if isExists, _ := redis.Exists("datag", "jyqyfw_es_query_times_"+userId); isExists {
-			// 	qt := redis.GetInt("datag", "jyqyfw_es_query_times_"+userId)
-			// 	if qt > 2 {
-			// 		log.Println("单个账号一分钟内超过3次 ", qt)
-			// 		err = errors.New("系统繁忙,请稍后再试")
-			// 		break
-			// 	} else {
-			// 		redis.Incr("datag", "jyqyfw_es_query_times_"+userId)
-			// 	}
-			// } else {
-			// 	redis.Put("datag", "jyqyfw_es_query_times_"+userId, 1, 60)
-			// }
-			log.Println("es空闲,当前进程数 ", listLens)
-			redis.RPUSH("datag", "jyqyfw_es_query", 1)
-			err, counts = searchData(index, esquery, sdataid, i_maxnum, tags, maths)
-			redis.LPOP("datag", "jyqyfw_es_query")
-			break
-		} else if times2 > 10 {
-			err = errors.New("系统繁忙,请稍后再试")
-			break
-		} else {
-			log.Println("企业级服务es进程数过多,", listLens)
-		}
-		times2 += 2
-		time.Sleep(2 * time.Second)
-	}
+	// for {
+	// listLens := int(redis.LLEN("datag", "jyqyfw_es_query"))
+	// if listLens < 2 {
+	// if isExists, _ := redis.Exists("datag", "jyqyfw_es_query_times_"+userId); isExists {
+	// 	qt := redis.GetInt("datag", "jyqyfw_es_query_times_"+userId)
+	// 	if qt > 2 {
+	// 		log.Println("单个账号一分钟内超过3次 ", qt)
+	// 		err = errors.New("系统繁忙,请稍后再试")
+	// 		break
+	// 	} else {
+	// 		redis.Incr("datag", "jyqyfw_es_query_times_"+userId)
+	// 	}
+	// } else {
+	// 	redis.Put("datag", "jyqyfw_es_query_times_"+userId, 1, 60)
+	// }
+	// log.Println("es空闲,当前进程数 ", listLens)
+	// redis.RPUSH("datag", "jyqyfw_es_query", 1)
+	err, counts = searchData(index, esquery, sdataid, i_maxnum, tags, maths)
+	// redis.LPOP("datag", "jyqyfw_es_query")
+	// break
+	// } else if times2 > 10 {
+	// err = errors.New("系统繁忙,请稍后再试")
+	// break
+	// } else {
+	// log.Println("企业级服务es进程数过多,", listLens)
+	// }
+	// times2 += 2
+	// time.Sleep(2 * time.Second)
+	// }
 	return err, counts
 }
 

+ 8 - 6
customerdata/task.go

@@ -326,12 +326,14 @@ func (c *Customer) EsConGetDataV7(stype string, esCon *esv.EsV7) {
 									continue
 								}
 							}
-							isExists, err := redis.Exists("datag", c.AppId+"_"+id)
-							if err != nil {
-								log.Println("redis信息id判重出错 ", err)
-							} else if isExists {
-								log.Println("信息id重复 ", id)
-								continue
+							if c.AppId != "jyMwBXQAIBBwJcTUhIFR99" {
+								isExists, err := redis.Exists("datag", c.AppId+"_"+id)
+								if err != nil {
+									log.Println("redis信息id判重出错 ", err)
+								} else if isExists {
+									log.Println("信息id重复 ", id)
+									continue
+								}
 							}
 							tmp["id"] = id //记录数据原有id
 							delete(tmp, "_id")