|
@@ -238,23 +238,28 @@ func (yp *Yellowpage) EnterpriseInfo(id string) error {
|
|
|
if relflag {
|
|
|
if d, err := json.Marshal(relation["nodes"]); err == nil && json.Unmarshal(d, &nodes) == nil && len(*nodes) > 0 {
|
|
|
//相关企业
|
|
|
- var regNos []string
|
|
|
+ var entmids []ObjectId
|
|
|
for _, v := range *nodes {
|
|
|
- if v["type"] == "e" {
|
|
|
- regNos = append(regNos, v["name"].(string))
|
|
|
- }
|
|
|
- if len(regNos) == 6 {
|
|
|
- break
|
|
|
+ if v["type"] == "e" && v["entmid"] != nil && v["entmid"].(string) != "" {
|
|
|
+ entmids = append(entmids, ObjectIdHex(v["entmid"].(string)))
|
|
|
}
|
|
|
}
|
|
|
- if len(regNos) > 0 {
|
|
|
- relevantEnts := Find("enterprise", M{"RegNo": M{"$in": regNos}}, nil, `{"s_avatar":1,"RegNo":1,"EntName":1}`, false, -1, -1)
|
|
|
+ if len(entmids) > 0 {
|
|
|
+ relevantEnts := Find("enterprise", M{"_id": M{"$in": entmids}}, nil, `{"s_avatar":1,"RegNo":1,"EntName":1}`, false, -1, -1)
|
|
|
if relevantEnts != nil && len(*relevantEnts) > 0 {
|
|
|
for _, relevantEnt := range *relevantEnts {
|
|
|
relevantEnt["_id"] = util.BsonIdToSId(relevantEnt["_id"])
|
|
|
+ for _, node := range *nodes {
|
|
|
+ if node["entmid"] != nil && node["entmid"].(string) == relevantEnt["_id"] {
|
|
|
+ node["haslink"] = true
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
yp.T["relevantEnts"] = relevantEnts
|
|
|
}
|
|
|
+ relation["nodes"] = nodes
|
|
|
+ redis.Put("enterprise", "relation-"+regNo, relation, 7*ONEDAY)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -415,7 +420,8 @@ func storeNode(data *map[string]interface{}, ls *list.List, dir /*方向反转*/
|
|
|
invopstate, _ := (*data)["invopstate"].(string)
|
|
|
regcapcurname, _ := (*data)["regcapcurname"].(string)
|
|
|
shortname, _ := (*data)["shortname"].(string)
|
|
|
- ls.PushBack([]string{invtype, invcerno, invname, entregno, entname, strconv.Itoa(level), fmt.Sprint(invweight), invacconam, fmt.Sprint(regcap), fmt.Sprint(invregcap), legcerno, opstate, invopstate, regcapcurname, util.BsonIdToSId((*data)["_id"]), shortname})
|
|
|
+ entmid := (*data)["entmid"]
|
|
|
+ ls.PushBack([]string{invtype, invcerno, invname, entregno, entname, strconv.Itoa(level), fmt.Sprint(invweight), invacconam, fmt.Sprint(regcap), fmt.Sprint(invregcap), legcerno, opstate, invopstate, regcapcurname, util.BsonIdToSId((*data)["_id"]), shortname, util.BsonIdToSId(entmid)})
|
|
|
}
|
|
|
|
|
|
func findIndex(code string, arr []interface{}) (index int, mtType string) {
|
|
@@ -521,6 +527,7 @@ func makeRelation(mnregno, mnname string) interface{} {
|
|
|
"regcapcurname": v[13],
|
|
|
"_id": v[14],
|
|
|
"shorttext": v[15],
|
|
|
+ "entmid": v[16],
|
|
|
}
|
|
|
}
|
|
|
//加企业
|
|
@@ -536,6 +543,7 @@ func makeRelation(mnregno, mnname string) interface{} {
|
|
|
"regcapcurname": v[13],
|
|
|
"_id": v[14],
|
|
|
"shorttext": v[15],
|
|
|
+ "entmid": v[16],
|
|
|
}
|
|
|
}
|
|
|
}
|