|
|
|
package domain
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"sort"
|
|
|
|
"time"
|
|
|
|
)
|
|
...
|
...
|
@@ -31,11 +32,13 @@ type Task struct { |
|
|
|
Alias string `json:"alias"` // 任务别名
|
|
|
|
Leader TaskLeader `json:"leader"` // 任务负责人
|
|
|
|
Status TaskState `json:"status"` // 任务的状态
|
|
|
|
Level int `json:"level"` // 优先级,值越小优先级越高
|
|
|
|
LevelName string `json:"levelName"` // 优先级名称
|
|
|
|
Level int `json:"level"` // 优先级 (优先级字段表示的意义变更,不再需要这个字段,仅数据保留)
|
|
|
|
LevelName string `json:"levelName"` // 字段表示的意义变更; 原来 (“优先级名称“)=> 现在 (“任务类型“)
|
|
|
|
SortBy int `json:"sortBy"` // 优先级排序;值越小优先级越高
|
|
|
|
EndTime int64 `json:"endTime"` // 任务截止的时间戳,单位:秒;等于0时表示未设置时间
|
|
|
|
RelatedUser []int `json:"relatedUser"` // 相关的员工id
|
|
|
|
RunAt int64 `json:"runAt"` // 启动的时间戳,秒
|
|
|
|
StopAt int64 `json:"stopAt"` // 停止的时间戳,秒
|
|
|
|
RunAt int64 `json:"runAt"` // 启动的时间戳,单位:秒
|
|
|
|
StopAt int64 `json:"stopAt"` // 停止的时间戳,单位:秒
|
|
|
|
Anomaly int `json:"anomaly"` // 异常反馈的次数
|
|
|
|
WarnFlag TaskWarnFlag `json:"warnFlag"` // 里程碑异常标记
|
|
|
|
CurrentStage TaskStage `json:"currentStage"` // 当前执行的里程碑
|
|
...
|
...
|
@@ -95,6 +98,29 @@ func (t *Task) SetCurrentStage(stageList []*TaskStage) { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 设置优先级的值
|
|
|
|
func (t *Task) SetSortBy(a int) error {
|
|
|
|
switch a {
|
|
|
|
case 100, 200, 300, 0:
|
|
|
|
default:
|
|
|
|
return errors.New("优先级值错误")
|
|
|
|
}
|
|
|
|
|
|
|
|
t.SortBy = a
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取优先级的名称描述
|
|
|
|
func (t *Task) GetNameSortBy() string {
|
|
|
|
nameMap := map[int]string{
|
|
|
|
100: "高",
|
|
|
|
200: "中",
|
|
|
|
300: "低",
|
|
|
|
0: "无",
|
|
|
|
}
|
|
|
|
return nameMap[t.SortBy]
|
|
|
|
}
|
|
|
|
|
|
|
|
type TaskRepository interface {
|
|
|
|
Save(param *Task) error
|
|
|
|
Remove(id int) error
|
...
|
...
|
|