公会埋点

This commit is contained in:
wh_zcy 2023-05-25 17:51:04 +08:00
parent 5ded8e1488
commit 0892a6c8e9
4 changed files with 68 additions and 56 deletions

View File

@ -11,20 +11,20 @@ import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/utils" "go_dreamfactory/utils"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"sync" "sync"
"sync/atomic" "sync/atomic"
cfg "go_dreamfactory/sys/configure/structs"
"fyne.io/fyne/v2" "fyne.io/fyne/v2"
"fyne.io/fyne/v2/container" "fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog" "fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/widget" "fyne.io/fyne/v2/widget"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/spf13/cast" "github.com/spf13/cast"
"github.com/tidwall/gjson"
) )
type RtaskTestView struct { type RtaskTestView struct {
@ -35,6 +35,7 @@ type RtaskTestView struct {
flag bool flag bool
msgs []string msgs []string
reportPath string //Json Data数据路径 reportPath string //Json Data数据路径
loadCount int32
} }
func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject { func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject {
@ -84,7 +85,7 @@ func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject {
//"F:\\projects\\workspace\\go_dreamfactory\\bin\\json" //"F:\\projects\\workspace\\go_dreamfactory\\bin\\json"
jsonPathEntry := widget.NewEntry() jsonPathEntry := widget.NewEntry()
jsonPathEntry.SetText("F:\\projects\\workspace\\go_dreamfactory\\bin\\json") jsonPathEntry.SetText("F:\\")
reportEntry := widget.NewEntry() reportEntry := widget.NewEntry()
reportEntry.SetText("F:\\") reportEntry.SetText("F:\\")
@ -101,55 +102,65 @@ func (this *RtaskTestView) CreateView(t *model.TestCase) fyne.CanvasObject {
this.reportPath = reportEntry.Text this.reportPath = reportEntry.Text
var wg sync.WaitGroup var wg sync.WaitGroup
if tb, err := cfg.NewTables(commCfg.Loader); err == nil { b, err := ioutil.ReadFile(filepath.Join(commCfg.Path, "game_rdtaskcondi.json"))
for _, v := range tb.RdtaskCondi.GetDataList() { if err != nil {
wg.Add(1) logrus.Error(err)
params := []int32{v.Data1, v.Data2, v.Data3, v.Data4, v.Data5} return
var p []int32 }
for _, v := range params {
if v > 0 { r := gjson.ParseBytes(b)
p = append(p, v)
} for _, line := range r.Array() {
logrus.Debug(line.String())
id := line.Get("id").Int()
rtype := line.Get("type").Int()
data1 := line.Get("data1").Int()
data2 := line.Get("data2").Int()
data3 := line.Get("data3").Int()
data4 := line.Get("data4").Int()
data5 := line.Get("data5").Int()
wg.Add(1)
params := []int32{int32(data1), int32(data2), int32(data3), int32(data4), int32(data5)}
var p []int32
for _, v := range params {
if v > 0 {
p = append(p, v)
} }
go func(condId, rtype int32, p []int32) {
defer wg.Done()
if err := service.GetPttService().SendToClient(
t.MainType,
t.SubType,
&pb.RtaskTestReq{
RtaskType: rtype,
Params: p,
},
); err != nil {
logrus.Error(err)
return
}
// logrus.Debugf("执行任务 id:%v rtype:%v params:%v", condId, rtype, p)
// msgs = append(msgs, fmt.Sprintf("condId:%v rtype:%v params:%v", condId, rtype, p))
}(v.Id, v.Type, p)
wg.Wait()
} }
logrus.Debugf("id:%v rtype:%v params:%v", id, rtype, p)
go func(condId, rtype int32, p []int32) {
defer wg.Done()
if err := service.GetPttService().SendToClient(
t.MainType,
t.SubType,
&pb.RtaskTestReq{
RtaskType: rtype,
Params: p,
},
); err != nil {
logrus.Error(err)
return
}
}(int32(id), int32(rtype), p)
wg.Wait()
} }
go func() { go func() {
for msg := range this.resultChan { for msg := range this.resultChan {
// logrus.Debug("add msg")
this.msgs = append(this.msgs, msg) this.msgs = append(this.msgs, msg)
// old := atomic.LoadInt32(&this.resultCount) atomic.AddInt32(&this.loadCount, 1)
// n := old - 1
// if atomic.CompareAndSwapInt32(&this.resultCount, old, n) {
// break
// }
} }
}() }()
go func() { go func() {
var flag bool var flag bool
for !flag { for !flag {
count := atomic.LoadInt32(&this.resultCount) count := atomic.LoadInt32(&this.resultCount)
logrus.Debug("count:", count) lcount := atomic.LoadInt32(&this.loadCount)
if count == 100 { // logrus.Debug("count:", count)
if count == lcount {
logrus.Debug("结束") logrus.Debug("结束")
record := strings.Join(this.msgs, "\n") record := strings.Join(this.msgs, "\n")
var buf bytes.Buffer var buf bytes.Buffer

View File

@ -669,6 +669,7 @@ const (
Rtype185 TaskType = 185 //完成X次每日1健(接取任务后每完成1次每日1健便进度加一) Rtype185 TaskType = 185 //完成X次每日1健(接取任务后每完成1次每日1健便进度加一)
Rtype186 TaskType = 186 Rtype186 TaskType = 186
Rtype187 TaskType = 187 Rtype187 TaskType = 187
Rtype188 TaskType = 188 //玩家创建1个工会
) )
const ( const (

View File

@ -79,8 +79,8 @@ func (this *ModuleRtask) registerVerifyHandle(condiId int32, condi *rtaskCondHan
func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle) { func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle) {
for _, v := range this.configure.getRtaskCondis(int32(tt)) { for _, v := range this.configure.getRtaskCondis(int32(tt)) {
switch tt { switch tt {
// 大于1个参数且第一个参数累计第二个参数等于 // 两个参数 大于1个参数且第一个参数累计第二个参数等于
case comm.Rtype1, comm.Rtype16, comm.Rtype17, comm.Rtype50, comm.Rtype125, comm.Rtype126, comm.Rtype127: case comm.Rtype1, comm.Rtype16, comm.Rtype17, comm.Rtype50, comm.Rtype125, comm.Rtype126, comm.Rtype127, comm.Rtype187:
handle := &rtaskCondHandle{ handle := &rtaskCondHandle{
condId: v.Id, condId: v.Id,
verify: this.modelRtaskRecord.verifyMultiEqual, verify: this.modelRtaskRecord.verifyMultiEqual,
@ -118,23 +118,22 @@ func (this *ModuleRtask) getHandle(tt comm.TaskType) (handles []*rtaskCondHandle
handles = append(handles, handle) handles = append(handles, handle)
this.registerVerifyHandle(v.Id, handle) this.registerVerifyHandle(v.Id, handle)
// 一个参数且累计 // 一个参数且累计
case comm.Rtype7, comm.Rtype12, comm.Rtype13, comm.Rtype14, comm.Rtype15, case comm.Rtype7,
comm.Rtype18, comm.Rtype19, comm.Rtype23, comm.Rtype24, comm.Rtype12, comm.Rtype13, comm.Rtype14, comm.Rtype15, comm.Rtype18, comm.Rtype19,
comm.Rtype26, comm.Rtype27, comm.Rtype28, comm.Rtype38, comm.Rtype23, comm.Rtype24, comm.Rtype26, comm.Rtype27, comm.Rtype28, comm.Rtype38, comm.Rtype39,
comm.Rtype39, comm.Rtype47, comm.Rtype51, comm.Rtype53, comm.Rtype47,
comm.Rtype54, comm.Rtype57, comm.Rtype60, comm.Rtype51, comm.Rtype53, comm.Rtype54, comm.Rtype57,
comm.Rtype62, comm.Rtype64, comm.Rtype87, comm.Rtype88, comm.Rtype89, comm.Rtype90, comm.Rtype60, comm.Rtype62, comm.Rtype64, comm.Rtype87, comm.Rtype88, comm.Rtype89,
comm.Rtype91, comm.Rtype92, comm.Rtype94, comm.Rtype95, comm.Rtype97, comm.Rtype104, comm.Rtype90, comm.Rtype91, comm.Rtype92, comm.Rtype94, comm.Rtype95, comm.Rtype97, comm.Rtype96, comm.Rtype98, comm.Rtype99,
comm.Rtype96, comm.Rtype98, comm.Rtype99, comm.Rtype102, comm.Rtype103, comm.Rtype105, comm.Rtype104, comm.Rtype102, comm.Rtype103, comm.Rtype105, comm.Rtype106, comm.Rtype108,
comm.Rtype106, comm.Rtype108, comm.Rtype113, comm.Rtype114, comm.Rtype115, comm.Rtype116, comm.Rtype113, comm.Rtype114, comm.Rtype115, comm.Rtype116, comm.Rtype117, comm.Rtype118, comm.Rtype119,
comm.Rtype117, comm.Rtype118, comm.Rtype119, comm.Rtype120, comm.Rtype121, comm.Rtype123, comm.Rtype120, comm.Rtype121, comm.Rtype123, comm.Rtype124, comm.Rtype128,
comm.Rtype124, comm.Rtype130, comm.Rtype131, comm.Rtype132, comm.Rtype135,
comm.Rtype128, comm.Rtype130, comm.Rtype131, comm.Rtype132, comm.Rtype135, comm.Rtype141, comm.Rtype142, comm.Rtype143, comm.Rtype144, comm.Rtype145, comm.Rtype146, comm.Rtype147, comm.Rtype148, comm.Rtype149,
comm.Rtype141, comm.Rtype142, comm.Rtype143, comm.Rtype144, comm.Rtype145, comm.Rtype146, comm.Rtype152, comm.Rtype153, comm.Rtype154, comm.Rtype156,
comm.Rtype147, comm.Rtype148, comm.Rtype149, comm.Rtype152, comm.Rtype153, comm.Rtype154, comm.Rtype161, comm.Rtype165, comm.Rtype166, comm.Rtype167,
comm.Rtype156, comm.Rtype161, comm.Rtype165, comm.Rtype166, comm.Rtype167,
comm.Rtype171, comm.Rtype172, comm.Rtype173, comm.Rtype175, comm.Rtype177, comm.Rtype171, comm.Rtype172, comm.Rtype173, comm.Rtype175, comm.Rtype177,
comm.Rtype181, comm.Rtype182, comm.Rtype183, comm.Rtype184, comm.Rtype185, comm.Rtype186, comm.Rtype187: comm.Rtype181, comm.Rtype182, comm.Rtype183, comm.Rtype184, comm.Rtype185, comm.Rtype186, comm.Rtype188:
handle := &rtaskCondHandle{ handle := &rtaskCondHandle{
condId: v.Id, condId: v.Id,
verify: this.modelRtaskRecord.verifyFirstGreatEqualParam, verify: this.modelRtaskRecord.verifyFirstGreatEqualParam,

View File

@ -136,6 +136,7 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
return return
} }
go this.module.ModuleRtask.TriggerTask(session.GetUserId(), comm.GettaskParam(comm.Rtype188, 1))
// 初始化玩家公会任务 // 初始化玩家公会任务
go func() { go func() {
if err := this.module.modelSociatyTask.initSociatyTask(user.Uid, sociaty.Id); err != nil { if err := this.module.modelSociatyTask.initSociatyTask(user.Uid, sociaty.Id); err != nil {