wangchuanjin 9 сар өмнө
parent
commit
f646cb9912

+ 1 - 1
api/internal/service/CoopHistoryService.go

@@ -132,7 +132,7 @@ func GetPrList(req *types.CoopHistoryReq) *PrListRes {
 	}
 	// 关联单位
 	var r4 []map[string]interface{}
-	Findfirstparty(req.PositionId, []string{pTmp.BuyerId}, r4, 0)
+	Findfirstparty(req.PositionId, []string{pTmp.BuyerId}, r4)
 	prListRes.Size_2 = int64(len(r4))
 	if req.ChannelType == "0" || req.ChannelType == "2" {
 		for _, m := range r4 {

+ 38 - 27
api/internal/service/owner.go

@@ -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" {

+ 2 - 2
api/internal/service/plistService.go

@@ -389,7 +389,7 @@ func moreInfo(req *types.ProjectListReq, plist []string, list []*ProjectEntry) (
 		}
 	}
 	var companyList []map[string]interface{}
-	Findfirstparty(req.PositionId, bArr, companyList, 0)
+	Findfirstparty(req.PositionId, bArr, companyList)
 	if companyList != nil && len(companyList) > 0 {
 		for _, m := range list {
 			if m.MyConn == false {
@@ -407,7 +407,7 @@ func moreInfo(req *types.ProjectListReq, plist []string, list []*ProjectEntry) (
 			}
 		}
 	} else {
-		companyList = Findwinner(req.PositionId, bArr, 0)
+		companyList = Findwinner(req.PositionId, bArr)
 		if companyList != nil && len(companyList) > 0 {
 			for _, m := range list {
 				if m.MyConn == false {