Bläddra i källkod

处理状态查询

WH01243 1 år sedan
förälder
incheckning
659c5d47b4
1 ändrade filer med 61 tillägg och 50 borttagningar
  1. 61 50
      api/internal/service/owner.go

+ 61 - 50
api/internal/service/owner.go

@@ -1,6 +1,7 @@
 package service
 
 import (
+	elastic "app.yhyue.com/moapp/jybase/es"
 	"context"
 	"encoding/json"
 	"fmt"
@@ -11,7 +12,6 @@ import (
 	"app.yhyue.com/moapp/jybase/encrypt"
 
 	"app.yhyue.com/moapp/jybase/common"
-	elastic "app.yhyue.com/moapp/jybase/es"
 	. "bp.jydev.jianyu360.cn/CRM/application/api/common"
 	"bp.jydev.jianyu360.cn/CRM/application/entity"
 	"github.com/gogf/gf/v2/util/gconv"
@@ -90,9 +90,7 @@ func (t *OwnerService) OwnerlList() map[string]interface{} {
 			}
 		}
 		//处理状态初始化
-		if t.ProcessingStatus != "" {
-			ProcessingStatusInit(t.PositionId, dataMap, t.ProcessingStatus)
-		}
+		ProcessingStatusInit(t.PositionId, dataMap, t.ProcessingStatus)
 		//监控状态处理
 		MonitorStatusInit(t.PositionId, dataMap, t.SourceType)
 		//项目数量查询
@@ -108,9 +106,7 @@ func (t *OwnerService) OwnerlList() map[string]interface{} {
 		projectMap, dataMap, _ = ProjectHandle([]string{}, t.EntAccountId, t.SearchEntName, t.Area, t.ProjectType, dataMap)
 		a7 := time.Now().Unix()
 		fmt.Println("es用时", a7-startTime)
-		if t.ProcessingStatus != "" {
-			ProcessingStatusInit(t.PositionId, dataMap, t.ProcessingStatus)
-		}
+		ProcessingStatusInit(t.PositionId, dataMap, t.ProcessingStatus)
 		a8 := time.Now().Unix()
 		fmt.Println("状态用时", a8-a7)
 		//监控状态处理
@@ -405,6 +401,7 @@ func Findfirstparty(buyerArr []string, returnData []map[string]interface{}) []ma
 			a.b_id as b_id,
 			a.a_name as a_name,
 			a.b_name as b_name,
+			111 as   status,
 			a.code as code
 		from
 			ent_map_code a
@@ -417,6 +414,7 @@ func Findfirstparty(buyerArr []string, returnData []map[string]interface{}) []ma
 			a.a_id as b_id,
 			a.b_name as a_name,
 			a.a_name as b_name,
+			222 as   status,
 			a.code as code
 		from
 			ent_map_code a
@@ -432,7 +430,6 @@ func Findfirstparty(buyerArr []string, returnData []map[string]interface{}) []ma
 			if v.Bid != "" {
 				entIdArr = append(entIdArr, fmt.Sprintf("'%s'", v.Bid))
 			}
-
 		}
 		personMap := map[string]string{}
 		if len(entIdArr) > 0 {
@@ -444,48 +441,47 @@ func Findfirstparty(buyerArr []string, returnData []map[string]interface{}) []ma
 			}
 		}
 		for _, v := range relationshipArr {
-			for _, v1 := range buyerArr {
-				code := v.Code
-				if fmt.Sprintf("'%s'", v.Aid) == v1 {
-					//key := fmt.Sprintf("%s_%s", a_id, b_id)
-					switch code {
-					case "0101": //管辖关系
-						returnData = append(returnData, map[string]interface{}{
-							"b_id":         v.Bid,
-							"b_name":       v.Bname,
-							"a_name":       v.Aname,
-							"a_id":         v.Aid,
-							"sourceType":   "firstparty",
-							"relationship": "业主的下级机构",
-							"personName":   gconv.String(personMap[v.Bid]),
-						})
+			code := v.Code
+			status := v.Status
+			if gconv.String(status) == "111" {
+				//key := fmt.Sprintf("%s_%s", a_id, b_id)
+				switch code {
+				case "0101": //管辖关系
+					returnData = append(returnData, map[string]interface{}{
+						"b_id":         v.Bid,
+						"b_name":       v.Bname,
+						"a_name":       v.Aname,
+						"a_id":         v.Aid,
+						"sourceType":   "firstparty",
+						"relationship": "业主的下级机构",
+						"personName":   gconv.String(personMap[v.Bid]),
+					})
 
-					case "0201": //投资关系
-						returnData = append(returnData, map[string]interface{}{
-							"b_id":         v.Bid,
-							"b_name":       v.Bname,
-							"a_name":       v.Aname,
-							"a_id":         v.Aid,
-							"sourceType":   "firstparty",
-							"relationship": "业主的股东",
-							"personName":   gconv.String(personMap[v.Bid]),
-						})
-					}
+				case "0201": //投资关系
+					returnData = append(returnData, map[string]interface{}{
+						"b_id":         v.Bid,
+						"b_name":       v.Bname,
+						"a_name":       v.Aname,
+						"a_id":         v.Aid,
+						"sourceType":   "firstparty",
+						"relationship": "业主的股东",
+						"personName":   gconv.String(personMap[v.Bid]),
+					})
 				}
-				if fmt.Sprintf("'%s'", v.Bid) == v1 {
-					//key := fmt.Sprintf("%s_%s", b_id, a_id)
-					if code == "0101" {
-						//"0101":管辖关系
-						returnData = append(returnData, map[string]interface{}{
-							"b_id":         v.Aid,
-							"b_name":       v.Aname,
-							"a_name":       v.Bname,
-							"a_id":         v.Bid,
-							"sourceType":   "firstparty",
-							"relationship": "业主的上级机构",
-							"personName":   gconv.String(personMap[v.Aid]),
-						})
-					}
+			}
+			if gconv.String(status) == "222" {
+				//key := fmt.Sprintf("%s_%s", b_id, a_id)
+				if code == "0101" {
+					//"0101":管辖关系
+					returnData = append(returnData, map[string]interface{}{
+						"b_id":         v.Bid,
+						"b_name":       v.Bname,
+						"a_name":       v.Aname,
+						"a_id":         v.Aid,
+						"sourceType":   "firstparty",
+						"relationship": "业主的上级机构",
+						"personName":   gconv.String(personMap[v.Aid]),
+					})
 				}
 			}
 		}
@@ -639,14 +635,25 @@ func ProcessingStatusInit(positionId int64, dataMap *map[string]map[string]inter
 				}
 			case "2":
 				if _, ok := ignoredMap[buyerId]; ok {
+					value["isIgnore"] = true
 					(*newMap)[buyerId] = value
 				}
 			case "3":
 				if _, ok := createdMap[buyerId]; ok {
+					value["isCreateCustomer"] = true
 					(*newMap)[buyerId] = value
 				}
+			case "全部":
+				if _, ok := ignoredMap[buyerId]; ok {
+					value["isIgnore"] = true
+				}
+				if _, ok := createdMap[buyerId]; ok {
+					value["isCreateCustomer"] = true
+				}
+				(*newMap)[buyerId] = value
 			}
 		}
+
 	}
 	if newMap != nil {
 		*dataMap = *newMap
@@ -855,6 +862,7 @@ type ConnectionsEntity struct {
 	Bid     string `ch:"b_id"`
 	Aname   string `ch:"a_name"`
 	Bname   string `ch:"b_name"`
+	Status  uint8  `ch:"status"`
 	Code    string `ch:"code"`
 	Cperson string `ch:"c_person"`
 }
@@ -899,7 +907,8 @@ func BuyerFindConnectionsHandle(sqlStr string) []ConnectionsEntity {
 	}
 	for rows.Next() {
 		data := ConnectionsEntity{}
-		rows.ScanStruct(&data)
+		err := rows.ScanStruct(&data)
+		logx.Info(err)
 		returnData = append(returnData, data)
 	}
 	return returnData
@@ -963,7 +972,6 @@ func SupplierFindConnectionsHandle(sqlStr string) []SupplierConnectionsEntitys {
 				})
 			}
 		}
-
 	}
 	return returnData
 }
@@ -1000,6 +1008,9 @@ func Deduplication(a, b string) string {
 
 // 路径列表
 func (t *OwnerService) OwnerRoute() []map[string]interface{} {
+	if t.BuyerId == "" {
+		return []map[string]interface{}{}
+	}
 	routeList := ConnectionsHandle([]string{
 		fmt.Sprintf("'%s'", t.BuyerId),
 	}, t.PositionId, false)