|
@@ -91,22 +91,33 @@ func (t *OwnerService) OwnerlList() map[string]interface{} {
|
|
|
}
|
|
|
//项目数量处理
|
|
|
projectMap, _ = ProjectHandle(buyerArr, t.PositionId, t.SearchEntName, t.Area, t.SourceType, t.ProcessingStatus)
|
|
|
- logx.Info(projectMap)
|
|
|
} else if t.SearchEntName != "" {
|
|
|
//1 只看转介绍成功率高2只看已监控的
|
|
|
//先查找采购单位数据
|
|
|
projectMap, dataMap = ProjectHandle([]string{}, t.PositionId, t.SearchEntName, t.Area, t.SourceType, t.ProcessingStatus)
|
|
|
+ a7 := time.Now().Unix()
|
|
|
+ fmt.Println("es用时", a7-startTime)
|
|
|
if t.ProcessingStatus != "" {
|
|
|
ProcessingStatusInit(t.PositionId, dataMap, t.ProcessingStatus)
|
|
|
}
|
|
|
+ a8 := time.Now().Unix()
|
|
|
+ fmt.Println("状态用时", a8-a7)
|
|
|
//监控状态处理
|
|
|
MonitorStatusInit(t.PositionId, dataMap, t.SourceType)
|
|
|
+ a9 := time.Now().Unix()
|
|
|
+ fmt.Println("监控用时", a9-a8)
|
|
|
}
|
|
|
+
|
|
|
+ endTime := time.Now().Unix()
|
|
|
+ fmt.Println("用时时间:", endTime-startTime)
|
|
|
if len(*dataMap) == 0 {
|
|
|
return map[string]interface{}{}
|
|
|
}
|
|
|
//采购单位和项目合并
|
|
|
+ a1 := time.Now().Unix()
|
|
|
returnData, connectionsNumber, highSuccessNumber, monitorNumber := BuyerProjectMerge(dataMap, projectMap, t.SourceType)
|
|
|
+ a2 := time.Now().Unix()
|
|
|
+ fmt.Println("组合数据", a2-a1)
|
|
|
//数组排序
|
|
|
//分页数据处理
|
|
|
if t.PageSize == 0 {
|
|
@@ -130,10 +141,16 @@ func (t *OwnerService) OwnerlList() map[string]interface{} {
|
|
|
}
|
|
|
buyerIdArr := []string{}
|
|
|
for _, value := range returnData {
|
|
|
- buyerIdArr = append(buyerIdArr, fmt.Sprintf("'%s'", value.BuyerId))
|
|
|
+ if value.BuyerId != "" {
|
|
|
+ buyerIdArr = append(buyerIdArr, fmt.Sprintf("'%s'", value.BuyerId))
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
//可介绍业主人脉处理
|
|
|
+ a3 := time.Now().Unix()
|
|
|
routeList := ConnectionsHandle(buyerIdArr, t.PositionId, false)
|
|
|
+ a4 := time.Now().Unix()
|
|
|
+ fmt.Println("组合数1111据", a4-a3)
|
|
|
for _, v := range routeList {
|
|
|
buyerId := gconv.String(v["a_id"])
|
|
|
for i, v1 := range returnData {
|
|
@@ -156,6 +173,189 @@ func (t *OwnerService) OwnerlList() map[string]interface{} {
|
|
|
// 可介绍业主人脉列表
|
|
|
func ConnectionsHandle(buyerArr []string, positionId int64, isAll bool) []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
|
|
|
+ }
|
|
|
+ //采购单位 投资关系 管辖关系
|
|
|
+ //采购单位
|
|
|
+ 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 = Findwinner(buyerArr, returnData)
|
|
|
+ a6 := time.Now().Unix()
|
|
|
+ logx.Info("供应商", a6-a5)
|
|
|
+ return returnData
|
|
|
+}
|
|
|
+
|
|
|
+// 供应商处理
|
|
|
+func Findwinner(buyerArr []string, returnData []map[string]interface{}) []map[string]interface{} {
|
|
|
+ //供应商 采购单位 供应商 招标代理机构 采购单位 招标代理机构 需要计算合作次数
|
|
|
+ winnerSql := fmt.Sprintf(`select
|
|
|
+ DISTINCT
|
|
|
+ zbtime,
|
|
|
+ project_id,
|
|
|
+ project_name,
|
|
|
+ buyer_id,
|
|
|
+ buyer,
|
|
|
+ agency_id,
|
|
|
+ agency,
|
|
|
+ winner_id,
|
|
|
+ winner
|
|
|
+ from
|
|
|
+ transaction_info
|
|
|
+ where
|
|
|
+ buyer_id in (%s)`, strings.Join(buyerArr, ","))
|
|
|
+ winnerArr := SupplierFindConnectionsHandle(winnerSql)
|
|
|
+ if winnerArr != nil && len(winnerArr) > 0 {
|
|
|
+ //企业联系人处理
|
|
|
+ entIdArr := []string{}
|
|
|
+ for _, v := range winnerArr {
|
|
|
+ if v.WinnerId != "" {
|
|
|
+ entIdArr = append(entIdArr, fmt.Sprintf("'%s'", v.WinnerId))
|
|
|
+ }
|
|
|
+ if v.Agency_id != "" {
|
|
|
+ entIdArr = append(entIdArr, fmt.Sprintf("'%s'", v.Agency_id))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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)
|
|
|
+ //联系人处理
|
|
|
+ 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)
|
|
|
+ for _, v := range entNameArr {
|
|
|
+ entNameMap[v.Id] = v.PersonName
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ winnerMap := map[string]map[string]interface{}{}
|
|
|
+ agencyMap := map[string]map[string]interface{}{}
|
|
|
+ agencyIdMap := map[string]bool{}
|
|
|
+ for _, m := range winnerArr {
|
|
|
+ buyerId := m.Buyer_id
|
|
|
+ winner := m.Winner
|
|
|
+ buyer := m.Buyer
|
|
|
+ winnerId := m.WinnerId
|
|
|
+ agency := m.Agency
|
|
|
+ agencyId := m.Agency_id
|
|
|
+ projectId := encrypt.EncodeArticleId2ByCheck(m.Project_id)
|
|
|
+ projectName := m.Project_name
|
|
|
+ zbtime := m.Zbtime
|
|
|
+ key := fmt.Sprintf("%s_%s", buyerId, winnerId)
|
|
|
+ if winnerId != "" {
|
|
|
+ if _, ok := winnerMap[key]; ok {
|
|
|
+ data := winnerMap[key]
|
|
|
+ data["count"] = gconv.Int64(data["data"]) + 1
|
|
|
+ dataList := gconv.Maps(data["list"])
|
|
|
+ dataList = append(dataList, map[string]interface{}{
|
|
|
+ "zbtime": zbtime,
|
|
|
+ "projectId": projectId,
|
|
|
+ "projectName": projectName,
|
|
|
+ })
|
|
|
+ data["list"] = dataList
|
|
|
+ winnerMap[key] = data
|
|
|
+ } else {
|
|
|
+ winnerMap[key] = map[string]interface{}{
|
|
|
+ "b_id": winnerId,
|
|
|
+ "b_name": winner,
|
|
|
+ "a_name": buyer,
|
|
|
+ "a_id": buyerId,
|
|
|
+ "sourceType": "supplier",
|
|
|
+ "personName": gconv.String(personMap[winnerId]),
|
|
|
+ "count": 1,
|
|
|
+ "list": []map[string]interface{}{
|
|
|
+ {
|
|
|
+ "zbtime": zbtime,
|
|
|
+ "entName": winner,
|
|
|
+ "projectId": projectId,
|
|
|
+ "projectName": projectName,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if agencyId != "" && buyerId != "" && projectId != "" {
|
|
|
+ key = fmt.Sprintf("%s_%s_%s", buyerId, agencyId, projectId)
|
|
|
+ key1 := fmt.Sprintf("%s_%s", buyerId, agencyId, projectId)
|
|
|
+ if _, ok := agencyIdMap[key]; ok {
|
|
|
+ data := agencyMap[key]
|
|
|
+ data["count"] = gconv.Int64(data["data"]) + 1
|
|
|
+ dataList := gconv.Maps(data["list"])
|
|
|
+ dataList = append(dataList, map[string]interface{}{
|
|
|
+ "zbtime": zbtime,
|
|
|
+ "projectId": projectId,
|
|
|
+ "projectName": projectName,
|
|
|
+ })
|
|
|
+ data["list"] = dataList
|
|
|
+ agencyMap[key] = data
|
|
|
+ } else {
|
|
|
+ agencyIdMap[key] = true
|
|
|
+ agencyMap[key1] = map[string]interface{}{
|
|
|
+ "b_id": agencyId,
|
|
|
+ "b_name": agency,
|
|
|
+ "a_name": buyer,
|
|
|
+ "a_id": buyerId,
|
|
|
+ "sourceType": "agency",
|
|
|
+ "count": 1,
|
|
|
+ "personName": gconv.String(personMap[agencyId]),
|
|
|
+ "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"]),
|
|
|
+ "list": m["list"],
|
|
|
+ })
|
|
|
+ }
|
|
|
+ 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"]),
|
|
|
+ "count": gconv.Int64(m["count"]),
|
|
|
+ "list": m["list"],
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return returnData
|
|
|
+}
|
|
|
+
|
|
|
+// 中间人查询
|
|
|
+func FindMiddleman(buyerArr []string, positionId int64, returnData []map[string]interface{}) []map[string]interface{} {
|
|
|
//中间人 作为可介绍业主 企业名称
|
|
|
companyArr := CrmMysql.SelectBySql(
|
|
|
fmt.Sprintf("select DISTINCT b.company_id,b.company_name,a.relate_id,a.relate_name,b.contact_person from connection_introduce a INNER JOIN connection b on a.position_id=%d and a.connection_id=b.id and a.relate_Id in (%s) and a.itype =1 and b.itype=4 and b.status=1 ", positionId, strings.Join(buyerArr, ",")))
|
|
@@ -175,23 +375,54 @@ func ConnectionsHandle(buyerArr []string, positionId int64, isAll bool) []map[st
|
|
|
"personName": gconv.String(v["contact_person"]),
|
|
|
})
|
|
|
}
|
|
|
- if isAll && len(returnData) > 0 {
|
|
|
- return returnData
|
|
|
- }
|
|
|
- //采购单位 投资关系 管辖关系
|
|
|
- //buyerSql := fmt.Sprintf("select a_id,b_id,a_name,b_name,code from ent_map_code a where ( a_name in (%s) or b_name in (%s) ) and code in('0101','0201')", strings.Join(buyerArr, ","), strings.Join(buyerArr, ","))
|
|
|
- buyerSql := fmt.Sprintf(`select a.a_id as a_id,a.b_id as b_id,a.a_name as a_name,a.b_name as b_name,a.code as code,c.legal_person as c_person,d.legal_person d_person from ent_map_code a
|
|
|
- left join ent_info c on (a.a_id in (%s) or a.b_id in (%s) ) and a.code in('0101','0201') and a.a_id =c.id
|
|
|
- left join ent_info d on (a.a_id in (%s) or a.b_id in (%s) ) and a.code in('0101','0201') and a.b_id =d.id
|
|
|
- where (a.a_id in (%s) or a.b_id in (%s) ) and a.code in('0101','0201')`,
|
|
|
- strings.Join(buyerArr, ","),
|
|
|
- strings.Join(buyerArr, ","),
|
|
|
- strings.Join(buyerArr, ","),
|
|
|
- strings.Join(buyerArr, ","),
|
|
|
+ return returnData
|
|
|
+}
|
|
|
+
|
|
|
+// 企业之间关系查询
|
|
|
+func Findfirstparty(buyerArr []string, returnData []map[string]interface{}) []map[string]interface{} {
|
|
|
+ buyerSql := fmt.Sprintf(`select DISTINCT
|
|
|
+ a.a_id as a_id,
|
|
|
+ a.b_id as b_id,
|
|
|
+ a.a_name as a_name,
|
|
|
+ a.b_name as b_name,
|
|
|
+ a.code as code
|
|
|
+ from
|
|
|
+ ent_map_code a
|
|
|
+ where
|
|
|
+ a.a_id in (%s)
|
|
|
+ and a.code in('0101', '0201')
|
|
|
+ UNION ALL
|
|
|
+ select
|
|
|
+ a.b_id as a_id,
|
|
|
+ a.a_id as b_id,
|
|
|
+ a.b_name as a_name,
|
|
|
+ a.a_name as b_name,
|
|
|
+ a.code as code
|
|
|
+ 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)
|
|
|
if relationshipArr != nil && len(relationshipArr) > 0 {
|
|
|
+ entIdArr := []string{}
|
|
|
+ for _, v := range relationshipArr {
|
|
|
+ if v.Bid != "" {
|
|
|
+ entIdArr = append(entIdArr, fmt.Sprintf("'%s'", v.Bid))
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ personMap := map[string]string{}
|
|
|
+ if len(entIdArr) > 0 {
|
|
|
+ personSql := fmt.Sprintf(`select id,name from ent_contact where id in (%s) ORDER by name`, strings.Join(entIdArr, ","))
|
|
|
+ personArr := PersonFindConnectionsHandle(personSql)
|
|
|
+ //联系人处理
|
|
|
+ for _, v := range personArr {
|
|
|
+ personMap[v.Id] = v.PersonName
|
|
|
+ }
|
|
|
+ }
|
|
|
for _, v := range relationshipArr {
|
|
|
for _, v1 := range buyerArr {
|
|
|
code := v.Code
|
|
@@ -206,7 +437,7 @@ func ConnectionsHandle(buyerArr []string, positionId int64, isAll bool) []map[st
|
|
|
"a_id": v.Aid,
|
|
|
"sourceType": "firstparty",
|
|
|
"relationship": "业主的上级机构",
|
|
|
- "personName": v.Dperson,
|
|
|
+ "personName": gconv.String(personMap[v.Bid]),
|
|
|
})
|
|
|
|
|
|
case "0201": //投资关系
|
|
@@ -217,7 +448,7 @@ func ConnectionsHandle(buyerArr []string, positionId int64, isAll bool) []map[st
|
|
|
"a_id": v.Aid,
|
|
|
"sourceType": "firstparty",
|
|
|
"relationship": "业主的股东",
|
|
|
- "personName": v.Dperson,
|
|
|
+ "personName": gconv.String(personMap[v.Bid]),
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -232,136 +463,13 @@ func ConnectionsHandle(buyerArr []string, positionId int64, isAll bool) []map[st
|
|
|
"a_id": v.Bid,
|
|
|
"sourceType": "firstparty",
|
|
|
"relationship": "业主的下级机构",
|
|
|
- "personName": v.Cperson,
|
|
|
+ "personName": gconv.String(personMap[v.Aid]),
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if isAll && len(returnData) > 0 {
|
|
|
- return returnData
|
|
|
- }
|
|
|
- //供应商 采购单位 供应商 招标代理机构 采购单位 招标代理机构 需要计算合作次数
|
|
|
- winnerSql := fmt.Sprintf(`SELECT DISTINCT a.project_name as project_name,a.project_id as project_id , a.zbtime as zbtime ,a.buyer_id as buyer_id,a.buyer as buyer,a.agency_id as agency_id,a.agency as agency,c.company_name as company_name ,b.name as personName ,a.winnerId as awinnerId
|
|
|
- FROM
|
|
|
- (select zbtime,project_id,project_name,project_id,buyer_id,buyer,agency_id,agency,winner_id as winnerId from transaction_info
|
|
|
- ARRAY JOIN winner_id ) a
|
|
|
- inner join ent_contact b on a.buyer_id in (%s) and a.winnerId=b.id
|
|
|
- inner join ent_info c on a.winnerId=c.id order by a.zbtime,a.winnerId`, strings.Join(buyerArr, ","))
|
|
|
- winnerArr := SupplierFindConnectionsHandle(winnerSql)
|
|
|
- if winnerArr != nil && len(winnerArr) > 0 {
|
|
|
- winnerMap := map[string]map[string]interface{}{}
|
|
|
- agencyMap := map[string]map[string]interface{}{}
|
|
|
- for _, m := range winnerArr {
|
|
|
- buyerId := m.Buyer_id
|
|
|
- winner := m.Company_name
|
|
|
- buyer := m.Buyer
|
|
|
- winnerId := m.AwinnerId
|
|
|
- agency := m.Agency
|
|
|
- agencyId := m.Agency_id
|
|
|
- projectId := encrypt.EncodeArticleId2ByCheck(m.Project_id)
|
|
|
- projectName := m.Project_name
|
|
|
- zbtime := m.Zbtime
|
|
|
- personName := m.PersonName
|
|
|
- key := fmt.Sprintf("%s_%s", buyerId, winnerId)
|
|
|
- returnData = append(returnData, map[string]interface{}{
|
|
|
- "b_id": winnerId,
|
|
|
- "b_name": winner,
|
|
|
- "a_name": buyer,
|
|
|
- "a_id": buyerId,
|
|
|
- "sourceType": "supplier",
|
|
|
- "personName": personName,
|
|
|
- })
|
|
|
- if _, ok := winnerMap[key]; ok {
|
|
|
- data := winnerMap[key]
|
|
|
- data["count"] = gconv.Int64(data["data"]) + 1
|
|
|
- dataList := gconv.Maps(data["list"])
|
|
|
- dataList = append(dataList, map[string]interface{}{
|
|
|
- "zbtime": zbtime,
|
|
|
- "entName": winner,
|
|
|
- "projectId": projectId,
|
|
|
- "projectName": projectName,
|
|
|
- })
|
|
|
- data["list"] = dataList
|
|
|
- winnerMap[key] = data
|
|
|
- } else {
|
|
|
- winnerMap[key] = map[string]interface{}{
|
|
|
- "b_id": winnerId,
|
|
|
- "b_name": winner,
|
|
|
- "a_name": buyer,
|
|
|
- "a_id": buyerId,
|
|
|
- "sourceType": "supplier",
|
|
|
- "personName": personName,
|
|
|
- "count": 1,
|
|
|
- "list": []map[string]interface{}{
|
|
|
- {
|
|
|
- "zbtime": zbtime,
|
|
|
- "entName": winner,
|
|
|
- "projectId": projectId,
|
|
|
- "projectName": projectName,
|
|
|
- },
|
|
|
- },
|
|
|
- }
|
|
|
- }
|
|
|
- key = fmt.Sprintf("%s_%s_%s", buyerId, agencyId, projectId)
|
|
|
- if _, ok := agencyMap[key]; ok {
|
|
|
- data := agencyMap[key]
|
|
|
- data["count"] = gconv.Int64(data["data"]) + 1
|
|
|
- dataList := gconv.Maps(data["list"])
|
|
|
- dataList = append(dataList, map[string]interface{}{
|
|
|
- "zbtime": zbtime,
|
|
|
- "entName": winner,
|
|
|
- "projectId": projectId,
|
|
|
- "projectName": projectName,
|
|
|
- })
|
|
|
- data["list"] = dataList
|
|
|
- agencyMap[key] = data
|
|
|
- } else {
|
|
|
- agencyMap[key] = map[string]interface{}{
|
|
|
- "b_id": agencyId,
|
|
|
- "b_name": agency,
|
|
|
- "a_name": buyer,
|
|
|
- "a_id": buyerId,
|
|
|
- "sourceType": "agency",
|
|
|
- "count": 1,
|
|
|
- "personName": personName,
|
|
|
- "list": []map[string]interface{}{
|
|
|
- {
|
|
|
- "zbtime": zbtime,
|
|
|
- "entName": agency,
|
|
|
- "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"]),
|
|
|
- "list": m["list"],
|
|
|
- })
|
|
|
- }
|
|
|
- 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"]),
|
|
|
- "count": gconv.Int64(m["count"]),
|
|
|
- "list": m["list"],
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
return returnData
|
|
|
}
|
|
|
|
|
@@ -435,7 +543,7 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
|
|
|
func MonitorStatusInit(positionId int64, dataMap *map[string]map[string]interface{}, sourceType string) {
|
|
|
monitorMap := map[string]bool{}
|
|
|
query := map[string]interface{}{
|
|
|
- "userId": positionId,
|
|
|
+ "userId": gconv.String(positionId),
|
|
|
}
|
|
|
clist, ok := Mgo.Find("follow_customer", query, ``, `{"name":1}`, false, -1, -1)
|
|
|
if ok && clist != nil && len(*clist) > 0 {
|
|
@@ -573,13 +681,16 @@ func ProjectHandle(buyerArr []string, positionId int64, entName, area, sourceTyp
|
|
|
sql := ""
|
|
|
sqlStr := ""
|
|
|
if entName != "" {
|
|
|
- sql = `{"query":{"bool":{"must":[{"multi_match":{"query":"%s","type":"phrase","fields":["buyer.mbuyer"]}}%s]}},"aggs":{"buyer_count":{"terms":{"field":"buyer","size":1000,"order":{"zbtime_count":"desc"}},"aggs":{"area_count":{"terms":{"field":"area"}},"buyer_id":{"terms":{"field":"buyer_id"}},"money_count":{"sum":{"field":"project_money"}},"zbtime_count":{"max":{"field":"zbtime"}}}}},"size":0}`
|
|
|
+ sql = `{"query":{"bool":{"must":[{"multi_match":{"query":"%s","type":"phrase","fields":["buyer.mbuyer"]}}%s]}},"aggs":{"buyer_count":{"terms":{"field":"buyer","size":500,"order":{"zbtime_count":"desc"}},"aggs":{"area_count":{"terms":{"field":"area"}},"buyer_id":{"terms":{"field":"buyer_id"}},"money_count":{"sum":{"field":"project_money"}},"zbtime_count":{"max":{"field":"zbtime"}}}}},"size":0}`
|
|
|
sqlStr = fmt.Sprintf(sql, entName, common.If(area != "", fmt.Sprintf(`,{"term":{"area":"%s"}}`, area), ""))
|
|
|
} else {
|
|
|
- sql = `{"query":{"bool":{"must":[{"terms":{"buyer":[%s]}}%s]}},"aggs":{"buyer_count":{"terms":{"field":"buyer","size":1000,"order":{"zbtime_count":"desc"}},"aggs":{"area_count":{"terms":{"field":"area"}},"buyer_id":{"terms":{"field":"buyer_id"}},"money_count":{"sum":{"field":"project_money"}},"zbtime_count":{"max":{"field":"zbtime"}}}}},"size":0}`
|
|
|
+ sql = `{"query":{"bool":{"must":[{"terms":{"buyer":[%s]}}%s]}},"aggs":{"buyer_count":{"terms":{"field":"buyer","size":500,"order":{"zbtime_count":"desc"}},"aggs":{"area_count":{"terms":{"field":"area"}},"buyer_id":{"terms":{"field":"buyer_id"}},"money_count":{"sum":{"field":"project_money"}},"zbtime_count":{"max":{"field":"zbtime"}}}}},"size":0}`
|
|
|
sqlStr = fmt.Sprintf(sql, strings.Join(buyerArr, ","), common.If(area != "", fmt.Sprintf(`,{"term":{"area":"%s"}}`, area), ""))
|
|
|
}
|
|
|
+ startTime := time.Now().Unix()
|
|
|
data, _, _ := elastic.GetAggs(INDEX_1, INDEX_1, sqlStr)
|
|
|
+ endTime := time.Now().Unix()
|
|
|
+ fmt.Println("es用时时间:", endTime-startTime)
|
|
|
if len(data) == 0 {
|
|
|
return projectMap, returnMap
|
|
|
}
|
|
@@ -590,8 +701,6 @@ func ProjectHandle(buyerArr []string, positionId int64, entName, area, sourceTyp
|
|
|
logx.Error("解析项目数据失败", object)
|
|
|
continue
|
|
|
}
|
|
|
- A := gconv.Map(bs)
|
|
|
- logx.Info(A)
|
|
|
err := json.Unmarshal(bs, &buyerArr)
|
|
|
logx.Info(err)
|
|
|
for _, v := range buyerArr.Buckets {
|
|
@@ -669,19 +778,32 @@ type ConnectionsEntity struct {
|
|
|
Bname string `ch:"b_name"`
|
|
|
Code string `ch:"code"`
|
|
|
Cperson string `ch:"c_person"`
|
|
|
- Dperson string `ch:"d_person"`
|
|
|
+}
|
|
|
+type PersonEntity struct {
|
|
|
+ Id string `ch:"id"`
|
|
|
+ PersonName string `ch:"personName"`
|
|
|
}
|
|
|
type SupplierConnectionsEntity struct {
|
|
|
- Project_name string `ch:"project_name"`
|
|
|
- Project_id string `ch:"project_id"`
|
|
|
- Zbtime int64 `ch:"zbtime"`
|
|
|
- Buyer_id string `ch:"buyer_id"`
|
|
|
- Buyer string `ch:"buyer"`
|
|
|
- Agency_id string `ch:"agency_id"`
|
|
|
- Agency string `ch:"agency"`
|
|
|
- Company_name string `ch:"company_name"`
|
|
|
- PersonName string `ch:"personName"`
|
|
|
- AwinnerId string `ch:"awinnerId"`
|
|
|
+ Zbtime int64 `ch:"zbtime"`
|
|
|
+ Project_id string `ch:"project_id"`
|
|
|
+ Project_name string `ch:"project_name"`
|
|
|
+ Buyer_id string `ch:"buyer_id"`
|
|
|
+ Buyer string `ch:"buyer"`
|
|
|
+ Agency_id string `ch:"agency_id"`
|
|
|
+ Agency string `ch:"agency"`
|
|
|
+ WinnerId []string `ch:"winner_id"`
|
|
|
+ Winner []string `ch:"winner"`
|
|
|
+}
|
|
|
+type SupplierConnectionsEntitys struct {
|
|
|
+ Zbtime int64
|
|
|
+ Project_id string
|
|
|
+ Project_name string
|
|
|
+ Buyer_id string
|
|
|
+ Buyer string
|
|
|
+ Agency_id string
|
|
|
+ Agency string
|
|
|
+ WinnerId string
|
|
|
+ Winner string
|
|
|
}
|
|
|
type TimeConnectionsEntity struct {
|
|
|
Zbtime int64 `ch:"zbtime"`
|
|
@@ -703,10 +825,23 @@ func BuyerFindConnectionsHandle(sqlStr string) []ConnectionsEntity {
|
|
|
}
|
|
|
return returnData
|
|
|
}
|
|
|
+func PersonFindConnectionsHandle(sqlStr string) []PersonEntity {
|
|
|
+ returnData := []PersonEntity{}
|
|
|
+ rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
|
|
|
+ if err != nil {
|
|
|
+ logx.Error("查询失败", sqlStr, err)
|
|
|
+ }
|
|
|
+ for rows.Next() {
|
|
|
+ data := PersonEntity{}
|
|
|
+ rows.ScanStruct(&data)
|
|
|
+ returnData = append(returnData, data)
|
|
|
+ }
|
|
|
+ return returnData
|
|
|
+}
|
|
|
|
|
|
// 供应商
|
|
|
-func SupplierFindConnectionsHandle(sqlStr string) []SupplierConnectionsEntity {
|
|
|
- returnData := []SupplierConnectionsEntity{}
|
|
|
+func SupplierFindConnectionsHandle(sqlStr string) []SupplierConnectionsEntitys {
|
|
|
+ returnData := []SupplierConnectionsEntitys{}
|
|
|
rows, err := ClickhouseConn.Query(context.Background(), sqlStr)
|
|
|
if err != nil {
|
|
|
logx.Error("查询失败", sqlStr, err)
|
|
@@ -715,7 +850,39 @@ func SupplierFindConnectionsHandle(sqlStr string) []SupplierConnectionsEntity {
|
|
|
data := SupplierConnectionsEntity{}
|
|
|
err = rows.ScanStruct(&data)
|
|
|
logx.Info(err)
|
|
|
- returnData = append(returnData, data)
|
|
|
+ if len(data.Winner) == 0 {
|
|
|
+ returnData = append(returnData, SupplierConnectionsEntitys{
|
|
|
+ Zbtime: data.Zbtime,
|
|
|
+ Project_id: data.Project_id,
|
|
|
+ Project_name: data.Project_name,
|
|
|
+ Buyer_id: data.Buyer_id,
|
|
|
+ Buyer: data.Buyer,
|
|
|
+ Agency_id: data.Agency_id,
|
|
|
+ Agency: data.Agency,
|
|
|
+ WinnerId: "",
|
|
|
+ Winner: "",
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+
|
|
|
+ for k, v := range data.WinnerId {
|
|
|
+ fmt.Println(k, len(data.Winner))
|
|
|
+ if k+1 > len(data.Winner) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ returnData = append(returnData, SupplierConnectionsEntitys{
|
|
|
+ Zbtime: data.Zbtime,
|
|
|
+ Project_id: data.Project_id,
|
|
|
+ Project_name: data.Project_name,
|
|
|
+ Buyer_id: data.Buyer_id,
|
|
|
+ Buyer: data.Buyer,
|
|
|
+ Agency_id: data.Agency_id,
|
|
|
+ Agency: data.Agency,
|
|
|
+ WinnerId: gconv.String(v),
|
|
|
+ Winner: gconv.String(data.Winner[k]),
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
return returnData
|
|
|
}
|
|
@@ -811,7 +978,6 @@ func (t *OwnerService) CandidateChannel() []*ResultData {
|
|
|
propertyForm = common.ObjToString((*m1)["probusfor"])
|
|
|
}
|
|
|
for buyerId := range *dataMap {
|
|
|
- logx.Info(buyerId)
|
|
|
r1, r2 := GetData(propertyForm, buyerId)
|
|
|
if r1 != nil && len(r1) > 0 {
|
|
|
for _, m := range r1 {
|