Merge branch 'test' of http://gitlab.fjmaimaimai.com/allied-creation/performance into test
正在显示
8 个修改的文件
包含
29 行增加
和
20 行删除
@@ -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 | // 下个周期起始时间 |
@@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
5 | "github.com/linmadan/egglib-go/utils/tool_funs" | 5 | "github.com/linmadan/egglib-go/utils/tool_funs" |
6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/user/query" | 7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/user/query" |
8 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
8 | ) | 9 | ) |
9 | 10 | ||
10 | type UserService struct{} | 11 | type UserService struct{} |
@@ -26,6 +27,7 @@ func (service *UserService) ListUsers(listUserQuery *query.ListUserQuery) (inter | @@ -26,6 +27,7 @@ func (service *UserService) ListUsers(listUserQuery *query.ListUserQuery) (inter | ||
26 | count, list, err := userRepo.Find(map[string]interface{}{ | 27 | count, list, err := userRepo.Find(map[string]interface{}{ |
27 | "companyId": listUserQuery.CompanyId, | 28 | "companyId": listUserQuery.CompanyId, |
28 | "name": listUserQuery.Name, | 29 | "name": listUserQuery.Name, |
30 | + "status": domain.UserStatusEnable, | ||
29 | }) | 31 | }) |
30 | if err != nil { | 32 | if err != nil { |
31 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 33 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -24,7 +24,7 @@ const ( | @@ -24,7 +24,7 @@ const ( | ||
24 | UserTypeCommon int = 1 | 24 | UserTypeCommon int = 1 |
25 | UserTypeManager int = 2 | 25 | UserTypeManager int = 2 |
26 | 26 | ||
27 | - UserStatusEnable int = 1 | 27 | + UserStatusEnable int = 1 // 正常用户 2禁用用户 |
28 | ) | 28 | ) |
29 | 29 | ||
30 | type UserRepository interface { | 30 | type UserRepository interface { |
@@ -21,9 +21,6 @@ func NewNodeTaskRepository(transactionContext *pgTransaction.TransactionContext) | @@ -21,9 +21,6 @@ func NewNodeTaskRepository(transactionContext *pgTransaction.TransactionContext) | ||
21 | } | 21 | } |
22 | 22 | ||
23 | func (repo *NodeTaskRepository) TransformToDomain(m *models.NodeTask) domain.NodeTask { | 23 | func (repo *NodeTaskRepository) TransformToDomain(m *models.NodeTask) domain.NodeTask { |
24 | - timeStart := m.TimeStart.Local() | ||
25 | - timeEnd := m.TimeEnd.Local() | ||
26 | - nextSentAt := m.NextSentAt.Local() | ||
27 | return domain.NodeTask{ | 24 | return domain.NodeTask{ |
28 | Id: m.Id, | 25 | Id: m.Id, |
29 | CompanyId: m.CompanyId, | 26 | CompanyId: m.CompanyId, |
@@ -34,10 +31,10 @@ func (repo *NodeTaskRepository) TransformToDomain(m *models.NodeTask) domain.Nod | @@ -34,10 +31,10 @@ func (repo *NodeTaskRepository) TransformToDomain(m *models.NodeTask) domain.Nod | ||
34 | NodeName: m.NodeName, | 31 | NodeName: m.NodeName, |
35 | NodeDescribe: m.NodeDescribe, | 32 | NodeDescribe: m.NodeDescribe, |
36 | NodeSort: m.NodeSort, | 33 | NodeSort: m.NodeSort, |
37 | - TimeStart: &timeStart, | ||
38 | - TimeEnd: &timeEnd, | 34 | + TimeStart: m.TimeStart, |
35 | + TimeEnd: m.TimeEnd, | ||
39 | KpiCycle: m.KpiCycle, | 36 | KpiCycle: m.KpiCycle, |
40 | - NextSentAt: &nextSentAt, | 37 | + NextSentAt: m.NextSentAt, |
41 | CreatedAt: m.CreatedAt.Local(), | 38 | CreatedAt: m.CreatedAt.Local(), |
42 | UpdatedAt: m.UpdatedAt.Local(), | 39 | UpdatedAt: m.UpdatedAt.Local(), |
43 | DeletedAt: m.DeletedAt, | 40 | DeletedAt: m.DeletedAt, |
@@ -119,6 +119,9 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d | @@ -119,6 +119,9 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d | ||
119 | if v, ok := queryOptions["account"]; ok { | 119 | if v, ok := queryOptions["account"]; ok { |
120 | query.Where("account like ?", v) | 120 | query.Where("account like ?", v) |
121 | } | 121 | } |
122 | + if v, ok := queryOptions["status"]; ok { | ||
123 | + query.Where("status=?", v) | ||
124 | + } | ||
122 | if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { | 125 | if v, ok := queryOptions["name"].(string); ok && len(v) > 0 { |
123 | query.Where("name like ?", fmt.Sprintf("%%%v%%", v)) | 126 | query.Where("name like ?", fmt.Sprintf("%%%v%%", v)) |
124 | } | 127 | } |
@@ -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) |
-
请 注册 或 登录 后发表评论