|
@@ -43,6 +43,7 @@ type OwnerService struct {
|
|
WinnerName string
|
|
WinnerName string
|
|
CooperateType string
|
|
CooperateType string
|
|
EntAccountId int64
|
|
EntAccountId int64
|
|
|
|
+ ProjectType string
|
|
}
|
|
}
|
|
|
|
|
|
type BuyerProject struct {
|
|
type BuyerProject struct {
|
|
@@ -93,18 +94,18 @@ func (t *OwnerService) OwnerlList() map[string]interface{} {
|
|
ProcessingStatusInit(t.PositionId, dataMap, t.ProcessingStatus)
|
|
ProcessingStatusInit(t.PositionId, dataMap, t.ProcessingStatus)
|
|
}
|
|
}
|
|
//监控状态处理
|
|
//监控状态处理
|
|
- //MonitorStatusInit(t.PositionId, dataMap, t.SourceType)
|
|
|
|
|
|
+ MonitorStatusInit(t.PositionId, dataMap, t.SourceType)
|
|
//项目数量查询
|
|
//项目数量查询
|
|
buyerArr := []string{}
|
|
buyerArr := []string{}
|
|
for _, value := range *dataMap {
|
|
for _, value := range *dataMap {
|
|
buyerArr = append(buyerArr, fmt.Sprintf(`"%s"`, gconv.String(value["buyerName"])))
|
|
buyerArr = append(buyerArr, fmt.Sprintf(`"%s"`, gconv.String(value["buyerName"])))
|
|
}
|
|
}
|
|
//项目数量处理
|
|
//项目数量处理
|
|
- projectMap, _ = ProjectHandle(buyerArr, t.PositionId, t.SearchEntName, t.Area, t.SourceType, t.ProcessingStatus)
|
|
|
|
|
|
+ projectMap, _ = ProjectHandle(buyerArr, t.EntAccountId, t.SearchEntName, t.Area, t.ProjectType)
|
|
} else if t.SearchEntName != "" {
|
|
} else if t.SearchEntName != "" {
|
|
//1 只看转介绍成功率高2只看已监控的
|
|
//1 只看转介绍成功率高2只看已监控的
|
|
//先查找采购单位数据
|
|
//先查找采购单位数据
|
|
- projectMap, dataMap = ProjectHandle([]string{}, t.PositionId, t.SearchEntName, t.Area, t.SourceType, t.ProcessingStatus)
|
|
|
|
|
|
+ projectMap, dataMap = ProjectHandle([]string{}, t.EntAccountId, t.SearchEntName, t.Area, t.ProjectType)
|
|
a7 := time.Now().Unix()
|
|
a7 := time.Now().Unix()
|
|
fmt.Println("es用时", a7-startTime)
|
|
fmt.Println("es用时", a7-startTime)
|
|
if t.ProcessingStatus != "" {
|
|
if t.ProcessingStatus != "" {
|
|
@@ -113,7 +114,7 @@ func (t *OwnerService) OwnerlList() map[string]interface{} {
|
|
a8 := time.Now().Unix()
|
|
a8 := time.Now().Unix()
|
|
fmt.Println("状态用时", a8-a7)
|
|
fmt.Println("状态用时", a8-a7)
|
|
//监控状态处理
|
|
//监控状态处理
|
|
- //MonitorStatusInit(t.PositionId, dataMap, t.SourceType)
|
|
|
|
|
|
+ MonitorStatusInit(t.PositionId, dataMap, t.SourceType)
|
|
a9 := time.Now().Unix()
|
|
a9 := time.Now().Unix()
|
|
fmt.Println("监控用时", a9-a8)
|
|
fmt.Println("监控用时", a9-a8)
|
|
}
|
|
}
|
|
@@ -500,53 +501,43 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
|
|
monitorNumber := int64(0)
|
|
monitorNumber := int64(0)
|
|
for buyerId, buyerMap := range *dataMap {
|
|
for buyerId, buyerMap := range *dataMap {
|
|
buyerName := gconv.String(buyerMap["buyerName"])
|
|
buyerName := gconv.String(buyerMap["buyerName"])
|
|
|
|
+ count := int64(0)
|
|
if _, ok := (*projectMap)[buyerName]; ok {
|
|
if _, ok := (*projectMap)[buyerName]; ok {
|
|
projectMap := (*projectMap)[buyerName]
|
|
projectMap := (*projectMap)[buyerName]
|
|
if isMonitor := gconv.Bool(buyerMap["isMonitor"]); isMonitor {
|
|
if isMonitor := gconv.Bool(buyerMap["isMonitor"]); isMonitor {
|
|
monitorNumber++
|
|
monitorNumber++
|
|
}
|
|
}
|
|
- count := gconv.Int64(projectMap["count"])
|
|
|
|
|
|
+ count = gconv.Int64(projectMap["count"])
|
|
money := gconv.Int64(projectMap["money"])
|
|
money := gconv.Int64(projectMap["money"])
|
|
zbtime := gconv.Int64(projectMap["zbtime"])
|
|
zbtime := gconv.Int64(projectMap["zbtime"])
|
|
|
|
+ if count >= 2 {
|
|
|
|
+ highSuccessNumber++
|
|
|
|
+ }
|
|
if sourceType == "1" {
|
|
if sourceType == "1" {
|
|
if count < 2 {
|
|
if count < 2 {
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- highSuccessNumber++
|
|
|
|
- returnData = append(returnData, BuyerProject{
|
|
|
|
- BuyerId: buyerId,
|
|
|
|
- BuyerName: buyerName,
|
|
|
|
- Project: ProjectEntity{
|
|
|
|
- Number: count,
|
|
|
|
- EstimatedAmount: money,
|
|
|
|
- Connections: []map[string]interface{}{},
|
|
|
|
- },
|
|
|
|
- Area: gconv.String(projectMap["area"]),
|
|
|
|
- Zbtime: zbtime,
|
|
|
|
- IsIgnore: gconv.Bool(buyerMap["isIgnore"]),
|
|
|
|
- IsMonitor: gconv.Bool(buyerMap["isMonitor"]),
|
|
|
|
- IsCreateCustomer: gconv.Bool(buyerMap["isCreateCustomer"]),
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
- if count > 2 {
|
|
|
|
- highSuccessNumber++
|
|
|
|
- }
|
|
|
|
- returnData = append(returnData, BuyerProject{
|
|
|
|
- BuyerId: buyerId,
|
|
|
|
- BuyerName: buyerName,
|
|
|
|
- Project: ProjectEntity{
|
|
|
|
- Number: count,
|
|
|
|
- EstimatedAmount: money,
|
|
|
|
- Connections: []map[string]interface{}{},
|
|
|
|
- },
|
|
|
|
- Area: gconv.String(projectMap["area"]),
|
|
|
|
- Zbtime: zbtime,
|
|
|
|
- IsIgnore: gconv.Bool(buyerMap["isIgnore"]),
|
|
|
|
- IsMonitor: gconv.Bool(buyerMap["isMonitor"]),
|
|
|
|
- IsCreateCustomer: gconv.Bool(buyerMap["isCreateCustomer"]),
|
|
|
|
- })
|
|
|
|
}
|
|
}
|
|
|
|
+ returnData = append(returnData, BuyerProject{
|
|
|
|
+ BuyerId: buyerId,
|
|
|
|
+ BuyerName: buyerName,
|
|
|
|
+ Project: ProjectEntity{
|
|
|
|
+ Number: count,
|
|
|
|
+ EstimatedAmount: money,
|
|
|
|
+ Connections: []map[string]interface{}{},
|
|
|
|
+ },
|
|
|
|
+ Area: gconv.String(projectMap["area"]),
|
|
|
|
+ Zbtime: zbtime,
|
|
|
|
+ IsIgnore: gconv.Bool(buyerMap["isIgnore"]),
|
|
|
|
+ IsMonitor: gconv.Bool(buyerMap["isMonitor"]),
|
|
|
|
+ IsCreateCustomer: gconv.Bool(buyerMap["isCreateCustomer"]),
|
|
|
|
+ })
|
|
} else {
|
|
} else {
|
|
|
|
+ if sourceType == "1" {
|
|
|
|
+ if count < 2 {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ }
|
|
returnData = append(returnData, BuyerProject{
|
|
returnData = append(returnData, BuyerProject{
|
|
BuyerId: buyerId,
|
|
BuyerId: buyerId,
|
|
BuyerName: buyerName,
|
|
BuyerName: buyerName,
|
|
@@ -557,10 +548,11 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
|
|
},
|
|
},
|
|
Area: "",
|
|
Area: "",
|
|
Zbtime: 0,
|
|
Zbtime: 0,
|
|
- IsIgnore: false,
|
|
|
|
- IsMonitor: false,
|
|
|
|
- IsCreateCustomer: false,
|
|
|
|
|
|
+ IsIgnore: gconv.Bool(buyerMap["isIgnore"]),
|
|
|
|
+ IsMonitor: gconv.Bool(buyerMap["isMonitor"]),
|
|
|
|
+ IsCreateCustomer: gconv.Bool(buyerMap["isCreateCustomer"]),
|
|
})
|
|
})
|
|
|
|
+
|
|
}
|
|
}
|
|
connectionsNumber++
|
|
connectionsNumber++
|
|
}
|
|
}
|
|
@@ -587,25 +579,27 @@ func MonitorStatusInit(positionId int64, dataMap *map[string]map[string]interfac
|
|
v["isMonitor"] = true
|
|
v["isMonitor"] = true
|
|
(*newMap)[k] = v
|
|
(*newMap)[k] = v
|
|
} else {
|
|
} else {
|
|
- if sourceType != "2" && sourceType != "1" {
|
|
|
|
|
|
+ if sourceType != "2" {
|
|
v["isMonitor"] = false
|
|
v["isMonitor"] = false
|
|
(*newMap)[k] = v
|
|
(*newMap)[k] = v
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if sourceType == "2" {
|
|
|
|
+ *dataMap = *newMap
|
|
|
|
+ return
|
|
|
|
+ }
|
|
if newMap != nil {
|
|
if newMap != nil {
|
|
- dataMap = newMap
|
|
|
|
|
|
+ *dataMap = *newMap
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-// 处理状态初始化
|
|
|
|
-func ProcessingStatusInit(positionId int64, dataMap *map[string]map[string]interface{}, processingStatus string) {
|
|
|
|
|
|
+func FindStatus(positionId int64) (map[string]bool, map[string]bool, map[string]bool) {
|
|
//未处理
|
|
//未处理
|
|
- untreatedMap := &map[string]bool{}
|
|
|
|
|
|
+ untreatedMap := map[string]bool{}
|
|
//已忽略
|
|
//已忽略
|
|
- ignoredMap := &map[string]bool{}
|
|
|
|
|
|
+ ignoredMap := map[string]bool{}
|
|
//已创建
|
|
//已创建
|
|
- createdMap := &map[string]bool{}
|
|
|
|
|
|
+ createdMap := map[string]bool{}
|
|
processingArr := CrmMysql.Find(entity.CONNECTION_STATUS, map[string]interface{}{
|
|
processingArr := CrmMysql.Find(entity.CONNECTION_STATUS, map[string]interface{}{
|
|
"type": 1,
|
|
"type": 1,
|
|
"position id": positionId,
|
|
"position id": positionId,
|
|
@@ -617,38 +611,45 @@ func ProcessingStatusInit(positionId int64, dataMap *map[string]map[string]inter
|
|
ignore := gconv.Int64(v["is_ignore"])
|
|
ignore := gconv.Int64(v["is_ignore"])
|
|
create := gconv.Int64(v["is_create"])
|
|
create := gconv.Int64(v["is_create"])
|
|
if handle == 1 {
|
|
if handle == 1 {
|
|
- (*untreatedMap)[entId] = true
|
|
|
|
|
|
+ untreatedMap[entId] = true
|
|
}
|
|
}
|
|
if ignore == 1 {
|
|
if ignore == 1 {
|
|
- (*ignoredMap)[entId] = true
|
|
|
|
|
|
+ ignoredMap[entId] = true
|
|
}
|
|
}
|
|
if create == 1 {
|
|
if create == 1 {
|
|
- (*createdMap)[entId] = true
|
|
|
|
|
|
+ createdMap[entId] = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ return untreatedMap, ignoredMap, createdMap
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 处理状态初始化
|
|
|
|
+func ProcessingStatusInit(positionId int64, dataMap *map[string]map[string]interface{}, processingStatus string) {
|
|
|
|
+ //收录数据处理
|
|
|
|
+ untreatedMap, ignoredMap, createdMap := FindStatus(positionId)
|
|
newMap := &map[string]map[string]interface{}{}
|
|
newMap := &map[string]map[string]interface{}{}
|
|
//所有采购单位和处理状态对比
|
|
//所有采购单位和处理状态对比
|
|
for buyerId, value := range *dataMap {
|
|
for buyerId, value := range *dataMap {
|
|
for _, v := range strings.Split(processingStatus, ",") {
|
|
for _, v := range strings.Split(processingStatus, ",") {
|
|
switch v {
|
|
switch v {
|
|
case "1":
|
|
case "1":
|
|
- if _, ok := (*untreatedMap)[buyerId]; !ok {
|
|
|
|
|
|
+ if _, ok := untreatedMap[buyerId]; !ok {
|
|
(*newMap)[buyerId] = value
|
|
(*newMap)[buyerId] = value
|
|
}
|
|
}
|
|
case "2":
|
|
case "2":
|
|
- if _, ok := (*ignoredMap)[buyerId]; ok {
|
|
|
|
|
|
+ if _, ok := ignoredMap[buyerId]; ok {
|
|
(*newMap)[buyerId] = value
|
|
(*newMap)[buyerId] = value
|
|
}
|
|
}
|
|
case "3":
|
|
case "3":
|
|
- if _, ok := (*createdMap)[buyerId]; ok {
|
|
|
|
|
|
+ if _, ok := createdMap[buyerId]; ok {
|
|
(*newMap)[buyerId] = value
|
|
(*newMap)[buyerId] = value
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if newMap != nil {
|
|
if newMap != nil {
|
|
- dataMap = newMap
|
|
|
|
|
|
+ *dataMap = *newMap
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -716,17 +717,30 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, posit
|
|
}
|
|
}
|
|
|
|
|
|
// 项目数量查询
|
|
// 项目数量查询
|
|
-func ProjectHandle(buyerArr []string, positionId int64, entName, area, sourceType, processingStatus string) (*map[string]map[string]interface{}, *map[string]map[string]interface{}) {
|
|
|
|
|
|
+func ProjectHandle(buyerArr []string, entAccountId int64, entName, area, projectType string) (*map[string]map[string]interface{}, *map[string]map[string]interface{}) {
|
|
projectMap := &map[string]map[string]interface{}{}
|
|
projectMap := &map[string]map[string]interface{}{}
|
|
returnMap := &map[string]map[string]interface{}{}
|
|
returnMap := &map[string]map[string]interface{}{}
|
|
sql := ""
|
|
sql := ""
|
|
sqlStr := ""
|
|
sqlStr := ""
|
|
|
|
+ propertyFormStr := ""
|
|
|
|
+ if projectType == "1" {
|
|
|
|
+ propertyForm := ""
|
|
|
|
+ m1 := CrmMysql.FindOne("config_tenant", map[string]interface{}{"account_id": entAccountId}, "probusfor", "")
|
|
|
|
+ if m1 != nil && len(*m1) > 0 {
|
|
|
|
+ propertyForm = common.ObjToString((*m1)["probusfor"])
|
|
|
|
+ if propertyForm != "" {
|
|
|
|
+ propertyFormStr = fmt.Sprintf(`,{"match":{"property_form":"%s"}}`, propertyForm)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
if entName != "" {
|
|
if entName != "" {
|
|
- 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), ""))
|
|
|
|
|
|
+ sql = `{"query":{"bool":{"must":[{"multi_match":{"query":"%s","type":"phrase","fields":["buyer.mbuyer"]}}%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, entName, common.If(area != "", fmt.Sprintf(`,{"term":{"area":"%s"}}`, area), ""), common.If(projectType == "1", propertyFormStr, ""))
|
|
} else {
|
|
} else {
|
|
- 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), ""))
|
|
|
|
|
|
+ sql = `{"query":{"bool":{"must":[{"terms":{"buyer":[%s]}}%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), ""), common.If(projectType == "1", propertyFormStr, ""))
|
|
}
|
|
}
|
|
startTime := time.Now().Unix()
|
|
startTime := time.Now().Unix()
|
|
data, _, _ := elastic.GetAggs(INDEX_1, INDEX_1, sqlStr)
|
|
data, _, _ := elastic.GetAggs(INDEX_1, INDEX_1, sqlStr)
|
|
@@ -759,7 +773,7 @@ func ProjectHandle(buyerArr []string, positionId int64, entName, area, sourceTyp
|
|
(*projectMap)[buyerName] = map[string]interface{}{
|
|
(*projectMap)[buyerName] = map[string]interface{}{
|
|
"area": area,
|
|
"area": area,
|
|
"zbtime": v.Zbtime_count.Value,
|
|
"zbtime": v.Zbtime_count.Value,
|
|
- "money": gconv.Int64(common.Float64All(v.Money_count.Value) * 10000),
|
|
|
|
|
|
+ "money": common.RetainDecimal(common.Float64All(v.Money_count.Value)/10000, 2),
|
|
"count": v.Doc_count,
|
|
"count": v.Doc_count,
|
|
"buyerId": buyerId,
|
|
"buyerId": buyerId,
|
|
}
|
|
}
|
|
@@ -768,6 +782,14 @@ func ProjectHandle(buyerArr []string, positionId int64, entName, area, sourceTyp
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if projectType == "1" {
|
|
|
|
+ for _, v := range *returnMap {
|
|
|
|
+ buyerName := gconv.String(v["buyerName"])
|
|
|
|
+ if _, ok := (*projectMap)[buyerName]; !ok {
|
|
|
|
+ delete(*returnMap, buyerName)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return projectMap, returnMap
|
|
return projectMap, returnMap
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1086,6 +1108,13 @@ func (t *OwnerService) CandidateChannel() []*ResultData {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //状态处理
|
|
|
|
+ /*if len(returnData) > 0 {
|
|
|
|
+ untreatedMap, ignoredMap, createdMap := FindStatus(t.PositionId)
|
|
|
|
+ for k, v := range returnData {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }*/
|
|
|
|
|
|
return returnData
|
|
return returnData
|
|
}
|
|
}
|