|
@@ -252,8 +252,10 @@ func Findwinner(buyerArr []string) []map[string]interface{} {
|
|
|
if len(buyerArr) == 0 {
|
|
|
return returnData
|
|
|
}
|
|
|
+ wh1, args1 := common.WhArgs(buyerArr)
|
|
|
+ args1 = append(args1, args1...)
|
|
|
//供应商 采购单位 供应商 招标代理机构 采购单位 招标代理机构 需要计算合作次数
|
|
|
- winnerSql := fmt.Sprintf(`select * from (select
|
|
|
+ winnerSql := `select * from (select
|
|
|
zbtime,
|
|
|
project_id,
|
|
|
project_name,
|
|
@@ -265,7 +267,7 @@ from
|
|
|
transaction_info_all ARRAY
|
|
|
JOIN winner_id as entId
|
|
|
where
|
|
|
- buyer_id in (%s)
|
|
|
+ buyer_id in (` + wh1 + `)
|
|
|
UNION ALL
|
|
|
select
|
|
|
zbtime,
|
|
@@ -278,8 +280,8 @@ UNION ALL
|
|
|
from
|
|
|
transaction_info_all
|
|
|
where
|
|
|
- buyer_id in (%s) and agency_id!='') order by zbtime DESC,project_id DESC `, strings.Join(buyerArr, ","), strings.Join(buyerArr, ","))
|
|
|
- winnerArr := SupplierFindConnectionsHandle(winnerSql)
|
|
|
+ buyer_id in (` + wh1 + `) and agency_id!='') order by zbtime DESC,project_id DESC`
|
|
|
+ winnerArr := SupplierFindConnectionsHandle(winnerSql, args1...)
|
|
|
if winnerArr != nil && len(winnerArr) > 0 {
|
|
|
//企业联系人处理
|
|
|
entIdArr := []string{}
|
|
@@ -291,14 +293,15 @@ where
|
|
|
personMap := map[string]string{}
|
|
|
entNameMap := map[string]string{}
|
|
|
if len(entIdArr) > 0 {
|
|
|
- personSql := fmt.Sprintf(`select id,name as personName from ent_contact where id in (%s) ORDER by name`, strings.Join(entIdArr, ","))
|
|
|
- personArr := PersonFindConnectionsHandle(personSql)
|
|
|
+ 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
|
|
|
}
|
|
|
- entSql := fmt.Sprintf(`select id ,company_name as personName from ent_info where id in (%s) ORDER by company_name`, strings.Join(entIdArr, ","))
|
|
|
- entNameArr := PersonFindConnectionsHandle(entSql)
|
|
|
+ entSql := `select id ,company_name as personName from ent_info where id in (` + wh2 + `) ORDER by company_name`
|
|
|
+ entNameArr := PersonFindConnectionsHandle(entSql, args2...)
|
|
|
for _, v := range entNameArr {
|
|
|
entNameMap[v.Id] = v.PersonName
|
|
|
}
|
|
@@ -459,7 +462,9 @@ func Findfirstparty(buyerArr []string, returnData []map[string]interface{}) []ma
|
|
|
if len(buyerArr) == 0 {
|
|
|
return returnData
|
|
|
}
|
|
|
- buyerSql := fmt.Sprintf(`select DISTINCT
|
|
|
+ wh1, args1 := common.WhArgs(buyerArr)
|
|
|
+ args1 = append(args1, args1...)
|
|
|
+ buyerSql := `select DISTINCT
|
|
|
a.a_id as a_id,
|
|
|
a.b_id as b_id,
|
|
|
a.a_name as a_name,
|
|
@@ -469,7 +474,7 @@ func Findfirstparty(buyerArr []string, returnData []map[string]interface{}) []ma
|
|
|
from
|
|
|
ent_map_code a
|
|
|
where
|
|
|
- a.a_id in (%s)
|
|
|
+ a.a_id in (` + wh1 + `)
|
|
|
and a.code in('0101', '0201')
|
|
|
UNION ALL
|
|
|
select
|
|
@@ -482,11 +487,9 @@ func Findfirstparty(buyerArr []string, returnData []map[string]interface{}) []ma
|
|
|
from
|
|
|
ent_map_code a
|
|
|
where
|
|
|
- a.b_id in (%s)
|
|
|
- and a.code in('0101', '0201')`,
|
|
|
- strings.Join(buyerArr, ","),
|
|
|
- strings.Join(buyerArr, ","))
|
|
|
- relationshipArr := BuyerFindConnectionsHandle(buyerSql)
|
|
|
+ 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 {
|
|
@@ -496,8 +499,9 @@ func Findfirstparty(buyerArr []string, returnData []map[string]interface{}) []ma
|
|
|
}
|
|
|
personMap := map[string]string{}
|
|
|
if len(entIdArr) > 0 {
|
|
|
- personSql := fmt.Sprintf(`select id,name as personName from ent_contact where id in (%s) ORDER by name`, strings.Join(entIdArr, ","))
|
|
|
- personArr := PersonFindConnectionsHandle(personSql)
|
|
|
+ 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
|
|
@@ -816,9 +820,9 @@ type TimeConnectionsEntity struct {
|
|
|
}
|
|
|
|
|
|
// 采购单位人脉信息查询sql
|
|
|
-func BuyerFindConnectionsHandle(sqlStr string) []ConnectionsEntity {
|
|
|
+func BuyerFindConnectionsHandle(sqlStr string, args ...interface{}) []ConnectionsEntity {
|
|
|
returnData := []ConnectionsEntity{}
|
|
|
- rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
|
|
|
+ rows, err := ClickhouseConn.Query(context.Background(), sqlStr, args...)
|
|
|
if err != nil {
|
|
|
logx.Error("查询失败", sqlStr, err)
|
|
|
}
|
|
@@ -830,9 +834,9 @@ func BuyerFindConnectionsHandle(sqlStr string) []ConnectionsEntity {
|
|
|
}
|
|
|
return returnData
|
|
|
}
|
|
|
-func PersonFindConnectionsHandle(sqlStr string) []PersonEntity {
|
|
|
+func PersonFindConnectionsHandle(sqlStr string, args ...interface{}) []PersonEntity {
|
|
|
returnData := []PersonEntity{}
|
|
|
- rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
|
|
|
+ rows, err := ClickhouseConn.Query(context.Background(), sqlStr, args...)
|
|
|
if err != nil {
|
|
|
logx.Error("查询失败", sqlStr, err)
|
|
|
}
|
|
@@ -845,9 +849,9 @@ func PersonFindConnectionsHandle(sqlStr string) []PersonEntity {
|
|
|
}
|
|
|
|
|
|
// 供应商
|
|
|
-func SupplierFindConnectionsHandle(sqlStr string) []SupplierConnectionsEntitys {
|
|
|
+func SupplierFindConnectionsHandle(sqlStr string, args ...interface{}) []SupplierConnectionsEntitys {
|
|
|
returnData := []SupplierConnectionsEntitys{}
|
|
|
- rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
|
|
|
+ rows, err := ClickhouseConn.Query(context.Background(), sqlStr, args...)
|
|
|
if err != nil {
|
|
|
logx.Error("查询失败", sqlStr, err)
|
|
|
}
|