作者 tangxvhui

暂存

... ... @@ -23,10 +23,10 @@ type UserData struct {
type TaskStage struct {
Id int `json:"id,string"`
Name string `json:"name"` //里程碑名称
StatusDescription string `json:"statusDescription"` //里程碑的完成情况
Status int `json:"status"` //里程碑状态
Name string `json:"name"` //里程碑名称
StatusDescription string `json:"statusDescription,omitempty"` //里程碑的完成情况
Status int `json:"status"` //里程碑状态
SortBy int `json:"sortBy"`
PlanCompletedAt string `json:"planCompletedAt"` //计划完成时间, 例:2006-01-02
RealCompletedAt string `json:"realCompletedAt"` //实际完成时间, 例:2006-01-02
PlanCompletedAt string `json:"planCompletedAt,omitempty"` //计划完成时间, 例:2006-01-02
RealCompletedAt string `json:"realCompletedAt,omitempty"` //实际完成时间, 例:2006-01-02
}
... ...
package command
type UpdateTaskStageStatusCommand struct {
}
... ...
... ... @@ -605,6 +605,10 @@ func (t TaskService) ListTask2(param command.SearchTaskCommand) (map[string]inte
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息"+err.Error())
}
if hrbpFlag == domain.RoleTypeSystem {
listData, err := t.ListTask2ForHrbp(param)
return listData, err
}
var limit = 20
var offset = 0
if param.PageSize > 0 {
... ... @@ -623,22 +627,166 @@ func (t TaskService) ListTask2(param command.SearchTaskCommand) (map[string]inte
LeaderId: param.LeaderId,
}
if hrbpFlag == domain.RoleTypeSystem {
//已hrbp权限获取
// info.IsHrbp = true
return nil, nil
}
taskDato := dao.NewTaskDao(map[string]interface{}{
"transactionContext": transactionContext,
})
taskDato.ListTaskStageNotHrbp(condition)
tasklistData, err := taskDato.ListTaskStageNotHrbp(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
}
taskCount, err := taskDato.CountTaskStageNotHrbp(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
return nil, nil
taskResult := []*adapter.TaskItem{}
taskMapResult := map[int]*adapter.TaskItem{}
for _, val := range tasklistData {
if _, ok := taskMapResult[val.TaskId]; ok {
continue
}
tk := adapter.TaskItem{
Id: val.TaskId,
Name: val.TaskName,
Alias: val.TaskAliasName,
Leader: val.LeaderName,
Status: val.TaskStatus,
Level: val.Level,
LevelName: val.LevelName,
// StageA: adapter.TaskStage{},
// StageB: adapter.TaskStage{},
// StageC: adapter.TaskStage{},
// StageD: adapter.TaskStage{},
// StageE: adapter.TaskStage{},
}
taskMapResult[val.TaskId] = &tk
taskResult = append(taskResult, &tk)
}
for _, val := range tasklistData {
taskData, ok := taskMapResult[val.TaskId]
if !ok {
continue
}
stage := adapter.TaskStage{
Id: val.StageId,
Name: val.StageName,
Status: val.StageStatus,
SortBy: val.StageSortBy,
}
switch val.StageSortBy {
case 1:
taskData.StageA = stage
case 2:
taskData.StageB = stage
case 3:
taskData.StageC = stage
case 4:
taskData.StageD = stage
case 5:
taskData.StageE = stage
}
}
result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
return result, nil
}
// 以hrbp角色权限获取任务列表
func (t TaskService) ListTask2ForHrbp(param command.SearchTaskCommand) (map[string]interface{}, error) {
return nil, nil
var limit = 20
var offset = 0
if param.PageSize > 0 {
limit = param.PageSize
if param.PageNumber > 0 {
offset = (param.PageNumber - 1) * param.PageSize
}
}
condition := dao.ListTaskCondition{
Limit: limit,
Offset: offset,
UserId: param.UserId,
TaskName: param.TaskName,
LevelName: param.LevelName,
OnlyMy: param.OnlyMy,
LeaderId: param.LeaderId,
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
_ = transactionContext.RollbackTransaction()
}()
taskDato := dao.NewTaskDao(map[string]interface{}{
"transactionContext": transactionContext,
})
tasklistData, err := taskDato.ListTaskStageByHrbp(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())
}
taskCount, err := taskDato.CountTaskStageByHrbp(condition)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
taskResult := []*adapter.TaskItem{}
taskMapResult := map[int]*adapter.TaskItem{}
for _, val := range tasklistData {
if _, ok := taskMapResult[val.TaskId]; ok {
continue
}
tk := adapter.TaskItem{
Id: val.TaskId,
Name: val.TaskName,
Alias: val.TaskAliasName,
Leader: val.LeaderName,
Status: val.TaskStatus,
Level: val.Level,
LevelName: val.LevelName,
// StageA: adapter.TaskStage{},
// StageB: adapter.TaskStage{},
// StageC: adapter.TaskStage{},
// StageD: adapter.TaskStage{},
// StageE: adapter.TaskStage{},
}
taskMapResult[val.TaskId] = &tk
taskResult = append(taskResult, &tk)
}
for _, val := range tasklistData {
taskData, ok := taskMapResult[val.TaskId]
if !ok {
continue
}
stage := adapter.TaskStage{
Id: val.StageId,
Name: val.StageName,
Status: val.StageStatus,
SortBy: val.StageSortBy,
}
switch val.StageSortBy {
case 1:
taskData.StageA = stage
case 2:
taskData.StageB = stage
case 3:
taskData.StageC = stage
case 4:
taskData.StageD = stage
case 5:
taskData.StageE = stage
}
}
result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
return result, nil
}
// 更新任务里程碑的状态
func (t TaskService) UpdateTaskStageStatus(param command.UpdateTaskStageStatusCommand) {
}
... ...
... ... @@ -6,8 +6,7 @@ type TaskStageState int
const (
TaskStageUncompleted TaskStageState = 1 //里程碑未完成
// TaskStageCompletedOverdue TaskStageState = 2 //里程碑逾期完成
TaskStageCompleted TaskStageState = 2 //里程碑完成
TaskStageCompleted TaskStageState = 2 //里程碑完成
)
... ...
... ... @@ -71,8 +71,10 @@ type ListTaskCondition struct {
// 任务和里程碑列表
type ListTaskStage struct {
TaskId string `pg:"task_id"`
TaskId int `pg:"task_id"`
TaskName string `pg:"task_name"`
TaskStatus int `pg:"task_status"`
TaskAliasName string `pg:"task_alias_name"`
LeaderName string `pg:"leader_name"`
LeaderId string `pg:"leader_id"`
LevelName string `pg:"level_name"`
... ... @@ -80,6 +82,7 @@ type ListTaskStage struct {
Anomaly int `pg:"anomaly"`
UpdatedAt time.Time `pg:"updated_at"`
CreatedAt time.Time `pg:"created_at"`
StageId int `pg:"stage_id"`
StageName string `pg:"stage_name"`
StageSortBy int `pg:"stage_sort_by"`
StageStatus int `pg:"stage_status"`
... ... @@ -98,6 +101,7 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage
select
task.id as task_id,
task."name" as task_name,
task."alias" as task_alias_name,
task.leader ->>'name' as leader_name,
task.leader ->>'id' as leader_id,
task.level_name ,
... ... @@ -105,6 +109,8 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage
task.updated_at ,
task.created_at ,
task."level" ,
task."status" as task_status,
task_stage."id" as stage_id,
task_stage."name" as stage_name,
task_stage.sort_by as stage_sort_by,
task_stage.status as stage_status,
... ... @@ -131,6 +137,8 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage
select
t_task_tage_1.task_id,
t_task_tage_1.task_name,
t_task_tage_1.task_alias_name,
t_task_tage_1.task_status,
t_task_tage_1.leader_name,
t_task_tage_1.level_name ,
t_task_tage_1.anomaly ,
... ... @@ -139,8 +147,9 @@ func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage
t_task_tage_1."level" ,
t_task_tage_1.plan_completed_at,
t_task_tage_1.stage_name,
t_task_tage_1.stage_id,
t_task_tage_1.stage_sort_by,
t_task_tage_1.stage_status,
t_task_tage_1.stage_status
from t_task_tage_1
where t_task_tage_1.task_id in(
select t_task_page.task_id from t_task_page
... ... @@ -214,6 +223,8 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage,
select
task.id as task_id,
task."name" as task_name,
task."alias" as task_alias_name,
task."status" as task_status,
task.leader ->>'name' as leader_name,
task.leader ->>'id' as leader_id,
task.level_name ,
... ... @@ -221,6 +232,7 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage,
task.updated_at ,
task.created_at ,
task."level" ,
task_stage."id" as stage_id,
task_stage."name" as stage_name,
task_stage.sort_by as stage_sort_by,
task_stage.status as stage_status,
... ... @@ -247,6 +259,8 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage,
select
t_task_tage_1.task_id,
t_task_tage_1.task_name,
t_task_tage_1.task_alias_name,
t_task_tage_1.task_status,
t_task_tage_1.leader_name,
t_task_tage_1.level_name ,
t_task_tage_1.anomaly ,
... ... @@ -255,8 +269,9 @@ func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage,
t_task_tage_1."level" ,
t_task_tage_1.plan_completed_at,
t_task_tage_1.stage_name,
t_task_tage_1.stage_id,
t_task_tage_1.stage_sort_by,
t_task_tage_1.stage_status,
t_task_tage_1.stage_status
from t_task_tage_1
where t_task_tage_1.task_id in(
select t_task_page.task_id from t_task_page
... ...