Explorar o código

监控数据不对处理

WH01243 hai 1 ano
pai
achega
34adce552c
Modificáronse 1 ficheiros con 52 adicións e 22 borrados
  1. 52 22
      api/internal/service/owner.go

+ 52 - 22
api/internal/service/owner.go

@@ -78,7 +78,15 @@ func (t *OwnerService) OwnerlList() map[string]interface{} {
 	dataMap := &map[string]map[string]interface{}{}
 	projectMap := &map[string]map[string]interface{}{}
 	if t.PartyA != "" || t.Supplier != "" || t.Heterotophy != "" || t.Intermediary != "" || t.Agency != "" {
-		dataMap = BuyerList(t.PartyA, t.Supplier, t.Heterotophy, t.Intermediary, t.Agency)
+		dataMap = BuyerList(t.PartyA, t.Supplier, t.Heterotophy, t.Intermediary, t.Agency, t.PositionId)
+		if len(*dataMap) == 0 {
+			return map[string]interface{}{
+				"connectionsNumber": 0,
+				"highSuccessNumber": 0,
+				"monitorNumber":     0,
+				"list":              []BuyerProject{},
+			}
+		}
 		//处理状态初始化
 		if t.ProcessingStatus != "" {
 			ProcessingStatusInit(t.PositionId, dataMap, t.ProcessingStatus)
@@ -201,6 +209,9 @@ func ConnectionsHandle(buyerArr []string, positionId int64, isAll bool) []map[st
 
 // 供应商处理
 func Findwinner(buyerArr []string, returnData []map[string]interface{}) []map[string]interface{} {
+	if len(buyerArr) == 0 {
+		return returnData
+	}
 	//供应商  采购单位 供应商     招标代理机构  采购单位  招标代理机构  需要计算合作次数
 	winnerSql := fmt.Sprintf(`select
 		DISTINCT 
@@ -357,6 +368,9 @@ func Findwinner(buyerArr []string, returnData []map[string]interface{}) []map[st
 
 // 中间人查询
 func FindMiddleman(buyerArr []string, positionId int64, returnData []map[string]interface{}) []map[string]interface{} {
+	if len(buyerArr) == 0 {
+		return returnData
+	}
 	//中间人  作为可介绍业主    企业名称
 	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, ",")))
@@ -381,6 +395,9 @@ func FindMiddleman(buyerArr []string, positionId int64, returnData []map[string]
 
 // 企业之间关系查询
 func Findfirstparty(buyerArr []string, returnData []map[string]interface{}) []map[string]interface{} {
+	if len(buyerArr) == 0 {
+		return returnData
+	}
 	buyerSql := fmt.Sprintf(`select DISTINCT 
 			a.a_id as a_id,
 			a.b_id as b_id,
@@ -503,8 +520,11 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
 						EstimatedAmount: money,
 						Connections:     []map[string]interface{}{},
 					},
-					Area:   gconv.String(projectMap["area"]),
-					Zbtime: zbtime,
+					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 {
@@ -518,8 +538,11 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
 						EstimatedAmount: money,
 						Connections:     []map[string]interface{}{},
 					},
-					Area:   gconv.String(projectMap["area"]),
-					Zbtime: zbtime,
+					Area:             gconv.String(projectMap["area"]),
+					Zbtime:           zbtime,
+					IsIgnore:         gconv.Bool(buyerMap["isIgnore"]),
+					IsMonitor:        gconv.Bool(buyerMap["isMonitor"]),
+					IsCreateCustomer: gconv.Bool(buyerMap["isCreateCustomer"]),
 				})
 			}
 		} else {
@@ -531,8 +554,11 @@ func BuyerProjectMerge(dataMap, projectMap *map[string]map[string]interface{}, s
 					EstimatedAmount: 0,
 					Connections:     []map[string]interface{}{},
 				},
-				Area:   "",
-				Zbtime: 0,
+				Area:             "",
+				Zbtime:           0,
+				IsIgnore:         false,
+				IsMonitor:        false,
+				IsCreateCustomer: false,
 			})
 		}
 		connectionsNumber++
