提交 424ee60f 编写于 作者: M monomania

1.调试C3模型中...

上级 09276f31
package main
import (
"fmt"
"math/rand"
"strconv"
"tesou.io/platform/foot-parent/foot-api/common/base"
"tesou.io/platform/foot-parent/foot-core/common/base/service/mysql"
"tesou.io/platform/foot-parent/foot-core/module/analy/service"
......@@ -12,14 +9,13 @@ import (
func main() {
//关闭SQL输出
fmt.Println(strconv.FormatFloat(rand.Float64(), 'f', -1, 64))
mysql.ShowSQL(false)
base.Log.Info("---------------------------------------------------------------")
base.Log.Info("---------------C1模型--------------")
base.Log.Info("---------------------------------------------------------------")
c1 := new(service.C2Service)
c1 := new(service.C3Service)
c1.MaxLetBall = 1
//c1.Analy(true)
c1.AnalyTest()
base.Log.Info("---------------------------------------------------------------")
base.Log.Info("---------------E1模型--------------")
base.Log.Info("---------------------------------------------------------------")
......
......@@ -23,6 +23,10 @@ func (this *A1Service) ModelName() string {
return "A1"
}
func (this *A1Service) AnalyTest() {
this.AnalyService.AnalyTest(this)
}
/**
分析比赛数据,, 结合亚赔 赔赔差异
( 1.欧赔降水,亚赔反之,以亚赔为准)
......
......@@ -24,6 +24,10 @@ func (this *A2Service) ModelName() string {
return "A2"
}
func (this *A2Service) AnalyTest() {
this.AnalyService.AnalyTest(this)
}
/**
分析比赛数据,, 结合亚赔 赔赔差异
( 1.欧赔降水,亚赔反之,以亚赔为准)
......
......@@ -27,6 +27,10 @@ func (this *A3Service) ModelName() string {
return "A3"
}
func (this *A3Service) AnalyTest() {
this.AnalyService.AnalyTest(this)
}
func (this *A3Service) Analy(analyAll bool) {
this.AnalyService.Analy(analyAll,this)
}
......@@ -64,9 +68,7 @@ func (this *A3Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult)
}
//限制初盘,即时盘让球在0.25以内
sLetBall := math.Abs(a18Bet.SLetBall)
eLetBall := math.Abs(a18Bet.ELetBall)
if math.Abs(sLetBall-eLetBall) > 0.25 {
if math.Abs(a18Bet.SLetBall-a18Bet.ELetBall) > 0.25 {
//temp_data.Result =""
//return -2, temp_data
//return -2, nil
......
......@@ -23,6 +23,8 @@ import (
type AnalyInterface interface {
ModelName() string
AnalyTest()
Analy_Near()
Analy(analyAll bool)
......@@ -54,10 +56,25 @@ func (this *AnalyService) FindAll() []*entity5.AnalyResult {
return dataList
}
func (this *AnalyService) AnalyTest(thiz AnalyInterface) {
var currentPage, pageSize int64 = 1, 30000
var page *pojo.Page
page = new(pojo.Page)
page.PageSize = pageSize
page.CurPage = currentPage
matchList := make([]*entity2.MatchLast, 0)
err := this.MatchHisService.PageSql("SELECT mh.* FROM foot.t_match_his mh WHERE mh.`MatchDate` > '2020-03-01 00:00:00' ", page, &matchList)
if nil != err {
base.Log.Error(err)
return
}
this.Analy_Process(matchList, thiz, false)
}
func (this *AnalyService) Analy(analyAll bool, thiz AnalyInterface) {
var matchList []*entity2.MatchLast
if analyAll {
var currentPage,pageSize int64 = 1,1000
var currentPage, pageSize int64 = 1, 1000
var page *pojo.Page
page = new(pojo.Page)
page.PageSize = pageSize
......@@ -68,7 +85,7 @@ func (this *AnalyService) Analy(analyAll bool, thiz AnalyInterface) {
base.Log.Error(err)
return
}
go this.Analy_Process(matchList, thiz)
go this.Analy_Process(matchList, thiz, true)
for currentPage <= page.TotalPage {
currentPage++
page = new(pojo.Page)
......@@ -80,24 +97,23 @@ func (this *AnalyService) Analy(analyAll bool, thiz AnalyInterface) {
base.Log.Error(err)
continue
}
go this.Analy_Process(matchList, thiz)
go this.Analy_Process(matchList, thiz, true)
}
} else {
matchList = this.MatchLastService.FindNotFinished()
this.Analy_Process(matchList, thiz)
this.Analy_Process(matchList, thiz, true)
}
}
func (this *AnalyService) Analy_Near(thiz AnalyInterface) {
matchList := this.MatchLastService.FindNear()
this.Analy_Process(matchList, thiz)
this.Analy_Process(matchList, thiz, true)
}
/**
汇总结果并输出,且持久化
*/
func (this *AnalyService) Analy_Process(matchList []*entity2.MatchLast, thiz AnalyInterface) {
func (this *AnalyService) Analy_Process(matchList []*entity2.MatchLast, thiz AnalyInterface, persisted bool) {
hit_count_str := utils.GetVal(constants.SECTION_NAME, "hit_count")
hit_count, _ := strconv.Atoi(hit_count_str)
data_list_slice := make([]interface{}, 0)
......@@ -108,15 +124,6 @@ func (this *AnalyService) Analy_Process(matchList []*entity2.MatchLast, thiz Ana
for _, v := range matchList {
stub, temp_data := thiz.analyStub(v)
if nil != temp_data {
if strings.EqualFold(temp_data.Result, "命中") {
rightCount++
}
if strings.EqualFold(temp_data.Result, "错误") {
errorCount++
}
}
if stub == 0 || stub == 1 {
temp_data.TOVoid = false
hours := v.MatchDate.Sub(time.Now()).Hours()
......@@ -130,6 +137,14 @@ func (this *AnalyService) Analy_Process(matchList []*entity2.MatchLast, thiz Ana
} else if stub == 1 {
data_modify_list_slice = append(data_modify_list_slice, temp_data)
}
if strings.EqualFold(temp_data.Result, "命中") {
rightCount++
}
if strings.EqualFold(temp_data.Result, "错误") {
errorCount++
}
} else if nil != temp_data {
temp_data.TOVoid = true
if len(temp_data.Id) > 0 {
......@@ -150,8 +165,10 @@ func (this *AnalyService) Analy_Process(matchList []*entity2.MatchLast, thiz Ana
base.Log.Info("X0000场次:", errorCount)
base.Log.Info("------------------")
this.SaveList(data_list_slice)
this.ModifyList(data_modify_list_slice)
if persisted {
this.SaveList(data_list_slice)
this.ModifyList(data_modify_list_slice)
}
}
/**
......@@ -459,7 +476,6 @@ func (this *AnalyService) ActualResult(last *entity2.MatchLast, analy *entity5.A
return result
}
/**
是否是主队让球,反之是客队让球
*/
......
......@@ -28,6 +28,10 @@ func (this *C1Service) ModelName() string {
return "C1"
}
func (this *C1Service) AnalyTest() {
this.AnalyService.AnalyTest(this)
}
func (this *C1Service) Analy(analyAll bool) {
this.AnalyService.Analy(analyAll,this)
......@@ -65,9 +69,7 @@ func (this *C1Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult)
}
//限制初盘,即时盘让球在0.25以内
sLetBall := math.Abs(a18Bet.SLetBall)
eLetBall := math.Abs(a18Bet.ELetBall)
if math.Abs(sLetBall-eLetBall) > 0.25 {
if math.Abs(a18Bet.SLetBall-a18Bet.ELetBall) > 0.25 {
//temp_data.Result = ""
//return -2, temp_data
}
......
......@@ -27,9 +27,12 @@ func (this *C2Service) ModelName() string {
return "C2"
}
func (this *C2Service) Analy(analyAll bool) {
this.AnalyService.Analy(analyAll,this)
func (this *C2Service) AnalyTest() {
this.AnalyService.AnalyTest(this)
}
func (this *C2Service) Analy(analyAll bool) {
this.AnalyService.Analy(analyAll, this)
}
func (this *C2Service) Analy_Near() {
......@@ -64,9 +67,7 @@ func (this *C2Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult)
}
//限制初盘,即时盘让球在0.25以内
sLetBall := math.Abs(a18Bet.SLetBall)
eLetBall := math.Abs(a18Bet.ELetBall)
if math.Abs(sLetBall-eLetBall) > 0.25 {
if math.Abs(a18Bet.SLetBall-a18Bet.ELetBall) > 0.25 {
//temp_data.Result =""
//return -2, temp_data
}
......@@ -169,8 +170,8 @@ func (this *C2Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult)
letBall -= baseVal + float64(guestWin-mainWin)*baseVal*3
}
//
bfj_main := this.BFJinService.FindNearByTeamName(v.MatchDate,v.MainTeamId, 4)
bfj_guest := this.BFJinService.FindNearByTeamName(v.MatchDate,v.GuestTeamId, 4)
bfj_main := this.BFJinService.FindNearByTeamName(v.MatchDate, v.MainTeamId, 4)
bfj_guest := this.BFJinService.FindNearByTeamName(v.MatchDate, v.GuestTeamId, 4)
bfj_mainWin := 0
bfj_guestWin := 0
for _, e := range bfj_main {
......@@ -201,7 +202,7 @@ func (this *C2Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult)
bffe_main := this.BFFutureEventService.FindNextBattle(matchId, v.MainTeamId)
bffe_guest := this.BFFutureEventService.FindNextBattle(matchId, v.GuestTeamId)
if this.IsCupMatch(bffe_main.EventLeagueId){
if this.IsCupMatch(bffe_main.EventLeagueId) {
//下一场打杯赛
return -3, temp_data
} else {
......@@ -210,7 +211,7 @@ func (this *C2Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult)
letBall += (baseVal)
}
}
if this.IsCupMatch(bffe_guest.EventLeagueId){
if this.IsCupMatch(bffe_guest.EventLeagueId) {
//下一场打杯赛
return -3, temp_data
} else {
......@@ -224,6 +225,8 @@ func (this *C2Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult)
mainLetball := this.AnalyService.mainLetball(a18Bet)
//2.0区间段
sLetBall := math.Abs(a18Bet.SLetBall)
eLetBall := math.Abs(a18Bet.ELetBall)
var sectionBlock1, sectionBlock2 int
tLetBall := math.Abs(letBall)
//maxLetBall := math.Max(sLetBall, eLetBall)
......@@ -288,23 +291,23 @@ func (this *C2Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult)
}
}
temp_bfj_main := this.BFJinService.FindNearByTeamName(v.MatchDate,v.MainTeamId, 1)
temp_bfj_guest := this.BFJinService.FindNearByTeamName(v.MatchDate,v.GuestTeamId, 1)
temp_bfj_main := this.BFJinService.FindNearByTeamName(v.MatchDate, v.MainTeamId, 1)
temp_bfj_guest := this.BFJinService.FindNearByTeamName(v.MatchDate, v.GuestTeamId, 1)
for _, e := range temp_bfj_main {
if e.HomeTeam == v.MainTeamId && e.HomeScore > e.GuestScore {
continue
}else if e.GuestTeam == v.MainTeamId && e.GuestScore > e.HomeScore {
} else if e.GuestTeam == v.MainTeamId && e.GuestScore > e.HomeScore {
continue
}else{
} else {
return -3, temp_data
}
}
for _, e := range temp_bfj_guest {
if e.HomeTeam == v.GuestTeamId && e.HomeScore > e.GuestScore {
return -3, temp_data
}else if e.GuestTeam == v.GuestTeamId && e.GuestScore > e.HomeScore {
} else if e.GuestTeam == v.GuestTeamId && e.GuestScore > e.HomeScore {
return -3, temp_data
}else{
} else {
continue
}
}
......
......@@ -26,9 +26,12 @@ func (this *C3Service) ModelName() string {
return "C3"
}
func (this *C3Service) AnalyTest() {
this.AnalyService.AnalyTest(this)
}
func (this *C3Service) Analy(analyAll bool) {
this.AnalyService.Analy(analyAll, this)
}
func (this *C3Service) Analy_Near() {
......@@ -60,27 +63,25 @@ func (this *C3Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult)
}
//限制初盘,即时盘让球在0.25以内
sLetBall := math.Abs(a18Bet.SLetBall)
eLetBall := math.Abs(a18Bet.ELetBall)
if math.Abs(sLetBall-eLetBall) > 0.25 {
if math.Abs(a18Bet.SLetBall-a18Bet.ELetBall) > 0.25 {
//temp_data.Result =""
//return -2, temp_data
return -2, temp_data
}
//得出结果
preResult := -1
letBall := 0.00
//------
bfs_arr := this.BFScoreService.FindByMatchId(matchId)
if len(bfs_arr) < 1 {
return -1, temp_data
}
var temp_val float64
var mainZongBfs *pojo.BFScore
var mainZhuBfs *pojo.BFScore
var mainZhuJinBfs *pojo.BFScore
var guestZongBfs *pojo.BFScore
var guestKeBfs *pojo.BFScore
var guestKeJinBfs *pojo.BFScore
for _, e := range bfs_arr { //bfs_arr有多语言版本,条数很多
if e.TeamId == v.MainTeamId {
if e.Type == "总" {
......@@ -89,6 +90,9 @@ func (this *C3Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult)
if e.Type == "主" {
mainZhuBfs = e
}
if e.Type == "近" {
mainZhuJinBfs = e
}
} else if e.TeamId == v.GuestTeamId {
if e.Type == "总" {
guestZongBfs = e
......@@ -96,140 +100,133 @@ func (this *C3Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult)
if e.Type == "客" {
guestKeBfs = e
}
if e.Type == "近" {
guestKeJinBfs = e
}
}
}
if mainZongBfs == nil || guestZongBfs == nil || mainZhuBfs == nil || guestKeBfs == nil {
if mainZongBfs == nil || mainZhuBfs == nil || mainZhuJinBfs == nil || guestZongBfs == nil || guestKeBfs == nil || guestKeJinBfs == nil {
return -1, temp_data
}
baseVal := 0.068
rankDiff := 3.0
var temp_zong_val_1, temp_zong_val_2 float64 = 0, 0
var temp_jin_val_1, temp_jin_val_2 float64 = 0, 0
if mainZongBfs.MatchCount >= 8 && guestZongBfs.MatchCount >= 8 {
//排名越小越好
temp_val = float64(mainZongBfs.Ranking - guestZongBfs.Ranking)
if temp_val >= rankDiff {
xishu := 1.0
if temp_val > 11 {
xishu = 3.0
} else if temp_val > 5 {
xishu = 2.0
}
letBall -= (temp_val / rankDiff) * baseVal * xishu
}
temp_val = float64(guestZongBfs.Ranking - mainZongBfs.Ranking)
if temp_val >= rankDiff {
xishu := 1.0
if temp_val > 11 {
xishu = 3.0
} else if temp_val > 5 {
xishu = 2.0
}
letBall += (temp_val / rankDiff) * baseVal * xishu
}
temp_val = float64(mainZhuBfs.Ranking - guestKeBfs.Ranking)
if temp_val >= rankDiff {
xishu := 1.0
letBall -= (temp_val / rankDiff / 2) * baseVal * xishu
}
temp_val = float64(guestKeBfs.Ranking - mainZhuBfs.Ranking)
if temp_val >= rankDiff {
xishu := 1.0
letBall += (temp_val / rankDiff / 2) * baseVal * xishu
}
temp_zong_val_1 = float64(mainZongBfs.Ranking - guestZongBfs.Ranking)
temp_zong_val_2 = float64(mainZongBfs.GetGoal - guestZongBfs.GetGoal)
temp_jin_val_1 = float64(mainZhuJinBfs.Score - guestKeJinBfs.Score)
temp_jin_val_2 = float64(mainZhuJinBfs.GetGoal - guestKeJinBfs.GetGoal)
} else {
//return -1, temp_data
return -1, temp_data
}
//------
bffe_main := this.BFFutureEventService.FindNextBattle(matchId, v.MainTeamId)
bffe_guest := this.BFFutureEventService.FindNextBattle(matchId, v.GuestTeamId)
//保证积分榜上,进球能力有支持
if (temp_zong_val_1 > 0 && temp_zong_val_2 < 0) || (temp_zong_val_1 < 0 && temp_zong_val_2 > 0) {
return -2, temp_data
}
if this.IsCupMatch(bffe_main.EventLeagueId) {
//下一场打杯赛
//return -3, temp_data
} else {
//如果主队下一场打客场,战意充足
if v.MainTeamId == bffe_main.EventGuestTeamId {
letBall += (baseVal)
//2.0区间段
var sectionBlock1, sectionBlock2 int = -1, -1
var sectionValArr = []float64{0.0, 0.25, 0.50, 0.75, 1, 1.25, 1.5, 1.75, 2}
//总积分的让球值
tempLetball1 := math.Abs(temp_zong_val_1) / 10
for i, e := range sectionValArr {
if tempLetball1 <= e {
sectionBlock1 = i
break;
}
}
if this.IsCupMatch(bffe_guest.EventLeagueId) {
//下一场打杯赛
//return -3, temp_data
} else {
//如果客队下一场打主场,战意懈怠
if v.GuestTeamId == bffe_guest.EventMainTeamId {
letBall += (baseVal)
tempLetball2 := math.Abs(temp_zong_val_2) / 10
for i, e := range sectionValArr {
if tempLetball2 <= e {
sectionBlock2 = i
break;
}
}
//1.0判断主队是否是让球方
mainLetball := this.AnalyService.mainLetball(a18Bet)
//2.0区间段
var sectionBlock1, sectionBlock2 int
tLetBall := math.Abs(letBall)
//maxLetBall := math.Max(sLetBall, eLetBall)
tempLetball1 := math.Abs(sLetBall - tLetBall)
if tempLetball1 < 0.0 {
sectionBlock1 = 1
} else if tempLetball1 < 0.256 {
sectionBlock1 = 2
} else if tempLetball1 < 0.51 {
sectionBlock1 = 3
} else if tempLetball1 < 0.76 {
sectionBlock1 = 4
} else {
sectionBlock1 = 10000
}
tempLetball2 := math.Abs(eLetBall - tLetBall)
if tempLetball2 < 0.0 {
sectionBlock2 = 1
} else if tempLetball2 < 0.256 {
sectionBlock2 = 2
} else if tempLetball2 < 0.51 {
sectionBlock2 = 3
} else if tempLetball2 < 0.76 {
sectionBlock2 = 4
} else {
sectionBlock2 = 10000
if sectionBlock1 == -1 || sectionBlock2 == -1 {
return -3, temp_data
}
//3.0即时盘赔率大于等于初盘赔率
sLetBall := math.Abs(a18Bet.SLetBall)
eLetBall := math.Abs(a18Bet.ELetBall)
endUp := eLetBall >= sLetBall
//3.1即时盘初盘
notZero := tLetBall >= eLetBall && tLetBall >= sLetBall
if !endUp {
return -3, temp_data
}
//看两个区间是否属于同一个区间
//if sectionBlock1 == 1 && sectionBlock2 == 1 {
if sectionBlock1 <= 2 && sectionBlock2 <= 2 {
if mainLetball && letBall > 0.1 && endUp && notZero {
preResult = 3
} else if !mainLetball && letBall < -0.1 && endUp && notZero {
//preResult = 0
if matchId == "1721267" {
fmt.Println("")
}
//
var bf_begin, bf_end float64
if sectionBlock1 == sectionBlock2 {
if sectionBlock1 == 0 {
return -3, temp_data
}
bf_begin = sectionValArr[sectionBlock1] - 0.25
bf_end = sectionValArr[sectionBlock1] + 0.25
} else if sectionBlock1-sectionBlock2 == 1 || sectionBlock1-sectionBlock2 == -1 {
if sectionBlock1 < sectionBlock2 {
bf_begin = sectionValArr[sectionBlock1] - 0.25
bf_end = sectionValArr[sectionBlock2] + 0.25
} else {
bf_begin = sectionValArr[sectionBlock2] - 0.25
bf_end = sectionValArr[sectionBlock1] + 0.25
}
}
if preResult < 0 {
//存在合理区间里
var smallLetBall float64
if eLetBall-sLetBall >= 0 {
smallLetBall = sLetBall
} else {
smallLetBall = eLetBall
}
if bf_end-smallLetBall >= 0.5 {
return -3, temp_data
}
var reasonable = false
if bf_begin <= eLetBall && eLetBall <= bf_end {
reasonable = true
}
if preResult == 3 && this.IsCupMatch(bffe_main.EventLeagueId) {
//下一场打杯赛
return -3, temp_data
} else if preResult == 0 && this.IsCupMatch(bffe_guest.EventLeagueId) {
//下一场打杯赛
//1.0判断主队是否是让球方
mainLetball := this.AnalyService.mainLetball(a18Bet)
if reasonable {
if mainLetball {
preResult = 3
} else {
preResult = 0
}
} else {
}
if preResult == 3 && (temp_jin_val_1 < 0 || temp_jin_val_2 < 0) {
preResult = -1
}
if preResult == 3 && (temp_jin_val_1 > 0 || temp_jin_val_2 > 0) {
preResult = -1
}
if preResult < 0 {
return -3, temp_data
}
base.Log.Info("所属于区间:", sectionBlock1, "-", sectionBlock2, ",对阵", v.MainTeamId+":"+v.GuestTeamId, ",计算得出让球为:", letBall, ",初盘让球:", a18Bet.SLetBall, ",即时盘让球:", a18Bet.ELetBall)
base.Log.Info("所属于区间: ", bf_begin, " - ", bf_end, " ,对阵", 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
temp_data.MyLetBall = Decimal(letBall)
data = temp_data
//比赛结果
data.Result = this.IsRight(v, data)
......@@ -245,11 +242,8 @@ func (this *C3Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult)
data.AlSeq = format
data.PreResult = preResult
data.HitCount = 3
data.MyLetBall = Decimal(letBall)
//比赛结果
data.Result = this.IsRight(v, data)
return 0, data
}
}
......@@ -19,6 +19,10 @@ func (this *E1Service) ModelName() string {
return "E1"
}
func (this *E1Service) AnalyTest() {
this.AnalyService.AnalyTest(this)
}
/**
计算欧赔81 616的即时盘,和初盘的差异
*/
......
......@@ -19,6 +19,10 @@ func (this *E2Service) ModelName() string {
return "E2"
}
func (this *E2Service) AnalyTest() {
this.AnalyService.AnalyTest(this)
}
/**
计算欧赔81 616的即时盘,和初盘的差异
*/
......
......@@ -23,6 +23,10 @@ func (this *E3Service) ModelName() string {
return "E3"
}
func (this *E3Service) AnalyTest() {
this.AnalyService.AnalyTest(this)
}
/**
计算欧赔81 616的即时盘,和初盘的差异
*/
......@@ -83,7 +87,7 @@ func (this *E3Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult)
//得出结果
//1.0判断主队是否是让球方
mainLetball := this.AnalyService.mainLetball(a18Bet)
mainLetball := this.AnalyService.mainLetball(aBet365)
preResult := -1
if mainLetball{
......
......@@ -19,6 +19,10 @@ func (this *Q1Service) ModelName() string {
return "Q1"
}
func (this *Q1Service) AnalyTest() {
this.AnalyService.AnalyTest(this)
}
func (this *Q1Service) Analy(analyAll bool) {
this.AnalyService.Analy(analyAll,this)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册