作者 tangxvhui

调整列表数据

1 package adapter 1 package adapter
2 2
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
  5 +)
  6 +
3 type TaskItem struct { 7 type TaskItem struct {
4 - Id int `json:"id,string"`  
5 - Name string `json:"name"` // 任务名称  
6 - Alias string `json:"alias"` // 任务别名  
7 - Leader string `json:"leader"` // 任务负责人  
8 - Status int `json:"status"` // 任务的状态  
9 - Level int `json:"level"` // 优先级,值越小优先级越高  
10 - LevelName string `json:"levelName"` // 优先级名称  
11 - StageA TaskStage `json:"stageA"` // 里程碑1  
12 - StageB TaskStage `json:"stageB"` // 里程碑2  
13 - StageC TaskStage `json:"stageC"` // 里程碑3  
14 - StageD TaskStage `json:"stageD"` // 里程碑4  
15 - StageE TaskStage `json:"stageE"` // 里程碑5  
16 - LastStage TaskStage `json:"lastStage"` //  
17 - CurrentStage TaskStage `json:"currentStage"` //  
18 - UpdatedAt string `json:"updatedAt"` //  
19 - Anomaly int `json:"anomaly"` //异常反馈情况  
20 - WarnFlag int `json:"warnFlag"` //里程碑完成时间异常标记 0:正常 1标记为异常 8 + Id int `json:"id,string"`
  9 + Name string `json:"name"` // 任务名称
  10 + Alias string `json:"alias"` // 任务别名
  11 + Leader string `json:"leader"` // 任务负责人
  12 + Status int `json:"status"` // 任务的状态
  13 + StatusDescript string `json:"statusDescript"` //任务的整体状态描述
  14 + SortBy int `json:"level"` // 优先级,值越小优先级越高
  15 + LevelName string `json:"levelName"` // 任务分类名称
  16 + StageA TaskStage `json:"stageA"` // 里程碑1
  17 + StageB TaskStage `json:"stageB"` // 里程碑2
  18 + StageC TaskStage `json:"stageC"` // 里程碑3
  19 + StageD TaskStage `json:"stageD"` // 里程碑4
  20 + StageE TaskStage `json:"stageE"` // 里程碑5
  21 + LastStage TaskStage `json:"lastStage"` //
  22 + CurrentStage TaskStage `json:"currentStage"` //
  23 + UpdatedAt string `json:"updatedAt"` //
  24 + Anomaly int `json:"anomaly"` //异常反馈情况
  25 + WarnFlag int `json:"warnFlag"` //里程碑完成时间异常标记 0:正常 1标记为异常
  26 +}
  27 +
  28 +func (t *TaskItem) GenStatusDescript() {
  29 + statusNamed := ""
  30 + if domain.TaskState(t.Status) == domain.TaskRunning {
  31 + statusNamed = "进行中"
  32 + }
  33 + if t.CurrentStage.Id == 0 && t.LastStage.PlanCompletedAt < t.LastStage.RealCompletedAt {
  34 + statusNamed = "逾期完成"
  35 + }
  36 + if t.CurrentStage.Id == 0 && t.LastStage.PlanCompletedAt >= t.LastStage.RealCompletedAt {
  37 + statusNamed = "如期完成"
  38 + }
  39 + if domain.TaskState(t.Status) == domain.TaskStop {
  40 + statusNamed = "已停止"
  41 + }
  42 + if domain.TaskWarnFlag(t.WarnFlag) == domain.TaskWarn {
  43 + statusNamed = "里程碑异常"
  44 + }
  45 + if t.Anomaly > 0 {
  46 + statusNamed = "反馈异常"
  47 + }
  48 + t.StatusDescript = statusNamed
21 } 49 }
@@ -655,7 +655,7 @@ func (srv TaskService) ListTask(param *command.ListTaskCommand) (map[string]inte @@ -655,7 +655,7 @@ func (srv TaskService) ListTask(param *command.ListTaskCommand) (map[string]inte
655 Alias: val.Alias, 655 Alias: val.Alias,
656 Leader: val.Leader.Name, 656 Leader: val.Leader.Name,
657 Status: int(val.Status), 657 Status: int(val.Status),
658 - Level: val.Level, 658 + SortBy: int(val.SortBy),
659 LevelName: val.LevelName, 659 LevelName: val.LevelName,
660 Anomaly: val.Anomaly, 660 Anomaly: val.Anomaly,
661 WarnFlag: int(val.WarnFlag), 661 WarnFlag: int(val.WarnFlag),
@@ -1069,7 +1069,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i @@ -1069,7 +1069,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i
1069 Alias: val.Alias, 1069 Alias: val.Alias,
1070 Leader: val.LeaderName, 1070 Leader: val.LeaderName,
1071 Status: val.Status, 1071 Status: val.Status,
1072 - Level: val.Level, 1072 + SortBy: val.SortBy,
1073 LevelName: val.LevelName, 1073 LevelName: val.LevelName,
1074 UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"), 1074 UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),
1075 Anomaly: val.Anomaly, 1075 Anomaly: val.Anomaly,
@@ -1135,6 +1135,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i @@ -1135,6 +1135,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i
1135 tk.StageE = stage 1135 tk.StageE = stage
1136 } 1136 }
1137 } 1137 }
  1138 + tk.GenStatusDescript()
1138 taskResult = append(taskResult, &tk) 1139 taskResult = append(taskResult, &tk)
1139 } 1140 }
1140 result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult) 1141 result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
@@ -1216,7 +1217,7 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s @@ -1216,7 +1217,7 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s
1216 Alias: val.Alias, 1217 Alias: val.Alias,
1217 Leader: val.LeaderName, 1218 Leader: val.LeaderName,
1218 Status: val.Status, 1219 Status: val.Status,
1219 - Level: val.Level, 1220 + SortBy: val.SortBy,
1220 LevelName: val.LevelName, 1221 LevelName: val.LevelName,
1221 UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"), 1222 UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),
1222 Anomaly: val.Anomaly, 1223 Anomaly: val.Anomaly,
@@ -1228,7 +1229,6 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s @@ -1228,7 +1229,6 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s
1228 SortBy: val.LastStage.SortBy, 1229 SortBy: val.LastStage.SortBy,
1229 PlanCompletedAt: time.Unix(int64(val.LastStage.PlanCompletedAt), 0).Local().Format("2006-01-02"), 1230 PlanCompletedAt: time.Unix(int64(val.LastStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
1230 RealCompletedAt: "", 1231 RealCompletedAt: "",
1231 - IsRef: false,  
1232 }, 1232 },
1233 CurrentStage: adapter.TaskStage{ 1233 CurrentStage: adapter.TaskStage{
1234 Id: val.CurrentStage.Id, 1234 Id: val.CurrentStage.Id,
@@ -1237,7 +1237,6 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s @@ -1237,7 +1237,6 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s
1237 SortBy: val.CurrentStage.SortBy, 1237 SortBy: val.CurrentStage.SortBy,
1238 PlanCompletedAt: time.Unix(int64(val.CurrentStage.PlanCompletedAt), 0).Local().Format("2006-01-02"), 1238 PlanCompletedAt: time.Unix(int64(val.CurrentStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
1239 RealCompletedAt: "", 1239 RealCompletedAt: "",
1240 - IsRef: false,  
1241 }, 1240 },
1242 } 1241 }
1243 if val.LastStage.RealCompletedAt > 0 { 1242 if val.LastStage.RealCompletedAt > 0 {
@@ -1283,6 +1282,7 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s @@ -1283,6 +1282,7 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s
1283 tk.StageE = stage 1282 tk.StageE = stage
1284 } 1283 }
1285 } 1284 }
  1285 + tk.GenStatusDescript()
1286 taskResult = append(taskResult, &tk) 1286 taskResult = append(taskResult, &tk)
1287 } 1287 }
1288 result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult) 1288 result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
@@ -1388,7 +1388,7 @@ func (srv *TaskService) ListTaskIgnore(param *command.SearchTaskCommand) (result @@ -1388,7 +1388,7 @@ func (srv *TaskService) ListTaskIgnore(param *command.SearchTaskCommand) (result
1388 Alias: val.Alias, 1388 Alias: val.Alias,
1389 Leader: val.LeaderName, 1389 Leader: val.LeaderName,
1390 Status: val.Status, 1390 Status: val.Status,
1391 - Level: val.Level, 1391 + SortBy: val.SortBy,
1392 LevelName: val.LevelName, 1392 LevelName: val.LevelName,
1393 UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"), 1393 UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),
1394 Anomaly: val.Anomaly, 1394 Anomaly: val.Anomaly,
@@ -1400,7 +1400,6 @@ func (srv *TaskService) ListTaskIgnore(param *command.SearchTaskCommand) (result @@ -1400,7 +1400,6 @@ func (srv *TaskService) ListTaskIgnore(param *command.SearchTaskCommand) (result
1400 SortBy: val.LastStage.SortBy, 1400 SortBy: val.LastStage.SortBy,
1401 PlanCompletedAt: time.Unix(int64(val.LastStage.PlanCompletedAt), 0).Local().Format("2006-01-02"), 1401 PlanCompletedAt: time.Unix(int64(val.LastStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
1402 RealCompletedAt: "", 1402 RealCompletedAt: "",
1403 - IsRef: false,  
1404 }, 1403 },
1405 CurrentStage: adapter.TaskStage{ 1404 CurrentStage: adapter.TaskStage{
1406 Id: val.CurrentStage.Id, 1405 Id: val.CurrentStage.Id,
@@ -1409,7 +1408,6 @@ func (srv *TaskService) ListTaskIgnore(param *command.SearchTaskCommand) (result @@ -1409,7 +1408,6 @@ func (srv *TaskService) ListTaskIgnore(param *command.SearchTaskCommand) (result
1409 SortBy: val.CurrentStage.SortBy, 1408 SortBy: val.CurrentStage.SortBy,
1410 PlanCompletedAt: time.Unix(int64(val.CurrentStage.PlanCompletedAt), 0).Local().Format("2006-01-02"), 1409 PlanCompletedAt: time.Unix(int64(val.CurrentStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
1411 RealCompletedAt: "", 1410 RealCompletedAt: "",
1412 - IsRef: false,  
1413 }, 1411 },
1414 } 1412 }
1415 if val.LastStage.RealCompletedAt > 0 { 1413 if val.LastStage.RealCompletedAt > 0 {
@@ -1455,6 +1453,7 @@ func (srv *TaskService) ListTaskIgnore(param *command.SearchTaskCommand) (result @@ -1455,6 +1453,7 @@ func (srv *TaskService) ListTaskIgnore(param *command.SearchTaskCommand) (result
1455 tk.StageE = stage 1453 tk.StageE = stage
1456 } 1454 }
1457 } 1455 }
  1456 + tk.GenStatusDescript()
1458 taskResult = append(taskResult, &tk) 1457 taskResult = append(taskResult, &tk)
1459 } 1458 }
1460 1459