@@ -627,18 +653,17 @@ func ProcessingStatusInit(positionId int64, dataMap *map[string]map[string]inter
 }
 
 // 采购单位查询
-func BuyerList(partyA, supplier, heterotophy, intermediary, agency string) *map[string]map[string]interface{} {
+func BuyerList(partyA, supplier, heterotophy, intermediary, agency string, positionId int64) *map[string]map[string]interface{} {
 	dataMap := &map[string]map[string]interface{}{}
 	//甲方
 	if partyA != "" {
+		intermediaryArr := []string{}
 		for _, v := range strings.Split(partyA, ",") {
-			intermediaryArr := strings.Split(v, "_")
-			if len(intermediaryArr) == 2 {
-				(*dataMap)[intermediaryArr[0]] = map[string]interface{}{
-					"buyerName": intermediaryArr[1],
-				}
-			}
+			intermediaryArr = append(intermediaryArr, fmt.Sprintf("'%s'", v))
+
 		}
+		partyASql := fmt.Sprintf(`select  id as buyer_id,company_name as buyer  from  ent_info   where  id in (%s)`, strings.Join(intermediaryArr, ","))
+		FindHandle(partyASql, dataMap)
 	}
 	//供应商 //同甲异业
 	if supplier != "" || heterotophy != "" {
@@ -654,11 +679,14 @@ func BuyerList(partyA, supplier, heterotophy, intermediary, agency string) *map[
 	}
 	//中间人
 	if intermediary != "" {
-		for _, v := range strings.Split(intermediary, ",") {
-			intermediaryArr := strings.Split(v, "_")
-			if len(intermediaryArr) == 2 {
-				(*dataMap)[intermediaryArr[0]] = map[string]interface{}{
-					"buyerName": intermediaryArr[1],
+		intermediarySql := fmt.Sprintf(`select b.relate_id as relate_id,b.relate_name as relate_name from crm.connection a inner join crm.connection_introduce b on (a.position_id=%s  and  find_in_set(company_id,"")and a.id=b.connection_id and b.itype=1)`, gconv.String(positionId), intermediary)
+		intermediaryArr := CrmMysql.SelectBySql(intermediarySql)
+		if intermediaryArr != nil && len(*intermediaryArr) > 0 {
+			for _, m := range *intermediaryArr {
+				buyerId := gconv.String(m["relate_id"])
+				buyerName := gconv.String(m["relate_name"])
+				(*dataMap)[buyerId] = map[string]interface{}{
+					"buyerName": buyerName,
 				}
 			}
 		}
@@ -765,8 +793,10 @@ func FindHandle(sqlStr string, dataMap *map[string]map[string]interface{}) {
 	for rows.Next() {
 		data := Recommend{}
 		rows.ScanStruct(&data)
-		(*dataMap)[data.buyerId] = map[string]interface{}{
-			"buyerName": data.buyer,
+		if data.buyerId != "" {
+			(*dataMap)[data.buyerId] = map[string]interface{}{
+				"buyerName": data.buyer,
+			}
 		}
 	}
 	return
@@ -974,7 +1004,7 @@ func (t *OwnerService) CandidateChannel() []*ResultData {
 	returnData := []*ResultData{}
 	dataMap := &map[string]map[string]interface{}{}
 	if t.PartyA != "" || t.Supplier != "" || t.Heterotophy != "" || t.Intermediary != "" || t.Agency != "" {
-		dataMap = BuyerList(t.PartyA, t.Supplier, t.Heterotophy, t.Intermediary, t.Agency)
+		dataMap = BuyerList(t.PartyA, t.Supplier, t.Heterotophy, t.Intermediary, t.Agency, t.PositionId)
 	}
 	if len(*dataMap) > 0 && dataMap != nil {
 		propertyForm := ""