派遣优化2

This commit is contained in:
wh_zcy 2023-03-03 18:03:23 +08:00
parent f01af25de3
commit 7360720f7e
5 changed files with 53 additions and 6 deletions

View File

@ -13,13 +13,24 @@ func (a *apiComp) AutoreceiveCheck(session comm.IUserSession, req *pb.DispatchAu
}
func (a *apiComp) Autoreceive(session comm.IUserSession, req *pb.DispatchAutoReceiveReq) (code pb.ErrorCode, data proto.Message) {
rsp := &pb.DispatchAutoReceiveResp{}
d := a.module.modelDispatch.getDBDispatch(session.GetUserId())
if d == nil {
code = pb.ErrorCode_DataNotFound
return
}
var flag bool
for _, v := range d.Nb.Tasks {
if v.Status == 2 {
flag = true
break
}
}
if !flag {
code = pb.ErrorCode_DispatchNoFinished
return
}
tasks, oldTasks := a.module.modelDispatch.replaceFinishedTask(session.GetUserId(), d)

View File

@ -3,6 +3,8 @@ package dispatch
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"google.golang.org/protobuf/proto"
)
@ -24,6 +26,14 @@ func (a *apiComp) Notice(session comm.IUserSession, req *pb.DispatchNoticeReq) (
if len(d.Nb.Tasks) == 0 {
rsp.Dispatch = a.module.modelDispatch.initDispatch(session.GetUserId(), d)
} else {
//周任务重置
n := utils.DiffDays(d.Nb.CreateTime, configure.Now().Unix())
day := a.module.configure.GetGlobalConf().DispatchWeektaskcheck
if int32(n) >= day {
d.Nb.WeekCount = 0
d.Nb.WeekReceived = []int32{}
}
a.module.modelDispatch.updateNotice(session.GetUserId(), d)
rsp.Dispatch = d.Nb
}

View File

@ -27,6 +27,21 @@ func (a *apiComp) Receive(session comm.IUserSession, req *pb.DispatchReceiveReq)
return
}
var flag bool
for _, v := range d.Nb.Tasks {
if v.TaskId == req.TaskId {
if v.Status == 2 {
flag = true
break
}
}
}
if !flag {
code = pb.ErrorCode_DispatchNoFinished
return
}
tasks, oldTaskIds := a.module.modelDispatch.replaceTask(session.GetUserId(), req.TaskId, d)
//更新公告任务

View File

@ -47,9 +47,10 @@ func (this *modelDispatch) initDispatch(uid string, dispatch *pb.DBDispatch) *pb
Uid: uid,
Ticket: ticketCount,
Nb: &pb.Noticeboard{
Lv: 1, //公告初始升级
FreeCount: freeCount,
Tasks: tasks,
Lv: 1, //公告初始升级
FreeCount: freeCount,
Tasks: tasks,
CreateTime: configure.Now().Unix(),
},
}

View File

@ -98,6 +98,7 @@ type Noticeboard struct {
WeekCount int32 `protobuf:"varint,6,opt,name=weekCount,proto3" json:"weekCount" bson:"weekCount"` //周任务数
TaskCount int32 `protobuf:"varint,7,opt,name=taskCount,proto3" json:"taskCount" bson:"taskCount"` //任务数
WeekReceived []int32 `protobuf:"varint,8,rep,packed,name=weekReceived,proto3" json:"weekReceived" bson:"weekReceived"` ////已领取的周任务索引ID
CreateTime int64 `protobuf:"varint,9,opt,name=createTime,proto3" json:"createTime" bson:"createTime"` //创建时间
}
func (x *Noticeboard) Reset() {
@ -188,6 +189,13 @@ func (x *Noticeboard) GetWeekReceived() []int32 {
return nil
}
func (x *Noticeboard) GetCreateTime() int64 {
if x != nil {
return x.CreateTime
}
return 0
}
// 派遣任务
type DispatchTask struct {
state protoimpl.MessageState
@ -286,7 +294,7 @@ var file_dispatch_dispatch_db_proto_rawDesc = []byte{
0x6e, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x4e, 0x6f, 0x74, 0x69, 0x63,
0x65, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x52, 0x02, 0x6e, 0x62, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x69,
0x63, 0x6b, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x69, 0x63, 0x6b,
0x65, 0x74, 0x22, 0x84, 0x02, 0x0a, 0x0b, 0x4e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x62, 0x6f, 0x61,
0x65, 0x74, 0x22, 0xa4, 0x02, 0x0a, 0x0b, 0x4e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x62, 0x6f, 0x61,
0x72, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x6c, 0x76, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02,
0x6c, 0x76, 0x12, 0x1e, 0x0a, 0x0a, 0x6e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x6e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x54, 0x79,
@ -302,7 +310,9 @@ var file_dispatch_dispatch_db_proto_rawDesc = []byte{
0x6f, 0x75, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x74, 0x61, 0x73, 0x6b,
0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x77, 0x65, 0x65, 0x6b, 0x52, 0x65, 0x63,
0x65, 0x69, 0x76, 0x65, 0x64, 0x18, 0x08, 0x20, 0x03, 0x28, 0x05, 0x52, 0x0c, 0x77, 0x65, 0x65,
0x6b, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x22, 0xaa, 0x01, 0x0a, 0x0c, 0x44, 0x69,
0x6b, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x72, 0x65,
0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x63,
0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0xaa, 0x01, 0x0a, 0x0c, 0x44, 0x69,
0x73, 0x70, 0x61, 0x74, 0x63, 0x68, 0x54, 0x61, 0x73, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61,
0x73, 0x6b, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b,
0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01,