...
|
...
|
@@ -14,6 +14,18 @@ const ( |
|
|
TaskStop TaskState = 3 //任务停止
|
|
|
)
|
|
|
|
|
|
func (t TaskState) Named() string {
|
|
|
switch t {
|
|
|
case TaskWait:
|
|
|
return "待启动"
|
|
|
case TaskRunning:
|
|
|
return "启动中"
|
|
|
case TaskStop:
|
|
|
return "停止"
|
|
|
}
|
|
|
return ""
|
|
|
}
|
|
|
|
|
|
type TaskWarnFlag int
|
|
|
|
|
|
const (
|
...
|
...
|
@@ -88,17 +100,6 @@ func (t *Task) ApplyLevelName(name string) { |
|
|
}
|
|
|
|
|
|
// StatusDescript
|
|
|
func (t *Task) StatusDescription() string {
|
|
|
switch t.Status {
|
|
|
case TaskWait:
|
|
|
return "待启动"
|
|
|
case TaskRunning:
|
|
|
return "启动中"
|
|
|
case TaskStop:
|
|
|
return "停止"
|
|
|
}
|
|
|
return ""
|
|
|
}
|
|
|
|
|
|
// 记录待执行的里程碑,和上一个执行的里程碑
|
|
|
func (t *Task) SetCurrentStage(stageList []*TaskStage) {
|
...
|
...
|
@@ -108,6 +109,7 @@ func (t *Task) SetCurrentStage(stageList []*TaskStage) { |
|
|
sort.Slice(stageList, func(i, j int) bool {
|
|
|
return stageList[i].SortBy < stageList[j].SortBy
|
|
|
})
|
|
|
t.LastStage = TaskStage{}
|
|
|
t.CurrentStage = TaskStage{}
|
|
|
for _, val := range stageList {
|
|
|
if val.DeletedAt != nil {
|
...
|
...
|
@@ -119,6 +121,10 @@ func (t *Task) SetCurrentStage(stageList []*TaskStage) { |
|
|
break
|
|
|
}
|
|
|
}
|
|
|
if t.CurrentStage.RealCompletedAt > 0 {
|
|
|
t.LastStage = t.CurrentStage
|
|
|
t.CurrentStage = TaskStage{}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 设置优先级的值
|
...
|
...
|
@@ -133,6 +139,29 @@ func (t *Task) SetSortBy(a int) error { |
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (t *Task) DescriptTaskStatus() string {
|
|
|
statusNamed := ""
|
|
|
if t.Status == TaskRunning {
|
|
|
statusNamed = "进行中"
|
|
|
}
|
|
|
if t.CurrentStage.Id == 0 && t.LastStage.PlanCompletedAt < t.LastStage.RealCompletedAt {
|
|
|
statusNamed = "逾期完成"
|
|
|
}
|
|
|
if t.CurrentStage.Id == 0 && t.LastStage.PlanCompletedAt >= t.LastStage.RealCompletedAt {
|
|
|
statusNamed = "如期完成"
|
|
|
}
|
|
|
if t.Status == TaskStop {
|
|
|
statusNamed = "已停止"
|
|
|
}
|
|
|
if t.WarnFlag == TaskWarn {
|
|
|
statusNamed = "里程碑异常"
|
|
|
}
|
|
|
if t.Anomaly > 0 {
|
|
|
statusNamed = "反馈异常"
|
|
|
}
|
|
|
return statusNamed
|
|
|
}
|
|
|
|
|
|
type TaskRepository interface {
|
|
|
Save(param *Task) error
|
|
|
Remove(id int) error
|
...
|
...
|
|