瀏覽代碼

feat:xiugai

wangchuanjin 9 月之前
父節點
當前提交
9969704b2c

+ 2 - 2
api/common/network.go

@@ -23,7 +23,7 @@ func (n *networkCom) GetEntIdByName(names []string) map[string]string {
 	}
 	var query = func(values []string) {
 		wh, args := WhArgs(values)
-		rows, err := ClickhouseConn.Query(context.Background(), `select id,company_name from information.ent_info where company_name in (`+wh+`)`, args...)
+		rows, err := ClickhouseConn.Query(context.Background(), `select id,company_name from information.ent_info prewhere company_name in (`+wh+`)`, args...)
 		if err != nil {
 			logx.Error(err)
 			return
@@ -60,7 +60,7 @@ func (n *networkCom) GetEntIdByName(names []string) map[string]string {
 
 //根据标签类型获取标签占位
 func (n *networkCom) GetEntTagSeat(labelType int) []string {
-	rows, err := ClickhouseConn.Query(context.Background(), `select bitmap_num from information.ent_label where label_type=?`, labelType)
+	rows, err := ClickhouseConn.Query(context.Background(), `select bitmap_num from information.ent_label prewhere label_type=?`, labelType)
 	if err != nil {
 		logx.Error(err)
 		return nil

+ 13 - 15
api/internal/service/CoopHistoryService.go

@@ -23,10 +23,10 @@ const (
 
 var (
 	INDEX_1   = "transaction_info_all"
-	sql_2_0   = `SELECT buyer_id FROM information.transaction_info_all WHERE project_id = ?`
-	sql_2_2   = `select id as buyer_id from ent_info where company_name=? order by id desc limit 1`
-	sql_2_1   = `SELECT project_id, project_name, zbtime FROM information.transaction_info_all WHERE buyer_id = ? AND has(winner, ?) ORDER BY zbtime DESC`
-	sql_2_1_1 = `SELECT project_id, project_name, zbtime FROM information.transaction_info_all WHERE buyer_id = ? AND agency = ? ORDER BY zbtime DESC`
+	sql_2_0   = `SELECT buyer_id FROM information.transaction_info_all prewhere project_id = ?`
+	sql_2_2   = `select id as buyer_id from ent_info prewhere company_name=? order by id desc limit 1`
+	sql_2_1   = `SELECT project_id, project_name, zbtime FROM information.transaction_info_all prewhere buyer_id = ? AND has(winner, ?) ORDER BY zbtime DESC`
+	sql_2_1_1 = `SELECT project_id, project_name, zbtime FROM information.transaction_info_all prewhere buyer_id = ? AND agency = ? ORDER BY zbtime DESC`
 )
 
 type ResultData struct {
@@ -116,7 +116,7 @@ func GetPrList(req *types.CoopHistoryReq) *PrListRes {
 	// 1、同甲异业数据/ 3、招标代理机构渠道
 	// 中间人可介绍业主
 	var r3 []map[string]interface{}
-	r3 = FindMiddleman([]string{pTmp.BuyerId}, req.PositionId, r3)
+	FindMiddleman(req.PositionId, []string{pTmp.BuyerId}, r3)
 	prListRes.Size_4 = int64(len(r3))
 	if req.ChannelType == "0" || req.ChannelType == "4" {
 		for _, m := range r3 {
@@ -124,7 +124,6 @@ func GetPrList(req *types.CoopHistoryReq) *PrListRes {
 				SourceType:   "middleman",
 				EntName:      common.ObjToString(m["b_name"]),
 				EntId:        common.ObjToString(m["b_id"]),
-				EntPerson:    common.ObjToString(m["personName"]),
 				Relationship: "业主的关系人",
 				BuyerId:      pTmp.BuyerId,
 			}
@@ -133,7 +132,7 @@ func GetPrList(req *types.CoopHistoryReq) *PrListRes {
 	}
 	// 关联单位
 	var r4 []map[string]interface{}
-	r4 = Findfirstparty([]string{pTmp.BuyerId}, r4)
+	Findfirstparty(req.PositionId, []string{pTmp.BuyerId}, r4, 0)
 	prListRes.Size_2 = int64(len(r4))
 	if req.ChannelType == "0" || req.ChannelType == "2" {
 		for _, m := range r4 {
@@ -141,7 +140,6 @@ func GetPrList(req *types.CoopHistoryReq) *PrListRes {
 				SourceType:   "sup_sub",
 				EntName:      common.ObjToString(m["b_name"]),
 				EntId:        common.ObjToString(m["b_id"]),
-				EntPerson:    common.ObjToString(m["personName"]),
 				Relationship: common.ObjToString(m["relationship"]),
 				BuyerId:      pTmp.BuyerId,
 			}
@@ -197,7 +195,7 @@ func GetWinnerData(scopeClass string, bid string) []AggStruct {
 	wh, newArgs := common.WhArgs(strings.Split(scopeClass, ","))
 	args = append(args, newArgs...)
 	rows, err1 := T.ClickhouseConn.Query(context.TODO(), `select distinct wr as name,wr_id as id from information.transaction_info_all ARRAY JOIN winner_id as wr_id,winner as wr
-			WHERE buyer_id IN (SELECT buyer_id from information.transaction_info_all WHERE has(winner_id,?) and buyer_id<>'') and wr_id<>? and LENGTH(winner)=LENGTH(winner_id) AND hasAny(topscopeclass,[`+wh+`])=0`, args...)
+			prewhere buyer_id IN (SELECT buyer_id from information.transaction_info_all prewhere has(winner_id,?) and buyer_id<>'') and wr_id<>? and LENGTH(winner)=LENGTH(winner_id) AND hasAny(topscopeclass,[`+wh+`])=0`, args...)
 	if err1 != nil {
 		logx.Error(err1)
 		return ass
@@ -238,7 +236,7 @@ func GetWinnerDataHz(buyerId string, winnerIds []string) map[string]AggStruct {
 	wh, newArgs := common.WhArgs(winnerIds)
 	args = append(args, newArgs...)
 	rows, err1 := T.ClickhouseConn.Query(context.TODO(), `select winner_id as id,sum(1) as sum,sum(project_money) as project_money,max(zbtime) as zbtime from information.transaction_info_all ARRAY JOIN winner_id
-			WHERE winner_id in(`+wh+`) and buyer_id=? group by winner_id`, args...)
+			prewhere winner_id in(`+wh+`) and buyer_id=? group by winner_id`, args...)
 	if err1 != nil {
 		logx.Error(err1)
 		return res
@@ -261,7 +259,7 @@ func GetWinnerDataHz(buyerId string, winnerIds []string) map[string]AggStruct {
 //代理机构
 func GetAgencyData(bid string) []AggStruct {
 	ass := []AggStruct{}
-	rows, err1 := T.ClickhouseConn.Query(context.TODO(), `select agency as name,agency_id as id,sum(1) as sum,sum(project_money) as project_money,max(zbtime) as zbtime from information.transaction_info_all where buyer_id=? and agency<>'' and agency_id<>'' GROUP by agency,agency_id`, bid)
+	rows, err1 := T.ClickhouseConn.Query(context.TODO(), `select agency as name,agency_id as id,sum(1) as sum,sum(project_money) as project_money,max(zbtime) as zbtime from information.transaction_info_all prewhere buyer_id=? and agency<>'' and agency_id<>'' GROUP by agency,agency_id`, bid)
 	if err1 != nil {
 		logx.Error(err1)
 		return ass
@@ -314,10 +312,10 @@ func LastTimeCoop(buyerId, ent, stype string) (bool, int64) {
 	zbtime := int64(0)
 	near := false
 	if stype == "adiffb" {
-		sql := `SELECT zbtime FROM information.transaction_info_all WHERE buyer_id = ? AND has(winner, ?) ORDER BY zbtime DESC LIMIT 1`
+		sql := `SELECT zbtime FROM information.transaction_info_all prewhere buyer_id = ? AND has(winner, ?) ORDER BY zbtime DESC LIMIT 1`
 		_ = T.ClickhouseConn.QueryRow(context.TODO(), sql, buyerId, ent).Scan(&zbtime)
 	} else if stype == "agency" {
-		sql := `SELECT zbtime FROM information.transaction_info_all WHERE buyer_id = ? AND agency = ? ORDER BY zbtime DESC LIMIT 1`
+		sql := `SELECT zbtime FROM information.transaction_info_all prewhere buyer_id = ? AND agency = ? ORDER BY zbtime DESC LIMIT 1`
 		_ = T.ClickhouseConn.QueryRow(context.TODO(), sql, buyerId, ent).Scan(&zbtime)
 	}
 	timestamp := time.Now().AddDate(-3, 0, 0).Unix()
@@ -377,7 +375,7 @@ func LastTimeCoopBath(positionId int64, buyerId string, winners, agencys []strin
 		if err == nil {
 			json.Unmarshal(*wb, &adiffb)
 		} else {
-			sql := `SELECT winner_one,max(zbtime) FROM information.transaction_info_all ARRAY JOIN winner AS winner_one WHERE buyer_id=? AND hasAny(winner,[%s])) group by winner_one`
+			sql := `SELECT winner_one,max(zbtime) FROM information.transaction_info_all ARRAY JOIN winner AS winner_one prewhere buyer_id=? AND hasAny(winner,[%s])) group by winner_one`
 			wns := []string{}
 			for _, v := range winners {
 				wns = append(wns, v)
@@ -398,7 +396,7 @@ func LastTimeCoopBath(positionId int64, buyerId string, winners, agencys []strin
 		if err == nil {
 			json.Unmarshal(*wb, &agency)
 		} else {
-			sql := `SELECT agency,max(zbtime) FROM information.transaction_info_all WHERE buyer_id=? AND agency in (%s) group by agency`
+			sql := `SELECT agency,max(zbtime) FROM information.transaction_info_all prewhere buyer_id=? AND agency in (%s) group by agency`
 			acs := []string{}
 			for _, v := range agencys {
 				acs = append(acs, v)

+ 5 - 5
api/internal/service/initNetwork.go

@@ -38,7 +38,7 @@ func (i *InitNetwork) Init() {
 	ids := []string{}
 	//①业主人脉:当前企业曾经合作过物业项目的采购单位的联系人作为业主人脉
 	func() {
-		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT buyer,buyer_id from information.transaction_info_all where has(winner,?)`, i.EntName)
+		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT buyer,buyer_id from information.transaction_info_all prewhere has(winner,?)`, i.EntName)
 		if err != nil {
 			logx.Error(err)
 			return
@@ -72,7 +72,7 @@ func (i *InitNetwork) Init() {
 		wh, newArgs := util.WhArgs(strings.Split(i.BusinessType, ","))
 		args = append(args, newArgs...)
 		args = append(args, NetworkCom.ProjectYearLimit())
-		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT wr,wr_id from information.transaction_info_all ARRAY JOIN winner_id as wr_id,winner as wr WHERE buyer_id IN (SELECT buyer_id from information.transaction_info_all WHERE has(winner,?) and buyer_id<>'') and wr<>? and LENGTH(winner)=LENGTH(winner_id) and hasAny(topscopeclass,[`+wh+`])=0 AND zbtime>?`, args...)
+		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT wr,wr_id from information.transaction_info_all ARRAY JOIN winner_id as wr_id,winner as wr prewhere buyer_id IN (SELECT buyer_id from information.transaction_info_all prewhere has(winner,?) and buyer_id<>'') and wr<>? and LENGTH(winner)=LENGTH(winner_id) and hasAny(topscopeclass,[`+wh+`])=0 AND zbtime>?`, args...)
 		if err != nil {
 			logx.Error(err)
 			return
@@ -99,7 +99,7 @@ func (i *InitNetwork) Init() {
 	}()
 	//③招标代理机构(人脉):当前企业曾经合作过的招标代理机构联系人信息
 	func() {
-		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT agency,agency_id from information.transaction_info_all where buyer=? or has(winner,?)`, i.EntName, i.EntName)
+		rows, err := ClickhouseConn.Query(context.Background(), `select DISTINCT agency,agency_id from information.transaction_info_all prewhere buyer=? or has(winner,?)`, i.EntName, i.EntName)
 		if err != nil {
 			logx.Error(err)
 			return
@@ -182,7 +182,7 @@ func (i *InitNetwork) GetCompanyId(ids []string) map[string]string {
 		return m
 	}
 	wh, args := util.WhArgs(ids)
-	rows, err := ClickhouseConn.Query(context.Background(), `select id,company_id from information.ent_info where id in(`+wh+`)`, args...)
+	rows, err := ClickhouseConn.Query(context.Background(), `select id,company_id from information.ent_info prewhere id in(`+wh+`)`, args...)
 	if err != nil {
 		logx.Error(err)
 		return m
@@ -208,7 +208,7 @@ func (i *InitNetwork) GetContactInfo(ids []string) map[string]*ContactInfo {
 		return m
 	}
 	wh, args := util.WhArgs(ids)
-	rows, err := ClickhouseConn.Query(context.Background(), `select id,phone,name from information.ent_contact where id in (`+wh+`)`, args...)
+	rows, err := ClickhouseConn.Query(context.Background(), `select id,phone,name from information.ent_contact prewhere id in (`+wh+`)`, args...)
 	if err != nil {
 		logx.Error(err)
 		return m

+ 10 - 10
api/internal/service/network.go

@@ -252,7 +252,7 @@ func (n *network) Associate(in *types.AssociateReq) (reply *types.Reply) {
 			args := []interface{}{in.EntName}
 			wh, newArgs := WhArgs(businessType)
 			args = append(args, newArgs...)
-			q := `select DISTINCT winner_id,winner from information.transaction_info_all where buyer_id in (select buyer_id from information.transaction_info_all where has(winner, ?) and buyer_id<>'') and hasAny(topscopeclass,[` + wh + `])=0 ORDER BY project_id`
+			q := `select DISTINCT winner_id,winner from information.transaction_info_all prewhere buyer_id in (select buyer_id from information.transaction_info_all prewhere has(winner, ?) and buyer_id<>'') and hasAny(topscopeclass,[` + wh + `])=0 ORDER BY project_id`
 			rows, err := ClickhouseConn.Query(context.Background(), q, args...)
 			if err != nil {
 				logx.Error(err)
@@ -989,7 +989,7 @@ func (n *network) FirstpartyNetwork(name string, values []string) map[string][]*
 	q := `select DISTINCT a.a_id,a.b_id as company_id,a.b_name as company_name,b.name from information.ent_map_code a 
 				inner join information.ent_code b on (a.a_id in (` + wh + `) and b.pcode in ('0100','0200') and a.code=b.code)`
 	if name != "" {
-		q += ` where c.company_name like ?`
+		q += ` prewhere c.company_name like ?`
 		args = append(args, "%"+name+"%")
 	}
 	q += ` order by b.name,a.a_id,a.b_name`
@@ -1035,7 +1035,7 @@ func (n *network) Introduce_Firstparty(fpn map[string][]*firstpartyNetwork, busi
 		return result
 	}
 	wh, args := WhArgs(values)
-	q := `select buyer_id,count(project_id) AS project_count,sum(project_money) AS project_amount,groupUniqArray(project_id) from information.transaction_info_all where buyer_id in (` + wh + `) and zbtime>? and project_bidstatus>1`
+	q := `select buyer_id,count(project_id) AS project_count,sum(project_money) AS project_amount,groupUniqArray(project_id) from information.transaction_info_all prewhere buyer_id in (` + wh + `) and zbtime>? and project_bidstatus>1`
 	args = append(args, NetworkCom.ProjectYearLimit())
 	if len(businessType) > 0 {
 		newWh, newArgs := WhArgs(businessType)
@@ -1096,7 +1096,7 @@ func (n *network) Introduce_Supplier(values []string, businessType []string) map
 	repeat := map[string]bool{}
 	whRepeat := map[string]map[string]bool{}
 	buyers := []string{}
-	q := `select winner_id,buyer_id,buyer from information.transaction_info_all where hasAny(winner_id,[` + wh + `]) and buyer_id<>''`
+	q := `select winner_id,buyer_id,buyer from information.transaction_info_all prewhere hasAny(winner_id,[` + wh + `]) and buyer_id<>''`
 	rows, err := ClickhouseConn.Query(context.Background(), q, args...)
 	if err != nil {
 		logx.Error(err)
@@ -1146,7 +1146,7 @@ func (n *network) Introduce_Agency(values []string, businessType []string) map[s
 		return map[string]*projectInfo{}
 	}
 	wh, args := WhArgs(values)
-	q := `select DISTINCT agency_id,buyer_id,buyer from information.transaction_info_all where agency_id in (` + wh + `) and buyer_id<>''`
+	q := `select DISTINCT agency_id,buyer_id,buyer from information.transaction_info_all prewhere agency_id in (` + wh + `) and buyer_id<>''`
 	rows, err := ClickhouseConn.Query(context.Background(), q, args...)
 	if err != nil {
 		logx.Error(err)
@@ -1194,7 +1194,7 @@ func (n *network) Introduce_Middleman_Project(values []string, businessType []st
 		return result
 	}
 	wh, args := WhArgs(values)
-	q := `select DISTINCT project_id,project_money from information.transaction_info_all where project_id in (` + wh + `)`
+	q := `select DISTINCT project_id,project_money from information.transaction_info_all prewhere project_id in (` + wh + `)`
 	if len(businessType) > 0 {
 		newWh, newArgs := WhArgs(businessType)
 		q += ` and hasAny(topscopeclass,[` + newWh + `])`
@@ -1266,7 +1266,7 @@ func (n *network) GetQyxyId(ids []string) map[string]string {
 		return m
 	}
 	wh, args := WhArgs(ids)
-	q := `select id,company_id from information.ent_info where id in (` + wh + `)`
+	q := `select id,company_id from information.ent_info prewhere id in (` + wh + `)`
 	rows, err := ClickhouseConn.Query(context.Background(), q, args...)
 	if err != nil {
 		logx.Error(err)
@@ -1314,7 +1314,7 @@ func (n *network) BuyerProjectInfoBatch(ids []string, businessType []string, vm
 		return
 	}
 	wh, args := WhArgs(ids)
-	q := `select buyer_id,count(DISTINCT project_id) AS project_count,sum(project_money) AS project_amount,groupUniqArray(project_id) from information.transaction_info_all where buyer_id in (` + wh + `) and zbtime>? and project_bidstatus>1`
+	q := `select buyer_id,count(DISTINCT project_id) AS project_count,sum(project_money) AS project_amount,groupUniqArray(project_id) from information.transaction_info_all prewhere buyer_id in (` + wh + `) and zbtime>? and project_bidstatus>1`
 	args = append(args, NetworkCom.ProjectYearLimit())
 	if len(businessType) > 0 {
 		newWh, newArgs := WhArgs(businessType)
@@ -1365,7 +1365,7 @@ func (n *network) TjProject(agencyIds, winnerIds []string, vbs map[string][]*idN
 	}
 	yearLimit := NetworkCom.ProjectYearLimit()
 	allArgs := []interface{}{}
-	q := `select buyer_id,count(DISTINCT project_id) AS project_count,sum(project_money) AS project_amount,groupUniqArray(project_id) from information.transaction_info_all where buyer_id in (select DISTINCT buyer_id from information.transaction_info_all where `
+	q := `select buyer_id,count(DISTINCT project_id) AS project_count,sum(project_money) AS project_amount,groupUniqArray(project_id) from information.transaction_info_all prewhere buyer_id in (select DISTINCT buyer_id from information.transaction_info_all prewhere `
 	if len(agencyIds) > 0 {
 		wh, args := WhArgs(agencyIds)
 		allArgs = append(allArgs, args...)
@@ -1452,7 +1452,7 @@ func (n *network) MakeProjectInfo(agencyIds, winnerIds []string, vbs map[string]
 func (n *network) AllIntroduceOwner(positionId int64, sqlAppend1, sqlAppend2 string, args []interface{}, isTjProject bool, businessType []string) *introduceOwnerProject {
 	logx.Info(positionId, " AllIntroduceOwner start 。。。")
 	q := `select a.id,a.company_id,a.company_name,a.qyxy_id,a.itype,a.contact_person as person,a.contact_phone as phone,count(DISTINCT if(b.itype=1,b.relate_id,null)) as buyer_count,count(DISTINCT if(b.itype=2,b.relate_id,null)) as project_count,GROUP_CONCAT(IF(b.itype=1,b.relate_id,NULL)) AS relate_buyer_id,GROUP_CONCAT(IF(b.itype=1,b.relate_name,NULL)) AS relate_buyer_name,GROUP_CONCAT(IF(b.itype=2,b.relate_id,NULL)) AS relate_project_id,a.create_time from crm.connection a 
-		left join crm.connection_introduce b on (a.position_id=? and b.position_id=? and a.id=b.connection_id) where a.position_id=?` + sqlAppend1 + ` GROUP BY a.id order by a.create_time desc` + sqlAppend2
+		left join crm.connection_introduce b on (a.position_id=? and b.position_id=? and a.id=b.connection_id) prewhere a.position_id=?` + sqlAppend1 + ` GROUP BY a.id order by a.create_time desc` + sqlAppend2
 	listTemp := CrmMysql.SelectBySql(q, args...)
 	firstparty_array, supplier_array, adiffb_array, agency_array, middleman_buyer_array, middleman_project_array := []string{}, []string{}, []string{}, []string{}, []string{}, []string{}
 	myNetworks := []*myNetwork{}

+ 223 - 253
api/internal/service/owner.go

@@ -157,7 +157,7 @@ func (t *OwnerService) OwnerlList() *OwnerlListRes {
 		}
 		// 可介绍业主人脉处理
 		logx.Info(t.PositionId, " ConnectionsHandle start 。。。")
-		routeList := ConnectionsHandle(buyerIdArr, t.PositionId, false)
+		routeList := ConnectionsHandle(buyerIdArr, t.PositionId, 1)
 		logx.Info(t.PositionId, " ConnectionsHandle over 。。。")
 		updateReturnDataWithRoutes(olr.ReturnData, routeList)
 	}
@@ -199,198 +199,155 @@ func updateReturnDataWithRoutes(returnData []BuyerProject, routeList []map[strin
 }
 
 // 可介绍业主人脉列表
-func ConnectionsHandle(buyerArr []string, positionId int64, isAll bool) []map[string]interface{} {
+func ConnectionsHandle(buyerArr []string, positionId int64, contactCount int) []map[string]interface{} {
 	returnData := []map[string]interface{}{}
-	a1 := time.Now().Unix()
 	//中间人
-	returnData = FindMiddleman(buyerArr, positionId, returnData)
-	a2 := time.Now().Unix()
-	fmt.Println("中间人", a2-a1)
-	if isAll && len(returnData) > 0 {
-		return returnData
-	}
+	logx.Info(positionId, " ConnectionsHandle start 。。。")
+	FindMiddleman(positionId, buyerArr, returnData)
+	logx.Info(positionId, " FindMiddleman over 。。。")
 	//采购单位 投资关系  管辖关系
 	//采购单位
-	a3 := time.Now().Unix()
-	returnData = Findfirstparty(buyerArr, returnData)
-	a4 := time.Now().Unix()
-	fmt.Println("采购单位", a4-a3)
-	if isAll && len(returnData) > 0 {
-		return returnData
-	}
-	a5 := time.Now().Unix()
-	returnData = append(returnData, Findwinner(buyerArr)...)
-	a6 := time.Now().Unix()
-	logx.Info("供应商", a6-a5)
+	Findfirstparty(positionId, buyerArr, returnData, contactCount)
+	logx.Info(positionId, " Findfirstparty over 。。。")
+	returnData = append(returnData, Findwinner(positionId, buyerArr, contactCount)...)
+	logx.Info(positionId, " Findwinner over 。。。")
 	return returnData
 }
 
 // 供应商处理
-func Findwinner(buyerArr []string) []map[string]interface{} {
+func Findwinner(positionId int64, buyerArr []string, contactCount int) []map[string]interface{} {
 	returnData := []map[string]interface{}{}
 	if len(buyerArr) == 0 {
 		return returnData
 	}
 	wh1, args1 := common.WhArgs(buyerArr)
-	args1 = append(args1, args1...)
 	//供应商  采购单位 供应商     招标代理机构  采购单位  招标代理机构  需要计算合作次数
-	winnerSql := `select zbtime,project_id,project_name,buyer_id,buyer,wr_id,wr,agency_id,agency from transaction_info_all ARRAY JOIN winner_id as wr_id,winner as wr where buyer_id in (` + wh1 + `) and LENGTH(winner)=LENGTH(winner_id) order by zbtime DESC,project_id DESC`
-	logx.Info("Findwinner 合作 sql ", winnerSql, args1)
+	winnerSql := `select zbtime,project_id,project_name,buyer_id,buyer,wr_id,wr,agency_id,agency from transaction_info_all ARRAY JOIN winner_id as wr_id,winner as wr prewhere buyer_id in (` + wh1 + `) and LENGTH(winner)=LENGTH(winner_id) order by zbtime DESC,project_id DESC`
+	logx.Info(positionId, " Findwinner 合作 sql ", winnerSql, args1)
 	winnerArr := SupplierFindConnectionsHandle(winnerSql, args1...)
-	if winnerArr != nil && len(winnerArr) > 0 {
-		//企业联系人处理
-		entIdArr := []string{}
-		entIdMap := map[string]bool{}
-		for _, v := range winnerArr {
-			if v.Winner_id != "" {
-				if !entIdMap[v.Winner_id] {
-					entIdArr = append(entIdArr, v.Winner_id)
-				}
-				entIdMap[v.Winner_id] = true
-			}
-			if v.Agency_id != "" {
-				if !entIdMap[v.Agency_id] {
-					entIdArr = append(entIdArr, v.Agency_id)
-				}
-				entIdMap[v.Agency_id] = true
-			}
-		}
-		personMap := map[string]string{}
-		if len(entIdArr) > 0 {
-			wh2, args2 := common.WhArgs(entIdArr)
-			personSql := `select id,name as personName from ent_contact where id in (` + wh2 + `) ORDER by name`
-			logx.Info("Findwinner 联系人 sql ", personSql, args2)
-			personArr := PersonFindConnectionsHandle(personSql, args2...)
-			//联系人处理
-			for _, v := range personArr {
-				personMap[v.Id] = v.PersonName
-			}
+	if winnerArr == nil || len(winnerArr) == 0 {
+		return returnData
+	}
+	winnerMap := map[string]map[string]interface{}{}
+	agencyMap := map[string]map[string]interface{}{}
+	agencyIdMap := map[string]bool{}
+	for _, m := range winnerArr {
+		if m.Winner_id == "" && m.Agency_id == "" {
+			continue
 		}
-		winnerMap := map[string]map[string]interface{}{}
-		agencyMap := map[string]map[string]interface{}{}
-		agencyIdMap := map[string]bool{}
-		for _, m := range winnerArr {
-			if m.Winner_id == "" && m.Agency_id == "" {
-				continue
-			}
-			projectId := encrypt.EncodeArticleId2ByCheck(m.Project_id)
-			projectName := m.Project_name
-			zbtime := m.Zbtime
-			if m.Winner_id != "" {
-				key := fmt.Sprintf("%s_%s", m.Buyer_id, m.Winner_id)
-				if _, ok := winnerMap[key]; ok {
-					data := winnerMap[key]
-					data["count"] = gconv.Int64(data["count"]) + 1
-					dataList := gconv.Maps(data["list"])
-					dataList = append(dataList, map[string]interface{}{
-						"zbtime":      zbtime,
-						"projectId":   projectId,
-						"projectName": projectName,
-					})
-					data["list"] = dataList
-					data["zbtime"] = zbtime
-					winnerMap[key] = data
-				} else {
-					winnerMap[key] = map[string]interface{}{
-						"b_id":       m.Winner_id,
-						"b_name":     m.Winner,
-						"a_name":     m.Buyer,
-						"a_id":       m.Buyer_id,
-						"sourceType": "supplier",
-						"zbtime":     zbtime,
-						"personName": personMap[m.Winner_id],
-						"count":      1,
-						"list": []map[string]interface{}{
-							{
-								"zbtime":      zbtime,
-								"entName":     m.Winner,
-								"projectId":   projectId,
-								"projectName": projectName,
-							},
+		projectId := encrypt.EncodeArticleId2ByCheck(m.Project_id)
+		projectName := m.Project_name
+		zbtime := m.Zbtime
+		if m.Winner_id != "" {
+			key := fmt.Sprintf("%s_%s", m.Buyer_id, m.Winner_id)
+			if _, ok := winnerMap[key]; ok {
+				data := winnerMap[key]
+				data["count"] = gconv.Int64(data["count"]) + 1
+				dataList := gconv.Maps(data["list"])
+				dataList = append(dataList, map[string]interface{}{
+					"zbtime":      zbtime,
+					"projectId":   projectId,
+					"projectName": projectName,
+				})
+				data["list"] = dataList
+				data["zbtime"] = zbtime
+				winnerMap[key] = data
+			} else {
+				winnerMap[key] = map[string]interface{}{
+					"b_id":       m.Winner_id,
+					"b_name":     m.Winner,
+					"a_name":     m.Buyer,
+					"a_id":       m.Buyer_id,
+					"sourceType": "supplier",
+					"zbtime":     zbtime,
+					"count":      1,
+					"list": []map[string]interface{}{
+						{
+							"zbtime":      zbtime,
+							"entName":     m.Winner,
+							"projectId":   projectId,
+							"projectName": projectName,
 						},
-					}
+					},
 				}
 			}
-			if m.Agency_id != "" {
-				key := fmt.Sprintf("%s_%s", m.Buyer_id, m.Agency_id)
-				if _, ok := agencyIdMap[key]; ok {
-					data := agencyMap[key]
-					data["count"] = gconv.Int64(data["count"]) + 1
-					dataList := gconv.Maps(data["list"])
-					dataList = append(dataList, map[string]interface{}{
-						"zbtime":      zbtime,
-						"projectId":   projectId,
-						"projectName": projectName,
-					})
-					data["list"] = dataList
-					data["zbtime"] = zbtime
-					agencyMap[key] = data
-				} else {
-					agencyIdMap[key] = true
-					agencyMap[key] = map[string]interface{}{
-						"b_id":       m.Agency_id,
-						"b_name":     m.Agency,
-						"a_name":     m.Buyer,
-						"a_id":       m.Buyer_id,
-						"sourceType": "agency",
-						"count":      1,
-						"zbtime":     zbtime,
-						"personName": gconv.String(personMap[m.Agency_id]),
-						"list": []map[string]interface{}{
-							{
-								"zbtime":      zbtime,
-								"projectId":   projectId,
-								"projectName": projectName,
-							},
+		}
+		if m.Agency_id != "" {
+			key := fmt.Sprintf("%s_%s", m.Buyer_id, m.Agency_id)
+			if _, ok := agencyIdMap[key]; ok {
+				data := agencyMap[key]
+				data["count"] = gconv.Int64(data["count"]) + 1
+				dataList := gconv.Maps(data["list"])
+				dataList = append(dataList, map[string]interface{}{
+					"zbtime":      zbtime,
+					"projectId":   projectId,
+					"projectName": projectName,
+				})
+				data["list"] = dataList
+				data["zbtime"] = zbtime
+				agencyMap[key] = data
+			} else {
+				agencyIdMap[key] = true
+				agencyMap[key] = map[string]interface{}{
+					"b_id":       m.Agency_id,
+					"b_name":     m.Agency,
+					"a_name":     m.Buyer,
+					"a_id":       m.Buyer_id,
+					"sourceType": "agency",
+					"count":      1,
+					"zbtime":     zbtime,
+					"list": []map[string]interface{}{
+						{
+							"zbtime":      zbtime,
+							"projectId":   projectId,
+							"projectName": projectName,
 						},
-					}
+					},
 				}
 			}
-
-		}
-		for _, m := range winnerMap {
-			returnData = append(returnData, map[string]interface{}{
-				"b_id":         gconv.String(m["b_id"]),
-				"b_name":       gconv.String(m["b_name"]),
-				"a_name":       gconv.String(m["a_name"]),
-				"a_id":         gconv.String(m["a_id"]),
-				"sourceType":   gconv.String(m["sourceType"]),
-				"relationship": gconv.String(m["relationship"]),
-				"count":        gconv.Int64(m["count"]),
-				"personName":   gconv.String(m["personName"]),
-				"list":         m["list"],
-				"zbtime":       m["zbtime"],
-			})
-		}
-		for _, m := range agencyMap {
-			returnData = append(returnData, map[string]interface{}{
-				"b_id":         gconv.String(m["b_id"]),
-				"b_name":       gconv.String(m["b_name"]),
-				"a_name":       gconv.String(m["a_name"]),
-				"a_id":         gconv.String(m["a_id"]),
-				"sourceType":   gconv.String(m["sourceType"]),
-				"relationship": gconv.String(m["relationship"]),
-				"personName":   gconv.String(m["personName"]),
-				"count":        gconv.Int64(m["count"]),
-				"list":         m["list"],
-				"zbtime":       m["zbtime"],
-			})
 		}
 	}
+	for _, m := range winnerMap {
+		returnData = append(returnData, map[string]interface{}{
+			"b_id":         gconv.String(m["b_id"]),
+			"b_name":       gconv.String(m["b_name"]),
+			"a_name":       gconv.String(m["a_name"]),
+			"a_id":         gconv.String(m["a_id"]),
+			"sourceType":   gconv.String(m["sourceType"]),
+			"relationship": gconv.String(m["relationship"]),
+			"count":        gconv.Int64(m["count"]),
+			"personName":   gconv.String(m["personName"]),
+			"list":         m["list"],
+			"zbtime":       m["zbtime"],
+		})
+	}
+	for _, m := range agencyMap {
+		returnData = append(returnData, map[string]interface{}{
+			"b_id":         gconv.String(m["b_id"]),
+			"b_name":       gconv.String(m["b_name"]),
+			"a_name":       gconv.String(m["a_name"]),
+			"a_id":         gconv.String(m["a_id"]),
+			"sourceType":   gconv.String(m["sourceType"]),
+			"relationship": gconv.String(m["relationship"]),
+			"personName":   gconv.String(m["personName"]),
+			"count":        gconv.Int64(m["count"]),
+			"list":         m["list"],
+			"zbtime":       m["zbtime"],
+		})
+	}
 	sort.Slice(returnData, func(i, j int) bool {
-		aa := fmt.Sprintf("%s%s", gconv.String(returnData[i]["zbtime"]),
-			gconv.String(returnData[i]["b_id"]))
-		bb := fmt.Sprintf("%s%s", gconv.String(returnData[j]["zbtime"]),
-			gconv.String(returnData[j]["b_id"]))
+		aa := fmt.Sprintf("%s%s", gconv.String(returnData[i]["zbtime"]), gconv.String(returnData[i]["b_id"]))
+		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
 }
 
 // 中间人查询
-func FindMiddleman(buyerArr []string, positionId int64, returnData []map[string]interface{}) []map[string]interface{} {
+func FindMiddleman(positionId int64, buyerArr []string, returnData []map[string]interface{}) {
 	if len(buyerArr) == 0 {
-		return returnData
+		return
 	}
 	//中间人  作为可介绍业主    企业名称
 	wh, args := common.WhArgs(buyerArr)
@@ -412,13 +369,13 @@ func FindMiddleman(buyerArr []string, positionId int64, returnData []map[string]
 			"personName":   gconv.String(v["contact_person"]),
 		})
 	}
-	return returnData
+	return
 }
 
 // 企业之间关系查询
-func Findfirstparty(buyerArr []string, returnData []map[string]interface{}) []map[string]interface{} {
+func Findfirstparty(positionId int64, buyerArr []string, returnData []map[string]interface{}, contactCount int) {
 	if len(buyerArr) == 0 {
-		return returnData
+		return
 	}
 	wh1, args1 := common.WhArgs(buyerArr)
 	args1 = append(args1, args1...)
@@ -431,7 +388,7 @@ func Findfirstparty(buyerArr []string, returnData []map[string]interface{}) []ma
 			a.code as code
 		from
 			ent_map_code a
-		where
+		prewhere
 			a.a_id in (` + wh1 + `)
 			and a.code in('0101', '0201')
 			UNION  ALL
@@ -444,86 +401,66 @@ func Findfirstparty(buyerArr []string, returnData []map[string]interface{}) []ma
 			a.code as code
 		from
 			ent_map_code a
-		where
+		prewhere
 			a.b_id in (` + wh1 + `)
 			and a.code in('0101', '0201')`
 	relationshipArr := BuyerFindConnectionsHandle(buyerSql, args1...)
-	if relationshipArr != nil && len(relationshipArr) > 0 {
-		entIdArr := []string{}
-		for _, v := range relationshipArr {
-			if v.Bid != "" {
-				entIdArr = append(entIdArr, v.Bid)
+	if relationshipArr == nil || len(relationshipArr) == 0 {
+		return
+	}
+	for _, v := range relationshipArr {
+		code := v.Code
+		status := v.Status
+		if gconv.String(status) == "111" {
+			//key := fmt.Sprintf("%s_%s", a_id, b_id)
+			switch code {
+			case "0101": //管辖关系
+				returnData = append(returnData, map[string]interface{}{
+					"b_id":         v.Bid,
+					"b_name":       v.Bname,
+					"a_name":       v.Aname,
+					"a_id":         v.Aid,
+					"sourceType":   "firstparty",
+					"relationship": "业主的下级机构",
+				})
+			case "0201": //投资关系
+				returnData = append(returnData, map[string]interface{}{
+					"b_id":         v.Bid,
+					"b_name":       v.Bname,
+					"a_name":       v.Aname,
+					"a_id":         v.Aid,
+					"sourceType":   "firstparty",
+					"relationship": "业主的股东",
+				})
 			}
 		}
-		personMap := map[string]string{}
-		if len(entIdArr) > 0 {
-			wh2, args2 := common.WhArgs(entIdArr)
-			personSql := `select id,name as personName from ent_contact where id in (` + wh2 + `) ORDER by name`
-			personArr := PersonFindConnectionsHandle(personSql, args2...)
-			//联系人处理
-			for _, v := range personArr {
-				personMap[v.Id] = v.PersonName
+		if gconv.String(status) == "222" {
+			//key := fmt.Sprintf("%s_%s", b_id, a_id)
+			if code == "0101" {
+				//"0101":管辖关系
+				returnData = append(returnData, map[string]interface{}{
+					"b_id":         v.Bid,
+					"b_name":       v.Bname,
+					"a_name":       v.Aname,
+					"a_id":         v.Aid,
+					"sourceType":   "firstparty",
+					"relationship": "业主的上级机构",
+				})
 			}
-		}
-		for _, v := range relationshipArr {
-			code := v.Code
-			status := v.Status
-			if gconv.String(status) == "111" {
-				//key := fmt.Sprintf("%s_%s", a_id, b_id)
-				switch code {
-				case "0101": //管辖关系
-					returnData = append(returnData, map[string]interface{}{
-						"b_id":         v.Bid,
-						"b_name":       v.Bname,
-						"a_name":       v.Aname,
-						"a_id":         v.Aid,
-						"sourceType":   "firstparty",
-						"relationship": "业主的下级机构",
-						"personName":   gconv.String(personMap[v.Bid]),
-					})
-
-				case "0201": //投资关系
-					returnData = append(returnData, map[string]interface{}{
-						"b_id":         v.Bid,
-						"b_name":       v.Bname,
-						"a_name":       v.Aname,
-						"a_id":         v.Aid,
-						"sourceType":   "firstparty",
-						"relationship": "业主的股东",
-						"personName":   gconv.String(personMap[v.Bid]),
-					})
-				}
-			}
-			if gconv.String(status) == "222" {
-				//key := fmt.Sprintf("%s_%s", b_id, a_id)
-				if code == "0101" {
-					//"0101":管辖关系
-					returnData = append(returnData, map[string]interface{}{
-						"b_id":         v.Bid,
-						"b_name":       v.Bname,
-						"a_name":       v.Aname,
-						"a_id":         v.Aid,
-						"sourceType":   "firstparty",
-						"relationship": "业主的上级机构",
-						"personName":   gconv.String(personMap[v.Bid]),
-					})
-				}
-				if code == "0201" {
-					returnData = append(returnData, map[string]interface{}{
-						"b_id":         v.Bid,
-						"b_name":       v.Bname,
-						"a_name":       v.Aname,
-						"a_id":         v.Aid,
-						"sourceType":   "firstparty",
-						"relationship": "业主的股东",
-						"personName":   gconv.String(personMap[v.Bid]),
-					})
-				}
-
+			if code == "0201" {
+				returnData = append(returnData, map[string]interface{}{
+					"b_id":         v.Bid,
+					"b_name":       v.Bname,
+					"a_name":       v.Aname,
+					"a_id":         v.Aid,
+					"sourceType":   "firstparty",
+					"relationship": "业主的股东",
+				})
 			}
 		}
 	}
-	return returnData
+	PersonFindConnectionsHandle(positionId, returnData, contactCount)
+	return
 }
 
 // 采购单位和项目合并
@@ -704,7 +641,7 @@ func (t *OwnerService) ProjectHandle(buyerArr []string, businessStr string, moni
 		allArgs = append(allArgs, args...)
 	}
 	if len(ors2) > 0 {
-		ors1 = append(ors1, `(buyer_id in (select DISTINCT buyer_id from transaction_info_all where (`+strings.Join(ors2, " or ")+`) and buyer_id<>''))`)
+		ors1 = append(ors1, `(buyer_id in (select DISTINCT buyer_id from transaction_info_all prewhere (`+strings.Join(ors2, " or ")+`) and buyer_id<>''))`)
 	}
 	allArgs = append(allArgs, NetworkCom.ProjectYearLimit())
 	ands := []string{}
@@ -718,7 +655,7 @@ func (t *OwnerService) ProjectHandle(buyerArr []string, businessStr string, moni
 		ands = append(ands, `area in (`+wh+`)`)
 		allArgs = append(allArgs, args...)
 	}
-	sqlStr += " where (" + strings.Join(ors1, " or ") + ") and zbtime>?"
+	sqlStr += " prewhere (" + strings.Join(ors1, " or ") + ") and zbtime>?"
 	if len(ands) > 0 {
 		sqlStr += " and " + strings.Join(ands, " and ")
 	}
@@ -758,9 +695,9 @@ func (t *OwnerService) ProjectHandle(buyerArr []string, businessStr string, moni
 			"buyerName": buyerName,
 		}
 	}
-	logx.Info(t.PositionId, " ProjectHandle sql over 。。。", sqlStr, allArgs)
+	logx.Info(t.PositionId, " ProjectHandle sql over 。。。")
 	count := T.NetworkCom.Count(countSql, allArgs...)
-	logx.Info(t.PositionId, " ProjectHandle count over 。。。", sqlStr, allArgs)
+	logx.Info(t.PositionId, " ProjectHandle count over 。。。")
 	return projectMap, count
 }
 
@@ -837,18 +774,51 @@ func BuyerFindConnectionsHandle(sqlStr string, args ...interface{}) []Connection
 	}
 	return returnData
 }
-func PersonFindConnectionsHandle(sqlStr string, args ...interface{}) []PersonEntity {
-	returnData := []PersonEntity{}
-	rows, err := ClickhouseConn.Query(context.Background(), sqlStr, args...)
-	if err != nil {
-		logx.Error("查询失败", sqlStr, err)
+func PersonFindConnectionsHandle(positionId int64, returnData []map[string]interface{}, 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 rows.Next() {
-		data := PersonEntity{}
-		rows.ScanStruct(&data)
-		returnData = append(returnData, data)
+	personMap := map[string]string{}
+	if len(entIdArr) > 0 {
+		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{}
+		rows, err := ClickhouseConn.Query(context.Background(), personSql, args2...)
+		if err != nil {
+			logx.Error("查询失败", personSql, err)
+		}
+		for rows.Next() {
+			data := PersonEntity{}
+			rows.ScanStruct(&data)
+			returnData = append(returnData, data)
+		}
+		//联系人处理
+		for _, v := range returnData {
+			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
+		}
 	}
-	return returnData
 }
 
 // 供应商
@@ -904,7 +874,7 @@ func (t *OwnerService) OwnerRoute() []map[string]interface{} {
 	if t.BuyerId == "" {
 		return []map[string]interface{}{}
 	}
-	routeList := ConnectionsHandle([]string{t.BuyerId}, t.PositionId, false)
+	routeList := ConnectionsHandle([]string{t.BuyerId}, t.PositionId, -1)
 	for i, routeMap := range routeList {
 		sourceType := gconv.String(routeMap["sourceType"])
 		if sourceType == "agency" || sourceType == "supplier" {
@@ -932,11 +902,11 @@ func (t *OwnerService) OwnerCooperate() []map[string]interface{} {
 			transaction_info_all     
 		ARRAY 
 		JOIN winner_id  as  winnerId  
-		where  buyer_id= '%s' and  winnerId='%s' order by  zbtime DESC,project_id DESC `, t.BuyerId, t.WinnerId)
+		prewhere  buyer_id= '%s' and  winnerId='%s' order by  zbtime DESC,project_id DESC `, t.BuyerId, t.WinnerId)
 		dataArr = TimeFindConnectionsHandle(supplierSql)
 	} else if t.CooperateType == "agency" {
 		//代理机构
-		agentSql := fmt.Sprintf(`select  zbtime,project_id,project_name  from   transaction_info_all  where  buyer_id ='%s' and  agency_id ='%s' order by  zbtime DESC,project_id DESC   `, t.BuyerId, t.WinnerId)
+		agentSql := fmt.Sprintf(`select  zbtime,project_id,project_name  from   transaction_info_all  prewhere  buyer_id ='%s' and  agency_id ='%s' order by  zbtime DESC,project_id DESC   `, t.BuyerId, t.WinnerId)
 		dataArr = TimeFindConnectionsHandle(agentSql)
 	}
 	if dataArr != nil && len(dataArr) > 0 {

+ 6 - 5
api/internal/service/plistService.go

@@ -20,7 +20,7 @@ import (
 )
 
 const (
-	sql_1                    = `SELECT buyer_id, count(1) as count FROM information.transaction_info_all WHERE buyer_id in (%s) GROUP BY buyer_id`
+	sql_1                    = `SELECT buyer_id, count(1) as count FROM information.transaction_info_all prewhere buyer_id in (%s) GROUP BY buyer_id`
 	sql_2                    = `SELECT relate_id, is_handle, is_ignore, is_create FROM crm.connection_status WHERE position_id = ? AND itype = 2`
 	sql_3                    = `SELECT * FROM crm.connection WHERE company_id in (%s) AND status = 1`
 	sql_4                    = `SELECT id, s_id FROM base_service.follow_project_monitor WHERE s_userid = ?`
@@ -207,7 +207,7 @@ func getQuerySql(req *types.ProjectListReq, plist []string, businessStr string)
 		allArgs = append(allArgs, args...)
 	}
 	if len(ors2) > 0 {
-		ors1 = append(ors1, `(buyer_id in (select DISTINCT buyer_id from transaction_info_all where (`+strings.Join(ors2, " or ")+`) and buyer_id<>'' and zbtime>?))`)
+		ors1 = append(ors1, `(buyer_id in (select uniqCombined(buyer_id) from transaction_info_all prewhere (`+strings.Join(ors2, " or ")+`) and buyer_id<>'' and zbtime>?))`)
 		allArgs = append(allArgs, yearLimit)
 	}
 	allArgs = append(allArgs, yearLimit)
@@ -251,7 +251,7 @@ func getQuerySql(req *types.ProjectListReq, plist []string, businessStr string)
 		}
 	}
 	//过滤掉已中标的招标项目数据
-	sqlAppend := " where (" + strings.Join(ors1, " or ") + ") and project_bidstatus>1 and zbtime>? and " + strings.Join(ands, " and ")
+	sqlAppend := " prewhere (" + strings.Join(ors1, " or ") + ") and project_bidstatus>1 and zbtime>? and " + strings.Join(ands, " and ")
 	countSql += sqlAppend
 	findSql += fmt.Sprintf(sqlAppend+" order by zbtime desc limit %d,%d", (req.PageNum-1)*req.PageSize, req.PageSize)
 	return
@@ -388,7 +388,8 @@ func moreInfo(req *types.ProjectListReq, plist []string, list []*ProjectEntry) (
 			bArr = append(bArr, fmt.Sprintf("'%s'", m.BuyerId))
 		}
 	}
-	companyList := Findfirstparty(bArr, nil)
+	var companyList []map[string]interface{}
+	Findfirstparty(req.PositionId, bArr, companyList, 0)
 	if companyList != nil && len(companyList) > 0 {
 		for _, m := range list {
 			if m.MyConn == false {
@@ -406,7 +407,7 @@ func moreInfo(req *types.ProjectListReq, plist []string, list []*ProjectEntry) (
 			}
 		}
 	} else {
-		companyList = Findwinner(bArr)
+		companyList = Findwinner(req.PositionId, bArr, 0)
 		if companyList != nil && len(companyList) > 0 {
 			for _, m := range list {
 				if m.MyConn == false {