|
|
|
@ -11,7 +11,9 @@ import (
|
|
|
|
|
func (c *Client) TaskTakeId(ctx context.Context, tx *gorm.DB, id uint) (result jobs_gorm_model.Task) {
|
|
|
|
|
err := tx.Where("id = ?", id).Take(&result).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.sLog.WithTraceId(ctx).Errorf("编号查询任务:%v", err)
|
|
|
|
|
if c.slog.status {
|
|
|
|
|
c.slog.client.WithTraceId(ctx).Errorf("编号查询任务:%v", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result
|
|
|
|
|
}
|
|
|
|
@ -20,7 +22,9 @@ func (c *Client) TaskTakeId(ctx context.Context, tx *gorm.DB, id uint) (result j
|
|
|
|
|
func (c *Client) TaskTake(ctx context.Context, tx *gorm.DB, customId string) (result jobs_gorm_model.Task) {
|
|
|
|
|
err := tx.Where("custom_id = ?", customId).Take(&result).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.sLog.WithTraceId(ctx).Errorf("自定义编号查询任务:%v", err)
|
|
|
|
|
if c.slog.status {
|
|
|
|
|
c.slog.client.WithTraceId(ctx).Errorf("自定义编号查询任务:%v", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result
|
|
|
|
|
}
|
|
|
|
@ -29,7 +33,9 @@ func (c *Client) TaskTake(ctx context.Context, tx *gorm.DB, customId string) (re
|
|
|
|
|
func (c *Client) taskTake(ctx context.Context, tx *gorm.DB, customId, status string) (result jobs_gorm_model.Task) {
|
|
|
|
|
err := tx.Where("custom_id = ?", customId).Where("status = ?", status).Take(&result).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.sLog.WithTraceId(ctx).Errorf("自定义编号加状态查询任务:%v", err)
|
|
|
|
|
if c.slog.status {
|
|
|
|
|
c.slog.client.WithTraceId(ctx).Errorf("自定义编号加状态查询任务:%v", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result
|
|
|
|
|
}
|
|
|
|
@ -63,7 +69,9 @@ func (c *Client) TaskTakeWait(ctx context.Context, tx *gorm.DB, customId string)
|
|
|
|
|
func (c *Client) TaskTypeTake(ctx context.Context, tx *gorm.DB, customId, Type string) (result jobs_gorm_model.Task) {
|
|
|
|
|
err := tx.Where("custom_id = ?", customId).Where("type = ?", Type).Take(&result).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.sLog.WithTraceId(ctx).Errorf("查询单任务:%v", err)
|
|
|
|
|
if c.slog.status {
|
|
|
|
|
c.slog.client.WithTraceId(ctx).Errorf("查询单任务:%v", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result
|
|
|
|
|
}
|
|
|
|
@ -72,7 +80,9 @@ func (c *Client) TaskTypeTake(ctx context.Context, tx *gorm.DB, customId, Type s
|
|
|
|
|
func (c *Client) taskTypeTake(ctx context.Context, tx *gorm.DB, customId, Type, status string) (result jobs_gorm_model.Task) {
|
|
|
|
|
err := tx.Where("custom_id = ?", customId).Where("type = ?", Type).Where("status = ?", status).Take(&result).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.sLog.WithTraceId(ctx).Errorf("查询单任务:%v", err)
|
|
|
|
|
if c.slog.status {
|
|
|
|
|
c.slog.client.WithTraceId(ctx).Errorf("查询单任务:%v", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result
|
|
|
|
|
}
|
|
|
|
@ -106,7 +116,9 @@ func (c *Client) TaskTypeTakeWait(ctx context.Context, tx *gorm.DB, customId, Ty
|
|
|
|
|
func (c *Client) TaskFindAll(ctx context.Context, tx *gorm.DB, frequency int64) (results []jobs_gorm_model.Task) {
|
|
|
|
|
err := tx.Where("frequency = ?", frequency).Order("id asc").Find(&results).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.sLog.WithTraceId(ctx).Errorf("查询多任务:%v", err)
|
|
|
|
|
if c.slog.status {
|
|
|
|
|
c.slog.client.WithTraceId(ctx).Errorf("查询多任务:%v", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return results
|
|
|
|
|
}
|
|
|
|
@ -115,7 +127,9 @@ func (c *Client) TaskFindAll(ctx context.Context, tx *gorm.DB, frequency int64)
|
|
|
|
|
func (c *Client) TaskFindAllType(ctx context.Context, tx *gorm.DB, Type string, frequency int64) (results []jobs_gorm_model.Task) {
|
|
|
|
|
err := tx.Where("type = ?", Type).Where("frequency = ?", frequency).Order("id asc").Find(&results).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.sLog.WithTraceId(ctx).Errorf("查询多任务:%v", err)
|
|
|
|
|
if c.slog.status {
|
|
|
|
|
c.slog.client.WithTraceId(ctx).Errorf("查询多任务:%v", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return results
|
|
|
|
|
}
|
|
|
|
@ -124,7 +138,9 @@ func (c *Client) TaskFindAllType(ctx context.Context, tx *gorm.DB, Type string,
|
|
|
|
|
func (c *Client) taskFindAll(ctx context.Context, tx *gorm.DB, frequency int64, status string) (results []jobs_gorm_model.Task) {
|
|
|
|
|
err := tx.Where("frequency = ?", frequency).Where("status = ?", status).Order("id asc").Find(&results).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.sLog.WithTraceId(ctx).Errorf("查询多任务:%v", err)
|
|
|
|
|
if c.slog.status {
|
|
|
|
|
c.slog.client.WithTraceId(ctx).Errorf("查询多任务:%v", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return results
|
|
|
|
|
}
|
|
|
|
@ -134,13 +150,17 @@ func (c *Client) taskFindAllType(ctx context.Context, tx *gorm.DB, Type string,
|
|
|
|
|
if frequency == 0 {
|
|
|
|
|
err := tx.Where("type = ?", Type).Where("status = ?", status).Order("id asc").Find(&results).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.sLog.WithTraceId(ctx).Errorf("查询多任务:%v", err)
|
|
|
|
|
if c.slog.status {
|
|
|
|
|
c.slog.client.WithTraceId(ctx).Errorf("查询多任务:%v", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return results
|
|
|
|
|
}
|
|
|
|
|
err := tx.Where("type = ?", Type).Where("frequency = ?", frequency).Where("status = ?", status).Order("id asc").Find(&results).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.sLog.WithTraceId(ctx).Errorf("查询多任务:%v", err)
|
|
|
|
|
if c.slog.status {
|
|
|
|
|
c.slog.client.WithTraceId(ctx).Errorf("查询多任务:%v", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return results
|
|
|
|
|
}
|
|
|
|
@ -204,7 +224,9 @@ func (c *Client) StartTask(ctx context.Context, tx *gorm.DB, id uint) error {
|
|
|
|
|
StatusDesc: "启动任务",
|
|
|
|
|
}).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.sLog.WithTraceId(ctx).Errorf("任务启动失败:%v", err)
|
|
|
|
|
if c.slog.status {
|
|
|
|
|
c.slog.client.WithTraceId(ctx).Errorf("任务启动失败:%v", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -221,7 +243,9 @@ func (c *Client) StartTaskCustom(ctx context.Context, tx *gorm.DB, customId stri
|
|
|
|
|
StatusDesc: "启动任务",
|
|
|
|
|
}).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.sLog.WithTraceId(ctx).Errorf("任务启动自定义失败:%v", err)
|
|
|
|
|
if c.slog.status {
|
|
|
|
|
c.slog.client.WithTraceId(ctx).Errorf("任务启动自定义失败:%v", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -240,7 +264,9 @@ func (c *Client) UpdateFrequency(ctx context.Context, tx *gorm.DB, id uint, freq
|
|
|
|
|
NextRunTime: gotime.Current().AfterSeconds(frequency).Time,
|
|
|
|
|
}).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
c.sLog.WithTraceId(ctx).Errorf("更新任务频率失败:%v", err)
|
|
|
|
|
if c.slog.status {
|
|
|
|
|
c.slog.client.WithTraceId(ctx).Errorf("更新任务频率失败:%v", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|