正在显示
3 个修改的文件
包含
25 行增加
和
19 行删除
@@ -198,8 +198,8 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | @@ -198,8 +198,8 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | ||
198 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 198 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
199 | } | 199 | } |
200 | 200 | ||
201 | - minTime := time.Date(cycle.TimeStart.Year(), cycle.TimeStart.Month(), cycle.TimeStart.Day(), cycle.TimeStart.Hour(), cycle.TimeStart.Minute(), 0, 0, time.Local) | ||
202 | - maxTime := time.Date(cycle.TimeEnd.Year(), cycle.TimeEnd.Month(), cycle.TimeEnd.Day(), cycle.TimeEnd.Hour(), cycle.TimeEnd.Minute(), 0, 0, time.Local) | 201 | + minTime := cycle.TimeStart.Local() |
202 | + maxTime := cycle.TimeEnd.Local() | ||
203 | 203 | ||
204 | if start.Before(minTime) { | 204 | if start.Before(minTime) { |
205 | return nil, application.ThrowError(application.BUSINESS_ERROR, "评估起始时间不能超出周期起始时间") | 205 | return nil, application.ThrowError(application.BUSINESS_ERROR, "评估起始时间不能超出周期起始时间") |
@@ -393,15 +393,20 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | @@ -393,15 +393,20 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | ||
393 | TimeEnd: node.TimeEnd, | 393 | TimeEnd: node.TimeEnd, |
394 | KpiCycle: node.KpiCycle, | 394 | KpiCycle: node.KpiCycle, |
395 | } | 395 | } |
396 | + | ||
397 | + // 环节起始和截止本地时间 | ||
398 | + startLocal := node.TimeStart.Local() | ||
399 | + endLocal := node.TimeEnd.Local() | ||
400 | + | ||
396 | // 在当前时间之前,则计算下一个周期时间 | 401 | // 在当前时间之前,则计算下一个周期时间 |
397 | - if node.TimeStart.Before(now) { | ||
398 | - nextTime := utils.NextTime(nowO, node.TimeStart, node.KpiCycle) | 402 | + if startLocal.Before(now) { |
403 | + nextTime := utils.NextTime(nowO, startLocal, node.KpiCycle) | ||
399 | task.NextSentAt = &nextTime | 404 | task.NextSentAt = &nextTime |
400 | } else { | 405 | } else { |
401 | - task.NextSentAt = node.TimeStart | 406 | + task.NextSentAt = &startLocal |
402 | } | 407 | } |
403 | // 如果超出截至时间,则周期置空 | 408 | // 如果超出截至时间,则周期置空 |
404 | - if task.NextSentAt.After(*node.TimeEnd) { | 409 | + if task.NextSentAt.After(endLocal) { |
405 | task.NextSentAt = nil | 410 | task.NextSentAt = nil |
406 | } | 411 | } |
407 | 412 |
@@ -77,16 +77,15 @@ func (rs *NodeTaskService) SendEvaluationNode() error { | @@ -77,16 +77,15 @@ func (rs *NodeTaskService) SendEvaluationNode() error { | ||
77 | // 项目 | 77 | // 项目 |
78 | project, ok := projectIdsMap[task.ProjectId] | 78 | project, ok := projectIdsMap[task.ProjectId] |
79 | if ok { | 79 | if ok { |
80 | - | ||
81 | // 环节截止时间 | 80 | // 环节截止时间 |
82 | - maxTime := time.Date(task.TimeEnd.Year(), task.TimeEnd.Month(), task.TimeEnd.Day(), task.TimeEnd.Hour(), task.TimeEnd.Minute(), 0, 0, time.Local) | 81 | + maxTime := task.TimeEnd.Local() |
83 | 82 | ||
84 | // 当前周起始时间和截止时间 | 83 | // 当前周起始时间和截止时间 |
85 | - var cycleTimeStart = task.NextSentAt | ||
86 | - var cycleTimeEnd *time.Time | 84 | + var cycleTimeStart = task.NextSentAt.Local() |
85 | + var cycleTimeEnd time.Time | ||
87 | 86 | ||
88 | // 下个周期起始时间 | 87 | // 下个周期起始时间 |
89 | - nextTime := utils.NextTimeInc(task.NextSentAt, task.KpiCycle) | 88 | + nextTime := utils.NextTimeInc(cycleTimeStart, task.KpiCycle) |
90 | // 超过截止时间 | 89 | // 超过截止时间 |
91 | if nextTime.After(maxTime) { | 90 | if nextTime.After(maxTime) { |
92 | task.NextSentAt = nil | 91 | task.NextSentAt = nil |
@@ -96,14 +95,14 @@ func (rs *NodeTaskService) SendEvaluationNode() error { | @@ -96,14 +95,14 @@ func (rs *NodeTaskService) SendEvaluationNode() error { | ||
96 | 95 | ||
97 | // 下个周期的起始时间=当前周期的截止时间 | 96 | // 下个周期的起始时间=当前周期的截止时间 |
98 | if task.NextSentAt == nil { | 97 | if task.NextSentAt == nil { |
99 | - cycleTimeEnd = &maxTime | 98 | + cycleTimeEnd = maxTime |
100 | } else { | 99 | } else { |
101 | - cycleTimeEnd = task.NextSentAt | 100 | + cycleTimeEnd = task.NextSentAt.Local() |
102 | } | 101 | } |
103 | 102 | ||
104 | // 格式化周期的起始和截止时间 | 103 | // 格式化周期的起始和截止时间 |
105 | - fmCycleStartTime := cycleTimeStart.Local().Format("2006-1-2 15:04:05") | ||
106 | - fmCycleTimeEnd := cycleTimeEnd.Local().Format("2006-1-2 15:04:05") | 104 | + fmCycleStartTime := cycleTimeStart.Format("2006-1-2 15:04:05") |
105 | + fmCycleTimeEnd := cycleTimeEnd.Format("2006-1-2 15:04:05") | ||
107 | 106 | ||
108 | csat := &command.CreateStaffAssessTask{ | 107 | csat := &command.CreateStaffAssessTask{ |
109 | CompanyId: int(project.CompanyId), | 108 | CompanyId: int(project.CompanyId), |
@@ -36,9 +36,10 @@ func ValidateCommand(commandType interface{}) error { | @@ -36,9 +36,10 @@ func ValidateCommand(commandType interface{}) error { | ||
36 | } | 36 | } |
37 | 37 | ||
38 | // NextTime 0点时刻为标准计算 | 38 | // NextTime 0点时刻为标准计算 |
39 | -func NextTime(now0 time.Time, start *time.Time, kpiCycle int) time.Time { | 39 | +func NextTime(now0 time.Time, start time.Time, kpiCycle int) time.Time { |
40 | + year, month, day := start.Date() | ||
40 | // 起始时间0点时刻 | 41 | // 起始时间0点时刻 |
41 | - start0 := time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local) | 42 | + start0 := time.Date(year, month, day, 0, 0, 0, 0, time.Local) |
42 | 43 | ||
43 | var nextTime time.Time | 44 | var nextTime time.Time |
44 | switch kpiCycle { | 45 | switch kpiCycle { |
@@ -71,9 +72,10 @@ func NextTime(now0 time.Time, start *time.Time, kpiCycle int) time.Time { | @@ -71,9 +72,10 @@ func NextTime(now0 time.Time, start *time.Time, kpiCycle int) time.Time { | ||
71 | } | 72 | } |
72 | 73 | ||
73 | // NextTimeInc 0点时刻为标准计算 | 74 | // NextTimeInc 0点时刻为标准计算 |
74 | -func NextTimeInc(start *time.Time, kpiCycle int) time.Time { | 75 | +func NextTimeInc(start time.Time, kpiCycle int) time.Time { |
76 | + year, month, day := start.Date() | ||
75 | // 起始时间0点时刻 | 77 | // 起始时间0点时刻 |
76 | - start0 := time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, time.Local) | 78 | + start0 := time.Date(year, month, day, 0, 0, 0, 0, time.Local) |
77 | 79 | ||
78 | var nextTime time.Time | 80 | var nextTime time.Time |
79 | switch kpiCycle { | 81 | switch kpiCycle { |
-
请 注册 或 登录 后发表评论