|
@@ -342,12 +342,11 @@ func (s *subscribePush) Datas(spqp *SubPushQueryParam) (hasNextPage bool, total
|
|
|
}
|
|
|
|
|
|
func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, endtime int64, size int, isLimit bool) (result []*bxsubscribe.SubscribeInfo, count int64) {
|
|
|
- start := time.Now().Unix()
|
|
|
querys := []string{}
|
|
|
userStr := " "
|
|
|
leftJoinStr := " "
|
|
|
var (
|
|
|
- searchSql, findSql string
|
|
|
+ countSql, searchSql, findSql string
|
|
|
)
|
|
|
codeMap, err := IC.CodeLib.CodeTransformation(context.Background(), &codeservice.Request{})
|
|
|
if codeMap.Data == nil || err != nil {
|
|
@@ -355,12 +354,12 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
|
|
|
return result, count
|
|
|
}
|
|
|
querys = append(querys, " 1=1 ")
|
|
|
- start2 := int64(0)
|
|
|
if spqp.SelectInfoIds != nil && len(spqp.SelectInfoIds) > 0 {
|
|
|
+ countSql = fmt.Sprintf("select count(1) as count from %s a LEFT JOIN %s b ON a.infoid = b.infoid where %s", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, fmt.Sprintf("a.id in ('%s')", strings.Join(spqp.SelectInfoIds, "','")))
|
|
|
+ logx.Info("countSql", countSql)
|
|
|
searchSql = fmt.Sprintf(" from %s a LEFT JOIN %s b ON a.infoid = b.infoid where %s order by a.date desc,a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, fmt.Sprintf("a.id in ('%s')", strings.Join(spqp.SelectInfoIds, "','")))
|
|
|
- logx.Info("searchSql", searchSql)
|
|
|
//查询总数
|
|
|
- count = spqp.BaseServiceMysql.CountBySql(fmt.Sprintf("select count(a.id)" + searchSql))
|
|
|
+ count = spqp.BaseServiceMysql.CountBySql(countSql)
|
|
|
findSql = "select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count"
|
|
|
} else {
|
|
|
if spqp.IsEnt {
|
|
@@ -401,7 +400,7 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
|
|
|
|
|
|
//时间
|
|
|
if starttime > 0 && endtime > 0 {
|
|
|
- userStr += fmt.Sprintf(" and a.date>=%d and date<=%d", starttime, endtime)
|
|
|
+ userStr += fmt.Sprintf(" and a.date>=%d and a.date<=%d", starttime, endtime)
|
|
|
} else if starttime > 0 && endtime == 0 {
|
|
|
userStr += fmt.Sprintf(" and a.date>=%d", starttime)
|
|
|
} else if starttime == 0 && endtime > 0 {
|
|
@@ -529,16 +528,17 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
|
|
|
querys = append(querys, fmt.Sprintf("b.isvalidfile =0 "))
|
|
|
}
|
|
|
}
|
|
|
+ if len(querys) > 1 {
|
|
|
+ countSql = fmt.Sprintf("select count(1) as count from %s a STRAIGHT_JOIN %s b ON %s and a.infoid = b.infoid %s where %s", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, userStr, leftJoinStr, strings.Join(querys, " and "))
|
|
|
+ } else {
|
|
|
+ countSql = fmt.Sprintf("select count(1) as count from %s a where %s", aboutDbMsg[s.ModuleFlag].MysqlTable, userStr)
|
|
|
+ }
|
|
|
+ logx.Info("countSql", countSql)
|
|
|
searchSql = fmt.Sprintf(" from %s a STRAIGHT_JOIN %s b ON %s and a.infoid = b.infoid %s where %s"+
|
|
|
" order by a.date desc,a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, Baseinfo, userStr, leftJoinStr, strings.Join(querys, " and "))
|
|
|
- logx.Info("searchSql", searchSql)
|
|
|
//查询总数
|
|
|
- logx.Info(fmt.Sprintf("select count(DISTINCT a.id) " + searchSql))
|
|
|
- count = spqp.BaseServiceMysql.CountBySql(fmt.Sprintf("select count( DISTINCT a.id) " + searchSql))
|
|
|
- start2 = time.Now().Unix()
|
|
|
- logx.Info("count:", count, "---", s.ModuleFlag)
|
|
|
- logx.Info("查询数据总数用时", start2-start)
|
|
|
- findSql = "select DISTINCT a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count"
|
|
|
+ count = spqp.BaseServiceMysql.CountBySql(countSql)
|
|
|
+ findSql = "select a.id,a.date,a.infoid,a.isvisit,a.matchkeys,a.type,b.isvalidfile as attachment_count"
|
|
|
if s.ModuleFlag == EntnicheFlag {
|
|
|
findSql += ", IF(a.source is NULL,1,a.source) as source "
|
|
|
}
|
|
@@ -550,15 +550,10 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
|
|
|
if isLimit {
|
|
|
findSql += fmt.Sprintf(" limit %d,%d", (spqp.PageNum-1)*size, size)
|
|
|
}
|
|
|
-
|
|
|
logx.Info(spqp.NewUserId, "subscribePush query sql:", findSql)
|
|
|
list := spqp.BaseServiceMysql.SelectBySql(findSql)
|
|
|
- start3 := time.Now().Unix()
|
|
|
- logx.Info("查询数据用时", start3-start2)
|
|
|
if list != nil && len(*list) > 0 {
|
|
|
pushCas := s.GetJyPushs(*list)
|
|
|
- start4 := time.Now().Unix()
|
|
|
- logx.Info("清洗数据耗时", start4-start3)
|
|
|
if !spqp.Export {
|
|
|
result = s.GetInfoByIds(spqp.Mgo_bidding, spqp.Bidding, spqp.Bidding_back, pushCas)
|
|
|
} else {
|