...
|
...
|
@@ -49,9 +49,9 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
|
Id: 0,
|
|
|
Name: param.Name,
|
|
|
Alias: param.Name,
|
|
|
Status: domain.TaskRunning,
|
|
|
Status: domain.TaskWait,
|
|
|
Level: 0,
|
|
|
LevalName: "",
|
|
|
LevelName: "",
|
|
|
RelatedUser: []int{},
|
|
|
RunAt: nowTime.Unix(),
|
|
|
}
|
...
|
...
|
@@ -70,8 +70,8 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
|
Name: "里程碑1",
|
|
|
SortBy: 1,
|
|
|
Status: domain.TaskStageUncompleted,
|
|
|
PlanCompletedAt: nowEndTime.Add(30 * 24 * time.Hour).Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
PlanCompletedAt: nowEndTime.Add(30 * 24 * time.Hour).Unix(),
|
|
|
RealCompletedAt: 0,
|
|
|
},
|
|
|
{
|
|
|
Id: 0,
|
...
|
...
|
@@ -79,8 +79,8 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
|
Name: "里程碑2",
|
|
|
SortBy: 2,
|
|
|
Status: domain.TaskStageUncompleted,
|
|
|
PlanCompletedAt: nowEndTime.Add(60 * 24 * time.Hour).Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
PlanCompletedAt: nowEndTime.Add(60 * 24 * time.Hour).Unix(),
|
|
|
RealCompletedAt: 0,
|
|
|
},
|
|
|
{
|
|
|
Id: 0,
|
...
|
...
|
@@ -88,8 +88,8 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
|
Name: "里程碑3",
|
|
|
SortBy: 3,
|
|
|
Status: domain.TaskStageUncompleted,
|
|
|
PlanCompletedAt: nowEndTime.Add(90 * 24 * time.Hour).Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
PlanCompletedAt: nowEndTime.Add(90 * 24 * time.Hour).Unix(),
|
|
|
RealCompletedAt: 0,
|
|
|
},
|
|
|
}
|
|
|
err = taskStageRepo.Save(newTaskStage)
|
...
|
...
|
@@ -131,6 +131,13 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
ok, err := srv.canUpdateTask(taskData, stageList)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
if !ok {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "日评数据已生成,任务不能再被编辑")
|
|
|
}
|
|
|
leaderData, err := userRepo.FindOne(map[string]interface{}{
|
|
|
"id": param.LeaderId,
|
|
|
})
|
...
|
...
|
@@ -172,8 +179,8 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
|
|
Name: val2.Name,
|
|
|
SortBy: i + 1,
|
|
|
Status: domain.TaskStageUncompleted,
|
|
|
PlanCompletedAt: val2.PlanCompletedAt,
|
|
|
RealCompletedAt: "",
|
|
|
PlanCompletedAt: t.Unix(),
|
|
|
RealCompletedAt: 0,
|
|
|
}
|
|
|
newStageList = append(newStageList, &newStage)
|
|
|
continue
|
...
|
...
|
@@ -184,7 +191,7 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
|
|
}
|
|
|
oldStage.DeletedAt = nil
|
|
|
oldStage.SortBy = i + 1
|
|
|
oldStage.PlanCompletedAt = val2.PlanCompletedAt
|
|
|
oldStage.PlanCompletedAt = t.Unix()
|
|
|
oldStage.Name = val2.Name
|
|
|
}
|
|
|
stageList = append(stageList, newStageList...)
|
...
|
...
|
@@ -261,7 +268,7 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task |
|
|
},
|
|
|
Status: int(taskData.Status),
|
|
|
Level: taskData.Level,
|
|
|
LevalName: taskData.LevalName,
|
|
|
LevalName: taskData.LevelName,
|
|
|
RelatedUserId: []string{},
|
|
|
RelatedUser: []adapter.UserData{},
|
|
|
StageList: []adapter.TaskStage{},
|
...
|
...
|
@@ -275,12 +282,22 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task |
|
|
Name: val.Name,
|
|
|
})
|
|
|
}
|
|
|
|
|
|
for _, val := range stageList {
|
|
|
t1 := ""
|
|
|
t2 := ""
|
|
|
if val.PlanCompletedAt > 0 {
|
|
|
t1 = time.Unix(val.PlanCompletedAt, 0).Local().Format("2006-01-02")
|
|
|
}
|
|
|
if val.RealCompletedAt > 0 {
|
|
|
t2 = time.Unix(val.RealCompletedAt, 0).Local().Format("2006-01-02")
|
|
|
}
|
|
|
result.StageList = append(result.StageList, adapter.TaskStage{
|
|
|
Id: val.Id,
|
|
|
Name: val.Name,
|
|
|
PlanCompletedAt: val.PlanCompletedAt,
|
|
|
RealCompletedAt: val.RealCompletedAt,
|
|
|
PlanCompletedAt: t1,
|
|
|
RealCompletedAt: t2,
|
|
|
StatusCompleted: val.DescriptStatus(),
|
|
|
})
|
|
|
}
|
|
|
return &result, nil
|
...
|
...
|
@@ -427,7 +444,7 @@ func (srv TaskService) ListTask(param *command.ListTaskCommand) (map[string]inte |
|
|
},
|
|
|
Status: int(val.Status),
|
|
|
Level: val.Level,
|
|
|
LevalName: val.LevalName,
|
|
|
LevelName: val.LevelName,
|
|
|
StageA: "",
|
|
|
StageB: "",
|
|
|
StageC: "",
|
...
|
...
|
@@ -458,3 +475,7 @@ func (srv TaskService) ListTask(param *command.ListTaskCommand) (map[string]inte |
|
|
result := tool_funs.SimpleWrapGridMap(int64(taskCnt), taskResult)
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
func (t TaskService) canUpdateTask(taskData *domain.Task, stageList []*domain.TaskStage) (bool, error) {
|
|
|
return true, nil
|
|
|
} |
...
|
...
|
|