正在显示
4 个修改的文件
包含
20 行增加
和
13 行删除
@@ -17,6 +17,7 @@ type EvaluationProjectAdapter struct { | @@ -17,6 +17,7 @@ type EvaluationProjectAdapter struct { | ||
17 | } | 17 | } |
18 | 18 | ||
19 | func (adapter *EvaluationProjectAdapter) TransformRecipientAdapter(recipients []*domain.User) { | 19 | func (adapter *EvaluationProjectAdapter) TransformRecipientAdapter(recipients []*domain.User) { |
20 | + adapter.RecipientList = make([]*UserAdapter, 0) | ||
20 | for i := range recipients { | 21 | for i := range recipients { |
21 | adapter.RecipientList = append(adapter.RecipientList, &UserAdapter{ | 22 | adapter.RecipientList = append(adapter.RecipientList, &UserAdapter{ |
22 | Id: recipients[i].Id, | 23 | Id: recipients[i].Id, |
@@ -26,6 +27,7 @@ func (adapter *EvaluationProjectAdapter) TransformRecipientAdapter(recipients [] | @@ -26,6 +27,7 @@ func (adapter *EvaluationProjectAdapter) TransformRecipientAdapter(recipients [] | ||
26 | } | 27 | } |
27 | 28 | ||
28 | func (adapter *EvaluationProjectAdapter) TransformPmpAdapter(pms []*domain.User) { | 29 | func (adapter *EvaluationProjectAdapter) TransformPmpAdapter(pms []*domain.User) { |
30 | + adapter.PmpList = make([]*UserAdapter, 0) | ||
29 | for i := range pms { | 31 | for i := range pms { |
30 | adapter.PmpList = append(adapter.PmpList, &UserAdapter{ | 32 | adapter.PmpList = append(adapter.PmpList, &UserAdapter{ |
31 | Id: pms[i].Id, | 33 | Id: pms[i].Id, |
@@ -46,6 +48,8 @@ func TransformProjectListAdapter(projects []*domain.EvaluationProject, users []* | @@ -46,6 +48,8 @@ func TransformProjectListAdapter(projects []*domain.EvaluationProject, users []* | ||
46 | 48 | ||
47 | epa := &EvaluationProjectAdapter{} | 49 | epa := &EvaluationProjectAdapter{} |
48 | epa.EvaluationProject = project | 50 | epa.EvaluationProject = project |
51 | + epa.PmpList = make([]*UserAdapter, 0) | ||
52 | + | ||
49 | projectAdapters = append(projectAdapters, epa) | 53 | projectAdapters = append(projectAdapters, epa) |
50 | 54 | ||
51 | for j := range project.PmpIds { | 55 | for j := range project.PmpIds { |
@@ -185,18 +185,20 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | @@ -185,18 +185,20 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | ||
185 | // 重新计算 | 185 | // 重新计算 |
186 | if task.NextSentAt == nil { | 186 | if task.NextSentAt == nil { |
187 | // 环节起始和截止本地时间 | 187 | // 环节起始和截止本地时间 |
188 | - startLocal := task.TimeStart | ||
189 | - endLocal := task.TimeEnd | 188 | + startLocal := task.TimeStart.Local() |
189 | + sYear, sMonth, sDay := startLocal.Date() | ||
190 | + startLocal = time.Date(sYear, sMonth, sDay, 0, 0, 0, 0, time.Local) // 开始时间以0点开始计算 | ||
191 | + endLocal := task.TimeEnd.Local() | ||
190 | 192 | ||
191 | // 在当前时间之前,则计算下一个周期时间 | 193 | // 在当前时间之前,则计算下一个周期时间 |
192 | if startLocal.Before(now) { | 194 | if startLocal.Before(now) { |
193 | nextTime := utils.NextTime(nowO, startLocal, task.KpiCycle) | 195 | nextTime := utils.NextTime(nowO, startLocal, task.KpiCycle) |
194 | task.NextSentAt = &nextTime | 196 | task.NextSentAt = &nextTime |
195 | } else { | 197 | } else { |
196 | - task.NextSentAt = startLocal | 198 | + task.NextSentAt = &startLocal |
197 | } | 199 | } |
198 | // 如果超出截至时间,则周期置空 | 200 | // 如果超出截至时间,则周期置空 |
199 | - if task.NextSentAt.After(endLocal.Local()) { | 201 | + if task.NextSentAt.After(endLocal) { |
200 | task.NextSentAt = nil | 202 | task.NextSentAt = nil |
201 | } | 203 | } |
202 | } else { | 204 | } else { |
@@ -435,6 +437,7 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | @@ -435,6 +437,7 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | ||
435 | }() | 437 | }() |
436 | 438 | ||
437 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 439 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
440 | + taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
438 | 441 | ||
439 | project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) | 442 | project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id}) |
440 | if err != nil { | 443 | if err != nil { |
@@ -456,8 +459,6 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | @@ -456,8 +459,6 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | ||
456 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 459 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
457 | } | 460 | } |
458 | 461 | ||
459 | - taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
460 | - | ||
461 | now := time.Now().Local() | 462 | now := time.Now().Local() |
462 | nowO := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻 | 463 | nowO := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻 |
463 | 464 | ||
@@ -479,18 +480,20 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | @@ -479,18 +480,20 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | ||
479 | } | 480 | } |
480 | 481 | ||
481 | // 环节起始和截止本地时间 | 482 | // 环节起始和截止本地时间 |
482 | - startLocal := node.TimeStart | ||
483 | - endLocal := node.TimeEnd | 483 | + startLocal := task.TimeStart.Local() |
484 | + sYear, sMonth, sDay := startLocal.Date() | ||
485 | + startLocal = time.Date(sYear, sMonth, sDay, 0, 0, 0, 0, time.Local) // 开始时间以0点开始计算 | ||
486 | + endLocal := task.TimeEnd.Local() | ||
484 | 487 | ||
485 | // 在当前时间之前,则计算下一个周期时间 | 488 | // 在当前时间之前,则计算下一个周期时间 |
486 | if startLocal.Before(now) { | 489 | if startLocal.Before(now) { |
487 | nextTime := utils.NextTime(nowO, startLocal, node.KpiCycle) | 490 | nextTime := utils.NextTime(nowO, startLocal, node.KpiCycle) |
488 | task.NextSentAt = &nextTime | 491 | task.NextSentAt = &nextTime |
489 | } else { | 492 | } else { |
490 | - task.NextSentAt = startLocal | 493 | + task.NextSentAt = &startLocal |
491 | } | 494 | } |
492 | // 如果超出截至时间,则周期置空 | 495 | // 如果超出截至时间,则周期置空 |
493 | - if task.NextSentAt.After(endLocal.Local()) { | 496 | + if task.NextSentAt.After(endLocal) { |
494 | task.NextSentAt = nil | 497 | task.NextSentAt = nil |
495 | } | 498 | } |
496 | 499 |
@@ -87,7 +87,7 @@ func (rs *NodeTaskService) SendEvaluationNode() error { | @@ -87,7 +87,7 @@ func (rs *NodeTaskService) SendEvaluationNode() error { | ||
87 | maxTime := task.TimeEnd.Local() | 87 | maxTime := task.TimeEnd.Local() |
88 | 88 | ||
89 | // 当前周起始时间和截止时间 | 89 | // 当前周起始时间和截止时间 |
90 | - var cycleTimeStart = task.NextSentAt | 90 | + var cycleTimeStart = task.NextSentAt.Local() |
91 | var cycleTimeEnd time.Time | 91 | var cycleTimeEnd time.Time |
92 | 92 | ||
93 | // 下个周期起始时间 | 93 | // 下个周期起始时间 |
@@ -37,7 +37,7 @@ func ValidateCommand(commandType interface{}) error { | @@ -37,7 +37,7 @@ func ValidateCommand(commandType interface{}) error { | ||
37 | } | 37 | } |
38 | 38 | ||
39 | // NextTime 0点时刻为标准计算 | 39 | // NextTime 0点时刻为标准计算 |
40 | -func NextTime(now0 time.Time, start *time.Time, kpiCycle int) time.Time { | 40 | +func NextTime(now0 time.Time, start time.Time, kpiCycle int) time.Time { |
41 | year, month, day := start.Date() | 41 | year, month, day := start.Date() |
42 | // 起始时间0点时刻 | 42 | // 起始时间0点时刻 |
43 | start0 := time.Date(year, month, day, 0, 0, 0, 0, time.Local) | 43 | start0 := time.Date(year, month, day, 0, 0, 0, 0, time.Local) |
@@ -141,7 +141,7 @@ func SubMonth(t1, t2 time.Time) (month int) { | @@ -141,7 +141,7 @@ func SubMonth(t1, t2 time.Time) (month int) { | ||
141 | } | 141 | } |
142 | 142 | ||
143 | // NextTimeInc 0点时刻为标准计算 | 143 | // NextTimeInc 0点时刻为标准计算 |
144 | -func NextTimeInc(start *time.Time, kpiCycle int) time.Time { | 144 | +func NextTimeInc(start time.Time, kpiCycle int) time.Time { |
145 | year, month, day := start.Date() | 145 | year, month, day := start.Date() |
146 | // 起始时间0点时刻 | 146 | // 起始时间0点时刻 |
147 | start0 := time.Date(year, month, day, 0, 0, 0, 0, time.Local) | 147 | start0 := time.Date(year, month, day, 0, 0, 0, 0, time.Local) |
-
请 注册 或 登录 后发表评论