Merge branch 'dev-tangxvhui' into test
正在显示
5 个修改的文件
包含
67 行增加
和
42 行删除
@@ -6,8 +6,8 @@ type CreateStaffAssessTask struct { | @@ -6,8 +6,8 @@ type CreateStaffAssessTask struct { | ||
6 | EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | 6 | EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 |
7 | CycleId int64 `json:"cycleId"` //对应的周期id | 7 | CycleId int64 `json:"cycleId"` //对应的周期id |
8 | CycleName string `json:"cycleName"` //对应周期的名称 | 8 | CycleName string `json:"cycleName"` //对应周期的名称 |
9 | - BeginTime string `json:"beginTime"` //绩效考核开始时间 | ||
10 | - EndTime string `json:"endTime"` //绩效考核截止时间 | 9 | + BeginTime string `json:"beginTime"` //绩效考核开始时间 2006-01-02 15:04:05 |
10 | + EndTime string `json:"endTime"` //绩效考核截止时间 2006-01-02 15:04:05 | ||
11 | StepList []AssessTaskStep `json:"steps"` //考评的流程 | 11 | StepList []AssessTaskStep `json:"steps"` //考评的流程 |
12 | ExecutorId []int `json:"executorId"` //参与此次考评的人 | 12 | ExecutorId []int `json:"executorId"` //参与此次考评的人 |
13 | } | 13 | } |
@@ -341,7 +341,9 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | @@ -341,7 +341,9 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | ||
341 | defer func() { | 341 | defer func() { |
342 | _ = transactionContext.RollbackTransaction() | 342 | _ = transactionContext.RollbackTransaction() |
343 | }() | 343 | }() |
344 | - | 344 | + assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ |
345 | + "transactionContext": transactionContext, | ||
346 | + }) | ||
345 | taskBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local) | 347 | taskBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local) |
346 | if err != nil { | 348 | if err != nil { |
347 | return nil, application.ThrowError(application.ARG_ERROR, "任务开始时间填写错误,"+param.BeginTime) | 349 | return nil, application.ThrowError(application.ARG_ERROR, "任务开始时间填写错误,"+param.BeginTime) |
@@ -351,24 +353,45 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | @@ -351,24 +353,45 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | ||
351 | return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime) | 353 | return nil, application.ThrowError(application.ARG_ERROR, "任务结束时间填写错误,"+param.EndTime) |
352 | } | 354 | } |
353 | nowTime := time.Now() | 355 | nowTime := time.Now() |
354 | - //建立评估任务 | ||
355 | - assessTask := domain.StaffAssessTask{ | ||
356 | - Id: 0, | ||
357 | - CompanyId: param.CompanyId, | ||
358 | - EvaluationProjectId: param.EvaluationProjectId, | ||
359 | - EvaluationProjectName: param.EvaluationProjectName, | ||
360 | - CycleId: param.CycleId, | ||
361 | - CycleName: param.CycleName, | ||
362 | - BeginTime: taskBeginTime, | ||
363 | - EndTime: taskEndTime, | ||
364 | - StepList: []domain.AssessTaskStep{}, | ||
365 | - ExecutorId: nil, | ||
366 | - CreatedAt: nowTime, | ||
367 | - UpdatedAt: nowTime, | ||
368 | - DeletedAt: nil, | 356 | + var assessTaskData *domain.StaffAssessTask |
357 | + _, assassessTaskList, err := assessTaskRepo.Find(map[string]interface{}{ | ||
358 | + "evaluationProjectId": param.EvaluationProjectId, | ||
359 | + "beginDay": param.BeginTime, | ||
360 | + }) | ||
361 | + if err != nil { | ||
362 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "查询同日期已存在评估任务"+err.Error()) | ||
363 | + } | ||
364 | + // 获取旧数据 | ||
365 | + | ||
366 | + if len(assassessTaskList) > 0 { | ||
367 | + assessTaskData = assassessTaskList[0] | ||
368 | + assessTaskData.UpdatedAt = nowTime | ||
369 | + } else { | ||
370 | + //建立评估任务 | ||
371 | + assessTaskData = &domain.StaffAssessTask{ | ||
372 | + Id: 0, | ||
373 | + CompanyId: param.CompanyId, | ||
374 | + EvaluationProjectId: param.EvaluationProjectId, | ||
375 | + EvaluationProjectName: param.EvaluationProjectName, | ||
376 | + CycleId: param.CycleId, | ||
377 | + CycleName: param.CycleName, | ||
378 | + BeginTime: taskBeginTime, | ||
379 | + EndTime: taskEndTime, | ||
380 | + StepList: []domain.AssessTaskStep{}, | ||
381 | + ExecutorId: nil, | ||
382 | + CreatedAt: nowTime, | ||
383 | + UpdatedAt: nowTime, | ||
384 | + DeletedAt: nil, | ||
385 | + } | ||
369 | } | 386 | } |
387 | + | ||
370 | //填充评估环节 | 388 | //填充评估环节 |
371 | for _, v := range param.StepList { | 389 | for _, v := range param.StepList { |
390 | + for _, vv := range assessTaskData.StepList { | ||
391 | + if vv.LinkNodeType == v.LinkNodeType { | ||
392 | + continue | ||
393 | + } | ||
394 | + } | ||
372 | stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local) | 395 | stepBeginTime, err := time.ParseInLocation("2006-01-02 15:04:05", param.BeginTime, time.Local) |
373 | if err != nil { | 396 | if err != nil { |
374 | return nil, application.ThrowError(application.ARG_ERROR, "评估环节开始时间填写错误,"+param.BeginTime) | 397 | return nil, application.ThrowError(application.ARG_ERROR, "评估环节开始时间填写错误,"+param.BeginTime) |
@@ -385,13 +408,10 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | @@ -385,13 +408,10 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | ||
385 | BeginTime: stepBeginTime, | 408 | BeginTime: stepBeginTime, |
386 | EndTime: stepEndTime, | 409 | EndTime: stepEndTime, |
387 | } | 410 | } |
388 | - assessTask.StepList = append(assessTask.StepList, step) | 411 | + assessTaskData.StepList = append(assessTaskData.StepList, step) |
389 | } | 412 | } |
390 | 413 | ||
391 | - assessTaskRepo := factory.CreateStaffAssessTaskRepository(map[string]interface{}{ | ||
392 | - "transactionContext": transactionContext, | ||
393 | - }) | ||
394 | - assessList, err := srv.createStaffAssess(transactionContext, &assessTask) | 414 | + assessList, err := srv.createStaffAssess(transactionContext, assessTaskData) |
395 | if err != nil { | 415 | if err != nil { |
396 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error()) | 416 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "生成个人评估项"+err.Error()) |
397 | } | 417 | } |
@@ -405,27 +425,35 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | @@ -405,27 +425,35 @@ func (srv StaffAssessServeice) CreateStaffAssessTask(param *command.CreateStaffA | ||
405 | } | 425 | } |
406 | executorIds = append(executorIds, v) | 426 | executorIds = append(executorIds, v) |
407 | } | 427 | } |
428 | + //过滤就数据 | ||
429 | + for _, v := range assessTaskData.ExecutorId { | ||
430 | + if _, ok := executorIdMap[v]; ok { | ||
431 | + continue | ||
432 | + } | ||
433 | + executorIds = append(executorIds, v) | ||
434 | + } | ||
408 | assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ | 435 | assessRepo := factory.CreateStaffAssessRepository(map[string]interface{}{ |
409 | "transactionContext": transactionContext, | 436 | "transactionContext": transactionContext, |
410 | }) | 437 | }) |
438 | + assessTaskData.ExecutorId = executorIds | ||
439 | + _, err = assessTaskRepo.Save(assessTaskData) | ||
440 | + if err != nil { | ||
441 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error()) | ||
442 | + } | ||
411 | 443 | ||
412 | for i := range assessList { | 444 | for i := range assessList { |
445 | + assessList[i].StaffAssessTaskId = assessTaskData.Id | ||
413 | _, err = assessRepo.Save(&assessList[i]) | 446 | _, err = assessRepo.Save(&assessList[i]) |
414 | if err != nil { | 447 | if err != nil { |
415 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error()) | 448 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存个人评估项"+err.Error()) |
416 | } | 449 | } |
417 | } | 450 | } |
418 | - assessTask.ExecutorId = executorIds | ||
419 | - _, err = assessTaskRepo.Save(&assessTask) | ||
420 | - if err != nil { | ||
421 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存评估任务"+err.Error()) | ||
422 | - } | ||
423 | 451 | ||
424 | if err := transactionContext.CommitTransaction(); err != nil { | 452 | if err := transactionContext.CommitTransaction(); err != nil { |
425 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 453 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
426 | } | 454 | } |
427 | return map[string]interface{}{ | 455 | return map[string]interface{}{ |
428 | - "assessTaskId": assessTask.Id, | 456 | + "assessTaskId": assessTaskData.Id, |
429 | }, nil | 457 | }, nil |
430 | } | 458 | } |
431 | 459 |
@@ -2,19 +2,6 @@ package domain | @@ -2,19 +2,6 @@ package domain | ||
2 | 2 | ||
3 | import "time" | 3 | import "time" |
4 | 4 | ||
5 | -//评估任务重复执行的方式 | ||
6 | -// type AssessTaskRepeatWay string | ||
7 | - | ||
8 | -// const ( | ||
9 | -// AssessTaskRepeatDay AssessTaskRepeatWay = "day" //按天重复 | ||
10 | -// AssessTaskRepeatWeek AssessTaskRepeatWay = "week" //按周重复 | ||
11 | -// AssessTaskRepeatMonth AssessTaskRepeatWay = "month" //按月 | ||
12 | -// AssessTaskRepeatMonthDouble AssessTaskRepeatWay = "month_double" //按双月 | ||
13 | -// AssessTaskRepeatQuarter AssessTaskRepeatWay = "quarter" //按季度 | ||
14 | -// AssessTaskRepeatYearHalf AssessTaskRepeatWay = "year_half" //按半年 | ||
15 | -// AssessTaskRepeatYear AssessTaskRepeatWay = "year" //按年 | ||
16 | -// ) | ||
17 | - | ||
18 | // 执行评估的任务列表 | 5 | // 执行评估的任务列表 |
19 | type StaffAssessTask struct { | 6 | type StaffAssessTask struct { |
20 | Id int `json:"id"` | 7 | Id int `json:"id"` |
@@ -23,6 +10,7 @@ type StaffAssessTask struct { | @@ -23,6 +10,7 @@ type StaffAssessTask struct { | ||
23 | EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 | 10 | EvaluationProjectName string `json:"evaluationProjectName"` //项目名称 |
24 | CycleId int64 `json:"cycleId"` //对应的周期id | 11 | CycleId int64 `json:"cycleId"` //对应的周期id |
25 | CycleName string `json:"cycleName"` //对应周期的名称 | 12 | CycleName string `json:"cycleName"` //对应周期的名称 |
13 | + BeginDay string `json:"beginDay"` //绩效考核日期 | ||
26 | BeginTime time.Time `json:"beginTime"` //绩效考核开始时间 | 14 | BeginTime time.Time `json:"beginTime"` //绩效考核开始时间 |
27 | EndTime time.Time `json:"endTime"` //绩效考核截止时间 | 15 | EndTime time.Time `json:"endTime"` //绩效考核截止时间 |
28 | StepList []AssessTaskStep `json:"stepList"` //考评的流程 | 16 | StepList []AssessTaskStep `json:"stepList"` //考评的流程 |
@@ -17,6 +17,7 @@ type StaffAssessTask struct { | @@ -17,6 +17,7 @@ type StaffAssessTask struct { | ||
17 | CycleName string //对应周期的名称 | 17 | CycleName string //对应周期的名称 |
18 | ExecutorId []int //参与考评的人 | 18 | ExecutorId []int //参与考评的人 |
19 | StepList []domain.AssessTaskStep `` //考评的流程 | 19 | StepList []domain.AssessTaskStep `` //考评的流程 |
20 | + BeginDay string //日期 天 2006-01-02 | ||
20 | BeginTime time.Time //开始时间 | 21 | BeginTime time.Time //开始时间 |
21 | EndTime time.Time //截止时间 | 22 | EndTime time.Time //截止时间 |
22 | CreatedAt time.Time //数据创建时间 | 23 | CreatedAt time.Time //数据创建时间 |
@@ -29,6 +29,7 @@ func (repo *StaffAssessTaskRepository) TransformToDomain(d *models.StaffAssessTa | @@ -29,6 +29,7 @@ func (repo *StaffAssessTaskRepository) TransformToDomain(d *models.StaffAssessTa | ||
29 | EvaluationProjectName: d.EvaluationProjectName, | 29 | EvaluationProjectName: d.EvaluationProjectName, |
30 | CycleId: d.CycleId, | 30 | CycleId: d.CycleId, |
31 | CycleName: d.CycleName, | 31 | CycleName: d.CycleName, |
32 | + BeginDay: d.BeginDay, | ||
32 | BeginTime: d.BeginTime, | 33 | BeginTime: d.BeginTime, |
33 | EndTime: d.EndTime, | 34 | EndTime: d.EndTime, |
34 | StepList: d.StepList, | 35 | StepList: d.StepList, |
@@ -47,6 +48,7 @@ func (repo *StaffAssessTaskRepository) Save(d *domain.StaffAssessTask) (*domain. | @@ -47,6 +48,7 @@ func (repo *StaffAssessTaskRepository) Save(d *domain.StaffAssessTask) (*domain. | ||
47 | EvaluationProjectName: d.EvaluationProjectName, | 48 | EvaluationProjectName: d.EvaluationProjectName, |
48 | CycleId: d.CycleId, | 49 | CycleId: d.CycleId, |
49 | CycleName: d.CycleName, | 50 | CycleName: d.CycleName, |
51 | + BeginDay: d.BeginDay, | ||
50 | ExecutorId: d.ExecutorId, | 52 | ExecutorId: d.ExecutorId, |
51 | StepList: d.StepList, | 53 | StepList: d.StepList, |
52 | BeginTime: d.BeginTime, | 54 | BeginTime: d.BeginTime, |
@@ -115,9 +117,15 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{}) | @@ -115,9 +117,15 @@ func (repo *StaffAssessTaskRepository) Find(queryOptions map[string]interface{}) | ||
115 | if v, ok := queryOptions["offset"].(int); ok { | 117 | if v, ok := queryOptions["offset"].(int); ok { |
116 | query.Offset(v) | 118 | query.Offset(v) |
117 | } | 119 | } |
120 | + if v, ok := queryOptions["beginDay"]; ok { | ||
121 | + query.Where("begin_day=?", v) | ||
122 | + } | ||
118 | if v, ok := queryOptions["executorId"].(int); ok && v > 0 { | 123 | if v, ok := queryOptions["executorId"].(int); ok && v > 0 { |
119 | query.Where(`executor_id @>'[?]'`, v) | 124 | query.Where(`executor_id @>'[?]'`, v) |
120 | } | 125 | } |
126 | + if v, ok := queryOptions["evaluationProjectId"]; ok { | ||
127 | + query.Where("evaluation_project_id=?", v) | ||
128 | + } | ||
121 | count, err := query.SelectAndCount() | 129 | count, err := query.SelectAndCount() |
122 | if err != nil { | 130 | if err != nil { |
123 | return 0, nil, err | 131 | return 0, nil, err |
-
请 注册 或 登录 后发表评论