refresh job
This commit is contained in:
@@ -78,7 +78,7 @@ func PublishJob(ctx *jxcontext.Context, job *model.Job) (err error) {
|
||||
if job.UserID == "" {
|
||||
return fmt.Errorf("任务发起人不能为空!")
|
||||
}
|
||||
jobs, err := dao.GetJobsNoPage(db, []string{job.UserID}, nil, utils.Str2Time(fromTime), utils.Str2Time(toTime), false)
|
||||
jobs, err := dao.GetJobsNoPage(db, []string{job.UserID}, nil, nil, utils.Str2Time(fromTime), utils.Str2Time(toTime), false)
|
||||
if len(jobs) > 0 {
|
||||
members, err := dao.GetUserMember(db, job.UserID, 0, 0, true)
|
||||
if err != nil {
|
||||
@@ -424,3 +424,23 @@ func AuditJob(ctx *jxcontext.Context, jobOrderID, status int, comment string) (e
|
||||
dao.Commit(db)
|
||||
return err
|
||||
}
|
||||
|
||||
func RefreshJobStatus(ctx *jxcontext.Context) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
globals.SugarLogger.Debugf("RefreshJobStatus begin...")
|
||||
jobs, err := dao.GetJobsNoPage(db, nil, nil, []int{model.JobStatusDoing}, utils.ZeroTimeValue, utils.ZeroTimeValue, false)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("RefreshJobStatus err :%v", err)
|
||||
return
|
||||
}
|
||||
for _, job := range jobs {
|
||||
if time.Now().Sub(job.FinishedAt) >= 0 {
|
||||
job.Status = model.JobStatusOverdue
|
||||
dao.UpdateEntity(db, job, "Status")
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Debugf("RefreshJobStatus end...")
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ package misc
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
@@ -10,7 +13,7 @@ import (
|
||||
|
||||
var (
|
||||
dailyWorkTimeList = []string{
|
||||
"20:30:00",
|
||||
"00:00:30",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -22,6 +25,8 @@ func Init() {
|
||||
|
||||
func doDailyWork() {
|
||||
globals.SugarLogger.Debug("doDailyWork")
|
||||
//刷新任务过期状态
|
||||
cms.RefreshUserMemberStatus(jxcontext.AdminCtx)
|
||||
}
|
||||
|
||||
// 按时间序列循环
|
||||
|
||||
@@ -88,7 +88,7 @@ func GetJobs(db *DaoDB, userIDs []string, categoryIDs, statuss, vendorIDs []int,
|
||||
return pagedInfo, err
|
||||
}
|
||||
|
||||
func GetJobsNoPage(db *DaoDB, userIDs []string, categoryIDs []int, fromTime, toTime time.Time, includeStep bool) (jobs []*GetJobsResult, err error) {
|
||||
func GetJobsNoPage(db *DaoDB, userIDs []string, categoryIDs, statuss []int, fromTime, toTime time.Time, includeStep bool) (jobs []*GetJobsResult, err error) {
|
||||
sql := `
|
||||
SELECT a.*, b.name
|
||||
FROM job a
|
||||
@@ -104,6 +104,10 @@ func GetJobsNoPage(db *DaoDB, userIDs []string, categoryIDs []int, fromTime, toT
|
||||
sql += ` AND a.job_category_id IN (` + GenQuestionMarks(len(categoryIDs)) + `)`
|
||||
sqlParams = append(sqlParams, categoryIDs)
|
||||
}
|
||||
if len(statuss) > 0 {
|
||||
sql += ` AND a.status IN (` + GenQuestionMarks(len(statuss)) + `)`
|
||||
sqlParams = append(sqlParams, statuss)
|
||||
}
|
||||
if fromTime != utils.ZeroTimeValue {
|
||||
sql += ` AND a.created_at >= ?`
|
||||
sqlParams = append(sqlParams, fromTime)
|
||||
|
||||
Reference in New Issue
Block a user