소스 검색

Merge branch 'develop' of 192.168.3.17:zhanghongbo/qfw into develop

wangshan 9 년 전
부모
커밋
396f08fe07
2개의 변경된 파일133개의 추가작업 그리고 5개의 파일을 삭제
  1. 1 1
      core/src/message.json
  2. 132 4
      core/src/qfw/search/searchService.go

+ 1 - 1
core/src/message.json

@@ -2,7 +2,7 @@
 	"weixinrpc":"127.0.0.1:82",
 	"swordfishaction":"/swordfish/page",
 	"signature":"/member/credit/myCredit",
-	"entsearchaction":"/wx/search/enterprise/index.html",
+	"entsearchaction":"/front/entCommunity.html",
 	"lawsearchaction":"/law/qfw/index",
 	"msiteaction":"/ent/wsite/edit",
 	"wxpushlist":"/wxpush/bidinfo/%s",

+ 132 - 4
core/src/qfw/search/searchService.go

@@ -138,6 +138,7 @@ func (n *Search) GetEnterpriseList(reqType, param /*参数*/ string) error {
 	//if ui, _ := (n.GetSession("userInfo")).(*map[string]interface{}); reqType == "m_" || (n.GetSession("userType") != nil && IntAll(n.GetSession("userType")) > 0) && ((n.GetSession("identWay") != nil && IntAll(n.GetSession("identWay")) == 1) || ((*ui)["s_pid"] != nil && (*ui)["s_pid"].(string) != "")) {
 	//n.T["uri"] = n.Uri()
 	ismobile := strings.Index(n.Header("User-Agent"), "Mobile")
+	i_mingpian := n.GetString("i_mingpian") //是否走名片查询
 	if len(param) == 0 {
 		//请求是表单提交,走的查询
 		//拼装查询对象
@@ -154,7 +155,17 @@ func (n *Search) GetEnterpriseList(reqType, param /*参数*/ string) error {
 			"cityNo":      n.GetString("cityNo"), // 是否是第一次查询并且没有选择地市,自动根据IP来设
 		}
 		//查询生成列表数据
-		data, pagination := searhWebContentent(querymap, n, reqType)
+		var data *[]map[string]interface{}
+		var pagination *[]interface{}
+		var has bool = false
+		if i_mingpian != "" {
+			data, pagination, has = searhWebContententMp(querymap, n, reqType, false)
+			if !has {
+				data, pagination = searhWebContentent(querymap, n, reqType)
+			}
+		} else {
+			data, pagination = searhWebContentent(querymap, n, reqType)
+		}
 		log.Println(len(*data))
 		//查询送积分
 		queryStr := querymap["query"]
@@ -218,9 +229,6 @@ func (n *Search) GetEnterpriseList(reqType, param /*参数*/ string) error {
 		}
 	}
 	return nil
-	//} else {
-	//return n.Render("/search/entcommunity.html")
-	//}
 }
 
 //即时搜索
@@ -635,3 +643,123 @@ func searhWebContentent(querymap map[string]string, n *Search, reqType string) (
 	return &res, &pagination
 
 }
