This commit is contained in:
shoopea 2020-01-13 16:42:26 +08:00
parent c2d51ce662
commit 9d7d962c28

21
job.go
View File

@ -593,9 +593,14 @@ func jobMsgDelete(j Job) {
err := setJobStart(j.ID64) err := setJobStart(j.ID64)
logOnError(err, "jobMsgDel : setJobStart") logOnError(err, "jobMsgDel : setJobStart")
log.Printf("jobMsgDelete[%d] : Starting.\n", j.ID64)
err = json.Unmarshal(j.Payload, &p) err = json.Unmarshal(j.Payload, &p)
logOnError(err, "jobMsgDel : Unmarshal payload") logOnError(err, "jobMsgDel : Unmarshal payload")
b, _ := json.Marshal(p)
log.Printf("jobMsgDelete[%d] : Payload => %s.\n", j.ID64, string(b))
if j.Trigger != 0 && p.MsgTypeID64 != 0 { if j.Trigger != 0 && p.MsgTypeID64 != 0 {
logOnError(err, "jobMsgDel : getObjMsg msg") logOnError(err, "jobMsgDel : getObjMsg msg")
id, err := getObjSubTypeId(j.Trigger) id, err := getObjSubTypeId(j.Trigger)
@ -1373,6 +1378,8 @@ func jobGWithdraw(j Job) {
doneTab map[int64]int64 doneTab map[int64]int64
) )
log.Printf("jobGWithdraw[%d] : Starting.\n", j.ID64)
reqTab = make(map[int64]int64) reqTab = make(map[int64]int64)
reqTab[cacheObjSubType[`item_res`]] = 1 << 0 reqTab[cacheObjSubType[`item_res`]] = 1 << 0
reqTab[cacheObjSubType[`item_alch`]] = 1 << 1 reqTab[cacheObjSubType[`item_alch`]] = 1 << 1
@ -1427,7 +1434,7 @@ func jobGWithdraw(j Job) {
} }
if (p.Status & reqTab[cacheObjSubType[`item_res`]]) == reqTab[cacheObjSubType[`item_res`]] { if (p.Status & reqTab[cacheObjSubType[`item_res`]]) == reqTab[cacheObjSubType[`item_res`]] {
log.Printf("jobGWithdraw : Requesting res.\n") log.Printf("jobGWithdraw[%d] : Requesting res.\n", j.ID64)
p.Status = p.Status &^ reqTab[cacheObjSubType[`item_res`]] p.Status = p.Status &^ reqTab[cacheObjSubType[`item_res`]]
p.Status = p.Status | doneTab[cacheObjSubType[`item_res`]] p.Status = p.Status | doneTab[cacheObjSubType[`item_res`]]
@ -1442,7 +1449,7 @@ func jobGWithdraw(j Job) {
createJobCallback(cacheObjSubType[`job_msg_del`], j.UserID64, p2.MsgTypeID64, b2, time.Minute) createJobCallback(cacheObjSubType[`job_msg_del`], j.UserID64, p2.MsgTypeID64, b2, time.Minute)
clientSendCWMsg(j.UserID64, `/g_stock_res`) clientSendCWMsg(j.UserID64, `/g_stock_res`)
} else if (p.Status & reqTab[cacheObjSubType[`item_alch`]]) == reqTab[cacheObjSubType[`item_alch`]] { } else if (p.Status & reqTab[cacheObjSubType[`item_alch`]]) == reqTab[cacheObjSubType[`item_alch`]] {
log.Printf("jobGWithdraw : Requesting alch.\n") log.Printf("jobGWithdraw[%d] : Requesting alch.\n", j.ID64)
p.Status = p.Status &^ reqTab[cacheObjSubType[`item_alch`]] p.Status = p.Status &^ reqTab[cacheObjSubType[`item_alch`]]
p.Status = p.Status | doneTab[cacheObjSubType[`item_alch`]] p.Status = p.Status | doneTab[cacheObjSubType[`item_alch`]]
@ -1457,7 +1464,7 @@ func jobGWithdraw(j Job) {
createJobCallback(cacheObjSubType[`job_msg_del`], j.UserID64, p2.MsgTypeID64, b2, time.Minute) createJobCallback(cacheObjSubType[`job_msg_del`], j.UserID64, p2.MsgTypeID64, b2, time.Minute)
clientSendCWMsg(j.UserID64, `/g_stock_alch`) clientSendCWMsg(j.UserID64, `/g_stock_alch`)
} else if (p.Status & reqTab[cacheObjSubType[`item_misc`]]) == reqTab[cacheObjSubType[`item_misc`]] { } else if (p.Status & reqTab[cacheObjSubType[`item_misc`]]) == reqTab[cacheObjSubType[`item_misc`]] {
log.Printf("jobGWithdraw : Requesting misc.\n") log.Printf("jobGWithdraw[%d] : Requesting misc.\n", j.ID64)
p.Status = p.Status &^ reqTab[cacheObjSubType[`item_misc`]] p.Status = p.Status &^ reqTab[cacheObjSubType[`item_misc`]]
p.Status = p.Status | doneTab[cacheObjSubType[`item_misc`]] p.Status = p.Status | doneTab[cacheObjSubType[`item_misc`]]
@ -1472,7 +1479,7 @@ func jobGWithdraw(j Job) {
createJobCallback(cacheObjSubType[`job_msg_del`], j.UserID64, p2.MsgTypeID64, b2, time.Minute) createJobCallback(cacheObjSubType[`job_msg_del`], j.UserID64, p2.MsgTypeID64, b2, time.Minute)
clientSendCWMsg(j.UserID64, `/g_stock_misc`) clientSendCWMsg(j.UserID64, `/g_stock_misc`)
} else if (p.Status & reqTab[cacheObjSubType[`item_recipe`]]) == reqTab[cacheObjSubType[`item_recipe`]] { } else if (p.Status & reqTab[cacheObjSubType[`item_recipe`]]) == reqTab[cacheObjSubType[`item_recipe`]] {
log.Printf("jobGWithdraw : Requesting recipe.\n") log.Printf("jobGWithdraw[%d] : Requesting recipe.\n", j.ID64)
p.Status = p.Status &^ reqTab[cacheObjSubType[`item_recipe`]] p.Status = p.Status &^ reqTab[cacheObjSubType[`item_recipe`]]
p.Status = p.Status | doneTab[cacheObjSubType[`item_recipe`]] p.Status = p.Status | doneTab[cacheObjSubType[`item_recipe`]]
@ -1487,7 +1494,7 @@ func jobGWithdraw(j Job) {
createJobCallback(cacheObjSubType[`job_msg_del`], j.UserID64, p2.MsgTypeID64, b2, time.Minute) createJobCallback(cacheObjSubType[`job_msg_del`], j.UserID64, p2.MsgTypeID64, b2, time.Minute)
clientSendCWMsg(j.UserID64, `/g_stock_rec`) clientSendCWMsg(j.UserID64, `/g_stock_rec`)
} else if (p.Status & reqTab[cacheObjSubType[`item_part`]]) == reqTab[cacheObjSubType[`item_part`]] { } else if (p.Status & reqTab[cacheObjSubType[`item_part`]]) == reqTab[cacheObjSubType[`item_part`]] {
log.Printf("jobGWithdraw : Requesting part.\n") log.Printf("jobGWithdraw[%d] : Requesting part.\n", j.ID64)
p.Status = p.Status &^ reqTab[cacheObjSubType[`item_part`]] p.Status = p.Status &^ reqTab[cacheObjSubType[`item_part`]]
p.Status = p.Status | doneTab[cacheObjSubType[`item_part`]] p.Status = p.Status | doneTab[cacheObjSubType[`item_part`]]
@ -1502,7 +1509,7 @@ func jobGWithdraw(j Job) {
createJobCallback(cacheObjSubType[`job_msg_del`], j.UserID64, p2.MsgTypeID64, b2, time.Minute) createJobCallback(cacheObjSubType[`job_msg_del`], j.UserID64, p2.MsgTypeID64, b2, time.Minute)
clientSendCWMsg(j.UserID64, `/g_stock_part`) clientSendCWMsg(j.UserID64, `/g_stock_part`)
} else if (p.Status & reqTab[cacheObjSubType[`item_other`]]) == reqTab[cacheObjSubType[`item_other`]] { } else if (p.Status & reqTab[cacheObjSubType[`item_other`]]) == reqTab[cacheObjSubType[`item_other`]] {
log.Printf("jobGWithdraw : Requesting other.\n") log.Printf("jobGWithdraw[%d] : Requesting other.\n", j.ID64)
p.Status = p.Status &^ reqTab[cacheObjSubType[`item_other`]] p.Status = p.Status &^ reqTab[cacheObjSubType[`item_other`]]
p.Status = p.Status | doneTab[cacheObjSubType[`item_other`]] p.Status = p.Status | doneTab[cacheObjSubType[`item_other`]]
@ -1517,7 +1524,7 @@ func jobGWithdraw(j Job) {
createJobCallback(cacheObjSubType[`job_msg_del`], j.UserID64, p2.MsgTypeID64, b2, time.Minute) createJobCallback(cacheObjSubType[`job_msg_del`], j.UserID64, p2.MsgTypeID64, b2, time.Minute)
clientSendCWMsg(j.UserID64, `/g_stock_other`) clientSendCWMsg(j.UserID64, `/g_stock_other`)
} else { } else {
log.Printf("jobGWithdraw : got all the info\n") log.Printf("jobGWithdraw[%d] : got all the info\n", j.ID64)
} }
err = setJobDone(j.ID64) err = setJobDone(j.ID64)