wangshan пре 5 година
родитељ
комит
87425211b0

+ 1 - 1
src/jfw/modules/app/src/app/front/ws_dataExport.go

@@ -78,7 +78,7 @@ func (w *WsDataExport) GetPreview() error {
 			}
 		}
 	}
-	list := public.FormatExportData(&res_screen, config.Sysconfig["webdomain"].(string), dataType, true, EntArr)
+	list := public.FormatExportData(&res_screen, config.Sysconfig["webdomain"].(string), dataType, EntArr)
 	_res["data"] = subUrl(list, dataType)
 	_res["dataType"] = dataType
 	w.ServeJson(map[string]interface{}{

+ 2 - 0
src/jfw/modules/subscribepay/src/config.json

@@ -2,6 +2,8 @@
 	"mongodbServers": "192.168.3.128:27080",
     "mongodbPoolSize": 5,
     "mongodbName": "qfw",
+	"mongodbServersEnt": "192.168.3.128:27080",
+    "mongodbNameEnt": "extract_v3",
     "redisaddrs": "other=192.168.3.128:1712,session=192.168.3.128:1712,push=192.168.3.128:1712,pushcache_1=192.168.3.128:5000,pushcache_2_a=192.168.3.128:5001",
     "elasticsearch": "http://192.168.3.128:9800",
     "elasticPoolSize": 30,

+ 15 - 13
src/jfw/modules/subscribepay/src/config/config.go

@@ -7,19 +7,21 @@ import (
 )
 
 type config struct {
-	MongodbServers  string
-	MongodbPoolSize int
-	MongodbName     string
-	Elasticsearch   string
-	ElasticPoolSize int
-	Redisaddrs      string
-	Appid           string
-	Appsecret       string
-	Webport         string
-	Webrpcport      string
-	Weixinrpc       string
-	Cassandra       map[string]interface{}
-	Mysql           struct {
+	MongodbServers    string
+	MongodbPoolSize   int
+	MongodbName       string
+	MongodbServersEnt string
+	MongodbNameEnt    string
+	Elasticsearch     string
+	ElasticPoolSize   int
+	Redisaddrs        string
+	Appid             string
+	Appsecret         string
+	Webport           string
+	Webrpcport        string
+	Weixinrpc         string
+	Cassandra         map[string]interface{}
+	Mysql             struct {
 		DbName       string
 		Address      string
 		UserName     string

+ 81 - 104
src/jfw/modules/subscribepay/src/entity/dataExportSearch.go

@@ -8,7 +8,6 @@ import (
 	qutil "qfw/util"
 	"qfw/util/elastic"
 	"qfw/util/jy"
-	"qfw/util/redis"
 	"regexp"
 	"sort"
 	"strconv"
@@ -16,6 +15,8 @@ import (
 	"sync"
 	"time"
 	"util"
+
+	"gopkg.in/mgo.v2/bson"
 )
 
 /*筛选条件--关键词*/
@@ -354,6 +355,8 @@ func isNullSearch(scd *SieveCondition) (isNull bool) {
  * webdomain 三级页域名
  * count 返回数量 (-1:预览数据查询)
  */
+var EntTable = "winner_enterprise"
+
 func GetDataExportSearchResultUseId(_id, dataType string, count int) (*[]map[string]interface{}, []KeyWord) {
 	defer qutil.Catch()
 	var res []map[string]interface{}
@@ -363,97 +366,93 @@ func GetDataExportSearchResultUseId(_id, dataType string, count int) (*[]map[str
 	qstr := getDataExportSql(scd)
 
 	kws = scd.Keyword
-	if count == -1 {
-		//数据预览数据查询
-		if scd.Comeinfrom == "supersearchPage" && len(scd.Keyword) == 0 && len(scd.Industry) == 0 {
-			//空查询
-			obj := redis.Get("other", "export_news")
-			if obj != nil {
-				res = qutil.ObjArrToMapArr(obj.([]interface{}))
-			} else {
-				res = *doSearch(qstr, 0, 500, "2")
-				if len(res) > 0 {
-					redis.Put("other", "export_news", res, 7200)
-				}
+	//数据导出数据查询
+	if count > onceSearchCount {
+		for t := 0; t < 3; t++ {
+			for n := 0; n*onceSearchCount < count; n++ {
+				searchWaitGroup.Add(1)
+				searchPool <- true
+				go func(start int) {
+					defer func() {
+						searchWaitGroup.Done()
+						<-searchPool
+					}()
+					r := doSearch(qstr, start*onceSearchCount, onceSearchCount, dataType)
+					if r != nil {
+						res = append(res, *r...)
+						log.Println("第", start+1, "页数据加载完成!")
+					}
+				}(n)
 			}
-			return &res, kws
-		} else if scd.Comeinfrom == "supersearchPage" {
-			//超级搜索非空查询
-			count = int(elastic.Count(INDEX, TYPE, qstr))
-			searchTextSize := 0
-			if len(scd.Keyword) > 0 {
-				searchTextSize = len([]rune(scd.Keyword[0].Keyword))
-			}
-			if searchTextSize > 3 && count < 50 {
-				var res *[]map[string]interface{}
-				if count > 0 {
-					res = doSearch(qstr, 0, count, "")
-				}
-				secondKWS := jy.HttpEs(scd.Keyword[0].Keyword, "ik_smart", config.Config.Elasticsearch)
-				scd.Keyword[0].Keyword = secondKWS
-				scd.SelectType = "title"
-				qstr = getDataExportSql(scd)
-				res2 := doSearch(qstr, 0, 100-count, "")
-				return delRepeatMapArr(res, res2), kws
+			searchWaitGroup.Wait()
+			//校验数量(预览数据查询不需要校验数据量)
+			if len(res) == count {
+				break
 			}
+			log.Println("第", t+1, "次加载数据完成,数据总数", len(res), ",由于数据量不够,重新加载!")
 		}
-		//非空查询
-		res = *doSearch(qstr, 0, 500, dataType)
-
 	} else {
-		//数据导出数据查询
-		if count > onceSearchCount {
-			for t := 0; t < 3; t++ {
-				for n := 0; n*onceSearchCount < count; n++ {
-					searchWaitGroup.Add(1)
-					searchPool <- true
-					go func(start int) {
-						defer func() {
-							searchWaitGroup.Done()
-							<-searchPool
-						}()
-						r := doSearch(qstr, start*onceSearchCount, onceSearchCount, dataType)
-						if r != nil {
-							res = append(res, *r...)
-							log.Println("第", start+1, "页数据加载完成!")
-						}
-					}(n)
-				}
-				searchWaitGroup.Wait()
-				//校验数量(预览数据查询不需要校验数据量)
-				if len(res) == count {
-					break
-				}
-				log.Println("第", t+1, "次加载数据完成,数据总数", len(res), ",由于数据量不够,重新加载!")
-			}
-		} else {
-			res = *doSearch(qstr, 0, count, dataType)
-		}
-
-		//和超级搜索同步
-		if scd.Comeinfrom == "supersearchPage" && (len(scd.Keyword) != 0 || len(scd.Industry) != 0) {
-			num := len(res)
-			searchTextSize := 0
-			if len(scd.Keyword) > 0 {
-				searchTextSize = len([]rune(scd.Keyword[0].Keyword))
-			}
-			if searchTextSize > 3 && num < 50 {
-				secondKWS := jy.HttpEs(scd.Keyword[0].Keyword, "ik_smart", config.Config.Elasticsearch)
-				scd.Keyword[0].Keyword = secondKWS
-				scd.SelectType = "title"
-				qstr = getDataExportSql(scd)
-				res2 := doSearch(qstr, 0, 100-num, "")
-				res = *delRepeatMapArr(&res, res2)
-			}
-		}
-		res = *FormatExportData(&res, config.Config.WebDomain, dataType, false)
+		res = *doSearch(qstr, 0, count, dataType)
 	}
+
+	//和超级搜索同步
+	if scd.Comeinfrom == "supersearchPage" && (len(scd.Keyword) != 0 || len(scd.Industry) != 0) {
+		num := len(res)
+		searchTextSize := 0
+		if len(scd.Keyword) > 0 {
+			searchTextSize = len([]rune(scd.Keyword[0].Keyword))
+		}
+		if searchTextSize > 3 && num < 50 {
+			secondKWS := jy.HttpEs(scd.Keyword[0].Keyword, "ik_smart", config.Config.Elasticsearch)
+			scd.Keyword[0].Keyword = secondKWS
+			scd.SelectType = "title"
+			qstr = getDataExportSql(scd)
+			res2 := doSearch(qstr, 0, 100-num, "")
+			res = *delRepeatMapArr(&res, res2)
+		}
+	}
+	var EntArr = []string{}
+	for _, v := range res {
+		//高级字段查询且winner不为空
+		if v["s_winner"] != "" && dataType == "2" {
+			EntArr = append(EntArr, v["s_winner"].(string))
+		}
+	}
+	res = *FormatExportData(&res, config.Config.WebDomain, dataType, EntArr)
 	return &res, kws
 }
 
-func FormatExportData(data *[]map[string]interface{}, webdomain string, dataType string, isBreviary bool) *[]map[string]interface{} {
+func FormatExportData(data *[]map[string]interface{}, webdomain string, dataType string, EntArr []string) *[]map[string]interface{} {
 	//格式化输出
 	for _, v := range *data {
+		//有中标企业 且 高级字段查询
+		if len(EntArr) > 0 && dataType == "2" {
+			//查询企业公示 法人 公司电话 公司邮箱地址
+			query := bson.M{"company_name": bson.M{"$in": EntArr}} //
+			if entData, ok := util.MQFWENT.Find(EntTable, query, nil, `{"company_name":1,"company_email":1,"legal_person":1,"company_phone":1}`, false, -1, -1); ok {
+				if entData != nil && *entData != nil && len(*entData) > 0 {
+					for _, ev := range *entData {
+						if v["s_winner"] == ev["company_name"] {
+							legal_person := ""
+							if ev["legal_person"] != nil {
+								legal_person = ev["legal_person"].(string)
+							}
+							company_phone := ""
+							if ev["company_phone"] != nil {
+								company_phone = ev["company_phone"].(string)
+							}
+							company_email := ""
+							if ev["company_email"] != nil && ev["company_email"] != "无" {
+								company_email = ev["company_email"].(string)
+							}
+							v["legal_person"] = legal_person
+							v["company_phone"] = company_phone
+							v["company_email"] = company_email
+						}
+					}
+				}
+			}
+		}
 		//====================字段补漏=========================
 		if v["toptype"] == "结果" && dataType == "2" && !(v["agency"] != nil && v["budget"] != nil && v["buyerperson"] != nil && v["buyertel"] != nil) {
 			r := elastic.Get("projectset", "projectset", fmt.Sprintf(`{"query":{"term":{"list.infoid":"%s"}},"_source": ["list"]}`, v["_id"]))
@@ -504,28 +503,6 @@ func FormatExportData(data *[]map[string]interface{}, webdomain string, dataType
 		if v["currency"] == "" || v["currency"] == nil {
 			v["currency"] = "人民币"
 		}
-		if v["projectscope"] != "" && v["projectscope"] != nil {
-			if isBreviary {
-				str := ClearHtml.ReplaceAllString(v["projectscope"].(string), "")
-				str = ClearOther.ReplaceAllString(str, "")
-				str = strings.Replace(str, " ", "", -1)
-				if len([]rune(str)) > 100 {
-					str = qutil.SubString(str, 0, 100) + "..."
-				}
-				v["projectscope"] = str
-			}
-		}
-		if v["detail"] != "" && v["detail"] != nil {
-			if isBreviary {
-				str := ClearHtml.ReplaceAllString(v["detail"].(string), "")
-				str = ClearOther.ReplaceAllString(str, "")
-				str = strings.Replace(str, " ", "", -1)
-				if len([]rune(str)) > 100 {
-					str = qutil.SubString(str, 0, 100) + "..."
-				}
-				v["detail"] = str
-			}
-		}
 		if v["subtype"] == nil && v["toptype"] != nil {
 			v["subtype"] = v["toptype"]
 		}

+ 1 - 2
src/jfw/modules/subscribepay/src/entity/dataexport.go

@@ -6,7 +6,6 @@ import (
 	"encoding/json"
 	"errors"
 	"fmt"
-	"jfw/public"
 	"log"
 	"os"
 	qutil "qfw/util"
@@ -148,7 +147,7 @@ var (
 //生成数据导出excel
 func CreateDataExortExcleFile(filter_id string, data_count int, isSenior bool, download_url, filename string) error {
 	//查询数据
-	list, _ := public.GetDataExportSearchResultUseId(filter_id, qutil.If(isSenior, "2", "1").(string), data_count)
+	list, _ := GetDataExportSearchResultUseId(filter_id, qutil.If(isSenior, "2", "1").(string), data_count)
 	if list == nil || len(*list) == 0 {
 		return errors.New("未查询到数据")
 	}

+ 8 - 0
src/jfw/modules/subscribepay/src/util/db.go

@@ -11,6 +11,7 @@ import (
 )
 
 var MQFW mg.MongodbSim
+var MQFWENT mg.MongodbSim
 var Mysql *mysql.Mysql
 var PushMysql *mysql.Mysql
 var Ca_Push = &ca.Cassandra{}
@@ -44,6 +45,13 @@ func init() {
 	}
 	MQFW.InitPool()
 	//
+	MQFWENT = mg.MongodbSim{
+		MongodbAddr: Config.MongodbServersEnt,
+		Size:        Config.MongodbPoolSize,
+		DbName:      Config.MongodbNameEnt,
+	}
+	MQFWENT.InitPool()
+	//
 	Mysql = &mysql.Mysql{
 		Address:      Config.Mysql.Address,
 		UserName:     Config.Mysql.UserName,

+ 54 - 117
src/jfw/public/search.go

@@ -347,102 +347,45 @@ func GetDataExportSearchResultUseId(_id, dataType string, count int) (*[]map[str
 	//获取查询语句
 	qstr := getDataExportSql(scd)
 	kws = scd.Keyword
-	if count == -1 {
-		//数据预览数据查询
-		if scd.Comeinfrom == "supersearchPage" && len(scd.Keyword) == 0 && len(scd.Industry) == 0 {
-			//空查询
-			obj := redis.Get("other", "export_news")
-			if obj != nil {
-				res = util.ObjArrToMapArr(obj.([]interface{}))
-			} else {
-				res = *doSearch(qstr, 0, 500, "2")
-				if len(res) > 0 {
-					redis.Put("other", "export_news", res, 7200)
-				}
-			}
-			return &res, kws
-		} else if scd.Comeinfrom == "supersearchPage" {
-			//超级搜索非空查询
-			count = int(elastic.Count(INDEX, TYPE, qstr))
-			searchTextSize := 0
-			if len(scd.Keyword) > 0 {
-				searchTextSize = len([]rune(scd.Keyword[0].Keyword))
-			}
-			if searchTextSize > 3 && count < 50 {
-				var res *[]map[string]interface{}
-				if count > 0 {
-					res = doSearch(qstr, 0, count, "")
-				}
-				secondKWS := jy.HttpEs(scd.Keyword[0].Keyword, "ik_smart", config.Sysconfig["elasticsearch"].(string))
-				scd.Keyword[0].Keyword = secondKWS
-				scd.SelectType = "title"
-				qstr = getDataExportSql(scd)
-				res2 := doSearch(qstr, 0, 100-count, "")
-				return delRepeatMapArr(res, res2), kws
-			}
-		}
-		//非空查询
-		res = *doSearch(qstr, 0, 500, dataType)
-
-	} else {
-		//数据导出数据查询
-		if count > onceSearchCount {
-			for t := 0; t < 3; t++ {
-				for n := 0; n*onceSearchCount < count; n++ {
-					searchWaitGroup.Add(1)
-					searchPool <- true
-					go func(start int) {
-						defer func() {
-							searchWaitGroup.Done()
-							<-searchPool
-						}()
-						r := doSearch(qstr, start*onceSearchCount, onceSearchCount, dataType)
-						if r != nil {
-							res = append(res, *r...)
-							log.Println("第", start+1, "页数据加载完成!")
-						}
-					}(n)
-				}
-				searchWaitGroup.Wait()
-				//校验数量(预览数据查询不需要校验数据量)
-				if len(res) == count {
-					break
-				}
-				log.Println("第", t+1, "次加载数据完成,数据总数", len(res), ",由于数据量不够,重新加载!")
-			}
+	//数据预览数据查询
+	if scd.Comeinfrom == "supersearchPage" && len(scd.Keyword) == 0 && len(scd.Industry) == 0 {
+		//空查询
+		obj := redis.Get("other", "export_news")
+		if obj != nil {
+			res = util.ObjArrToMapArr(obj.([]interface{}))
 		} else {
-			res = *doSearch(qstr, 0, count, dataType)
-		}
-
-		//和超级搜索同步
-		if scd.Comeinfrom == "supersearchPage" && (len(scd.Keyword) != 0 || len(scd.Industry) != 0) {
-			num := len(res)
-			searchTextSize := 0
-			if len(scd.Keyword) > 0 {
-				searchTextSize = len([]rune(scd.Keyword[0].Keyword))
-			}
-			if searchTextSize > 3 && num < 50 {
-				secondKWS := jy.HttpEs(scd.Keyword[0].Keyword, "ik_smart", config.Sysconfig["elasticsearch"].(string))
-				scd.Keyword[0].Keyword = secondKWS
-				scd.SelectType = "title"
-				qstr = getDataExportSql(scd)
-				res2 := doSearch(qstr, 0, 100-num, "")
-				res = *delRepeatMapArr(&res, res2)
+			res = *doSearch(qstr, 0, 500, "2")
+			if len(res) > 0 {
+				redis.Put("other", "export_news", res, 7200)
 			}
 		}
-		var EntArr = []string{}
-		for _, v := range res {
-			//高级字段查询且winner不为空
-			if v["s_winner"] != "" && dataType == "2" {
-				EntArr = append(EntArr, v["s_winner"].(string))
+		return &res, kws
+	} else if scd.Comeinfrom == "supersearchPage" {
+		//超级搜索非空查询
+		count = int(elastic.Count(INDEX, TYPE, qstr))
+		searchTextSize := 0
+		if len(scd.Keyword) > 0 {
+			searchTextSize = len([]rune(scd.Keyword[0].Keyword))
+		}
+		if searchTextSize > 3 && count < 50 {
+			var res *[]map[string]interface{}
+			if count > 0 {
+				res = doSearch(qstr, 0, count, "")
 			}
+			secondKWS := jy.HttpEs(scd.Keyword[0].Keyword, "ik_smart", config.Sysconfig["elasticsearch"].(string))
+			scd.Keyword[0].Keyword = secondKWS
+			scd.SelectType = "title"
+			qstr = getDataExportSql(scd)
+			res2 := doSearch(qstr, 0, 100-count, "")
+			return delRepeatMapArr(res, res2), kws
 		}
-		res = *FormatExportData(&res, config.Sysconfig["webdomain"].(string), dataType, false, EntArr)
 	}
+	//非空查询
+	res = *doSearch(qstr, 0, 500, dataType)
 	return &res, kws
 }
 
-func FormatExportData(data *[]map[string]interface{}, webdomain string, dataType string, isBreviary bool, EntArr []string) *[]map[string]interface{} {
+func FormatExportData(data *[]map[string]interface{}, webdomain string, dataType string, EntArr []string) *[]map[string]interface{} {
 	//格式化输出
 	for _, v := range *data {
 		//有中标企业 且 高级字段查询
@@ -465,21 +408,19 @@ func FormatExportData(data *[]map[string]interface{}, webdomain string, dataType
 							if ev["company_email"] != nil && ev["company_email"] != "无" {
 								company_email = ev["company_email"].(string)
 							}
-							if isBreviary {
-								if legal_person != "" {
-									var xx = "*"
-									switch len([]rune(legal_person)) {
-									case 3:
-										xx = "**"
-									case 4:
-										xx = "***"
-									}
-									legal_person = string([]rune(legal_person)[:1]) + xx
-								}
-								company_phone = company_phone[:7] + "****"
-								if len(strings.Split(company_email, "@")) > 1 {
-									company_email = "******" + strings.Split(company_email, "@")[1]
+							if legal_person != "" {
+								var xx = "*"
+								switch len([]rune(legal_person)) {
+								case 3:
+									xx = "**"
+								case 4:
+									xx = "***"
 								}
+								legal_person = string([]rune(legal_person)[:1]) + xx
+							}
+							company_phone = company_phone[:7] + "****"
+							if len(strings.Split(company_email, "@")) > 1 {
+								company_email = "******" + strings.Split(company_email, "@")[1]
 							}
 							v["legal_person"] = legal_person
 							v["company_phone"] = company_phone
@@ -540,26 +481,22 @@ func FormatExportData(data *[]map[string]interface{}, webdomain string, dataType
 			v["currency"] = "人民币"
 		}
 		if v["projectscope"] != "" && v["projectscope"] != nil {
-			if isBreviary {
-				str := ClearHtml.ReplaceAllString(v["projectscope"].(string), "")
-				str = ClearOther.ReplaceAllString(str, "")
-				str = strings.Replace(str, " ", "", -1)
-				if len([]rune(str)) > 100 {
-					str = util.SubString(str, 0, 100) + "..."
-				}
-				v["projectscope"] = str
+			str := ClearHtml.ReplaceAllString(v["projectscope"].(string), "")
+			str = ClearOther.ReplaceAllString(str, "")
+			str = strings.Replace(str, " ", "", -1)
+			if len([]rune(str)) > 100 {
+				str = util.SubString(str, 0, 100) + "..."
 			}
+			v["projectscope"] = str
 		}
 		if v["detail"] != "" && v["detail"] != nil {
-			if isBreviary {
-				str := ClearHtml.ReplaceAllString(v["detail"].(string), "")
-				str = ClearOther.ReplaceAllString(str, "")
-				str = strings.Replace(str, " ", "", -1)
-				if len([]rune(str)) > 100 {
-					str = util.SubString(str, 0, 100) + "..."
-				}
-				v["detail"] = str
+			str := ClearHtml.ReplaceAllString(v["detail"].(string), "")
+			str = ClearOther.ReplaceAllString(str, "")
+			str = strings.Replace(str, " ", "", -1)
+			if len([]rune(str)) > 100 {
+				str = util.SubString(str, 0, 100) + "..."
 			}
+			v["detail"] = str
 		}
 		if v["subtype"] == nil && v["toptype"] != nil {
 			v["subtype"] = v["toptype"]