+
+//通过企业名片查询
+func searhWebContententMp(querymap map[string]string, n *Search, reqType string, has bool) (*[]map[string]interface{}, *[]interface{}, bool) {
+	queryStr := querymap["query"]
+	fmt.Println("检索条件:", queryStr)
+	keyword := queryStr
+	var query = `{
+	    "query": {
+	        "bool": {
+	            "must": ["match": {"enterprise.EntName": {"query": "` + keyword + `","operator": "and"}}}],
+	            "must_not": {"terms": {"SourceType": ["03", "04"]}},
+	            "should": [],
+	            "minimum_should_match": 1
+	        }
+	    },
+	    "highlight": {
+	        "pre_tags": ["<span class='highlight'>"],
+	        "post_tags": ["</span>"],
+	        "fields": {
+	            "EntName": {"force_source": true},
+	            "LeRep": {"force_source": true},
+	            "s_servicenames": {"force_source": true},
+	            "RegNo": {"force_source": true},
+	            "OpScope": {"force_source": true},
+	            "s_synopsis": {"force_source": true},
+	            "stock": {"force_source": true}
+	        }
+	    },
+	    "_source": [
+	        "_id","EntName","RegOrgName","RegNo","EntType",
+	        "LeRep","EstDate","OpLocDistrictName","OpStateName",
+	        "s_servicenames","s_action","OpLocDistrict","s_submitid"
+	    ],
+	    "from": 0,"size": 10,
+	    "sort": [{"OpSint": "desc","RegCap": "desc"}]
+	}`
+	//查询列表数据
+	client := elastic.GetEsConn()
+	defer elastic.DestoryEsConn(client)
+	if client == nil {
+		return nil, nil, false
+	}
+	searchResult, err := client.Search().Index("enterprise").Type("enterprise").Source(query).Do()
+	if err != nil {
+		return nil, nil, false
+	}
+	var res []map[string]interface{}
+	if searchResult.Hits != nil {
+		resNum := len(searchResult.Hits.Hits)
+		res = make([]map[string]interface{}, resNum)
+		for i, hit := range searchResult.Hits.Hits {
+			json.Unmarshal(*hit.Source, &res[i])
+			//查询结果数据加工处理
+			for k, v := range hit.Highlight {
+				res[i][k] = v[0]
+			}
+			EntName, _ := res[i]["EntName"].(string)
+			if EntName != keyword {
+				continue
+			} else {
+				has = true
+			}
+			tmpNo := res[i]["EntType"]
+			if tmpNo != nil {
+				switch tmpNo.(string) {
+				case "4500", "6800", "6810", "6820", "7100", "7110", "7120", "7130", "7190", "9200", "6840", "2100", "2110", "2120", "2121", "2122", "2123", "2130", "2140", "2150", "2151", "2152", "2190", "2200", "2210", "2211", "2212", "2213", "2219", "2220", "2221", "2222", "2223", "2229", "4000", "4300", "4310", "4320", "4330", "4340", "4550", "4551", "4552", "4553", "4560", "5800", "5810", "5820":
+					res[i]["EntType"] = "5810"
+				}
+			}
+
+			entlerp, _ := res[i]["LeRep"].(string)
+			tmpentno, _ := res[i]["RegNo"].(string)
+			if len(keyword) < 1 {
+				tmpentno = strings.Replace(tmpentno, "highlight", "", -1)
+				EntName = strings.Replace(EntName, "highlight", "", -1)
+			}
+			res[i]["RegNo"] = template.HTML(tmpentno)
+			if tmpNo == "9600" && strings.Contains(EntName, tmpentno) {
+				res[i]["EntName"] = template.HTML(strings.Replace(EntName, tmpentno, entlerp, -1))
+			} else {
+				res[i]["EntName"] = template.HTML(EntName)
+			}
+
+			id := res[i]["s_submitid"]
+			if id != nil {
+				ud := FindById("user", id.(string), `{"i_comauthenttype":1}`)
+				res[i]["i_comauthenttype"] = (*ud)["i_comauthenttype"]
+			}
+			//
+
+			res[i]["tmpentno"] = template.HTML(tmpentno)
+			LeRep, _ := res[i]["LeRep"].(string)
+			res[i]["LeRep"] = template.HTML(LeRep)
+			s_servicenames, _ := res[i]["s_servicenames"].(string)
+			res[i]["s_servicenames"] = template.HTML(s_servicenames)
+
+			OpScope, _ := res[i]["OpScope"].(string)
+			if len(OpScope) > 0 {
+				res[i]["OpScope"] = template.HTML(OpScope)
+			}
+			s_synopsis, _ := res[i]["s_synopsis"].(string)
+			if len(s_synopsis) > 0 {
+				res[i]["s_synopsis"] = template.HTML(s_synopsis)
+			}
+			stock, _ := res[i]["stock"].(string)
+			if len(stock) > 0 {
+				res[i]["stock"] = template.HTML(stock)
+			}
+			tmpdate, _ := res[i]["EstDate"]
+			if tmpdate != nil {
+				res[i]["EstDate"] = FormatDateWithObj(&tmpdate, Date_Short_Layout)
+			} else {
+				res[i]["EstDate"] = ""
+			}
+		}
+	}
+	//生成分页
+	pagination := front.MakePagination(1, 1, 1, querymap, "/wx/search/enterprise/"+reqType+"ent_%s.html")
+	return &res, &pagination, has
+}