From bdca8cb04129014a17216ef9d6bbc758a50216eb Mon Sep 17 00:00:00 2001 From: monomania Date: Sat, 28 Mar 2020 06:45:18 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0c4=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FC002AnalyTest.go | 4 +- foot-core/module/analy/service/C4Service.go | 161 ++++++++++++++++++ foot-spider/launch/FS101PortalApplication.go | 2 +- foot-spider/module/win007/Constant.go | 62 ++++--- .../win007/proc/AsiaLastNewProcesser.go | 4 +- .../module/win007/proc/BaseFaceProcesser.go | 4 +- .../module/win007/proc/EuroLastProcesser.go | 4 +- .../module/win007/proc/EuroTrackProcesser.go | 4 +- .../module/win007/proc/LeagueProcesser.go | 4 +- .../win007/proc/LeagueSeasonProcesser.go | 4 +- .../module/win007/proc/MatchHisProcesser.go | 4 +- .../module/win007/proc/MatchLastProcesser.go | 2 +- 12 files changed, 213 insertions(+), 46 deletions(-) create mode 100644 foot-core/module/analy/service/C4Service.go diff --git a/FC002AnalyTest.go b/FC002AnalyTest.go index b754a3e..9d27ca0 100644 --- a/FC002AnalyTest.go +++ b/FC002AnalyTest.go @@ -13,8 +13,8 @@ func main() { base.Log.Info("---------------------------------------------------------------") base.Log.Info("---------------C1模型--------------") base.Log.Info("---------------------------------------------------------------") - c1 := new(service.C3Service) - c1.MaxLetBall = 1 + c1 := new(service.C4Service) + c1.MaxLetBall = 2 c1.AnalyTest() base.Log.Info("---------------------------------------------------------------") base.Log.Info("---------------E1模型--------------") diff --git a/foot-core/module/analy/service/C4Service.go b/foot-core/module/analy/service/C4Service.go new file mode 100644 index 0000000..ebe6db1 --- /dev/null +++ b/foot-core/module/analy/service/C4Service.go @@ -0,0 +1,161 @@ +package service + +import ( + "math" + "strings" + "tesou.io/platform/foot-parent/foot-api/common/base" + pojo2 "tesou.io/platform/foot-parent/foot-api/common/base/pojo" + entity5 "tesou.io/platform/foot-parent/foot-api/module/analy/pojo" + "tesou.io/platform/foot-parent/foot-api/module/match/pojo" + entity3 "tesou.io/platform/foot-parent/foot-api/module/odds/pojo" + "tesou.io/platform/foot-parent/foot-core/module/analy/constants" + "tesou.io/platform/foot-parent/foot-core/module/match/service" + "time" +) + +type C4Service struct { + AnalyService + service.BFScoreService + service.BFBattleService + service.BFFutureEventService + service.BFJinService + + //最大让球数据 + MaxLetBall float64 +} + +func (this *C4Service) ModelName() string { + return "C4" +} + +func (this *C4Service) AnalyTest() { + this.AnalyService.AnalyTest(this) +} + +func (this *C4Service) Analy(analyAll bool) { + this.AnalyService.Analy(analyAll, this) +} + +func (this *C4Service) Analy_Near() { + this.AnalyService.Analy_Near(this) +} + +/** + -1 参数错误 + -2 不符合让球数 + -3 计算分析错误 + 0 新增的分析结果 + 1 需要更新结果 + */ +func (this *C4Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult) { + temp_data := this.Find(v.Id, this.ModelName()) + matchId := v.Id + //声明使用变量 + var a18Bet *entity3.AsiaHis + //亚赔 + aList := this.AsiaHisService.FindByMatchIdCompId(matchId, constants.C1_REFER_ASIA) + if len(aList) < 1 { + return -1, temp_data + } + a18Bet = aList[0] + temp_data.LetBall = a18Bet.ELetBall + if math.Abs(a18Bet.ELetBall) > this.MaxLetBall { + //temp_data.Result ="" + return -2, temp_data + } + + //限制初盘,即时盘让球在0.25以内 + if math.Abs(a18Bet.SLetBall-a18Bet.ELetBall) > 0.25 { + //temp_data.Result ="" + //return -2, temp_data + } + + //得出结果 + preResult := -1 + + matchDateStr := v.MatchDate.Format("2006-01-02 15:04:05") + var currentPage, pageSize int64 = 1, 10 + var page *pojo2.Page + page = new(pojo2.Page) + page.PageSize = pageSize + page.CurPage = currentPage + mainJinList := make([]*pojo.BFJin, 0) + err1 := this.BFJinService.PageSql("SELECT j.* FROM foot.t_b_f_jin j WHERE j.HomeTeam = "+v.MainTeamId+" AND STR_TO_DATE(j.MatchTimeStr, '%Y%m%d%H%i%s') < '"+matchDateStr+"' ORDER BY j.MatchTimeStr DESC ", page, &mainJinList) + if nil != err1 { + base.Log.Error(err1) + return -2, temp_data + } + + guestJinList := make([]*pojo.BFJin, 0) + err2 := this.BFJinService.PageSql("SELECT j.* FROM foot.t_b_f_jin j WHERE j.HomeTeam = "+v.MainTeamId+" AND STR_TO_DATE(j.MatchTimeStr, '%Y%m%d%H%i%s') < '"+matchDateStr+"' ORDER BY j.MatchTimeStr DESC ", page, &guestJinList) + if nil != err2 { + base.Log.Error(err2) + return -2, temp_data + } + + if len(mainJinList) < 10 || len(guestJinList) < 10 { + return -2, temp_data + } + + mainGoal,guestGoal := 0,0 + mainScore,guestScore := 0,0 + for _, temp := range mainJinList { + if strings.EqualFold(temp.HomeTeam,v.MainTeamId){ + mainGoal += temp.HomeScore + if temp.HomeScore > temp.GuestScore{ + mainScore += 3 + } + } + if strings.EqualFold(temp.GuestTeam,v.MainTeamId){ + mainGoal += temp.GuestScore + if temp.GuestScore > temp.HomeScore{ + mainScore += 3 + } + } + } + + + for _, temp := range guestJinList { + if strings.EqualFold(temp.HomeTeam,v.GuestTeamId){ + guestGoal += temp.HomeScore + if temp.HomeScore > temp.GuestScore{ + guestScore += 3 + } + } + if strings.EqualFold(temp.GuestTeam,v.GuestTeamId){ + guestGoal += temp.GuestScore + if temp.GuestScore > temp.HomeScore{ + guestScore += 3 + } + } + } + + + + + base.Log.Info("总进球:", mainGoal,":",guestGoal, " ,得分:", mainScore,":",guestScore, " ,对阵", v.MainTeamId+":"+v.GuestTeamId, ",初盘让球:", a18Bet.SLetBall, ",即时盘让球:", a18Bet.ELetBall) + var data *entity5.AnalyResult + if len(temp_data.Id) > 0 { + temp_data.PreResult = preResult + temp_data.HitCount = temp_data.HitCount + 1 + temp_data.LetBall = a18Bet.ELetBall + data = temp_data + //比赛结果 + data.Result = this.IsRight(v, data) + return 1, data + } else { + data = new(entity5.AnalyResult) + data.MatchId = v.Id + data.MatchDate = v.MatchDate + data.SLetBall = a18Bet.SLetBall + data.LetBall = a18Bet.ELetBall + data.AlFlag = this.ModelName() + format := time.Now().Format("0102150405") + data.AlSeq = format + data.PreResult = preResult + data.HitCount = 3 + //比赛结果 + data.Result = this.IsRight(v, data) + return 0, data + } +} diff --git a/foot-spider/launch/FS101PortalApplication.go b/foot-spider/launch/FS101PortalApplication.go index 62de43f..da55ce0 100644 --- a/foot-spider/launch/FS101PortalApplication.go +++ b/foot-spider/launch/FS101PortalApplication.go @@ -77,7 +77,7 @@ func Spider_History() { for _, v := range seasons { mysql.ShowSQL(true) Spider_match_his(v) - go Spider_euroLast_his(v) + //go Spider_euroLast_his(v) go Spider_asiaLastNew_his(v) go Spider_baseFace_his(v) //欧赔历史变盘euro track win007己无法获取到 diff --git a/foot-spider/module/win007/Constant.go b/foot-spider/module/win007/Constant.go index 7cf896e..00d6c91 100644 --- a/foot-spider/module/win007/Constant.go +++ b/foot-spider/module/win007/Constant.go @@ -1,30 +1,36 @@ package win007 -const MODULE_FLAG = "win007" - -const WIN007_BASE_URL = "http://m.win007.com/" - -/** - * 比赛分析页面数据 - */ -const WIN007_BASE_FACE_URL_PATTERN = "http://m.win007.com/analy/Analysis/${matchId}.htm" - -/** - * 欧赔, scheid为比赛Id , cId为公司Id - */ -const WIN007_EUROODD_URL_PATTERN = "http://m.win007.com/Compensate/${matchId}.htm" -const WIN007_EUROODD_BET_URL_PATTERN = "http://m.win007.com/1x2Detail.aspx?scheid=${scheid}&cId=${cId}" - -/** - * 亚赔, scheid为比赛Id , cId为公司Id - */ -const WIN007_ASIAODD_URL_PATTERN = "http://m.win007.com/asian/${matchId}.htm" -const WIN007_ASIAODD_NEW_URL_PATTERN = "http://m.win007.com/HandicapDataInterface.ashx?scheid=${matchId}&type=1&oddskind=0&flesh=${flesh}" - -/** -资料库里的比赛赛程前缀 -示例:http://m.win007.com/info/Fixture/2019-2020/34_0_0.htm - */ -const WIN007_MATCH_HIS_PATTERN = "http://m.win007.com/info/Fixture/${season}/${leagueId}_${subId}_${round}.htm" - - +const ( + MODULE_FLAG = "win007" + + WIN007_BASE_URL = "http://m.win007.com/" + + /** + * 比赛分析页面数据 + */ + WIN007_BASE_FACE_URL_PATTERN = "http://m.win007.com/analy/Analysis/${matchId}.htm" + + /** + * 欧赔, scheid为比赛Id , cId为公司Id + */ + WIN007_EUROODD_URL_PATTERN = "http://m.win007.com/Compensate/${matchId}.htm" + WIN007_EUROODD_BET_URL_PATTERN = "http://m.win007.com/1x2Detail.aspx?scheid=${scheid}&cId=${cId}" + + /** + * 亚赔, scheid为比赛Id , cId为公司Id + */ + WIN007_ASIAODD_URL_PATTERN = "http://m.win007.com/asian/${matchId}.htm" + WIN007_ASIAODD_NEW_URL_PATTERN = "http://m.win007.com/HandicapDataInterface.ashx?scheid=${matchId}&type=1&oddskind=0&flesh=${flesh}" + + /** + 资料库里的比赛赛程前缀 + 示例:http://m.win007.com/info/Fixture/2019-2020/34_0_0.htm + */ + WIN007_MATCH_HIS_PATTERN = "http://m.win007.com/info/Fixture/${season}/${leagueId}_${subId}_${round}.htm" +) + +const ( + SLEEP_RAND_S = 10 + SLEEP_RAND_E = 200 + +) diff --git a/foot-spider/module/win007/proc/AsiaLastNewProcesser.go b/foot-spider/module/win007/proc/AsiaLastNewProcesser.go index 5c92374..4b62546 100644 --- a/foot-spider/module/win007/proc/AsiaLastNewProcesser.go +++ b/foot-spider/module/win007/proc/AsiaLastNewProcesser.go @@ -54,7 +54,7 @@ func (this *AsiaLastNewProcesser) Startup() { //先将前面的spider启动 newSpider.SetDownloader(down.NewMAsiaLastApiDownloader()) newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole()) - newSpider.SetSleepTime("rand", 1, 300) + newSpider.SetSleepTime("rand", win007.SLEEP_RAND_S, win007.SLEEP_RAND_E) newSpider.SetThreadnum(10).Run() processer = GetAsiaLastNewProcesser() @@ -77,7 +77,7 @@ func (this *AsiaLastNewProcesser) Startup() { newSpider.SetDownloader(down.NewMAsiaLastApiDownloader()) newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole()) - newSpider.SetSleepTime("rand", 1, 300) + newSpider.SetSleepTime("rand", win007.SLEEP_RAND_S, win007.SLEEP_RAND_E) newSpider.SetThreadnum(1).Run() } diff --git a/foot-spider/module/win007/proc/BaseFaceProcesser.go b/foot-spider/module/win007/proc/BaseFaceProcesser.go index 54b72cf..e8f0e50 100644 --- a/foot-spider/module/win007/proc/BaseFaceProcesser.go +++ b/foot-spider/module/win007/proc/BaseFaceProcesser.go @@ -58,7 +58,7 @@ func (this *BaseFaceProcesser) Startup() { //先将前面的spider启动 newSpider.SetDownloader(down.NewMWin007Downloader()) newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole()) - newSpider.SetSleepTime("rand", 1, 300) + newSpider.SetSleepTime("rand", win007.SLEEP_RAND_S, win007.SLEEP_RAND_E) newSpider.SetThreadnum(10).Run() processer = GetBaseFaceProcesser() @@ -80,7 +80,7 @@ func (this *BaseFaceProcesser) Startup() { newSpider.SetDownloader(down.NewMWin007Downloader()) newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole()) - newSpider.SetSleepTime("rand", 1, 300) + newSpider.SetSleepTime("rand", win007.SLEEP_RAND_S, win007.SLEEP_RAND_E) newSpider.SetThreadnum(1).Run() } diff --git a/foot-spider/module/win007/proc/EuroLastProcesser.go b/foot-spider/module/win007/proc/EuroLastProcesser.go index b30f9da..52da57f 100644 --- a/foot-spider/module/win007/proc/EuroLastProcesser.go +++ b/foot-spider/module/win007/proc/EuroLastProcesser.go @@ -60,7 +60,7 @@ func (this *EuroLastProcesser) Startup() { //先将前面的spider启动 newSpider.SetDownloader(down.NewMWin007Downloader()) newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole()) - newSpider.SetSleepTime("rand", 1, 300) + newSpider.SetSleepTime("rand", win007.SLEEP_RAND_S, win007.SLEEP_RAND_E) newSpider.SetThreadnum(10).Run() processer = GetEuroLastProcesser() @@ -82,7 +82,7 @@ func (this *EuroLastProcesser) Startup() { newSpider.SetDownloader(down.NewMWin007Downloader()) newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole()) - newSpider.SetSleepTime("rand", 1, 300) + newSpider.SetSleepTime("rand", win007.SLEEP_RAND_S, win007.SLEEP_RAND_E) newSpider.SetThreadnum(1).Run() } diff --git a/foot-spider/module/win007/proc/EuroTrackProcesser.go b/foot-spider/module/win007/proc/EuroTrackProcesser.go index d752b02..847ca6e 100644 --- a/foot-spider/module/win007/proc/EuroTrackProcesser.go +++ b/foot-spider/module/win007/proc/EuroTrackProcesser.go @@ -59,7 +59,7 @@ func (this *EuroTrackProcesser) Startup() { //先将前面的spider启动 newSpider.SetDownloader(down.NewMWin007Downloader()) newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole()) - newSpider.SetSleepTime("rand", 1, 300) + newSpider.SetSleepTime("rand", win007.SLEEP_RAND_S, win007.SLEEP_RAND_E) newSpider.SetThreadnum(10).Run() processer = GetEuroTrackProcesser() @@ -83,7 +83,7 @@ func (this *EuroTrackProcesser) Startup() { newSpider.SetDownloader(down.NewMWin007Downloader()) newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole()) - newSpider.SetSleepTime("rand", 1, 300) + newSpider.SetSleepTime("rand", win007.SLEEP_RAND_S, win007.SLEEP_RAND_E) newSpider.SetThreadnum(1).Run() } diff --git a/foot-spider/module/win007/proc/LeagueProcesser.go b/foot-spider/module/win007/proc/LeagueProcesser.go index 4a726e0..cc47934 100644 --- a/foot-spider/module/win007/proc/LeagueProcesser.go +++ b/foot-spider/module/win007/proc/LeagueProcesser.go @@ -70,14 +70,14 @@ func (this *LeagueProcesser) Startup() { if i%10 == 0 { //10个联赛一个spider,总数1000多个联赛,最多100spider newSpider.SetDownloader(down.NewMWin007Downloader()) newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole()) - newSpider.SetSleepTime("rand", 1, 300) + newSpider.SetSleepTime("rand", win007.SLEEP_RAND_S, win007.SLEEP_RAND_E) newSpider.SetThreadnum(1).Run() } }) newSpider.SetDownloader(down.NewMWin007Downloader()) newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole()) - newSpider.SetSleepTime("rand", 1, 300) + newSpider.SetSleepTime("rand", win007.SLEEP_RAND_S, win007.SLEEP_RAND_E) newSpider.SetThreadnum(1).Run() } diff --git a/foot-spider/module/win007/proc/LeagueSeasonProcesser.go b/foot-spider/module/win007/proc/LeagueSeasonProcesser.go index 01f1a7b..1b93d13 100644 --- a/foot-spider/module/win007/proc/LeagueSeasonProcesser.go +++ b/foot-spider/module/win007/proc/LeagueSeasonProcesser.go @@ -83,14 +83,14 @@ func (this *LeagueSeasonProcesser) Startup() { if i % 10 == 0 {//10个联赛一个spider,总数1000多个联赛,最多100spider newSpider.SetDownloader(down.NewMWin007Downloader()) newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole()) - newSpider.SetSleepTime("rand", 1, 300) + newSpider.SetSleepTime("rand", win007.SLEEP_RAND_S, win007.SLEEP_RAND_E) newSpider.SetThreadnum(10).Run() } } newSpider.SetDownloader(down.NewMWin007Downloader()) newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole()) - newSpider.SetSleepTime("rand", 1, 300) + newSpider.SetSleepTime("rand", win007.SLEEP_RAND_S, win007.SLEEP_RAND_E) newSpider.SetThreadnum(1).Run() } diff --git a/foot-spider/module/win007/proc/MatchHisProcesser.go b/foot-spider/module/win007/proc/MatchHisProcesser.go index 5838a26..50a1c65 100644 --- a/foot-spider/module/win007/proc/MatchHisProcesser.go +++ b/foot-spider/module/win007/proc/MatchHisProcesser.go @@ -70,7 +70,7 @@ func (this *MatchHisProcesser) Startup() { //先将前面的spider启动 newSpider.SetDownloader(down.NewMWin007Downloader()) newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole()) - newSpider.SetSleepTime("rand", 1, 300) + newSpider.SetSleepTime("rand", win007.SLEEP_RAND_S, win007.SLEEP_RAND_E) newSpider.SetThreadnum(10).Run() processer = GetMatchHisProcesser() @@ -94,7 +94,7 @@ func (this *MatchHisProcesser) Startup() { newSpider.SetDownloader(down.NewMWin007Downloader()) newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole()) - newSpider.SetSleepTime("rand", 1, 300) + newSpider.SetSleepTime("rand", win007.SLEEP_RAND_S, win007.SLEEP_RAND_E) newSpider.SetThreadnum(1).Run() } diff --git a/foot-spider/module/win007/proc/MatchLastProcesser.go b/foot-spider/module/win007/proc/MatchLastProcesser.go index c4a773b..f4b75af 100644 --- a/foot-spider/module/win007/proc/MatchLastProcesser.go +++ b/foot-spider/module/win007/proc/MatchLastProcesser.go @@ -57,7 +57,7 @@ func (this *MatchLastProcesser) Startup() { newSpider = newSpider.AddUrl(this.MatchlastUrl, "text") newSpider.SetDownloader(down.NewMWin007Downloader()) newSpider = newSpider.AddPipeline(pipeline.NewPipelineConsole()) - newSpider.SetSleepTime("rand", 1, 300) + newSpider.SetSleepTime("rand", win007.SLEEP_RAND_S, win007.SLEEP_RAND_E) newSpider.SetThreadnum(1).Run() } -- GitLab