...
|
...
|
@@ -14,6 +14,11 @@ import ( |
|
|
|
|
|
type TaskService struct{}
|
|
|
|
|
|
func NewTaskService() *TaskService {
|
|
|
newService := &TaskService{}
|
|
|
return newService
|
|
|
}
|
|
|
|
|
|
func dayEndTime(t time.Time) time.Time {
|
|
|
y, m, d := t.Local().Date()
|
|
|
t2 := time.Date(y, m, d, 23, 59, 59, 0, time.Local)
|
...
|
...
|
@@ -35,6 +40,7 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询任务失败:"+err.Error())
|
|
|
}
|
|
|
if cnt > 0 {
|
|
|
//TODO
|
|
|
//任务已存在
|
|
|
return nil
|
|
|
}
|
...
|
...
|
@@ -64,8 +70,8 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
|
Name: "里程碑1",
|
|
|
SortBy: 1,
|
|
|
Status: domain.TaskStageUncompleted,
|
|
|
PlanCompletedAt: nowEndTime.Add(30 * 24 * time.Hour).Unix(),
|
|
|
RealCompletedAt: 0,
|
|
|
PlanCompletedAt: nowEndTime.Add(30 * 24 * time.Hour).Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
},
|
|
|
{
|
|
|
Id: 0,
|
...
|
...
|
@@ -73,8 +79,8 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
|
Name: "里程碑2",
|
|
|
SortBy: 2,
|
|
|
Status: domain.TaskStageUncompleted,
|
|
|
PlanCompletedAt: nowEndTime.Add(60 * 24 * time.Hour).Unix(),
|
|
|
RealCompletedAt: 0,
|
|
|
PlanCompletedAt: nowEndTime.Add(60 * 24 * time.Hour).Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
},
|
|
|
{
|
|
|
Id: 0,
|
...
|
...
|
@@ -82,8 +88,8 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
|
Name: "里程碑3",
|
|
|
SortBy: 3,
|
|
|
Status: domain.TaskStageUncompleted,
|
|
|
PlanCompletedAt: nowEndTime.Add(90 * 24 * time.Hour).Unix(),
|
|
|
RealCompletedAt: 0,
|
|
|
PlanCompletedAt: nowEndTime.Add(90 * 24 * time.Hour).Format("2006-01-02"),
|
|
|
RealCompletedAt: "",
|
|
|
},
|
|
|
}
|
|
|
err = taskStageRepo.Save(newTaskStage)
|
...
|
...
|
@@ -166,8 +172,8 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
|
|
Name: val2.Name,
|
|
|
SortBy: i + 1,
|
|
|
Status: domain.TaskStageUncompleted,
|
|
|
PlanCompletedAt: t.Unix(),
|
|
|
RealCompletedAt: 0,
|
|
|
PlanCompletedAt: val2.PlanCompletedAt,
|
|
|
RealCompletedAt: "",
|
|
|
}
|
|
|
newStageList = append(newStageList, &newStage)
|
|
|
continue
|
...
|
...
|
@@ -178,7 +184,7 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
|
|
}
|
|
|
oldStage.DeletedAt = nil
|
|
|
oldStage.SortBy = i + 1
|
|
|
oldStage.PlanCompletedAt = t.Unix()
|
|
|
oldStage.PlanCompletedAt = val2.PlanCompletedAt
|
|
|
oldStage.Name = val2.Name
|
|
|
}
|
|
|
stageList = append(stageList, newStageList...)
|
...
|
...
|
@@ -270,14 +276,11 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task |
|
|
})
|
|
|
}
|
|
|
for _, val := range stageList {
|
|
|
var t string
|
|
|
if val.PlanCompletedAt > 0 {
|
|
|
t = time.Unix(val.PlanCompletedAt, 0).Local().Format("2006-01-02")
|
|
|
}
|
|
|
result.StageList = append(result.StageList, adapter.TaskStage{
|
|
|
Id: val.Id,
|
|
|
Name: val.Name,
|
|
|
PlanCompletedAt: t,
|
|
|
PlanCompletedAt: val.PlanCompletedAt,
|
|
|
RealCompletedAt: val.RealCompletedAt,
|
|
|
})
|
|
|
}
|
|
|
return &result, nil
|
...
|
...
|
@@ -411,11 +414,47 @@ func (srv TaskService) ListTask(param *command.ListTaskCommand) (map[string]inte |
|
|
}
|
|
|
|
|
|
taskResult := []*adapter.TaskItem{}
|
|
|
_ = stageList
|
|
|
// taskMapResult := map[int]*adapter.TaskItem{}
|
|
|
// for _, val := range taskList {
|
|
|
|
|
|
// }
|
|
|
taskMapResult := map[int]*adapter.TaskItem{}
|
|
|
for _, val := range taskList {
|
|
|
tk := adapter.TaskItem{
|
|
|
Id: val.Id,
|
|
|
Name: val.Name,
|
|
|
Alias: val.Alias,
|
|
|
Leader: adapter.UserData{
|
|
|
Id: val.Leader.Id,
|
|
|
Account: val.Leader.Account,
|
|
|
Name: val.Leader.Name,
|
|
|
},
|
|
|
Status: int(val.Status),
|
|
|
Level: val.Level,
|
|
|
LevalName: val.LevalName,
|
|
|
StageA: "",
|
|
|
StageB: "",
|
|
|
StageC: "",
|
|
|
StageD: "",
|
|
|
StageE: "",
|
|
|
}
|
|
|
taskResult = append(taskResult, &tk)
|
|
|
taskMapResult[val.Id] = &tk
|
|
|
}
|
|
|
for _, val := range stageList {
|
|
|
taskData, ok := taskMapResult[val.TaskId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
switch val.SortBy {
|
|
|
case 1:
|
|
|
taskData.StageA = val.Name
|
|
|
case 2:
|
|
|
taskData.StageB = val.Name
|
|
|
case 3:
|
|
|
taskData.StageC = val.Name
|
|
|
case 4:
|
|
|
taskData.StageD = val.Name
|
|
|
case 5:
|
|
|
taskData.StageE = val.Name
|
|
|
}
|
|
|
}
|
|
|
result := tool_funs.SimpleWrapGridMap(int64(taskCnt), taskResult)
|
|
|
return result, nil
|
|
|
} |
...
|
...
|
|