Selaa lähdekoodia

监控代码注释打开

WH01243 1 vuosi sitten
vanhempi
commit
6d41ff7d8b

+ 2 - 0
api/application.api

@@ -200,6 +200,8 @@ type (
 		PositionId       int64  `header:"positionId,optional"`
 		PageSize         int64  `json:"pageSize,optional"`
 		PageIndex        int64  `json:"pageIndex,optional"`
+		ProjectType      string `json:"projectType,optional"`
+		EntAccountId     int64  `header:"entAccountId"`
 	}
 	ProjectListReq {
 		UserId       string `header:"userId,optional"`

+ 2 - 0
api/internal/logic/ownerlistlogic.go

@@ -41,6 +41,8 @@ func (l *OwnerListLogic) OwnerList(req *types.OwnerListReq) (resp *types.Reply,
 		PositionId:       req.PositionId,
 		PageIndex:        req.PageIndex,
 		PageSize:         req.PageSize,
+		ProjectType:      req.ProjectType,
+		EntAccountId:     req.EntAccountId,
 	}
 	data := ownerService.OwnerlList()
 	resp.Data = data

+ 55 - 21
api/internal/service/owner.go

@@ -43,6 +43,7 @@ type OwnerService struct {
 	WinnerName       string
 	CooperateType    string
 	EntAccountId     int64
+	ProjectType      string
 }
 
 type BuyerProject struct {
@@ -93,18 +94,18 @@ func (t *OwnerService) OwnerlList() map[string]interface{} {
 			ProcessingStatusInit(t.PositionId, dataMap, t.ProcessingStatus)
 		}
 		//监控状态处理
-		//MonitorStatusInit(t.PositionId, dataMap, t.SourceType)
+		MonitorStatusInit(t.PositionId, dataMap, t.SourceType)
 		//项目数量查询
 		buyerArr := []string{}
 		for _, value := range *dataMap {
 			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 != "" {
 		//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()
 		fmt.Println("es用时", a7-startTime)
 		if t.ProcessingStatus != "" {
@@ -113,7 +114,7 @@ func (t *OwnerService) OwnerlList() map[string]interface{} {
 		a8 := time.Now().Unix()
 		fmt.Println("状态用时", a8-a7)
 		//监控状态处理
-		//MonitorStatusInit(t.PositionId, dataMap, t.SourceType)
+		MonitorStatusInit(t.PositionId, dataMap, t.SourceType)
 		a9 := time.Now().Unix()
 		fmt.Println("监控用时", a9-a8)
 	}
@@ -597,15 +598,13 @@ func MonitorStatusInit(positionId int64, dataMap *map[string]map[string]interfac
 		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{}{
 		"type":        1,
 		"position id": positionId,
@@ -617,31 +616,38 @@ func ProcessingStatusInit(positionId int64, dataMap *map[string]map[string]inter
 			ignore := gconv.Int64(v["is_ignore"])
 			create := gconv.Int64(v["is_create"])
 			if handle == 1 {
-				(*untreatedMap)[entId] = true
+				untreatedMap[entId] = true
 			}
 			if ignore == 1 {
-				(*ignoredMap)[entId] = true
+				ignoredMap[entId] = true
 			}
 			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{}{}
 	//所有采购单位和处理状态对比
 	for buyerId, value := range *dataMap {
 		for _, v := range strings.Split(processingStatus, ",") {
 			switch v {
 			case "1":
-				if _, ok := (*untreatedMap)[buyerId]; !ok {
+				if _, ok := untreatedMap[buyerId]; !ok {
 					(*newMap)[buyerId] = value
 				}
 			case "2":
-				if _, ok := (*ignoredMap)[buyerId]; ok {
+				if _, ok := ignoredMap[buyerId]; ok {
 					(*newMap)[buyerId] = value
 				}
 			case "3":
-				if _, ok := (*createdMap)[buyerId]; ok {
+				if _, ok := createdMap[buyerId]; ok {
 					(*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{}{}
 	returnMap := &map[string]map[string]interface{}{}
 	sql := ""
 	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 != "" {
-		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 {
-		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()
 	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
 }
 
@@ -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
 }

+ 2 - 0
api/internal/types/types.go

@@ -215,6 +215,8 @@ type OwnerListReq struct {
 	PositionId       int64  `header:"positionId,optional"`
 	PageSize         int64  `json:"pageSize,optional"`
 	PageIndex        int64  `json:"pageIndex,optional"`
+	ProjectType      string `json:"projectType,optional"`
+	EntAccountId     int64  `header:"entAccountId"`
 }
 
 type ProjectListReq struct {