|
@@ -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)
|
|
}
|
|
}
|
|
@@ -597,15 +598,13 @@ func MonitorStatusInit(positionId int64, dataMap *map[string]map[string]interfac
|
|
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,31 +616,38 @@ 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
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -716,17 +722,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)
|
|
@@ -768,6 +787,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 +1113,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
|
|
}
|
|
}
|