作者 郑周

提交 项目更新

@@ -198,13 +198,14 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp @@ -198,13 +198,14 @@ 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 := cycle.TimeStart  
202 - maxTime := cycle.TimeEnd  
203 - if start.Before(*minTime) { 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)
  203 +
  204 + if start.Before(minTime) {
204 return nil, application.ThrowError(application.BUSINESS_ERROR, "评估起始时间不能超出周期起始时间") 205 return nil, application.ThrowError(application.BUSINESS_ERROR, "评估起始时间不能超出周期起始时间")
205 } 206 }
206 207
207 - if end.After(*maxTime) { 208 + if end.After(maxTime) {
208 return nil, application.ThrowError(application.BUSINESS_ERROR, "评估截至时间不能超出周期截至时间") 209 return nil, application.ThrowError(application.BUSINESS_ERROR, "评估截至时间不能超出周期截至时间")
209 } 210 }
210 211
@@ -3,6 +3,7 @@ package service @@ -3,6 +3,7 @@ package service
3 import ( 3 import (
4 "github.com/linmadan/egglib-go/core/application" 4 "github.com/linmadan/egglib-go/core/application"
5 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" 5 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
  6 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
6 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils" 7 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/utils"
7 "time" 8 "time"
8 ) 9 )
@@ -25,6 +26,8 @@ func (rs *NodeTaskService) SendEvaluationNode() error { @@ -25,6 +26,8 @@ func (rs *NodeTaskService) SendEvaluationNode() error {
25 transactionContext.RollbackTransaction() 26 transactionContext.RollbackTransaction()
26 }() 27 }()
27 taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) 28 taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
  29 + projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
  30 + //cycleRepository := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext})
28 31
29 tasks, err := taskRepository.Find(map[string]interface{}{"now": time.Now().Local()}) 32 tasks, err := taskRepository.Find(map[string]interface{}{"now": time.Now().Local()})
30 if err != nil { 33 if err != nil {
@@ -33,17 +36,53 @@ func (rs *NodeTaskService) SendEvaluationNode() error { @@ -33,17 +36,53 @@ func (rs *NodeTaskService) SendEvaluationNode() error {
33 36
34 //ttaffAssessRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) 37 //ttaffAssessRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
35 // 38 //
36 - //for i := range tasks {  
37 - //  
38 - // staffAssessService := service.NewStaffAssessServeice()  
39 - // //staffAssessService.CreateStaffAssessTask()  
40 - //  
41 - // //task := tasks[i]  
42 - // 39 +
  40 + projectIdsMap := map[int64]*domain.EvaluationProject{}
  41 + cycleIdsMap := map[int64]*domain.EvaluationCycle{}
  42 + for i := range tasks {
  43 + task := tasks[i]
  44 + projectIdsMap[task.ProjectId] = nil
  45 + cycleIdsMap[task.CycleId] = nil
  46 + }
  47 + projectIds := make([]int64, 0)
  48 + cycleIds := make([]int64, 0)
  49 + for k := range projectIdsMap {
  50 + projectIds = append(projectIds, k)
  51 + }
  52 + for k := range cycleIdsMap {
  53 + cycleIds = append(cycleIds, k)
  54 + }
  55 +
  56 + _, projects, err := projectRepository.Find(map[string]interface{}{"ids": projectIds})
  57 + if err != nil {
  58 + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  59 + }
  60 + //_, cycles, err := cycleRepository.Find(map[string]interface{}{"ids": cycleIds})
  61 + //if err != nil {
  62 + // return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
43 //} 63 //}
44 64
  65 + for i := range projects {
  66 + projectIdsMap[projects[i].Id] = projects[i]
  67 + }
  68 +
  69 + //staffAssessService := service.NewStaffAssessServeice()
  70 +
45 for i := range tasks { 71 for i := range tasks {
46 task := tasks[i] 72 task := tasks[i]
  73 +
  74 + //if project, ok := projectIdsMap[task.ProjectId]; ok {
  75 +
  76 + //csat := &command.CreateStaffAssessTask{
  77 + // CompanyId: project.CompanyId,
  78 + // EvaluationProjectId: project.Id,
  79 + // EvaluationProjectName: project.Name,
  80 + // CycleId: project.CycleId,
  81 + //}
  82 + //
  83 + //staffAssessService.CreateStaffAssessTask(csat)
  84 + //}
  85 +
47 // 下一次发送时间 86 // 下一次发送时间
48 nextTime := utils.NextTimeInc(task.NextSentAt, task.KpiCycle) 87 nextTime := utils.NextTimeInc(task.NextSentAt, task.KpiCycle)
49 task.NextSentAt = &nextTime 88 task.NextSentAt = &nextTime