Merge branch 'test' into dev-tangxvhui
正在显示
7 个修改的文件
包含
31 行增加
和
11 行删除
| @@ -60,6 +60,8 @@ spec: | @@ -60,6 +60,8 @@ spec: | ||
| 60 | value: "debug" | 60 | value: "debug" |
| 61 | - name: LOG_FILE | 61 | - name: LOG_FILE |
| 62 | value: "true" | 62 | value: "true" |
| 63 | + - name: ENV_MOD | ||
| 64 | + value: "prd" | ||
| 63 | - name: ERROR_BASE_CODE | 65 | - name: ERROR_BASE_CODE |
| 64 | value: "1" | 66 | value: "1" |
| 65 | - name: ERROR_BASE_CODE_MULTIPLE | 67 | - name: ERROR_BASE_CODE_MULTIPLE |
| @@ -60,6 +60,8 @@ spec: | @@ -60,6 +60,8 @@ spec: | ||
| 60 | value: "debug" | 60 | value: "debug" |
| 61 | - name: LOG_FILE | 61 | - name: LOG_FILE |
| 62 | value: "true" | 62 | value: "true" |
| 63 | + - name: ENV_MOD | ||
| 64 | + value: "test" | ||
| 63 | - name: ERROR_BASE_CODE | 65 | - name: ERROR_BASE_CODE |
| 64 | value: "1" | 66 | value: "1" |
| 65 | - name: ERROR_BASE_CODE_MULTIPLE | 67 | - name: ERROR_BASE_CODE_MULTIPLE |
| 1 | package main | 1 | package main |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant" | ||
| 4 | "time" | 5 | "time" |
| 5 | 6 | ||
| 6 | "github.com/beego/beego/v2/server/web" | 7 | "github.com/beego/beego/v2/server/web" |
| @@ -27,7 +28,13 @@ func startNodeTask() { | @@ -27,7 +28,13 @@ func startNodeTask() { | ||
| 27 | go func() { | 28 | go func() { |
| 28 | nodeTaskService := serviceTask.NewNodeTaskService() | 29 | nodeTaskService := serviceTask.NewNodeTaskService() |
| 29 | for { | 30 | for { |
| 30 | - timer := time.NewTimer(time.Second * 60) | 31 | + var duration time.Duration |
| 32 | + if constant.Env == "prd" { | ||
| 33 | + duration = time.Minute * 5 | ||
| 34 | + } else { | ||
| 35 | + duration = time.Minute * 1 | ||
| 36 | + } | ||
| 37 | + timer := time.NewTimer(duration) | ||
| 31 | <-timer.C | 38 | <-timer.C |
| 32 | if err := nodeTaskService.SendEvaluationNode(); err != nil { | 39 | if err := nodeTaskService.SendEvaluationNode(); err != nil { |
| 33 | log.Logger.Error(err.Error()) | 40 | log.Logger.Error(err.Error()) |
| @@ -176,7 +176,8 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | @@ -176,7 +176,8 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | ||
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | now := time.Now().Local() | 178 | now := time.Now().Local() |
| 179 | - nowO := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻 | 179 | + year, month, day := now.Date() |
| 180 | + nowO := time.Date(year, month, day, 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻 | ||
| 180 | 181 | ||
| 181 | for i := range tasks { | 182 | for i := range tasks { |
| 182 | task := tasks[i] | 183 | task := tasks[i] |
| @@ -191,7 +192,7 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | @@ -191,7 +192,7 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp | ||
| 191 | endLocal := task.TimeEnd.Local() | 192 | endLocal := task.TimeEnd.Local() |
| 192 | 193 | ||
| 193 | // 在当前时间之前,则计算下一个周期时间 | 194 | // 在当前时间之前,则计算下一个周期时间 |
| 194 | - if startLocal.Before(now) { | 195 | + if startLocal.Before(nowO) { |
| 195 | nextTime := utils.NextTime(nowO, startLocal, task.KpiCycle) | 196 | nextTime := utils.NextTime(nowO, startLocal, task.KpiCycle) |
| 196 | task.NextSentAt = &nextTime | 197 | task.NextSentAt = &nextTime |
| 197 | } else { | 198 | } else { |
| @@ -460,7 +461,8 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | @@ -460,7 +461,8 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | ||
| 460 | } | 461 | } |
| 461 | 462 | ||
| 462 | now := time.Now().Local() | 463 | now := time.Now().Local() |
| 463 | - nowO := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻 | 464 | + year, month, day := now.Date() |
| 465 | + nowO := time.Date(year, month, day, 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻 | ||
| 464 | 466 | ||
| 465 | for i := range project.Template.LinkNodes { | 467 | for i := range project.Template.LinkNodes { |
| 466 | node := project.Template.LinkNodes[i] | 468 | node := project.Template.LinkNodes[i] |
| @@ -486,7 +488,7 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | @@ -486,7 +488,7 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand) | ||
| 486 | endLocal := task.TimeEnd.Local() | 488 | endLocal := task.TimeEnd.Local() |
| 487 | 489 | ||
| 488 | // 在当前时间之前,则计算下一个周期时间 | 490 | // 在当前时间之前,则计算下一个周期时间 |
| 489 | - if startLocal.Before(now) { | 491 | + if startLocal.Before(nowO) { |
| 490 | nextTime := utils.NextTime(nowO, startLocal, node.KpiCycle) | 492 | nextTime := utils.NextTime(nowO, startLocal, node.KpiCycle) |
| 491 | task.NextSentAt = &nextTime | 493 | task.NextSentAt = &nextTime |
| 492 | } else { | 494 | } else { |
| @@ -11,8 +11,15 @@ var AdminJwtExpiresIn = int64(3600 * 24 * 7) | @@ -11,8 +11,15 @@ var AdminJwtExpiresIn = int64(3600 * 24 * 7) | ||
| 11 | 11 | ||
| 12 | var AdminJWTSecretKey = "sg-storage" | 12 | var AdminJWTSecretKey = "sg-storage" |
| 13 | 13 | ||
| 14 | +// Env 判断当前环境变量 | ||
| 15 | +var Env = "dev" | ||
| 16 | + | ||
| 14 | func init() { | 17 | func init() { |
| 15 | if os.Getenv("LOG_LEVEL") != "" { | 18 | if os.Getenv("LOG_LEVEL") != "" { |
| 16 | LOG_LEVEL = os.Getenv("LOG_LEVEL") | 19 | LOG_LEVEL = os.Getenv("LOG_LEVEL") |
| 17 | } | 20 | } |
| 21 | + | ||
| 22 | + if os.Getenv("ENV_MOD") != "" { | ||
| 23 | + Env = os.Getenv("ENV_MOD") | ||
| 24 | + } | ||
| 18 | } | 25 | } |
| @@ -63,8 +63,8 @@ func (repo *StaffAssessRepository) Save(d *domain.StaffAssess) (*domain.StaffAss | @@ -63,8 +63,8 @@ func (repo *StaffAssessRepository) Save(d *domain.StaffAssess) (*domain.StaffAss | ||
| 63 | Status: string(d.Status), | 63 | Status: string(d.Status), |
| 64 | BeginTime: d.BeginTime, | 64 | BeginTime: d.BeginTime, |
| 65 | EndTime: d.EndTime, | 65 | EndTime: d.EndTime, |
| 66 | - CreatedAt: d.EndTime, | ||
| 67 | - UpdatedAt: d.CreatedAt, | 66 | + CreatedAt: d.CreatedAt, |
| 67 | + UpdatedAt: d.UpdatedAt, | ||
| 68 | DeletedAt: d.DeletedAt, | 68 | DeletedAt: d.DeletedAt, |
| 69 | } | 69 | } |
| 70 | tx := repo.transactionContext.PgTx | 70 | tx := repo.transactionContext.PgTx |
| @@ -34,8 +34,8 @@ func (repo *StaffAssessTaskRepository) TransformToDomain(d *models.StaffAssessTa | @@ -34,8 +34,8 @@ func (repo *StaffAssessTaskRepository) TransformToDomain(d *models.StaffAssessTa | ||
| 34 | EndTime: d.EndTime, | 34 | EndTime: d.EndTime, |
| 35 | StepList: d.StepList, | 35 | StepList: d.StepList, |
| 36 | ExecutorId: d.ExecutorId, | 36 | ExecutorId: d.ExecutorId, |
| 37 | - CreatedAt: d.EndTime, | ||
| 38 | - UpdatedAt: d.CreatedAt, | 37 | + CreatedAt: d.CreatedAt, |
| 38 | + UpdatedAt: d.UpdatedAt, | ||
| 39 | DeletedAt: d.DeletedAt, | 39 | DeletedAt: d.DeletedAt, |
| 40 | } | 40 | } |
| 41 | } | 41 | } |
| @@ -53,8 +53,8 @@ func (repo *StaffAssessTaskRepository) Save(d *domain.StaffAssessTask) (*domain. | @@ -53,8 +53,8 @@ func (repo *StaffAssessTaskRepository) Save(d *domain.StaffAssessTask) (*domain. | ||
| 53 | StepList: d.StepList, | 53 | StepList: d.StepList, |
| 54 | BeginTime: d.BeginTime, | 54 | BeginTime: d.BeginTime, |
| 55 | EndTime: d.EndTime, | 55 | EndTime: d.EndTime, |
| 56 | - CreatedAt: d.EndTime, | ||
| 57 | - UpdatedAt: d.CreatedAt, | 56 | + CreatedAt: d.CreatedAt, |
| 57 | + UpdatedAt: d.UpdatedAt, | ||
| 58 | DeletedAt: d.DeletedAt, | 58 | DeletedAt: d.DeletedAt, |
| 59 | } | 59 | } |
| 60 | tx := repo.transactionContext.PgTx | 60 | tx := repo.transactionContext.PgTx |
-
请 注册 或 登录 后发表评论