Commit c810434a by lenx065@gmail.com

赛事

parent 25fdd5db
package com.live.common.domain.dto.api;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MatchHomeListByDayResponse {
private String matchDay;
private List<MatchInfo> matchInfos;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class MatchInfo{
private String matchShortName;
private String matchTime;
private MatchListInfo home;
private MatchListInfo away;
//是否已订阅
private boolean subscribed;
}
}
package com.live.common.domain.dto.api;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MatchTypeListResponse {
private String sportsId;
private String sportsName;
private String sportsIcon;
}
......@@ -31,7 +31,7 @@ public class Sports extends BaseStringIdEntity {
private String competitionType;
//参加球队的类型(club: 俱乐部, national: 国家队)
private String teamType;
//1显示在文章搜索top上
//1显示在赛程搜索top上
private int searchTop;
//1显示在赛程页面
private int showMatch;
......
package com.live.common.domain.request;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class GetMatchListByRequest {
private String sportsId;
@ApiModelProperty("-1 全部 0 展示正在进行 和 未开始 1 正在进行 2未开始 3完场")
private Integer status;
@ApiModelProperty("比赛日期 yyyy-MM-dd 格式")
private String matchTime;
}
......@@ -2,6 +2,8 @@ package com.live.common.service;
import com.live.common.domain.ResponseData;
import javax.servlet.http.HttpServletRequest;
public interface CategoryService {
ResponseData<?> getTitleTab();
......@@ -10,4 +12,6 @@ public interface CategoryService {
ResponseData<?> getLiveTitleTab();
ResponseData<?> getMatchHomeType(HttpServletRequest request);
}
......@@ -14,6 +14,10 @@ import java.util.List;
public interface MatchService {
ResponseData<?> getMatchListBySportsId(GetMatchListByRequest commonStringId, HttpServletRequest request);
ResponseData<?> getMatchList(GetMatchListRequest commonStringId, HttpServletRequest request);
ResponseData<?> getMatchInfo(CommonStringId commonStringId, HttpServletRequest request);
......
......@@ -2,9 +2,11 @@ package com.live.common.service.impl;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.live.common.constant.ConstantValue;
import com.live.common.domain.ResponseData;
import com.live.common.domain.dto.api.CategoryListResponse;
import com.live.common.domain.dto.api.MatchSportsTypeResponse;
import com.live.common.domain.dto.api.MatchTypeListResponse;
import com.live.common.domain.entity.Category;
import com.live.common.domain.entity.Match;
import com.live.common.domain.entity.Sports;
......@@ -15,6 +17,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
......@@ -105,4 +109,28 @@ public class CategoryServiceImpl implements CategoryService {
.sportsName(b.getSportsName())
.build()).collect(Collectors.toList()));
}
@Override
public ResponseData<?> getMatchHomeType(HttpServletRequest request) {
List<Sports> sports = sportsMapper.selectList(Wrappers.<Sports>lambdaQuery()
.eq(Sports::getDeleted, 0)
.eq(Sports::getSourceType, 1)
.eq(Sports::getShowMatch, 1)
.orderByDesc(Sports::getSort)
);
List<MatchTypeListResponse> matchTypeListResponses = new LinkedList<>();
matchTypeListResponses.add(MatchTypeListResponse.builder()
.sportsId("-1")
.sportsIcon(null)
.sportsName("热门")
.build());
sports.forEach(b -> matchTypeListResponses.add(MatchTypeListResponse.builder()
.sportsId(b.getId())
.sportsIcon(ConstantValue.completeAddress(b.getCompetitionIcon()))
.sportsName(b.getCompetitionShortName())
.build()));
return ResponseData.successResponse(matchTypeListResponses);
}
}
......@@ -109,6 +109,98 @@ public class MatchServiceImpl implements MatchService {
}
@Override
public ResponseData<?> getMatchListBySportsId(GetMatchListByRequest commonStringId, HttpServletRequest request) {
List<Match> matches;
QueryWrapper<Match> wrapper = new QueryWrapper<>();
wrapper.eq("deleted", StatusEnum.ENABLE.getCode());
wrapper.eq("source_type", 1);
if (StringUtils.isNotBlank(commonStringId.getSportsId())) {
wrapper.eq("sports_id", commonStringId.getSportsId());
}
//-1 全部 0 展示正在进行 和 未开始 1 正在进行 2未开始 3完场
//1正在进行 2未开始 3完场 4 未知
Integer status = commonStringId.getStatus() == null ? 0 : commonStringId.getStatus();
switch (status) {
case -1:
wrapper.notIn("competition_status", 4);
wrapper.orderByDesc("match_time");
wrapper.last(String.format(" limit %s,%s", 0, 30));
matches = matchMapper.selectList(wrapper);
break;
case 1:
case 2:
case 3:
wrapper.eq("competition_status", status);
wrapper.orderByDesc("match_time");
wrapper.last(String.format(" limit %s,%s", 0, 30));
matches = matchMapper.selectList(wrapper);
break;
default:
wrapper.in("competition_status", 1, 2);
wrapper.orderByDesc("match_time");
wrapper.last(String.format(" limit %s,%s", 0, 30));
matches = matchMapper.selectList(wrapper);
break;
}
MatchHomeListByDayResponse response = new MatchHomeListByDayResponse();
for (int i = matches.size() - 1; i >= 0; i--) {
if (i == matches.size()) {
response.setMatchDay(DateUtil.format(matches.get(0).getMatchTime(), DateUtil.YMD_));
}
Match match = matches.get(i);
MatchHomeListByDayResponse.MatchInfo matchInfo = new MatchHomeListByDayResponse.MatchInfo();
matchInfo.setSubscribed(false);
if (DateUtil.format(match.getMatchTime(), DateUtil.YMD_).equals(response.getMatchDay())) {
try {
String phone = CommonMethod.getUserPhone(request);
User account = userMapper.selectOne(Wrappers.<User>lambdaQuery()
.eq(User::getPhone, phone)
);
if (account != null) {
UserReserve userReserves = userReserveMapper.selectOne(Wrappers.<UserReserve>lambdaQuery()
.eq(UserReserve::getUserId, account.getId())
.eq(UserReserve::getMatchId, match.getId())
.eq(UserReserve::getDeleted, 0)
);
if (userReserves != null)
matchInfo.setSubscribed(true);
}
} catch (Exception e) {
log.warn("未携带 Token");
}
Team home = teamMapper.selectById(match.getHomeId());
Team away = teamMapper.selectById(match.getAwayId());
matchInfo.setMatchShortName(match.getCompetitionShortName());
matchInfo.setAway(MatchListInfo.builder()
.teamName(away.getTeamName())
.teamLogo(away.getTeamIcon())
.score(match.getAwayScore())
.build());
matchInfo.setHome(MatchListInfo.builder()
.teamName(home.getTeamName())
.teamLogo(home.getTeamIcon())
.score(match.getHomeScore())
.build());
matchInfo.setMatchTime(DateUtil.format(match.getMatchTime(), DateUtil.HM_));
response.getMatchInfos().add(matchInfo);
}
}
return ResponseData.successResponse(response);
}
@Override
public ResponseData<?> getMatchList(GetMatchListRequest commonStringId, HttpServletRequest request) {
List<Match> matches;
......@@ -122,7 +214,7 @@ public class MatchServiceImpl implements MatchService {
case -1:
wrapper.notIn("competition_status", 4);
if (StringUtils.isNotBlank(commonStringId.getId())) {
if(commonStringId.getId().length() < 10){
if (commonStringId.getId().length() < 10) {
wrapper.apply("FIND_IN_SET({0},category_id)", commonStringId.getId());
} else {
wrapper.eq("sports_id", commonStringId.getId());
......@@ -136,7 +228,7 @@ public class MatchServiceImpl implements MatchService {
case 3:
wrapper.eq("competition_status", status);
if (StringUtils.isNotBlank(commonStringId.getId())) {
if(commonStringId.getId().length() < 10){
if (commonStringId.getId().length() < 10) {
wrapper.apply("FIND_IN_SET({0},category_id)", commonStringId.getId());
} else {
wrapper.eq("sports_id", commonStringId.getId());
......@@ -149,7 +241,7 @@ public class MatchServiceImpl implements MatchService {
default:
wrapper.in("competition_status", 1, 2);
if (StringUtils.isNotBlank(commonStringId.getId())) {
if(commonStringId.getId().length() < 10){
if (commonStringId.getId().length() < 10) {
wrapper.apply("FIND_IN_SET({0},category_id)", commonStringId.getId());
} else {
wrapper.eq("sports_id", commonStringId.getId());
......@@ -2046,7 +2138,7 @@ public class MatchServiceImpl implements MatchService {
.matchId(quizRecord.getMatchId())
.title(quizRecord.getTitle())
.userId(quizRecord.getUserId())
.homeVsAway(home.getTeamName()+"VS"+away.getTeamName())
.homeVsAway(home.getTeamName() + "VS" + away.getTeamName())
.id(quizRecord.getId())
.matchName(match.getCompetitionShortName())
.userName(user.getUserName())
......@@ -2061,7 +2153,6 @@ public class MatchServiceImpl implements MatchService {
}
@Override
public ResponseData<?> editHotRankInfo(EditHotRankInfoRequest rankListRequest, HttpServletRequest request) {
QuizRecord quizRecord = quizRecordMapper.selectById(rankListRequest.getId());
......@@ -2075,7 +2166,7 @@ public class MatchServiceImpl implements MatchService {
quizRecord.setDeleted(rankListRequest.getDeleted());
quizRecord.setUserId(rankListRequest.getUserId());
if(quizRecord.getId() == null || quizRecord.getId() == 0){
if (quizRecord.getId() == null || quizRecord.getId() == 0) {
quizRecord.setId(null);
quizRecordMapper.insert(quizRecord);
} else {
......
package com.live.job.service;
import com.live.common.domain.entity.ScheduledTask;
import com.live.common.mapper.ScheduledTaskMapper;
import com.live.job.constant.CrawlPlatformEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.Instant;
import java.util.Date;
import java.util.concurrent.ThreadPoolExecutor;
@Slf4j
@Component
public class ScheduledService {
private ThreadPoolExecutor threadPoolExecutor;
private CrawlStrategyFactory crawStrategyFactory;
private ScheduledTaskMapper scheduledTaskMapper;
@Resource
private ThreadPoolTaskScheduler taskScheduler;
/**
* 10 分钟爬取一次 AlStat 足球盘口指数
*/
// @Scheduled(fixedRate = 10 * 60 * 1000)
@Scheduled(cron = "01 15/10 * * * ?")
public void crawlIndexCompanyFootball(){
String desc = "10 分钟爬取一次 AlStat 足球盘口指数";
log.info(desc);
scheduledTaskMapper.insert(ScheduledTask.builder()
.createTime(new Date())
.method("crawlIndexCompanyFootball")
.methodDesc(desc)
.build());
crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.AlStat.getCode())
.crawlIndexCompanyFootball("http://data61.aistat.cn/zhishu/mainOdds?key=");
}
/**
* 11 分钟爬取一次 AlStat 篮球盘口指数
*/
// @Scheduled(fixedRate = 10 * 60 * 1000)
@Scheduled(cron = "01 13/11 * * * ?")
public void crawlIndexCompanyBasketball(){
String desc = "11 分钟爬取一次 AlStat 篮球盘口指数";
log.info(desc);
scheduledTaskMapper.insert(ScheduledTask.builder()
.createTime(new Date())
.method("crawlIndexCompanyBasketball")
.methodDesc(desc)
.build());
crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.AlStat.getCode())
.crawlIndexCompanyBasketball("http://data91.aistat.cn/basketball/zhishu/mainOdds?key=");
}
/**
* 20 分钟爬取一次 AlStat 篮球赛程
*/
// @Scheduled(fixedRate = 2 * 60 * 60 * 1000)
@Scheduled(cron = "01 20/20 * * * ?")
public void crawlAlStatBasketball(){
log.info("20 分钟爬取一次 AlStat 篮球赛程");
scheduledTaskMapper.insert(ScheduledTask.builder()
.createTime(new Date())
.method("crawlAlStatBasketball")
.methodDesc("20 分钟爬取一次 AlStat 篮球赛程")
.build());
crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.AlStat.getCode())
.crawlScheduleMatch("http://data71.aistat.cn/basketball/matchs/queryFixtureByDate?key=");
}
/**
* 篮球赛事阶段比分 -> 赛况
*/
// @Scheduled(fixedRate = 10 * 60 * 1000)
@Scheduled(cron = "01 12/10 * * * ?")
public void crawlAlStatBasketballMatchStageScore(){
log.info("10 分钟爬取一次 AlStat 篮球赛况");
scheduledTaskMapper.insert(ScheduledTask.builder()
.createTime(new Date())
.method("crawlAlStatBasketballMatchStageScore")
.methodDesc("10 分钟爬取一次 AlStat 篮球赛况")
.build());
crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.AlStat.getCode())
.crawlMatchStageScore("http://data71.aistat.cn/basketball/matchs/liveScores?key=");
}
/**
* 20 分钟爬取一次 AlStat 足球赛程
*/
// @Scheduled(fixedRate = 2 * 60 * 60 * 1000)
@Scheduled(cron = "01 21/20 * * * ?")
public void crawlAlStatFootball(){
log.info("20 分钟爬取一次 AlStat 足球赛程");
scheduledTaskMapper.insert(ScheduledTask.builder()
.createTime(new Date())
.method("crawlAlStatFootball")
.methodDesc("20 分钟爬取一次 AlStat 足球赛程")
.build());
crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.AlStat.getCode())
.crawlScheduleMatch("http://data43.aistat.cn/competitions/queryFixtureByDate?key=");
}
@Scheduled(cron = "01 10 01 * * ?")
public void crawlAlStatFootballEverOne(){
String desc = "每天爬取一次 3 天后的 AlStat 足球赛程";
log.info(desc);
scheduledTaskMapper.insert(ScheduledTask.builder()
.createTime(new Date())
.method("crawlAlStatFootballEverOne")
.methodDesc(desc)
.build());
crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.AlStat.getCode())
.crawlScheduleMatchByDay("http://data43.aistat.cn/competitions/queryFixtureByDate?key=", 3);
}
@Scheduled(cron = "01 10 02 * * ?")
public void crawlAlStatBasketballEverOne(){
String desc = "每天爬取一次 3 天后的 AlStat 篮球赛程";
log.info(desc);
scheduledTaskMapper.insert(ScheduledTask.builder()
.createTime(new Date())
.method("crawlAlStatBasketballEverOne")
.methodDesc(desc)
.build());
crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.AlStat.getCode())
.crawlScheduleMatchByDay("http://data71.aistat.cn/basketball/matchs/liveScores?key=", 3);
}
/**
* 每天爬取一次资讯
*/
// @Scheduled(fixedRate = 5 * 60 * 60 * 1000)
@Scheduled(cron = "01 01 0/05 * * ?")
public void crawlArticle() {
log.info("五小时爬取资讯");
scheduledTaskMapper.insert(ScheduledTask.builder()
.createTime(new Date())
.method("crawlArticle")
.methodDesc("五小时爬取资讯")
.build());
crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.ARTICLE24BWZ.getCode())
.crawlScheduleArticle("https://www.24zbw.com/news/lanqiu/");
taskScheduler.schedule(() -> crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.ARTICLE24BWZ.getCode())
.crawlScheduleArticle("https://www.24zbw.com/news/zuqiu/"), Instant.now().plusSeconds(2 * 60));
taskScheduler.schedule(() -> crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.ARTICLE24BWZ.getCode())
.crawlScheduleArticle("https://www.24zbw.com/news/tag/shenshuiqu/"), Instant.now().plusSeconds(4 * 60));
}
/**
* 每 5 分钟更新 sportlive360 赛程直播源
*/
@Scheduled(cron = "50 01/5 * * * ?")
public void updateSportLive360List() {
scheduledTaskMapper.insert(ScheduledTask.builder()
.createTime(new Date())
.method("updateSportLive360List")
.methodDesc("每 5 分钟更新 sportlive360 赛程直播源")
.build());
threadPoolExecutor.execute(() ->
crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.SportLive360.getCode()).crawlScheduleMatch(null));
}
//package com.live.job.service;
//
//import com.live.common.domain.entity.ScheduledTask;
//import com.live.common.mapper.ScheduledTaskMapper;
//import com.live.job.constant.CrawlPlatformEnum;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Lazy;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.time.Instant;
//import java.util.Date;
//import java.util.concurrent.ThreadPoolExecutor;
//
//@Slf4j
//@Component
//public class ScheduledService {
//
// private ThreadPoolExecutor threadPoolExecutor;
// private CrawlStrategyFactory crawStrategyFactory;
// private ScheduledTaskMapper scheduledTaskMapper;
// @Resource
// private ThreadPoolTaskScheduler taskScheduler;
//
//
// /**
// * 每天爬取一次 乐鱼 赛事 篮球
// * 10 分钟爬取一次 AlStat 足球盘口指数
// */
// @Scheduled(cron = "01 01/12 * * * ?")
// public void crawlBasketball() {
// log.info("爬取篮球赛事");
//// @Scheduled(fixedRate = 10 * 60 * 1000)
// @Scheduled(cron = "01 15/10 * * * ?")
// public void crawlIndexCompanyFootball(){
// String desc = "10 分钟爬取一次 AlStat 足球盘口指数";
// log.info(desc);
// scheduledTaskMapper.insert(ScheduledTask.builder()
// .createTime(new Date())
// .method("crawlBasketball")
// .methodDesc("12 分钟爬取一次 乐鱼 赛事 篮球")
// .method("crawlIndexCompanyFootball")
// .methodDesc(desc)
// .build());
//
// crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.LeYu.getCode())
// .crawlScheduleMatch("http://preview.611.com/api/Index/getLiveData?tabId=b5f013cd-777b-4b36-85b1-a0f9cbc0a5ee&tabName=%E7%AF%AE%E7%90%83&groupName=&millinsecond=&isFuture=true");
// crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.AlStat.getCode())
// .crawlIndexCompanyFootball("http://data61.aistat.cn/zhishu/mainOdds?key=");
// }
//
// /**
// * 每天爬取一次 乐鱼 赛事 足球
// * 11 分钟爬取一次 AlStat 篮球盘口指数
// */
// @Scheduled(cron = "10 01/11 * * * ?")
// public void crawlFootball() {
// log.info("爬取足球赛事");
//// @Scheduled(fixedRate = 10 * 60 * 1000)
// @Scheduled(cron = "01 13/11 * * * ?")
// public void crawlIndexCompanyBasketball(){
// String desc = "11 分钟爬取一次 AlStat 篮球盘口指数";
// log.info(desc);
// scheduledTaskMapper.insert(ScheduledTask.builder()
// .createTime(new Date())
// .method("crawlFootball")
// .methodDesc("11 分钟爬取一次 乐鱼 赛事 足球")
// .method("crawlIndexCompanyBasketball")
// .methodDesc(desc)
// .build());
//
// crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.LeYu.getCode())
// .crawlScheduleMatch("http://preview.611.com/api/Index/getLiveData?tabId=0ecfe170-15de-4c6d-ae89-fb37920ea616&tabName=%E8%B6%B3%E7%90%83&groupName=&millinsecond=&isFuture=true");
// crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.AlStat.getCode())
// .crawlIndexCompanyBasketball("http://data91.aistat.cn/basketball/zhishu/mainOdds?key=");
// }
//
// @Scheduled(cron = "01 02/10 * * * ?")
// public void updateMatchSchedule() {
// log.info("更新乐鱼赛程");
// /**
// * 20 分钟爬取一次 AlStat 篮球赛程
// */
//// @Scheduled(fixedRate = 2 * 60 * 60 * 1000)
// @Scheduled(cron = "01 20/20 * * * ?")
// public void crawlAlStatBasketball(){
// log.info("20 分钟爬取一次 AlStat 篮球赛程");
// scheduledTaskMapper.insert(ScheduledTask.builder()
// .createTime(new Date())
// .method("updateMatchSchedule")
// .methodDesc("10分钟 乐鱼 赛程")
// .method("crawlAlStatBasketball")
// .methodDesc("20 分钟爬取一次 AlStat 篮球赛程")
// .build());
//
// updateMatchStateService.updateStateMatch();
// crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.AlStat.getCode())
// .crawlScheduleMatch("http://data71.aistat.cn/basketball/matchs/queryFixtureByDate?key=");
// }
//
// /**
// * 每 30 分钟更新 乐鱼 赛程
// * 篮球赛事阶段比分 -> 赛况
// */
// @Scheduled(cron = "40 30/30 * * * ?")
// public void updateMatchList() {
// log.info("更新赛程");
//// @Scheduled(fixedRate = 10 * 60 * 1000)
// @Scheduled(cron = "01 12/10 * * * ?")
// public void crawlAlStatBasketballMatchStageScore(){
// log.info("10 分钟爬取一次 AlStat 篮球赛况");
// scheduledTaskMapper.insert(ScheduledTask.builder()
// .createTime(new Date())
// .method("updateMatchList")
// .methodDesc("每 30 分钟更新 乐鱼 赛程")
// .method("crawlAlStatBasketballMatchStageScore")
// .methodDesc("10 分钟爬取一次 AlStat 篮球赛况")
// .build());
//
// threadPoolExecutor.execute(() -> crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.LeYu.getCode()).updateMatchList());
// crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.AlStat.getCode())
// .crawlMatchStageScore("http://data71.aistat.cn/basketball/matchs/liveScores?key=");
// }
//
// /**
// * 每 10 分钟爬取一次 UU球 主播信息
// * 20 分钟爬取一次 AlStat 足球赛程
// */
// @Scheduled(cron = "50 10/10 * * * ?")
// public void crawlUUQiuAnchor() {
// log.info("爬取主播信息");
//// @Scheduled(fixedRate = 2 * 60 * 60 * 1000)
// @Scheduled(cron = "01 21/20 * * * ?")
// public void crawlAlStatFootball(){
// log.info("20 分钟爬取一次 AlStat 足球赛程");
// scheduledTaskMapper.insert(ScheduledTask.builder()
// .createTime(new Date())
// .method("crawlUUQiuAnchor")
// .methodDesc("每 10 分钟爬取一次 UU球 主播信息")
// .method("crawlAlStatFootball")
// .methodDesc("20 分钟爬取一次 AlStat 足球赛程")
// .build());
//
// threadPoolExecutor.execute(() ->
// crawStrategyFactory.getCrawlAnchorService(CrawlPlatformEnum.UUQiu.getCode()).crawlAnchor()
// );
// crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.AlStat.getCode())
// .crawlScheduleMatch("http://data43.aistat.cn/competitions/queryFixtureByDate?key=");
// }
//
// /**
// * 每 30 分钟更新 UU球 主播
// */
// @Scheduled(cron = "20 30/30 * * * ?")
// public void updateUUQiuAnchor() {
// log.info("更新主播");
// @Scheduled(cron = "01 10 01 * * ?")
// public void crawlAlStatFootballEverOne(){
// String desc = "每天爬取一次 3 天后的 AlStat 足球赛程";
// log.info(desc);
// scheduledTaskMapper.insert(ScheduledTask.builder()
// .createTime(new Date())
// .method("updateUUQiuAnchor")
// .methodDesc("每 30 分钟更新 UU球 主播")
// .method("crawlAlStatFootballEverOne")
// .methodDesc(desc)
// .build());
//
// threadPoolExecutor.execute(() ->
// crawStrategyFactory.getCrawlAnchorService(CrawlPlatformEnum.UUQiu.getCode()).updateAllAnchor()
// );
// crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.AlStat.getCode())
// .crawlScheduleMatchByDay("http://data43.aistat.cn/competitions/queryFixtureByDate?key=", 3);
// }
//
// /**
// * 每 30 分钟更新 UU球 赛程
// */
// @Scheduled(cron = "33 30/30 * * * ?")
// public void crawlUUQiuMatchList() {
// log.info("更新 UU球 赛程");
// @Scheduled(cron = "01 10 02 * * ?")
// public void crawlAlStatBasketballEverOne(){
// String desc = "每天爬取一次 3 天后的 AlStat 篮球赛程";
// log.info(desc);
// scheduledTaskMapper.insert(ScheduledTask.builder()
// .createTime(new Date())
// .method("crawlUUQiuMatchList")
// .methodDesc("每 30 分钟更新 UU球 赛程")
// .method("crawlAlStatBasketballEverOne")
// .methodDesc(desc)
// .build());
//
// threadPoolExecutor.execute(() ->
// crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.UUQiu.getCode()).crawlScheduleMatch("http://uuqiu.net/match/list")
// );
// crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.AlStat.getCode())
// .crawlScheduleMatchByDay("http://data71.aistat.cn/basketball/matchs/liveScores?key=", 3);
// }
//
// /**
// * 每 10 分钟爬取一次 红杉 主播信息
// * 每天爬取一次资讯
// */
// @Scheduled(cron = "10 10/10 * * * ?")
// public void crawlSequoiaAnchor() {
// log.info("爬取主播信息");
//// @Scheduled(fixedRate = 5 * 60 * 60 * 1000)
// @Scheduled(cron = "01 01 0/05 * * ?")
// public void crawlArticle() {
// log.info("五小时爬取资讯");
// scheduledTaskMapper.insert(ScheduledTask.builder()
// .createTime(new Date())
// .method("crawlSequoiaAnchor")
// .methodDesc("每 10 分钟爬取一次 红杉 主播信息")
// .method("crawlArticle")
// .methodDesc("五小时爬取资讯")
// .build());
//
// threadPoolExecutor.execute(() ->
// crawStrategyFactory.getCrawlAnchorService(CrawlPlatformEnum.Sequoia.getCode()).crawlAnchor()
// );
// crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.ARTICLE24BWZ.getCode())
// .crawlScheduleArticle("https://www.24zbw.com/news/lanqiu/");
//
// taskScheduler.schedule(() -> crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.ARTICLE24BWZ.getCode())
// .crawlScheduleArticle("https://www.24zbw.com/news/zuqiu/"), Instant.now().plusSeconds(2 * 60));
//
// taskScheduler.schedule(() -> crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.ARTICLE24BWZ.getCode())
// .crawlScheduleArticle("https://www.24zbw.com/news/tag/shenshuiqu/"), Instant.now().plusSeconds(4 * 60));
// }
//
// /**
// * 每 30 分钟更新 红杉 主播
// * 每 5 分钟更新 sportlive360 赛程直播源
// */
// @Scheduled(cron = "30 30/30 * * * ?")
// public void updateSequoiaAnchor() {
// log.info("更新主播");
// @Scheduled(cron = "50 01/5 * * * ?")
// public void updateSportLive360List() {
// scheduledTaskMapper.insert(ScheduledTask.builder()
// .createTime(new Date())
// .method("updateSequoiaAnchor")
// .methodDesc("每 30 分钟更新 红杉 主播")
// .method("updateSportLive360List")
// .methodDesc("每 5 分钟更新 sportlive360 赛程直播源")
// .build());
//
// threadPoolExecutor.execute(() ->
// crawStrategyFactory.getCrawlAnchorService(CrawlPlatformEnum.Sequoia.getCode()).updateAllAnchor()
// );
// crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.SportLive360.getCode()).crawlScheduleMatch(null));
// }
//
// /**
// * 每 30 分钟更新 红杉 赛程
// */
// @Scheduled(cron = "01 30/30 * * * ?")
// public void crawlSequoiaMatchList() {
// log.info("更新 红杉 赛程");
// scheduledTaskMapper.insert(ScheduledTask.builder()
// .createTime(new Date())
// .method("crawlSequoiaMatchList")
// .methodDesc("每 30 分钟更新 红杉 赛程")
// .build());
//// /**
//// * 每天爬取一次 乐鱼 赛事 篮球
//// */
//// @Scheduled(cron = "01 01/12 * * * ?")
//// public void crawlBasketball() {
//// log.info("爬取篮球赛事");
//// scheduledTaskMapper.insert(ScheduledTask.builder()
//// .createTime(new Date())
//// .method("crawlBasketball")
//// .methodDesc("12 分钟爬取一次 乐鱼 赛事 篮球")
//// .build());
////
//// crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.LeYu.getCode())
//// .crawlScheduleMatch("http://preview.611.com/api/Index/getLiveData?tabId=b5f013cd-777b-4b36-85b1-a0f9cbc0a5ee&tabName=%E7%AF%AE%E7%90%83&groupName=&millinsecond=&isFuture=true");
//// }
////
//// /**
//// * 每天爬取一次 乐鱼 赛事 足球
//// */
//// @Scheduled(cron = "10 01/11 * * * ?")
//// public void crawlFootball() {
//// log.info("爬取足球赛事");
//// scheduledTaskMapper.insert(ScheduledTask.builder()
//// .createTime(new Date())
//// .method("crawlFootball")
//// .methodDesc("11 分钟爬取一次 乐鱼 赛事 足球")
//// .build());
////
//// crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.LeYu.getCode())
//// .crawlScheduleMatch("http://preview.611.com/api/Index/getLiveData?tabId=0ecfe170-15de-4c6d-ae89-fb37920ea616&tabName=%E8%B6%B3%E7%90%83&groupName=&millinsecond=&isFuture=true");
//// }
////
//// @Scheduled(cron = "01 02/10 * * * ?")
//// public void updateMatchSchedule() {
//// log.info("更新乐鱼赛程");
//// scheduledTaskMapper.insert(ScheduledTask.builder()
//// .createTime(new Date())
//// .method("updateMatchSchedule")
//// .methodDesc("10分钟 乐鱼 赛程")
//// .build());
////
//// updateMatchStateService.updateStateMatch();
//// }
////
//// /**
//// * 每 30 分钟更新 乐鱼 赛程
//// */
//// @Scheduled(cron = "40 30/30 * * * ?")
//// public void updateMatchList() {
//// log.info("更新赛程");
//// scheduledTaskMapper.insert(ScheduledTask.builder()
//// .createTime(new Date())
//// .method("updateMatchList")
//// .methodDesc("每 30 分钟更新 乐鱼 赛程")
//// .build());
////
//// threadPoolExecutor.execute(() -> crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.LeYu.getCode()).updateMatchList());
//// }
////
//// /**
//// * 每 10 分钟爬取一次 UU球 主播信息
//// */
//// @Scheduled(cron = "50 10/10 * * * ?")
//// public void crawlUUQiuAnchor() {
//// log.info("爬取主播信息");
//// scheduledTaskMapper.insert(ScheduledTask.builder()
//// .createTime(new Date())
//// .method("crawlUUQiuAnchor")
//// .methodDesc("每 10 分钟爬取一次 UU球 主播信息")
//// .build());
////
//// threadPoolExecutor.execute(() ->
//// crawStrategyFactory.getCrawlAnchorService(CrawlPlatformEnum.UUQiu.getCode()).crawlAnchor()
//// );
//// }
////
//// /**
//// * 每 30 分钟更新 UU球 主播
//// */
//// @Scheduled(cron = "20 30/30 * * * ?")
//// public void updateUUQiuAnchor() {
//// log.info("更新主播");
//// scheduledTaskMapper.insert(ScheduledTask.builder()
//// .createTime(new Date())
//// .method("updateUUQiuAnchor")
//// .methodDesc("每 30 分钟更新 UU球 主播")
//// .build());
////
//// threadPoolExecutor.execute(() ->
//// crawStrategyFactory.getCrawlAnchorService(CrawlPlatformEnum.UUQiu.getCode()).updateAllAnchor()
//// );
//// }
////
//// /**
//// * 每 30 分钟更新 UU球 赛程
//// */
//// @Scheduled(cron = "33 30/30 * * * ?")
//// public void crawlUUQiuMatchList() {
//// log.info("更新 UU球 赛程");
//// scheduledTaskMapper.insert(ScheduledTask.builder()
//// .createTime(new Date())
//// .method("crawlUUQiuMatchList")
//// .methodDesc("每 30 分钟更新 UU球 赛程")
//// .build());
////
//// threadPoolExecutor.execute(() ->
//// crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.UUQiu.getCode()).crawlScheduleMatch("http://uuqiu.net/match/list")
//// );
//// }
////
//// /**
//// * 每 10 分钟爬取一次 红杉 主播信息
//// */
//// @Scheduled(cron = "10 10/10 * * * ?")
//// public void crawlSequoiaAnchor() {
//// log.info("爬取主播信息");
//// scheduledTaskMapper.insert(ScheduledTask.builder()
//// .createTime(new Date())
//// .method("crawlSequoiaAnchor")
//// .methodDesc("每 10 分钟爬取一次 红杉 主播信息")
//// .build());
////
//// threadPoolExecutor.execute(() ->
//// crawStrategyFactory.getCrawlAnchorService(CrawlPlatformEnum.Sequoia.getCode()).crawlAnchor()
//// );
//// }
////
//// /**
//// * 每 30 分钟更新 红杉 主播
//// */
//// @Scheduled(cron = "30 30/30 * * * ?")
//// public void updateSequoiaAnchor() {
//// log.info("更新主播");
//// scheduledTaskMapper.insert(ScheduledTask.builder()
//// .createTime(new Date())
//// .method("updateSequoiaAnchor")
//// .methodDesc("每 30 分钟更新 红杉 主播")
//// .build());
////
//// threadPoolExecutor.execute(() ->
//// crawStrategyFactory.getCrawlAnchorService(CrawlPlatformEnum.Sequoia.getCode()).updateAllAnchor()
//// );
//// }
////
//// /**
//// * 每 30 分钟更新 红杉 赛程
//// */
//// @Scheduled(cron = "01 30/30 * * * ?")
//// public void crawlSequoiaMatchList() {
//// log.info("更新 红杉 赛程");
//// scheduledTaskMapper.insert(ScheduledTask.builder()
//// .createTime(new Date())
//// .method("crawlSequoiaMatchList")
//// .methodDesc("每 30 分钟更新 红杉 赛程")
//// .build());
////
//// threadPoolExecutor.execute(() ->
//// crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.Sequoia.getCode()).crawlScheduleMatch("http://hszb.cc/match/list")
//// );
//// }
//
// threadPoolExecutor.execute(() ->
// crawStrategyFactory.getCrawMatchService(CrawlPlatformEnum.Sequoia.getCode()).crawlScheduleMatch("http://hszb.cc/match/list")
// );
// @Lazy
// @Resource
// public void setCrawStrategyFactory(CrawlStrategyFactory crawStrategyFactory) {
// this.crawStrategyFactory = crawStrategyFactory;
// }
//
// @Autowired
// public void setScheduledTaskMapper(ScheduledTaskMapper scheduledTaskMapper) {
// this.scheduledTaskMapper = scheduledTaskMapper;
// }
@Lazy
@Resource
public void setCrawStrategyFactory(CrawlStrategyFactory crawStrategyFactory) {
this.crawStrategyFactory = crawStrategyFactory;
}
@Autowired
public void setScheduledTaskMapper(ScheduledTaskMapper scheduledTaskMapper) {
this.scheduledTaskMapper = scheduledTaskMapper;
}
@Autowired
public void setThreadPoolExecutor(ThreadPoolExecutor threadPoolExecutor) {
this.threadPoolExecutor = threadPoolExecutor;
}
}
//
// @Autowired
// public void setThreadPoolExecutor(ThreadPoolExecutor threadPoolExecutor) {
// this.threadPoolExecutor = threadPoolExecutor;
// }
//
//}
......@@ -35,7 +35,7 @@ public class ChatTimedSendingServiceImpl {
private ThreadPoolTaskScheduler taskScheduler;
// @Scheduled(fixedRate = 10 * 60 * 1000)
@Scheduled(cron = "01 01/01 * * * ?")
// @Scheduled(cron = "01 01/01 * * * ?")
public void timedSendingServiceImpl() {
List<Room> rooms = roomMapper.selectList(Wrappers.<Room>lambdaQuery()
.eq(Room::getDeleted, 0)
......
......@@ -116,7 +116,7 @@ public class CrawlAlStatServiceImpl implements CrawlMatchService {
* 爬取赛事信息 (英超 - 等)
*/
// @Scheduled(fixedRate = 50 * 60 * 1000)
@Scheduled(cron = "01 10 02/6 * * ?")
// @Scheduled(cron = "01 10 02/6 * * ?")
public void crawlSportsInfoFootball() {
log.info("爬取赛事基本信息 -> 足球");
String url = "http://data43.aistat.cn/competitions/infos?key=" + footballKey;
......@@ -161,7 +161,7 @@ public class CrawlAlStatServiceImpl implements CrawlMatchService {
* 爬取赛事信息 (美国职业篮球赛 - 等)
*/
// @Scheduled(fixedRate = 50 * 60 * 1000)
@Scheduled(cron = "01 01 02/6 * * ?")
// @Scheduled(cron = "01 01 02/6 * * ?")
public void crawlSportsInfoBasketball() {
log.info("爬取赛事基本信息 -> 篮球");
String url = "http://data71.aistat.cn/basketball/competitions/infos?key=" + basketballKey;
......@@ -209,7 +209,7 @@ public class CrawlAlStatServiceImpl implements CrawlMatchService {
* 爬取指数公司信息 -> 足球
*/
// @Scheduled(fixedRate = 50 * 60 * 1000)
@Scheduled(cron = "01 01 01/5 * * ?")
// @Scheduled(cron = "01 01 01/5 * * ?")
public void crawlIndexCompanyInfoFootball() {
log.info("爬取指数公司信息 -> 足球");
String url = "http://data61.aistat.cn/companies/infos?key=" + footballKey;
......@@ -245,7 +245,7 @@ public class CrawlAlStatServiceImpl implements CrawlMatchService {
* 爬取指数公司信息 -> 篮球
*/
// @Scheduled(fixedRate = 50 * 60 * 1000)
@Scheduled(cron = "01 01 10/5 * * ?")
// @Scheduled(cron = "01 01 10/5 * * ?")
public void crawlIndexCompanyInfoBasketball() {
log.info("爬取指数公司信息 -> 篮球");
String url = "http://data91.aistat.cn/basketball/companies/infos?key=" + basketballKey;
......@@ -280,7 +280,7 @@ public class CrawlAlStatServiceImpl implements CrawlMatchService {
* 爬取赛事积分榜 -> 足球
*/
// @Scheduled(fixedRate = 50 * 60 * 1000)
@Scheduled(cron = "01 01 0 * * ?")
// @Scheduled(cron = "01 01 0 * * ?")
public void crawlFootballLeagueRank() {
log.info("爬取赛事积分榜 -> 足球");
List<SystemConfig> systemConfigs = systemConfigMapper.selectList(Wrappers.<SystemConfig>lambdaQuery()
......@@ -362,7 +362,7 @@ public class CrawlAlStatServiceImpl implements CrawlMatchService {
* 爬取赛事积分榜 -> 篮球
*/
// @Scheduled(fixedRate = 50 * 60 * 1000)
@Scheduled(cron = "02 02 0 * * ?")
// @Scheduled(cron = "02 02 0 * * ?")
public void crawlBasketballLeagueRank() {
log.info("爬取赛事积分榜 -> 篮球");
List<SystemConfig> systemConfigs = systemConfigMapper.selectList(Wrappers.<SystemConfig>lambdaQuery()
......@@ -452,7 +452,7 @@ public class CrawlAlStatServiceImpl implements CrawlMatchService {
* 10 分钟爬取一次 AlStat 足球实时比分
*/
// @Scheduled(fixedRate = 2 * 60 * 60 * 1000)
@Scheduled(cron = "11 11/10 * * * ?")
// @Scheduled(cron = "11 11/10 * * * ?")
public void crawlAlStatFootballScore() {
String url = String.format("http://data43.aistat.cn/matchs/liveScores?key=%s", footballKey);
ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);
......
......@@ -42,7 +42,7 @@ public class CrawlChatHistoryServiceImpl implements CrawlChatHistoryService {
@Override
// @Scheduled(fixedRate = 20 * 60 * 1000)
@Scheduled(cron = "01 10/20 * * * ?")
// @Scheduled(cron = "01 10/20 * * * ?")
public void crawlTg2ChatHistory() {
log.info("爬取http://tg2.qqzb.vip/正在直播列表");
String url = "http://tg2.qqzb.vip/home/index-pc1";
......@@ -64,7 +64,7 @@ public class CrawlChatHistoryServiceImpl implements CrawlChatHistoryService {
@Override
// @Scheduled(fixedRate = 20 * 60 * 1000)
@Scheduled(cron = "10 10/20 * * * ?")
// @Scheduled(cron = "10 10/20 * * * ?")
public void crawlQiuShenChatHistory() {
log.info("爬取 https://qiushenzhibo1.com/d 正在直播列表");
String url = "https://api.zclhsq.com/schedules/broadcaster/replay/1/?getReplayData";
......
......@@ -51,21 +51,21 @@ public class MatchController {
// return categoryService.getMatchSportsType();
// }
// @PostMapping(value = "/getMatchHomeType")
// @ApiOperation(value = "获取比赛页赛程分类")
// @ApiResponses({
// @ApiResponse(code = 200, message = "成功处理请求"),
// @ApiResponse(code = 401, message = "没有权限访问该服务"),
// @ApiResponse(code = 403, message = "权限不足无法访问该服务"),
// @ApiResponse(code = 404, message = "未发现该服务"),
// @ApiResponse(code = 500, message = "服务器内部错误")
// })
// public ResponseData<?> getMatchHomeType(HttpServletRequest request) {
// return categoryService.getMatchHomeType(request);
// }
@PostMapping(value = "/getMatchHomeType")
@ApiOperation(value = "获取比赛页赛程分类")
@ApiResponses({
@ApiResponse(code = 200, message = "成功处理请求"),
@ApiResponse(code = 401, message = "没有权限访问该服务"),
@ApiResponse(code = 403, message = "权限不足无法访问该服务"),
@ApiResponse(code = 404, message = "未发现该服务"),
@ApiResponse(code = 500, message = "服务器内部错误")
})
public ResponseData<?> getMatchHomeType(HttpServletRequest request) {
return categoryService.getMatchHomeType(request);
}
@PostMapping(value = "/getMatchList")
@ApiOperation(value = "根据 sportsId 获取赛程列表(可带可不带token,带token判断预约)")
@PostMapping(value = "/getMatchListBySportsId")
@ApiOperation(value = "根据 sportsId 获取赛程列表(可带可不带token,带token判断关注)")
@ApiResponses({
@ApiResponse(code = 200, message = "成功处理请求"),
@ApiResponse(code = 401, message = "没有权限访问该服务"),
......@@ -76,10 +76,26 @@ public class MatchController {
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "登录凭证(登录后 token 值)", dataType = "String", paramType = "header", required = true)
})
public ResponseData<?> getMatchList(@RequestBody GetMatchListRequest commonStringId, HttpServletRequest request) {
return matchService.getMatchList(commonStringId, request);
public ResponseData<?> getMatchListBySportsId(@RequestBody GetMatchListByRequest commonStringId, HttpServletRequest request) {
return matchService.getMatchListBySportsId(commonStringId, request);
}
// @PostMapping(value = "/getMatchList")
// @ApiOperation(value = "根据 sportsId 获取赛程列表(可带可不带token,带token判断预约)")
// @ApiResponses({
// @ApiResponse(code = 200, message = "成功处理请求"),
// @ApiResponse(code = 401, message = "没有权限访问该服务"),
// @ApiResponse(code = 403, message = "权限不足无法访问该服务"),
// @ApiResponse(code = 404, message = "未发现该服务"),
// @ApiResponse(code = 500, message = "服务器内部错误")
// })
// @ApiImplicitParams({
// @ApiImplicitParam(name = "token", value = "登录凭证(登录后 token 值)", dataType = "String", paramType = "header", required = true)
// })
// public ResponseData<?> getMatchList(@RequestBody GetMatchListRequest commonStringId, HttpServletRequest request) {
// return matchService.getMatchList(commonStringId, request);
// }
@PostMapping(value = "/getMatchInfo")
@ApiOperation(value = "获取赛事详情")
@ApiResponses({
......@@ -94,7 +110,7 @@ public class MatchController {
}
@PostMapping(value = "/userReserveMatch")
@ApiOperation(value = "用户预约比赛")
@ApiOperation(value = "用户关注比赛")
@ApiResponses({
@ApiResponse(code = 200, message = "成功处理请求"),
@ApiResponse(code = 401, message = "没有权限访问该服务"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment