作者 tangxvhui

调整任务管理

1 package adapter 1 package adapter
2 2
3 type TaskItem struct { 3 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 - UpdatedAt string `json:"updatedAt"` //  
17 - Anomaly int `json:"anomaly"` //异常反馈情况  
18 - WarnFlag int `json:"warnFlag"` //里程碑完成时间异常标记 0:正常 1标记为异常 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标记为异常
19 } 21 }
@@ -1196,6 +1196,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i @@ -1196,6 +1196,7 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i
1196 taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{ 1196 taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{
1197 "transactionContext": transactionContext, 1197 "transactionContext": transactionContext,
1198 }) 1198 })
  1199 + nowTime := time.Now().Unix()
1199 for _, val := range taskListData { 1200 for _, val := range taskListData {
1200 tk := adapter.TaskItem{ 1201 tk := adapter.TaskItem{
1201 Id: val.TaskId, 1202 Id: val.TaskId,
@@ -1208,6 +1209,36 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i @@ -1208,6 +1209,36 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i
1208 UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"), 1209 UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),
1209 Anomaly: val.Anomaly, 1210 Anomaly: val.Anomaly,
1210 WarnFlag: 0, 1211 WarnFlag: 0,
  1212 + LastStage: adapter.TaskStage{
  1213 + Id: val.LastStage.Id,
  1214 + Name: val.LastStage.Name,
  1215 + StatusDescription: val.LastStage.StatusDescription(),
  1216 + SortBy: val.LastStage.SortBy,
  1217 + PlanCompletedAt: time.Unix(int64(val.LastStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
  1218 + RealCompletedAt: "",
  1219 + IsRef: false,
  1220 + },
  1221 + CurrentStage: adapter.TaskStage{
  1222 + Id: val.CurrentStage.Id,
  1223 + Name: val.CurrentStage.Name,
  1224 + StatusDescription: val.CurrentStage.StatusDescription(),
  1225 + SortBy: val.CurrentStage.SortBy,
  1226 + PlanCompletedAt: time.Unix(int64(val.CurrentStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
  1227 + RealCompletedAt: "",
  1228 + IsRef: false,
  1229 + },
  1230 + }
  1231 + if val.LastStage.RealCompletedAt > 0 {
  1232 + tk.LastStage.RealCompletedAt = time.Unix(int64(val.LastStage.RealCompletedAt), 0).Local().Format("2006-01-02")
  1233 + }
  1234 + if val.CurrentStage.RealCompletedAt > 0 {
  1235 + tk.CurrentStage.RealCompletedAt = time.Unix(int64(val.CurrentStage.RealCompletedAt), 0).Local().Format("2006-01-02")
  1236 + }
  1237 + if val.LastStage.Id > 0 && val.LastStage.PlanCompletedAt < val.LastStage.RealCompletedAt {
  1238 + tk.WarnFlag = int(domain.TaskWarn)
  1239 + }
  1240 + if val.CurrentStage.Id > 0 && val.CurrentStage.PlanCompletedAt < nowTime {
  1241 + tk.WarnFlag = int(domain.TaskWarn)
1211 } 1242 }
1212 _, stageList, err := taskStageRepo.Find(map[string]interface{}{ 1243 _, stageList, err := taskStageRepo.Find(map[string]interface{}{
1213 "taskId": val.TaskId, 1244 "taskId": val.TaskId,
@@ -1215,7 +1246,6 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i @@ -1215,7 +1246,6 @@ func (srv TaskService) ListTask3(param *command.SearchTaskCommand) (map[string]i
1215 if err != nil { 1246 if err != nil {
1216 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务里程碑"+err.Error()) 1247 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务里程碑"+err.Error())
1217 } 1248 }
1218 -  
1219 for _, val2 := range stageList { 1249 for _, val2 := range stageList {
1220 stage := adapter.TaskStage{ 1250 stage := adapter.TaskStage{
1221 Id: val2.Id, 1251 Id: val2.Id,
@@ -1308,6 +1338,7 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s @@ -1308,6 +1338,7 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s
1308 taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{ 1338 taskStageRepo := factory.CreateTaskStageRepository(map[string]interface{}{
1309 "transactionContext": transactionContext, 1339 "transactionContext": transactionContext,
1310 }) 1340 })
  1341 + nowTime := time.Now().Unix()
1311 for _, val := range taskListData { 1342 for _, val := range taskListData {
1312 tk := adapter.TaskItem{ 1343 tk := adapter.TaskItem{
1313 Id: val.TaskId, 1344 Id: val.TaskId,
@@ -1320,6 +1351,36 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s @@ -1320,6 +1351,36 @@ func (srv TaskService) listTask3ForHrbp(param *command.SearchTaskCommand) (map[s
1320 UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"), 1351 UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),
1321 Anomaly: val.Anomaly, 1352 Anomaly: val.Anomaly,
1322 WarnFlag: 0, 1353 WarnFlag: 0,
  1354 + LastStage: adapter.TaskStage{
  1355 + Id: val.LastStage.Id,
  1356 + Name: val.LastStage.Name,
  1357 + StatusDescription: val.LastStage.StatusDescription(),
  1358 + SortBy: val.LastStage.SortBy,
  1359 + PlanCompletedAt: time.Unix(int64(val.LastStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
  1360 + RealCompletedAt: "",
  1361 + IsRef: false,
  1362 + },
  1363 + CurrentStage: adapter.TaskStage{
  1364 + Id: val.CurrentStage.Id,
  1365 + Name: val.CurrentStage.Name,
  1366 + StatusDescription: val.CurrentStage.StatusDescription(),
  1367 + SortBy: val.CurrentStage.SortBy,
  1368 + PlanCompletedAt: time.Unix(int64(val.CurrentStage.PlanCompletedAt), 0).Local().Format("2006-01-02"),
  1369 + RealCompletedAt: "",
  1370 + IsRef: false,
  1371 + },
  1372 + }
  1373 + if val.LastStage.RealCompletedAt > 0 {
  1374 + tk.LastStage.RealCompletedAt = time.Unix(int64(val.LastStage.RealCompletedAt), 0).Local().Format("2006-01-02")
  1375 + }
  1376 + if val.CurrentStage.RealCompletedAt > 0 {
  1377 + tk.CurrentStage.RealCompletedAt = time.Unix(int64(val.CurrentStage.RealCompletedAt), 0).Local().Format("2006-01-02")
  1378 + }
  1379 + if val.LastStage.Id > 0 && val.LastStage.PlanCompletedAt < val.LastStage.RealCompletedAt {
  1380 + tk.WarnFlag = int(domain.TaskWarn)
  1381 + }
  1382 + if val.CurrentStage.Id > 0 && val.CurrentStage.PlanCompletedAt < nowTime {
  1383 + tk.WarnFlag = int(domain.TaskWarn)
1323 } 1384 }
1324 _, stageList, err := taskStageRepo.Find(map[string]interface{}{ 1385 _, stageList, err := taskStageRepo.Find(map[string]interface{}{
1325 "taskId": val.TaskId, 1386 "taskId": val.TaskId,
@@ -6,6 +6,7 @@ import ( @@ -6,6 +6,7 @@ import (
6 6
7 "github.com/go-pg/pg/v10" 7 "github.com/go-pg/pg/v10"
8 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 8 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  9 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
9 ) 10 )
10 11
11 type TaskDao struct { 12 type TaskDao struct {
@@ -608,18 +609,20 @@ func (d TaskDao) TaskStageAnomalyAll(companyId int) ([]TaskData4, error) { @@ -608,18 +609,20 @@ func (d TaskDao) TaskStageAnomalyAll(companyId int) ([]TaskData4, error) {
608 } 609 }
609 610
610 type ListTask struct { 611 type ListTask struct {
611 - SortBy1 int `pg:"sort_by_1"`  
612 - CPlanCompletedAt int `pg:"c_plan_completed_at"`  
613 - LastStageDiff int `pg:"last_stage_diff"`  
614 - TaskId int `pg:"task_id"`  
615 - Alias string `pg:"alias"`  
616 - LeaderName string `pg:"leader_name"`  
617 - Level int `pg:"level"`  
618 - LevelName string `pg:"level_name"`  
619 - Anomaly int `pg:"anomaly"`  
620 - Status int `pg:"status"`  
621 - UpdatedAt time.Time `pg:"updated_at"`  
622 - CreatedAt time.Time `pg:"created_at"` 612 + SortBy1 int `pg:"sort_by_1"`
  613 + CPlanCompletedAt int `pg:"c_plan_completed_at"`
  614 + LastStageDiff int `pg:"last_stage_diff"`
  615 + TaskId int `pg:"task_id"`
  616 + Alias string `pg:"alias"`
  617 + LeaderName string `pg:"leader_name"`
  618 + Level int `pg:"level"`
  619 + LevelName string `pg:"level_name"`
  620 + Anomaly int `pg:"anomaly"`
  621 + Status int `pg:"status"`
  622 + UpdatedAt time.Time `pg:"updated_at"`
  623 + CreatedAt time.Time `pg:"created_at"`
  624 + CurrentStage domain.TaskStage `pg:"current_stage"` // 当前执行的里程碑
  625 + LastStage domain.TaskStage `pg:"last_stage"` // 上一个完成的里程碑
623 } 626 }
624 627
625 // (新)获取任务,用于页面展示; 无过滤查看权限 628 // (新)获取任务,用于页面展示; 无过滤查看权限
@@ -646,6 +649,8 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error) @@ -646,6 +649,8 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error)
646 task.anomaly , 649 task.anomaly ,
647 task.status , 650 task.status ,
648 task.updated_at, 651 task.updated_at,
  652 + task.current_stage,
  653 + task.last_stage,
649 task.created_at 654 task.created_at
650 from task 655 from task
651 left join t_task_ignore on t_task_ignore.task_id=task.id 656 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) @@ -669,6 +674,8 @@ func (d *TaskDao) ListTaskByHrbpV2(param ListTaskCondition) ([]ListTask, error)
669 t_task.anomaly , 674 t_task.anomaly ,
670 t_task.status , 675 t_task.status ,
671 t_task.updated_at , 676 t_task.updated_at ,
  677 + t_task.current_stage,
  678 + t_task.last_stage,
672 t_task.created_at 679 t_task.created_at
673 from t_task 680 from t_task
674 where 1=1 681 where 1=1
@@ -711,6 +718,8 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) @@ -711,6 +718,8 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error)
711 task."level", 718 task."level",
712 task.level_name , 719 task.level_name ,
713 task.anomaly , 720 task.anomaly ,
  721 + task.current_stage,
  722 + task.last_stage,
714 task.status , 723 task.status ,
715 task.updated_at, 724 task.updated_at,
716 task.created_at 725 task.created_at
@@ -734,6 +743,8 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error) @@ -734,6 +743,8 @@ func (d *TaskDao) ListTaskNotHrbpV2(param ListTaskCondition) ([]ListTask, error)
734 t_task."level", 743 t_task."level",
735 t_task.level_name , 744 t_task.level_name ,
736 t_task.anomaly , 745 t_task.anomaly ,
  746 + t_task.current_stage,
  747 + t_task.last_stage,
737 t_task.status , 748 t_task.status ,
738 t_task.updated_at , 749 t_task.updated_at ,
739 t_task.created_at 750 t_task.created_at