提交 bdca8cb0 编写于 作者: M monomania

1.增加c4模型

上级 1ae91420
......@@ -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模型--------------")
......
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
}
}
......@@ -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己无法获取到
......
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
)
......@@ -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()
}
......
......@@ -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()
}
......
......@@ -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()
}
......
......@@ -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()
}
......
......@@ -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()
}
......
......@@ -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()
}
......
......@@ -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()
}
......
......@@ -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()
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册