作者 tangxvhui

调整任务管理

package adapter
type TaskItem struct {
Id int `json:"id,string"`
Name string `json:"name"` // 任务名称
Alias string `json:"alias"` // 任务别名
Leader string `json:"leader"` // 任务负责人
Status int `json:"status"` // 任务的状态
Level int `json:"level"` // 优先级,值越小优先级越高
LevelName string `json:"levelName"` // 优先级名称
StageA TaskStage `json:"stageA"` // 里程碑1
StageB TaskStage `json:"stageB"` // 里程碑2
StageC TaskStage `json:"stageC"` // 里程碑3
StageD TaskStage `json:"stageD"` // 里程碑4
StageE TaskStage `json:"stageE"` // 里程碑5
UpdatedAt string `json:"updatedAt"` //
Anomaly int `json:"anomaly"` //异常反馈情况
WarnFlag int `json:"warnFlag"` //里程碑完成时间异常标记 0:正常 1标记为异常
Id int `json:"id,string"`
Name string `json:"name"` // 任务名称
Alias string `json:"alias"` // 任务别名
Leader string `json:"leader"` // 任务负责人
Status int `json:"status"` // 任务的状态
Level int `json:"level"` // 优先级,值越小优先级越高
LevelName string `json:"levelName"` // 优先级名称
StageA TaskStage `json:"stageA"` // 里程碑1
StageB TaskStage `json:"stageB"` // 里程碑2
StageC TaskStage `json:"stageC"` // 里程碑3
StageD TaskStage `json:"stageD"` // 里程碑4
StageE TaskStage `json:"stageE"` // 里程碑5
LastStage TaskStage `json:"lastStage"` //
CurrentStage TaskStage `json:"currentStage"` //
UpdatedAt string `json:"updatedAt"` //
Anomaly int `json:"anomaly"` //异常反馈情况
WarnFlag int `json:"warnFlag"` //里程碑完成时间异常标记 0:正常 1标记为异常
}
... ...
... ... @@ -1196,6 +1196,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i
taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
nowTime := time.Now().Unix()
for _, val := range taskListData {
tk := adapter.TaskItem{
Id: val.TaskId,
... ... @@ -1208,6 +1209,36 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i
UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),
Anomaly: val.Anomaly,
WarnFlag: 0,
LastStage: adapter.TaskStage{
Id: val.LastStage.Id,
Name: val.LastStage.Name,
StatusDescription: val.LastStage.StatusDescription(),
SortBy: val.LastStage.SortBy,
PlanCompletedAt: time.Unix(int64(val.LastStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
RealCompletedAt: "",
IsRef: false,
},
CurrentStage: adapter.TaskStage{
Id: val.CurrentStage.Id,
Name: val.CurrentStage.Name,
StatusDescription: val.CurrentStage.StatusDescription(),
SortBy: val.CurrentStage.SortBy,
PlanCompletedAt: time.Unix(int64(val.CurrentStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
RealCompletedAt: "",
IsRef: false,
},
}
if val.LastStage.RealCompletedAt > 0 {
tk.LastStage.RealCompletedAt = time.Unix(int64(val.LastStage.RealCompletedAt), 0).Local().Format("2006-01-02")
}
if val.CurrentStage.RealCompletedAt > 0 {
tk.CurrentStage.RealCompletedAt = time.Unix(int64(val.CurrentStage.RealCompletedAt), 0).Local().Format("2006-01-02")
}
if val.LastStage.Id > 0 && val.LastStage.PlanCompletedAt < val.LastStage.RealCompletedAt {
tk.WarnFlag = int(domain.TaskWarn)
}
if val.CurrentStage.Id > 0 && val.CurrentStage.PlanCompletedAt < nowTime {
tk.WarnFlag = int(domain.TaskWarn)
}
_, stageList, err := taskStageRepo.Find(map[string]interface{}{
"taskId": val.TaskId,
... ... @@ -1215,7 +1246,6 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务里程碑"+err.Error())
}
for _, val2 := range stageList {
stage := adapter.TaskStage{
Id: val2.Id,
... ... @@ -1308,6 +1338,7 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s
taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{
"transactionContext": transactionContext,
})
nowTime := time.Now().Unix()
for _, val := range taskListData {
tk := adapter.TaskItem{
Id: val.TaskId,
... ... @@ -1320,6 +1351,36 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s
UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),
Anomaly: val.Anomaly,
WarnFlag: 0,
LastStage: adapter.TaskStage{
Id: val.LastStage.Id,
Name: val.LastStage.Name,
StatusDescription: val.LastStage.StatusDescription(),
SortBy: val.LastStage.SortBy,
PlanCompletedAt: time.Unix(int64(val.LastStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
RealCompletedAt: "",
IsRef: false,
},
CurrentStage: adapter.TaskStage{
Id: val.CurrentStage.Id,
Name: val.CurrentStage.Name,
StatusDescription: val.CurrentStage.StatusDescription(),
SortBy: val.CurrentStage.SortBy,
PlanCompletedAt: time.Unix(int64(val.CurrentStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
RealCompletedAt: "",
IsRef: false,
},
}
if val.LastStage.RealCompletedAt > 0 {
tk.LastStage.RealCompletedAt = time.Unix(int64(val.LastStage.RealCompletedAt), 0).Local().Format("2006-01-02")
}
if val.CurrentStage.RealCompletedAt > 0 {
tk.CurrentStage.RealCompletedAt = time.Unix(int64(val.CurrentStage.RealCompletedAt), 0).Local().Format("2006-01-02")
}
if val.LastStage.Id > 0 && val.LastStage.PlanCompletedAt < val.LastStage.RealCompletedAt {
tk.WarnFlag = int(domain.TaskWarn)
}
if val.CurrentStage.Id > 0 && val.CurrentStage.PlanCompletedAt < nowTime {
tk.WarnFlag = int(domain.TaskWarn)
}
_, stageList, err := taskStageRepo.Find(map[string]interface{}{
"taskId": val.TaskId,
... ...
... ... @@ -6,6 +6,7 @@ import (
"github.com/go-pg/pg/v10"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
type TaskDao struct {
... ... @@ -608,18 +609,20 @@ func (d TaskDao) TaskStageAnomalyAll(companyId int) ([]TaskData4, error) {
}
type ListTask struct {
SortBy1 int `pg:"sort_by_1"`
CPlanCompletedAt int `pg:"c_plan_completed_at"`
LastStageDiff int `pg:"last_stage_diff"`
TaskId int `pg:"task_id"`
Alias string `pg:"alias"`
LeaderName string `pg:"leader_name"`
Level int `pg:"level"`
LevelName string `pg:"level_name"`
Anomaly int `pg:"anomaly"`
Status int `pg:"status"`
UpdatedAt time.Time `pg:"updated_at"`
CreatedAt time.Time `pg:"created_at"`
SortBy1 int `pg:"sort_by_1"`
CPlanCompletedAt int `pg:"c_plan_completed_at"`
LastStageDiff int `pg:"last_stage_diff"`
TaskId int `pg:"task_id"`
Alias string `pg:"alias"`
LeaderName string `pg:"leader_name"`
Level int `pg:"level"`
LevelName string `pg:"level_name"`
Anomaly int `pg:"anomaly"`
Status int `pg:"status"`
UpdatedAt time.Time `pg:"updated_at"`
CreatedAt time.Time `pg:"created_at"`
CurrentStage domain.TaskStage `pg:"current_stage"` // 当前执行的里程碑
LastStage domain.TaskStage `pg:"last_stage"` // 上一个完成的里程碑
}
// (新)获取任务,用于页面展示; 无过滤查看权限
... ... @@ -646,6 +649,8 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error)
task.anomaly ,
task.status ,
task.updated_at,
task.current_stage,
task.last_stage,
task.created_at
from task
left join t_task_ignore on t_task_ignore.task_id=task.id
... ... @@ -669,6 +674,8 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error)
t_task.anomaly ,
t_task.status ,
t_task.updated_at ,
t_task.current_stage,
t_task.last_stage,
t_task.created_at
from t_task
where 1=1
... ... @@ -711,6 +718,8 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error)
task."level",
task.level_name ,
task.anomaly ,
task.current_stage,
task.last_stage,
task.status ,
task.updated_at,
task.created_at
... ... @@ -734,6 +743,8 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error)
t_task."level",
t_task.level_name ,
t_task.anomaly ,
t_task.current_stage,
t_task.last_stage,
t_task.status ,
t_task.updated_at ,
t_task.created_at
... ...