|
@@ -14,6 +14,11 @@ import ( |
|
@@ -14,6 +14,11 @@ import ( |
14
|
|
14
|
|
15
|
type TaskService struct{}
|
15
|
type TaskService struct{}
|
16
|
|
16
|
|
|
|
17
|
+func NewTaskService() *TaskService {
|
|
|
18
|
+ newService := &TaskService{}
|
|
|
19
|
+ return newService
|
|
|
20
|
+}
|
|
|
21
|
+
|
17
|
func dayEndTime(t time.Time) time.Time {
|
22
|
func dayEndTime(t time.Time) time.Time {
|
18
|
y, m, d := t.Local().Date()
|
23
|
y, m, d := t.Local().Date()
|
19
|
t2 := time.Date(y, m, d, 23, 59, 59, 0, time.Local)
|
24
|
t2 := time.Date(y, m, d, 23, 59, 59, 0, time.Local)
|
|
@@ -35,6 +40,7 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
@@ -35,6 +40,7 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
35
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询任务失败:"+err.Error())
|
40
|
return application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询任务失败:"+err.Error())
|
36
|
}
|
41
|
}
|
37
|
if cnt > 0 {
|
42
|
if cnt > 0 {
|
|
|
43
|
+ //TODO
|
38
|
//任务已存在
|
44
|
//任务已存在
|
39
|
return nil
|
45
|
return nil
|
40
|
}
|
46
|
}
|
|
@@ -64,8 +70,8 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
@@ -64,8 +70,8 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
64
|
Name: "里程碑1",
|
70
|
Name: "里程碑1",
|
65
|
SortBy: 1,
|
71
|
SortBy: 1,
|
66
|
Status: domain.TaskStageUncompleted,
|
72
|
Status: domain.TaskStageUncompleted,
|
67
|
- PlanCompletedAt: nowEndTime.Add(30 * 24 * time.Hour).Unix(),
|
|
|
68
|
- RealCompletedAt: 0,
|
73
|
+ PlanCompletedAt: nowEndTime.Add(30 * 24 * time.Hour).Format("2006-01-02"),
|
|
|
74
|
+ RealCompletedAt: "",
|
69
|
},
|
75
|
},
|
70
|
{
|
76
|
{
|
71
|
Id: 0,
|
77
|
Id: 0,
|
|
@@ -73,8 +79,8 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
@@ -73,8 +79,8 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
73
|
Name: "里程碑2",
|
79
|
Name: "里程碑2",
|
74
|
SortBy: 2,
|
80
|
SortBy: 2,
|
75
|
Status: domain.TaskStageUncompleted,
|
81
|
Status: domain.TaskStageUncompleted,
|
76
|
- PlanCompletedAt: nowEndTime.Add(60 * 24 * time.Hour).Unix(),
|
|
|
77
|
- RealCompletedAt: 0,
|
82
|
+ PlanCompletedAt: nowEndTime.Add(60 * 24 * time.Hour).Format("2006-01-02"),
|
|
|
83
|
+ RealCompletedAt: "",
|
78
|
},
|
84
|
},
|
79
|
{
|
85
|
{
|
80
|
Id: 0,
|
86
|
Id: 0,
|
|
@@ -82,8 +88,8 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
|
@@ -82,8 +88,8 @@ func (srv TaskService) CreateTask(transactionContext application.TransactionCont |
82
|
Name: "里程碑3",
|
88
|
Name: "里程碑3",
|
83
|
SortBy: 3,
|
89
|
SortBy: 3,
|
84
|
Status: domain.TaskStageUncompleted,
|
90
|
Status: domain.TaskStageUncompleted,
|
85
|
- PlanCompletedAt: nowEndTime.Add(90 * 24 * time.Hour).Unix(),
|
|
|
86
|
- RealCompletedAt: 0,
|
91
|
+ PlanCompletedAt: nowEndTime.Add(90 * 24 * time.Hour).Format("2006-01-02"),
|
|
|
92
|
+ RealCompletedAt: "",
|
87
|
},
|
93
|
},
|
88
|
}
|
94
|
}
|
89
|
err = taskStageRepo.Save(newTaskStage)
|
95
|
err = taskStageRepo.Save(newTaskStage)
|
|
@@ -166,8 +172,8 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
|
@@ -166,8 +172,8 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
166
|
Name: val2.Name,
|
172
|
Name: val2.Name,
|
167
|
SortBy: i + 1,
|
173
|
SortBy: i + 1,
|
168
|
Status: domain.TaskStageUncompleted,
|
174
|
Status: domain.TaskStageUncompleted,
|
169
|
- PlanCompletedAt: t.Unix(),
|
|
|
170
|
- RealCompletedAt: 0,
|
175
|
+ PlanCompletedAt: val2.PlanCompletedAt,
|
|
|
176
|
+ RealCompletedAt: "",
|
171
|
}
|
177
|
}
|
172
|
newStageList = append(newStageList, &newStage)
|
178
|
newStageList = append(newStageList, &newStage)
|
173
|
continue
|
179
|
continue
|
|
@@ -178,7 +184,7 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
|
@@ -178,7 +184,7 @@ func (srv TaskService) UpdateTask(param *command.UpdateTaskCommand) (map[string] |
178
|
}
|
184
|
}
|
179
|
oldStage.DeletedAt = nil
|
185
|
oldStage.DeletedAt = nil
|
180
|
oldStage.SortBy = i + 1
|
186
|
oldStage.SortBy = i + 1
|
181
|
- oldStage.PlanCompletedAt = t.Unix()
|
187
|
+ oldStage.PlanCompletedAt = val2.PlanCompletedAt
|
182
|
oldStage.Name = val2.Name
|
188
|
oldStage.Name = val2.Name
|
183
|
}
|
189
|
}
|
184
|
stageList = append(stageList, newStageList...)
|
190
|
stageList = append(stageList, newStageList...)
|
|
@@ -270,14 +276,11 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task |
|
@@ -270,14 +276,11 @@ func (srv TaskService) GetTaskInfo(param *command.GetTaskCommand) (*adapter.Task |
270
|
})
|
276
|
})
|
271
|
}
|
277
|
}
|
272
|
for _, val := range stageList {
|
278
|
for _, val := range stageList {
|
273
|
- var t string
|
|
|
274
|
- if val.PlanCompletedAt > 0 {
|
|
|
275
|
- t = time.Unix(val.PlanCompletedAt, 0).Local().Format("2006-01-02")
|
|
|
276
|
- }
|
|
|
277
|
result.StageList = append(result.StageList, adapter.TaskStage{
|
279
|
result.StageList = append(result.StageList, adapter.TaskStage{
|
278
|
Id: val.Id,
|
280
|
Id: val.Id,
|
279
|
Name: val.Name,
|
281
|
Name: val.Name,
|
280
|
- PlanCompletedAt: t,
|
282
|
+ PlanCompletedAt: val.PlanCompletedAt,
|
|
|
283
|
+ RealCompletedAt: val.RealCompletedAt,
|
281
|
})
|
284
|
})
|
282
|
}
|
285
|
}
|
283
|
return &result, nil
|
286
|
return &result, nil
|
|
@@ -411,11 +414,47 @@ func (srv TaskService) ListTask(param *command.ListTaskCommand) (map[string]inte |
|
@@ -411,11 +414,47 @@ func (srv TaskService) ListTask(param *command.ListTaskCommand) (map[string]inte |
411
|
}
|
414
|
}
|
412
|
|
415
|
|
413
|
taskResult := []*adapter.TaskItem{}
|
416
|
taskResult := []*adapter.TaskItem{}
|
414
|
- _ = stageList
|
|
|
415
|
- // taskMapResult := map[int]*adapter.TaskItem{}
|
|
|
416
|
- // for _, val := range taskList {
|
|
|
417
|
-
|
|
|
418
|
- // }
|
417
|
+ taskMapResult := map[int]*adapter.TaskItem{}
|
|
|
418
|
+ for _, val := range taskList {
|
|
|
419
|
+ tk := adapter.TaskItem{
|
|
|
420
|
+ Id: val.Id,
|
|
|
421
|
+ Name: val.Name,
|
|
|
422
|
+ Alias: val.Alias,
|
|
|
423
|
+ Leader: adapter.UserData{
|
|
|
424
|
+ Id: val.Leader.Id,
|
|
|
425
|
+ Account: val.Leader.Account,
|
|
|
426
|
+ Name: val.Leader.Name,
|
|
|
427
|
+ },
|
|
|
428
|
+ Status: int(val.Status),
|
|
|
429
|
+ Level: val.Level,
|
|
|
430
|
+ LevalName: val.LevalName,
|
|
|
431
|
+ StageA: "",
|
|
|
432
|
+ StageB: "",
|
|
|
433
|
+ StageC: "",
|
|
|
434
|
+ StageD: "",
|
|
|
435
|
+ StageE: "",
|
|
|
436
|
+ }
|
|
|
437
|
+ taskResult = append(taskResult, &tk)
|
|
|
438
|
+ taskMapResult[val.Id] = &tk
|
|
|
439
|
+ }
|
|
|
440
|
+ for _, val := range stageList {
|
|
|
441
|
+ taskData, ok := taskMapResult[val.TaskId]
|
|
|
442
|
+ if !ok {
|
|
|
443
|
+ continue
|
|
|
444
|
+ }
|
|
|
445
|
+ switch val.SortBy {
|
|
|
446
|
+ case 1:
|
|
|
447
|
+ taskData.StageA = val.Name
|
|
|
448
|
+ case 2:
|
|
|
449
|
+ taskData.StageB = val.Name
|
|
|
450
|
+ case 3:
|
|
|
451
|
+ taskData.StageC = val.Name
|
|
|
452
|
+ case 4:
|
|
|
453
|
+ taskData.StageD = val.Name
|
|
|
454
|
+ case 5:
|
|
|
455
|
+ taskData.StageE = val.Name
|
|
|
456
|
+ }
|
|
|
457
|
+ }
|
419
|
result := tool_funs.SimpleWrapGridMap(int64(taskCnt), taskResult)
|
458
|
result := tool_funs.SimpleWrapGridMap(int64(taskCnt), taskResult)
|
420
|
return result, nil
|
459
|
return result, nil
|
421
|
} |
460
|
} |