a
This commit is contained in:
@@ -109,7 +109,7 @@ func PublishJob(ctx *jxcontext.Context, jobExt *model.JobExt) (errCode string, e
|
||||
if job.UserID == "" {
|
||||
return errCode, fmt.Errorf("任务发起人不能为空!")
|
||||
}
|
||||
jobs, err := dao.GetJobsNoPage(db, []string{job.UserID}, nil, nil, nil, DayTimeBegin, DayTimeEnd, false)
|
||||
jobs, err := dao.GetJobsNoPage(db, []string{job.UserID}, nil, nil, nil, DayTimeBegin, DayTimeEnd, 0, false)
|
||||
if len(jobs) > 0 {
|
||||
members, err := dao.GetUserMember(db, job.UserID, model.MemberTypeNormal)
|
||||
if err != nil {
|
||||
@@ -625,7 +625,7 @@ func RefreshJobStatus(ctx *jxcontext.Context) (err error) {
|
||||
db = dao.GetDB()
|
||||
)
|
||||
globals.SugarLogger.Debugf("RefreshJobStatus begin...")
|
||||
jobs, err := dao.GetJobsNoPage(db, nil, nil, []int{model.JobStatusDoing}, nil, utils.ZeroTimeValue, utils.ZeroTimeValue, false)
|
||||
jobs, err := dao.GetJobsNoPage(db, nil, nil, []int{model.JobStatusDoing}, nil, utils.ZeroTimeValue, utils.ZeroTimeValue, 0, false)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("RefreshJobStatus err :%v", err)
|
||||
return
|
||||
@@ -1147,3 +1147,26 @@ func RefreshJobSpan(ctx *jxcontext.Context) (err error) {
|
||||
task.GetID()
|
||||
return err
|
||||
}
|
||||
|
||||
func ReloadJobSpan(ctx *jxcontext.Context, jobIDs []int) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
jobs, err := dao.GetJobsNoPage(db, nil, nil, []int{model.JobStatusDoing}, nil, utils.ZeroTimeValue, utils.ZeroTimeValue, model.JobSpanTop, false)
|
||||
if len(jobs) != len(jobIDs) {
|
||||
return fmt.Errorf("传入的任务IDs有误!")
|
||||
}
|
||||
for k, v := range jobIDs {
|
||||
job := &model.Job{}
|
||||
job.ID = v
|
||||
if err = dao.GetEntity(db, job); err == nil {
|
||||
if job.JobSpanTop == model.JobSpanTop {
|
||||
job.TopSeq = k + 1
|
||||
dao.UpdateEntity(db, job, "TopSeq")
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ func GetJobs(db *DaoDB, userIDs []string, categoryIDs, statuss, vendorIDs, types
|
||||
}
|
||||
|
||||
func GetJob(db *DaoDB, userIDs []string, categoryIDs, statuss, types []int, fromTime, toTime time.Time, includeStep bool) (job *model.Job, err error) {
|
||||
jobs, err := GetJobsNoPage(db, userIDs, categoryIDs, statuss, types, fromTime, toTime, includeStep)
|
||||
jobs, err := GetJobsNoPage(db, userIDs, categoryIDs, statuss, types, fromTime, toTime, 0, includeStep)
|
||||
if err != nil {
|
||||
return job, err
|
||||
}
|
||||
@@ -167,7 +167,7 @@ func GetJob(db *DaoDB, userIDs []string, categoryIDs, statuss, types []int, from
|
||||
return job, err
|
||||
}
|
||||
|
||||
func GetJobsNoPage(db *DaoDB, userIDs []string, categoryIDs, statuss, types []int, fromTime, toTime time.Time, includeStep bool) (jobs []*GetJobsResult, err error) {
|
||||
func GetJobsNoPage(db *DaoDB, userIDs []string, categoryIDs, statuss, types []int, fromTime, toTime time.Time, span int, includeStep bool) (jobs []*GetJobsResult, err error) {
|
||||
sql := `
|
||||
SELECT a.*, b.name
|
||||
FROM job a
|
||||
@@ -199,6 +199,13 @@ func GetJobsNoPage(db *DaoDB, userIDs []string, categoryIDs, statuss, types []in
|
||||
sql += ` AND a.created_at <= ?`
|
||||
sqlParams = append(sqlParams, toTime)
|
||||
}
|
||||
if span != 0 {
|
||||
if span == model.JobSpanTop {
|
||||
sql += ` AND a.job_span_top = 1`
|
||||
} else {
|
||||
sql += ` AND a.job_span_recmd = 1`
|
||||
}
|
||||
}
|
||||
err = GetRows(db, &jobs, sql, sqlParams...)
|
||||
for _, v := range jobs {
|
||||
if includeStep {
|
||||
|
||||
@@ -427,6 +427,12 @@ func (c *JobController) CreateJobSpan() {
|
||||
// @router /ReloadJobSpan [post]
|
||||
func (c *JobController) ReloadJobSpan() {
|
||||
c.callReloadJobSpan(func(params *tJobReloadJobSpanParams) (retVal interface{}, errCode string, err error) {
|
||||
var (
|
||||
jobIDs []int
|
||||
)
|
||||
if err = jxutils.Strings2Objs(params.JobIDs, &jobIDs); err == nil {
|
||||
err = cms.ReloadJobSpan(params.Ctx, jobIDs)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user