소스 검색

Merge branch 'feature/v1.1.38_ws' of BaseService/jyMicroservices into feature/v1.1.38

wangshan 1 년 전
부모
커밋
72d17d10a2
1개의 변경된 파일31개의 추가작업 그리고 12개의 파일을 삭제
  1. 31 12
      jyBXSubscribe/rpc/model/push.go

+ 31 - 12
jyBXSubscribe/rpc/model/push.go

@@ -400,14 +400,33 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 	userStr := " 1=1  "
 	var (
 		countSql, findSql string
+		list              []map[string]interface{}
 	)
 	querys = append(querys, " ")
 	if spqp.SelectInfoIds != nil && len(spqp.SelectInfoIds) > 0 {
-		countSql = fmt.Sprintf("select count(1) as count from %s a  where %s", aboutDbMsg[s.ModuleFlag].MysqlTable, fmt.Sprintf("a.id in ('%s')", strings.Join(spqp.SelectInfoIds, "','")))
-		logx.Info("countSql", countSql)
-		findSql = fmt.Sprintf("select a.id,a.date,a.infoid,a.isvisit,REPLACE(a.matchkeys,'+',' ') as matchkeys,a.type,a.attachment_count from %s a  where %s order by a.date desc,a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, fmt.Sprintf("a.id in ('%s')", strings.Join(spqp.SelectInfoIds, "','")))
-		//查询总数
-		count = spqp.BaseServiceMysql.CountBySql(countSql)
+		var (
+			selectInfoIds []string
+		)
+		for _, sId := range spqp.SelectInfoIds {
+			selectInfoIds = append(selectInfoIds, sId)
+			if len(selectInfoIds) == 50 {
+				findSelectSql := fmt.Sprintf("select a.id,a.date,a.infoid,a.isvisit,REPLACE(a.matchkeys,'+',' ') as matchkeys,a.type,a.attachment_count from %s a  where %s order by a.date desc,a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, fmt.Sprintf("a.id in ('%s')", strings.Join(selectInfoIds, "','")))
+				logx.Info(spqp.NewUserId, "subscribePush info ids query sql:", findSelectSql)
+				list = append(list, *spqp.BaseServiceMysql.SelectBySql(findSelectSql)...)
+				selectInfoIds = []string{}
+			}
+		}
+		if len(selectInfoIds) > 0 {
+			findSelectSql := fmt.Sprintf("select a.id,a.date,a.infoid,a.isvisit,REPLACE(a.matchkeys,'+',' ') as matchkeys,a.type,a.attachment_count from %s a  where %s order by a.date desc,a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, fmt.Sprintf("a.id in ('%s')", strings.Join(selectInfoIds, "','")))
+			logx.Info(spqp.NewUserId, "subscribePush info ids query sql:", findSelectSql)
+			list = append(list, *spqp.BaseServiceMysql.SelectBySql(findSelectSql)...)
+			selectInfoIds = []string{}
+		}
+		//countSql = fmt.Sprintf("select count(1) as count from %s a  where %s", aboutDbMsg[s.ModuleFlag].MysqlTable, fmt.Sprintf("a.id in ('%s')", strings.Join(spqp.SelectInfoIds, "','")))
+		//logx.Info("countSql", countSql)
+		//findSql = fmt.Sprintf("select a.id,a.date,a.infoid,a.isvisit,REPLACE(a.matchkeys,'+',' ') as matchkeys,a.type,a.attachment_count from %s a  where %s order by a.date desc,a.id desc", aboutDbMsg[s.ModuleFlag].MysqlTable, fmt.Sprintf("a.id in ('%s')", strings.Join(spqp.SelectInfoIds, "','")))
+		////查询总数
+		//count = spqp.BaseServiceMysql.CountBySql(countSql)
 	} else {
 		//公共查询条件
 		//时间
@@ -670,16 +689,16 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 			count = spqp.BaseServiceMysql.CountBySql(countSql)
 		}
 		log.Println("数据总数查询", count)
+		if isLimit {
+			findSql += fmt.Sprintf(" limit %d,%d", (spqp.PageNum-1)*size, size)
+		}
+		list = *spqp.BaseServiceMysql.SelectBySql(findSql)
+		logx.Info(spqp.NewUserId, "subscribePush query sql:", findSql)
 	}
-	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)
 	end1 := time.Now().Unix()
 	log.Println("mysql查询用时:", end1-start)
-	if list != nil && len(*list) > 0 {
-		pushCas := s.GetJyPushs(*list)
+	if list != nil && len(list) > 0 {
+		pushCas := s.GetJyPushs(list)
 		if !spqp.Export {
 			result = s.GetInfoByIds(spqp.Mgo_bidding, spqp.Bidding, spqp.Bidding_back, pushCas, spqp.IsPayUser)
 		} else {