|
@@ -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 {
|