Jianghan 9 месяцев назад
Родитель
Сommit
dfe0aeddd6

+ 50 - 40
api/internal/service/plistService.go

@@ -3,6 +3,7 @@ package service
 import (
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/encrypt"
+	"app.yhyue.com/moapp/jybase/redis"
 	"app.yhyue.com/moapp/jypkg/ent/util"
 	T "bp.jydev.jianyu360.cn/CRM/networkManage/api/common"
 	"bp.jydev.jianyu360.cn/CRM/networkManage/api/internal/types"
@@ -74,47 +75,56 @@ func GetProjectList(req *types.ProjectListReq) (resultList []*ProjectEntry, hasN
 	for b := range *buyerM {
 		buyerArr = append(buyerArr, b)
 	}
-	preSales := preSalesStatus(req.PositionId)
-	isSqlPage := false
-	if req.SaleStatus == "0" {
-		isSqlPage = true // 是否sql分页
-	}
-	countSql, findSql := getQuerySql(req, isSqlPage, buyerArr, plist)
-	logx.Info("findSql: ", findSql)
-	rows, err := T.ClickhouseConn.Query(context.TODO(), findSql)
-	defer rows.Close()
-	if err != nil {
-		return nil, false, 0
-	}
-	for rows.Next() {
-		project := ProjectEntry{}
-		_ = rows.ScanStruct(&project)
-		resultList = append(resultList, &project)
+	//preSales := preSalesStatus(req.PositionId)
+	//isSqlPage := true
+	//if req.SaleStatus == "0" {
+	//	isSqlPage = true // 是否sql分页
+	//}
+
+	// 缓存
+	rkey := "projectList-" + common.GetMd5String(fmt.Sprintf("%+v", req))
+	if cacheObj := redis.Get("newother", rkey); cacheObj != nil {
+		resultList = cacheObj.([]*ProjectEntry)
+	} else {
+		countSql, findSql := getQuerySql(req, true, buyerArr, plist)
+		logx.Info("findSql: ", findSql)
+		logx.Info("countSql: ", countSql)
+		rows, err := T.ClickhouseConn.Query(context.TODO(), findSql)
+		defer rows.Close()
+		if err != nil {
+			return nil, false, 0
+		}
+		for rows.Next() {
+			project := ProjectEntry{}
+			_ = rows.ScanStruct(&project)
+			resultList = append(resultList, &project)
+		}
+		redis.Put("newother", rkey, resultList, T.C.CacheTimeOut)
 	}
 
-	resultList = filterData(req, resultList, preSales, mmp, isSqlPage)
-	if !isSqlPage {
-		total = len(resultList)
-		if total > req.PageSize {
-			hasNextPage = true
-			start := (req.PageNum - 1) * req.PageSize
-			end := req.PageNum * req.PageSize
-			if end > total {
-				end = total
-				hasNextPage = false
-			}
-			resultList = resultList[start:end]
-		} else {
+	resultList = filterData(req, resultList, nil, mmp, true)
+	//if !isSqlPage {
+	total = len(resultList)
+	if total > req.PageSize {
+		hasNextPage = true
+		start := (req.PageNum - 1) * req.PageSize
+		end := req.PageNum * req.PageSize
+		if end > total {
+			end = total
 			hasNextPage = false
 		}
+		resultList = resultList[start:end]
 	} else {
-		total = int(T.NetworkCom.Count(countSql))
-		if total > req.PageSize {
-			hasNextPage = true
-		} else {
-			hasNextPage = false
-		}
+		hasNextPage = false
 	}
+	//} else {
+	//	total = int(T.NetworkCom.Count(countSql))
+	//	if total > req.PageSize {
+	//		hasNextPage = true
+	//	} else {
+	//		hasNextPage = false
+	//	}
+	//}
 	moreInfo(req, plist, resultList) //  补充信息
 
 	return
@@ -286,11 +296,11 @@ func filterData(req *types.ProjectListReq, resultList []*ProjectEntry, preSales,
 	}
 	for _, m := range resultList {
 		// 处理/忽略/销售机会
-		if m1, ok := preSales[m.ProjectId].(map[string]interface{}); ok {
-			m.IsIgnore = common.IntAll(m1["is_handle"])
-			m.IsIgnore = common.IntAll(m1["is_ignore"])
-			m.IsCreate = common.IntAll(m1["is_create"])
-		}
+		//if m1, ok := preSales[m.ProjectId].(map[string]interface{}); ok {
+		//	m.IsIgnore = common.IntAll(m1["is_handle"])
+		//	m.IsIgnore = common.IntAll(m1["is_ignore"])
+		//	m.IsCreate = common.IntAll(m1["is_create"])
+		//}
 		// 监控
 		for _, s := range strings.Split(m.InfoId, ",") {
 			if mmp[s] != nil {

+ 2 - 2
api/internal/service/prListService.go

@@ -21,7 +21,7 @@ var (
 
 func GetMonitorList(req *types.PrMonitorListReq) (resultList []map[string]interface{}, total int64, hasMonitor bool) {
 
-	bList, b := T.Mgo.Find("follow_customer", map[string]interface{}{"userId": req.MgoUserId}, `{_id: 1}`, nil, false, -1, -1)
+	bList, b := T.Mgo.Find("follow_customer", map[string]interface{}{"userId": req.UserId}, `{_id: 1}`, nil, false, -1, -1)
 	if b && len(*bList) > 0 {
 		hasMonitor = true
 		var bName []string
@@ -32,7 +32,7 @@ func GetMonitorList(req *types.PrMonitorListReq) (resultList []map[string]interf
 		}
 		pageStart := (req.PageNum - 1) * req.PageSize
 		esQuery1 := ""
-		scopeClass := FindBusiness(req.EntId, req.MgoUserId)
+		scopeClass := FindBusiness(req.EntId, req.UserId)
 		if scopeClass != "" {
 			var should []string
 			for _, v := range strings.Split(scopeClass, ",") {

+ 1 - 1
api/internal/types/types.go

@@ -128,7 +128,7 @@ type PrCollectListReq struct {
 }
 
 type PrMonitorListReq struct {
-	MgoUserId  string `header:"mgoUserId,optional"`
+	UserId     string `header:"userId,optional"`
 	PositionId int64  `header:"positionId,optional"`
 	EntId      int64  `header:"entId,optional"`
 	PageSize   int    `json:"pageSize"`

+ 1 - 1
api/networkmanage.api

@@ -163,7 +163,7 @@ type (
 		EntRole      int64  `header:"entRole,optional"`
 	}
 	PrMonitorListReq {
-		MgoUserId  string `header:"mgoUserId,optional"`
+		UserId     string `header:"userId,optional"`
 		PositionId int64  `header:"positionId,optional"`
 		EntId      int64  `header:"entId,optional"`
 		PageSize   int    `json:"pageSize"`