|
@@ -157,9 +157,10 @@ func (t *OwnerService) OwnerlList() *OwnerlListRes {
|
|
|
}
|
|
|
// 可介绍业主人脉处理
|
|
|
logx.Info(t.PositionId, " ConnectionsHandle start 。。。")
|
|
|
- routeList := ConnectionsHandle(buyerIdArr, t.PositionId, 1)
|
|
|
+ routeList := ConnectionsHandle(t.PositionId, buyerIdArr)
|
|
|
logx.Info(t.PositionId, " ConnectionsHandle over 。。。")
|
|
|
updateReturnDataWithRoutes(olr.ReturnData, routeList)
|
|
|
+ PersonFindConnectionsHandle(t.PositionId, olr.ReturnData, 1)
|
|
|
}
|
|
|
if len(olr.ReturnData) > 0 {
|
|
|
for k, value := range olr.ReturnData {
|
|
@@ -199,7 +200,7 @@ func updateReturnDataWithRoutes(returnData []BuyerProject, routeList []map[strin
|
|
|
}
|
|
|
|
|
|
// 可介绍业主人脉列表
|
|
|
-func ConnectionsHandle(buyerArr []string, positionId int64, contactCount int) []map[string]interface{} {
|
|
|
+func ConnectionsHandle(positionId int64, buyerArr []string) []map[string]interface{} {
|
|
|
returnData := []map[string]interface{}{}
|
|
|
//中间人
|
|
|
logx.Info(positionId, " ConnectionsHandle start 。。。")
|
|
@@ -207,15 +208,15 @@ func ConnectionsHandle(buyerArr []string, positionId int64, contactCount int) []
|
|
|
logx.Info(positionId, " FindMiddleman over 。。。")
|
|
|
//采购单位 投资关系 管辖关系
|
|
|
//采购单位
|
|
|
- Findfirstparty(positionId, buyerArr, returnData, contactCount)
|
|
|
+ Findfirstparty(positionId, buyerArr, returnData)
|
|
|
logx.Info(positionId, " Findfirstparty over 。。。")
|
|
|
- returnData = append(returnData, Findwinner(positionId, buyerArr, contactCount)...)
|
|
|
+ returnData = append(returnData, Findwinner(positionId, buyerArr)...)
|
|
|
logx.Info(positionId, " Findwinner over 。。。")
|
|
|
return returnData
|
|
|
}
|
|
|
|
|
|
// 供应商处理
|
|
|
-func Findwinner(positionId int64, buyerArr []string, contactCount int) []map[string]interface{} {
|
|
|
+func Findwinner(positionId int64, buyerArr []string) []map[string]interface{} {
|
|
|
returnData := []map[string]interface{}{}
|
|
|
if len(buyerArr) == 0 {
|
|
|
return returnData
|
|
@@ -340,7 +341,6 @@ func Findwinner(positionId int64, buyerArr []string, contactCount int) []map[str
|
|
|
bb := fmt.Sprintf("%s%s", gconv.String(returnData[j]["zbtime"]), gconv.String(returnData[j]["b_id"]))
|
|
|
return aa > bb
|
|
|
})
|
|
|
- PersonFindConnectionsHandle(positionId, returnData, contactCount)
|
|
|
return returnData
|
|
|
}
|
|
|
|
|
@@ -373,7 +373,7 @@ func FindMiddleman(positionId int64, buyerArr []string, returnData []map[string]
|
|
|
}
|
|
|
|
|
|
// 企业之间关系查询
|
|
|
-func Findfirstparty(positionId int64, buyerArr []string, returnData []map[string]interface{}, contactCount int) {
|
|
|
+func Findfirstparty(positionId int64, buyerArr []string, returnData []map[string]interface{}) {
|
|
|
if len(buyerArr) == 0 {
|
|
|
return
|
|
|
}
|
|
@@ -459,7 +459,6 @@ func Findfirstparty(positionId int64, buyerArr []string, returnData []map[string
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- PersonFindConnectionsHandle(positionId, returnData, contactCount)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -774,22 +773,24 @@ func BuyerFindConnectionsHandle(sqlStr string, args ...interface{}) []Connection
|
|
|
}
|
|
|
return returnData
|
|
|
}
|
|
|
-func PersonFindConnectionsHandle(positionId int64, returnData []map[string]interface{}, contactCount int) {
|
|
|
+func PersonFindConnectionsHandle(positionId int64, bps []BuyerProject, contactCount int) {
|
|
|
if contactCount == 0 {
|
|
|
return
|
|
|
}
|
|
|
//企业联系人处理
|
|
|
entIdArr := []string{}
|
|
|
entIdMap := map[string]bool{}
|
|
|
- for k, v := range returnData {
|
|
|
- b_id, _ := v["b_id"].(string)
|
|
|
- if b_id == "" || entIdMap[b_id] {
|
|
|
- continue
|
|
|
- }
|
|
|
- entIdMap[b_id] = true
|
|
|
- entIdArr = append(entIdArr, b_id)
|
|
|
- if k == contactCount-1 {
|
|
|
- break
|
|
|
+ for _, v := range bps {
|
|
|
+ for kk, vv := range v.Project.Connections {
|
|
|
+ b_id, _ := vv["b_id"].(string)
|
|
|
+ if b_id == "" || entIdMap[b_id] {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ entIdMap[b_id] = true
|
|
|
+ entIdArr = append(entIdArr, b_id)
|
|
|
+ if kk == contactCount-1 {
|
|
|
+ break
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
personMap := map[string]string{}
|
|
@@ -797,7 +798,7 @@ func PersonFindConnectionsHandle(positionId int64, returnData []map[string]inter
|
|
|
wh2, args2 := common.WhArgs(entIdArr)
|
|
|
personSql := `select id,name as personName from ent_contact prewhere id in (` + wh2 + `) ORDER by name`
|
|
|
logx.Info(positionId, " Findwinner 联系人 sql ", personSql, args2)
|
|
|
- returnData := []PersonEntity{}
|
|
|
+ pes := []PersonEntity{}
|
|
|
rows, err := ClickhouseConn.Query(context.Background(), personSql, args2...)
|
|
|
if err != nil {
|
|
|
logx.Error("查询失败", personSql, err)
|
|
@@ -805,18 +806,20 @@ func PersonFindConnectionsHandle(positionId int64, returnData []map[string]inter
|
|
|
for rows.Next() {
|
|
|
data := PersonEntity{}
|
|
|
rows.ScanStruct(&data)
|
|
|
- returnData = append(returnData, data)
|
|
|
+ pes = append(pes, data)
|
|
|
}
|
|
|
//联系人处理
|
|
|
- for _, v := range returnData {
|
|
|
+ for _, v := range pes {
|
|
|
personMap[v.Id] = v.PersonName
|
|
|
}
|
|
|
}
|
|
|
- for k, v := range returnData {
|
|
|
- b_id, _ := v["b_id"].(string)
|
|
|
- v["personName"] = personMap[b_id]
|
|
|
- if k == contactCount-1 {
|
|
|
- break
|
|
|
+ for _, v := range bps {
|
|
|
+ for kk, vv := range v.Project.Connections {
|
|
|
+ b_id, _ := vv["b_id"].(string)
|
|
|
+ vv["personName"] = personMap[b_id]
|
|
|
+ if kk == contactCount-1 {
|
|
|
+ break
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -874,7 +877,15 @@ func (t *OwnerService) OwnerRoute() []map[string]interface{} {
|
|
|
if t.BuyerId == "" {
|
|
|
return []map[string]interface{}{}
|
|
|
}
|
|
|
- routeList := ConnectionsHandle([]string{t.BuyerId}, t.PositionId, -1)
|
|
|
+ routeList := ConnectionsHandle(t.PositionId, []string{t.BuyerId})
|
|
|
+ bps := []BuyerProject{
|
|
|
+ BuyerProject{
|
|
|
+ Project: ProjectEntity{
|
|
|
+ Connections: routeList,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+ PersonFindConnectionsHandle(t.PositionId, bps, -1)
|
|
|
for i, routeMap := range routeList {
|
|
|
sourceType := gconv.String(routeMap["sourceType"])
|
|
|
if sourceType == "agency" || sourceType == "supplier" {
|