作者 tangxvhui

暂存

@@ -23,10 +23,10 @@ type UserData struct { @@ -23,10 +23,10 @@ type UserData struct {
23 23
24 type TaskStage struct { 24 type TaskStage struct {
25 Id int `json:"id,string"` 25 Id int `json:"id,string"`
26 - Name string `json:"name"` //里程碑名称  
27 - StatusDescription string `json:"statusDescription"` //里程碑的完成情况  
28 - Status int `json:"status"` //里程碑状态 26 + Name string `json:"name"` //里程碑名称
  27 + StatusDescription string `json:"statusDescription,omitempty"` //里程碑的完成情况
  28 + Status int `json:"status"` //里程碑状态
29 SortBy int `json:"sortBy"` 29 SortBy int `json:"sortBy"`
30 - PlanCompletedAt string `json:"planCompletedAt"` //计划完成时间, 例:2006-01-02  
31 - RealCompletedAt string `json:"realCompletedAt"` //实际完成时间, 例:2006-01-02 30 + PlanCompletedAt string `json:"planCompletedAt,omitempty"` //计划完成时间, 例:2006-01-02
  31 + RealCompletedAt string `json:"realCompletedAt,omitempty"` //实际完成时间, 例:2006-01-02
32 } 32 }
  1 +package command
  2 +
  3 +type UpdateTaskStageStatusCommand struct {
  4 +}
@@ -605,6 +605,10 @@ func (t TaskService) ListTask2(param command.SearchTaskCommand) (map[string]inte @@ -605,6 +605,10 @@ func (t TaskService) ListTask2(param command.SearchTaskCommand) (map[string]inte
605 if err != nil { 605 if err != nil {
606 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息"+err.Error()) 606 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息"+err.Error())
607 } 607 }
  608 + if hrbpFlag == domain.RoleTypeSystem {
  609 + listData, err := t.ListTask2ForHrbp(param)
  610 + return listData, err
  611 + }
608 var limit = 20 612 var limit = 20
609 var offset = 0 613 var offset = 0
610 if param.PageSize > 0 { 614 if param.PageSize > 0 {
@@ -623,22 +627,166 @@ func (t TaskService) ListTask2(param command.SearchTaskCommand) (map[string]inte @@ -623,22 +627,166 @@ func (t TaskService) ListTask2(param command.SearchTaskCommand) (map[string]inte
623 LeaderId: param.LeaderId, 627 LeaderId: param.LeaderId,
624 } 628 }
625 629
626 - if hrbpFlag == domain.RoleTypeSystem {  
627 - //已hrbp权限获取  
628 - // info.IsHrbp = true  
629 - return nil, nil  
630 - }  
631 taskDato := dao.NewTaskDao(map[string]interface{}{ 630 taskDato := dao.NewTaskDao(map[string]interface{}{
632 "transactionContext": transactionContext, 631 "transactionContext": transactionContext,
633 }) 632 })
634 - taskDato.ListTaskStageNotHrbp(condition) 633 + tasklistData, err := taskDato.ListTaskStageNotHrbp(condition)
  634 + if err != nil {
  635 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
  636 + }
  637 + taskCount, err := taskDato.CountTaskStageNotHrbp(condition)
  638 + if err != nil {
  639 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())
  640 + }
635 if err := transactionContext.CommitTransaction(); err != nil { 641 if err := transactionContext.CommitTransaction(); err != nil {
636 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 642 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
637 } 643 }
638 - return nil, nil 644 + taskResult := []*adapter.TaskItem{}
  645 + taskMapResult := map[int]*adapter.TaskItem{}
  646 + for _, val := range tasklistData {
  647 + if _, ok := taskMapResult[val.TaskId]; ok {
  648 + continue
  649 + }
  650 + tk := adapter.TaskItem{
  651 + Id: val.TaskId,
  652 + Name: val.TaskName,
  653 + Alias: val.TaskAliasName,
  654 + Leader: val.LeaderName,
  655 + Status: val.TaskStatus,
  656 + Level: val.Level,
  657 + LevelName: val.LevelName,
  658 + // StageA: adapter.TaskStage{},
  659 + // StageB: adapter.TaskStage{},
  660 + // StageC: adapter.TaskStage{},
  661 + // StageD: adapter.TaskStage{},
  662 + // StageE: adapter.TaskStage{},
  663 + }
  664 + taskMapResult[val.TaskId] = &tk
  665 + taskResult = append(taskResult, &tk)
  666 + }
  667 + for _, val := range tasklistData {
  668 + taskData, ok := taskMapResult[val.TaskId]
  669 + if !ok {
  670 + continue
  671 + }
  672 + stage := adapter.TaskStage{
  673 + Id: val.StageId,
  674 + Name: val.StageName,
  675 + Status: val.StageStatus,
  676 + SortBy: val.StageSortBy,
  677 + }
  678 + switch val.StageSortBy {
  679 + case 1:
  680 + taskData.StageA = stage
  681 + case 2:
  682 + taskData.StageB = stage
  683 + case 3:
  684 + taskData.StageC = stage
  685 + case 4:
  686 + taskData.StageD = stage
  687 + case 5:
  688 + taskData.StageE = stage
  689 + }
  690 + }
  691 + result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
  692 + return result, nil
639 } 693 }
640 694
641 // 以hrbp角色权限获取任务列表 695 // 以hrbp角色权限获取任务列表
642 func (t TaskService) ListTask2ForHrbp(param command.SearchTaskCommand) (map[string]interface{}, error) { 696 func (t TaskService) ListTask2ForHrbp(param command.SearchTaskCommand) (map[string]interface{}, error) {
643 - return nil, nil 697 + var limit = 20
  698 + var offset = 0
  699 + if param.PageSize > 0 {
  700 + limit = param.PageSize
  701 + if param.PageNumber > 0 {
  702 + offset = (param.PageNumber - 1) * param.PageSize
  703 + }
  704 + }
  705 + condition := dao.ListTaskCondition{
  706 + Limit: limit,
  707 + Offset: offset,
  708 + UserId: param.UserId,
  709 + TaskName: param.TaskName,
  710 + LevelName: param.LevelName,
  711 + OnlyMy: param.OnlyMy,
  712 + LeaderId: param.LeaderId,
  713 + }
  714 + transactionContext, err := factory.CreateTransactionContext(nil)
  715 + if err != nil {
  716 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  717 + }
  718 + if err := transactionContext.StartTransaction(); err != nil {
  719 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  720 + }
  721 + defer func() {
  722 + _ = transactionContext.RollbackTransaction()
  723 + }()
  724 + taskDato := dao.NewTaskDao(map[string]interface{}{
  725 + "transactionContext": transactionContext,
  726 + })
  727 + tasklistData, err := taskDato.ListTaskStageByHrbp(condition)
  728 + if err != nil {
  729 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
  730 + }
  731 + taskCount, err := taskDato.CountTaskStageByHrbp(condition)
  732 + if err != nil {
  733 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())
  734 + }
  735 + if err := transactionContext.CommitTransaction(); err != nil {
  736 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  737 + }
  738 + taskResult := []*adapter.TaskItem{}
  739 + taskMapResult := map[int]*adapter.TaskItem{}
  740 + for _, val := range tasklistData {
  741 + if _, ok := taskMapResult[val.TaskId]; ok {
  742 + continue
  743 + }
  744 + tk := adapter.TaskItem{
  745 + Id: val.TaskId,
  746 + Name: val.TaskName,
  747 + Alias: val.TaskAliasName,
  748 + Leader: val.LeaderName,
  749 + Status: val.TaskStatus,
  750 + Level: val.Level,
  751 + LevelName: val.LevelName,
  752 + // StageA: adapter.TaskStage{},
  753 + // StageB: adapter.TaskStage{},
  754 + // StageC: adapter.TaskStage{},
  755 + // StageD: adapter.TaskStage{},
  756 + // StageE: adapter.TaskStage{},
  757 + }
  758 + taskMapResult[val.TaskId] = &tk
  759 + taskResult = append(taskResult, &tk)
  760 + }
  761 + for _, val := range tasklistData {
  762 + taskData, ok := taskMapResult[val.TaskId]
  763 + if !ok {
  764 + continue
  765 + }
  766 + stage := adapter.TaskStage{
  767 + Id: val.StageId,
  768 + Name: val.StageName,
  769 + Status: val.StageStatus,
  770 + SortBy: val.StageSortBy,
  771 + }
  772 + switch val.StageSortBy {
  773 + case 1:
  774 + taskData.StageA = stage
  775 + case 2:
  776 + taskData.StageB = stage
  777 + case 3:
  778 + taskData.StageC = stage
  779 + case 4:
  780 + taskData.StageD = stage
  781 + case 5:
  782 + taskData.StageE = stage
  783 + }
  784 + }
  785 + result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
  786 + return result, nil
  787 +}
  788 +
  789 +// 更新任务里程碑的状态
  790 +func (t TaskService) UpdateTaskStageStatus(param command.UpdateTaskStageStatusCommand) {
  791 +
644 } 792 }
@@ -6,8 +6,7 @@ type TaskStageState int @@ -6,8 +6,7 @@ type TaskStageState int
6 6
7 const ( 7 const (
8 TaskStageUncompleted TaskStageState = 1 //里程碑未完成 8 TaskStageUncompleted TaskStageState = 1 //里程碑未完成
9 - // TaskStageCompletedOverdue TaskStageState = 2 //里程碑逾期完成  
10 - TaskStageCompleted TaskStageState = 2 //里程碑完成 9 + TaskStageCompleted TaskStageState = 2 //里程碑完成
11 10
12 ) 11 )
13 12
@@ -71,8 +71,10 @@ type ListTaskCondition struct { @@ -71,8 +71,10 @@ type ListTaskCondition struct {
71 71
72 // 任务和里程碑列表 72 // 任务和里程碑列表
73 type ListTaskStage struct { 73 type ListTaskStage struct {
74 - TaskId string `pg:"task_id"` 74 + TaskId int `pg:"task_id"`
75 TaskName string `pg:"task_name"` 75 TaskName string `pg:"task_name"`
  76 + TaskStatus int `pg:"task_status"`
  77 + TaskAliasName string `pg:"task_alias_name"`
76 LeaderName string `pg:"leader_name"` 78 LeaderName string `pg:"leader_name"`
77 LeaderId string `pg:"leader_id"` 79 LeaderId string `pg:"leader_id"`
78 LevelName string `pg:"level_name"` 80 LevelName string `pg:"level_name"`
@@ -80,6 +82,7 @@ type ListTaskStage struct { @@ -80,6 +82,7 @@ type ListTaskStage struct {
80 Anomaly int `pg:"anomaly"` 82 Anomaly int `pg:"anomaly"`
81 UpdatedAt time.Time `pg:"updated_at"` 83 UpdatedAt time.Time `pg:"updated_at"`
82 CreatedAt time.Time `pg:"created_at"` 84 CreatedAt time.Time `pg:"created_at"`
  85 + StageId int `pg:"stage_id"`
83 StageName string `pg:"stage_name"` 86 StageName string `pg:"stage_name"`
84 StageSortBy int `pg:"stage_sort_by"` 87 StageSortBy int `pg:"stage_sort_by"`
85 StageStatus int `pg:"stage_status"` 88 StageStatus int `pg:"stage_status"`
@@ -98,6 +101,7 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage @@ -98,6 +101,7 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage
98 select 101 select
99 task.id as task_id, 102 task.id as task_id,
100 task."name" as task_name, 103 task."name" as task_name,
  104 + task."alias" as task_alias_name,
101 task.leader ->>'name' as leader_name, 105 task.leader ->>'name' as leader_name,
102 task.leader ->>'id' as leader_id, 106 task.leader ->>'id' as leader_id,
103 task.level_name , 107 task.level_name ,
@@ -105,6 +109,8 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage @@ -105,6 +109,8 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage
105 task.updated_at , 109 task.updated_at ,
106 task.created_at , 110 task.created_at ,
107 task."level" , 111 task."level" ,
  112 + task."status" as task_status,
  113 + task_stage."id" as stage_id,
108 task_stage."name" as stage_name, 114 task_stage."name" as stage_name,
109 task_stage.sort_by as stage_sort_by, 115 task_stage.sort_by as stage_sort_by,
110 task_stage.status as stage_status, 116 task_stage.status as stage_status,
@@ -131,6 +137,8 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage @@ -131,6 +137,8 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage
131 select 137 select
132 t_task_tage_1.task_id, 138 t_task_tage_1.task_id,
133 t_task_tage_1.task_name, 139 t_task_tage_1.task_name,
  140 + t_task_tage_1.task_alias_name,
  141 + t_task_tage_1.task_status,
134 t_task_tage_1.leader_name, 142 t_task_tage_1.leader_name,
135 t_task_tage_1.level_name , 143 t_task_tage_1.level_name ,
136 t_task_tage_1.anomaly , 144 t_task_tage_1.anomaly ,
@@ -139,8 +147,9 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage @@ -139,8 +147,9 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage
139 t_task_tage_1."level" , 147 t_task_tage_1."level" ,
140 t_task_tage_1.plan_completed_at, 148 t_task_tage_1.plan_completed_at,
141 t_task_tage_1.stage_name, 149 t_task_tage_1.stage_name,
  150 + t_task_tage_1.stage_id,
142 t_task_tage_1.stage_sort_by, 151 t_task_tage_1.stage_sort_by,
143 - t_task_tage_1.stage_status, 152 + t_task_tage_1.stage_status
144 from t_task_tage_1 153 from t_task_tage_1
145 where t_task_tage_1.task_id in( 154 where t_task_tage_1.task_id in(
146 select t_task_page.task_id from t_task_page 155 select t_task_page.task_id from t_task_page
@@ -214,6 +223,8 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage, @@ -214,6 +223,8 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage,
214 select 223 select
215 task.id as task_id, 224 task.id as task_id,
216 task."name" as task_name, 225 task."name" as task_name,
  226 + task."alias" as task_alias_name,
  227 + task."status" as task_status,
217 task.leader ->>'name' as leader_name, 228 task.leader ->>'name' as leader_name,
218 task.leader ->>'id' as leader_id, 229 task.leader ->>'id' as leader_id,
219 task.level_name , 230 task.level_name ,
@@ -221,6 +232,7 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage, @@ -221,6 +232,7 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage,
221 task.updated_at , 232 task.updated_at ,
222 task.created_at , 233 task.created_at ,
223 task."level" , 234 task."level" ,
  235 + task_stage."id" as stage_id,
224 task_stage."name" as stage_name, 236 task_stage."name" as stage_name,
225 task_stage.sort_by as stage_sort_by, 237 task_stage.sort_by as stage_sort_by,
226 task_stage.status as stage_status, 238 task_stage.status as stage_status,
@@ -247,6 +259,8 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage, @@ -247,6 +259,8 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage,
247 select 259 select
248 t_task_tage_1.task_id, 260 t_task_tage_1.task_id,
249 t_task_tage_1.task_name, 261 t_task_tage_1.task_name,
  262 + t_task_tage_1.task_alias_name,
  263 + t_task_tage_1.task_status,
250 t_task_tage_1.leader_name, 264 t_task_tage_1.leader_name,
251 t_task_tage_1.level_name , 265 t_task_tage_1.level_name ,
252 t_task_tage_1.anomaly , 266 t_task_tage_1.anomaly ,
@@ -255,8 +269,9 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage, @@ -255,8 +269,9 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage,
255 t_task_tage_1."level" , 269 t_task_tage_1."level" ,
256 t_task_tage_1.plan_completed_at, 270 t_task_tage_1.plan_completed_at,
257 t_task_tage_1.stage_name, 271 t_task_tage_1.stage_name,
  272 + t_task_tage_1.stage_id,
258 t_task_tage_1.stage_sort_by, 273 t_task_tage_1.stage_sort_by,
259 - t_task_tage_1.stage_status, 274 + t_task_tage_1.stage_status
260 from t_task_tage_1 275 from t_task_tage_1
261 where t_task_tage_1.task_id in( 276 where t_task_tage_1.task_id in(
262 select t_task_page.task_id from t_task_page 277 select t_task_page.task_id from t_task_page