正在显示
9 个修改的文件
包含
54 行增加
和
10 行删除
1 | package service | 1 | package service |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "strconv" | ||
5 | + "time" | ||
6 | + | ||
4 | "github.com/linmadan/egglib-go/core/application" | 7 | "github.com/linmadan/egglib-go/core/application" |
5 | "github.com/linmadan/egglib-go/utils/tool_funs" | 8 | "github.com/linmadan/egglib-go/utils/tool_funs" |
6 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_cycle/adapter" | 9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_cycle/adapter" |
7 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_cycle/command" | 10 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/evaluation_cycle/command" |
8 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | 11 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" |
9 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | 12 | "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" |
10 | - "strconv" | ||
11 | - "time" | ||
12 | ) | 13 | ) |
13 | 14 | ||
14 | type EvaluationCycleService struct { | 15 | type EvaluationCycleService struct { |
@@ -356,7 +357,7 @@ func (rs *EvaluationCycleService) Remove(in *command.DeleteCycleCommand) (interf | @@ -356,7 +357,7 @@ func (rs *EvaluationCycleService) Remove(in *command.DeleteCycleCommand) (interf | ||
356 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) | 357 | projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext}) |
357 | taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) | 358 | taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) |
358 | staffRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) | 359 | staffRepository := factory.CreateStaffAssessTaskRepository(map[string]interface{}{"transactionContext": transactionContext}) |
359 | - | 360 | + summaryEvaluationRepository := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) |
360 | // 删除周期 | 361 | // 删除周期 |
361 | cycle, err := cycleRepository.FindOne(map[string]interface{}{"id": in.Id}) | 362 | cycle, err := cycleRepository.FindOne(map[string]interface{}{"id": in.Id}) |
362 | if err != nil { | 363 | if err != nil { |
@@ -380,11 +381,6 @@ func (rs *EvaluationCycleService) Remove(in *command.DeleteCycleCommand) (interf | @@ -380,11 +381,6 @@ func (rs *EvaluationCycleService) Remove(in *command.DeleteCycleCommand) (interf | ||
380 | if _, err := projectRepository.Remove(projects[i]); err != nil { | 381 | if _, err := projectRepository.Remove(projects[i]); err != nil { |
381 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 382 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
382 | } | 383 | } |
383 | - | ||
384 | - // 删除项目已生成的周期评估数据 | ||
385 | - if err := staffRepository.RemoveByProjectId(int(projects[i].Id)); err != nil { | ||
386 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
387 | - } | ||
388 | } | 384 | } |
389 | 385 | ||
390 | // 删除周期下的所有定时任务 | 386 | // 删除周期下的所有定时任务 |
@@ -398,6 +394,14 @@ func (rs *EvaluationCycleService) Remove(in *command.DeleteCycleCommand) (interf | @@ -398,6 +394,14 @@ func (rs *EvaluationCycleService) Remove(in *command.DeleteCycleCommand) (interf | ||
398 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 394 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
399 | } | 395 | } |
400 | } | 396 | } |
397 | + // 删除项目已生成的周期评估数据 | ||
398 | + if err := staffRepository.RemoveByCycleId(int(cycle.Id)); err != nil { | ||
399 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
400 | + } | ||
401 | + // | ||
402 | + if err := summaryEvaluationRepository.RemoveByCycleId(cycle.Id); err != nil { | ||
403 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
404 | + } | ||
401 | 405 | ||
402 | if err := transactionContext.CommitTransaction(); err != nil { | 406 | if err := transactionContext.CommitTransaction(); err != nil { |
403 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 407 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -20,7 +20,7 @@ func sendSummaryEvaluation(project *domain.EvaluationProject, | @@ -20,7 +20,7 @@ func sendSummaryEvaluation(project *domain.EvaluationProject, | ||
20 | userMap map[int64]*domain.User, departmentMap map[int64]*domain.Department) ([]domain.SummaryEvaluation, error) { | 20 | userMap map[int64]*domain.User, departmentMap map[int64]*domain.Department) ([]domain.SummaryEvaluation, error) { |
21 | //自评的时间范围 | 21 | //自评的时间范围 |
22 | beginTimeSelf := project.EndTime | 22 | beginTimeSelf := project.EndTime |
23 | - endTimeSelf := dayZeroTime(project.EndTime).Add(3*24*time.Hour - time.Second) | 23 | + endTimeSelf := dayZeroTime(project.EndTime).Add(4*24*time.Hour - time.Second) |
24 | //人资、360评估的时间范围 | 24 | //人资、360评估的时间范围 |
25 | beginTime360 := endTimeSelf | 25 | beginTime360 := endTimeSelf |
26 | endTime360 := endTimeSelf.Add(2 * 24 * time.Hour) | 26 | endTime360 := endTimeSelf.Add(2 * 24 * time.Hour) |
@@ -195,7 +195,8 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | @@ -195,7 +195,8 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | ||
195 | } | 195 | } |
196 | //自评的时间范围 | 196 | //自评的时间范围 |
197 | beginTimeSelf := *cycleData.TimeEnd | 197 | beginTimeSelf := *cycleData.TimeEnd |
198 | - endTimeSelf := dayZeroTime(beginTimeSelf).Add(3*24*time.Hour - time.Second) | 198 | + //修改 周期结束时间那天的第二天开始计算 |
199 | + endTimeSelf := dayZeroTime(beginTimeSelf).Add(4*24*time.Hour - time.Second) | ||
199 | //人资、360评估的时间范围 | 200 | //人资、360评估的时间范围 |
200 | beginTime360 := endTimeSelf | 201 | beginTime360 := endTimeSelf |
201 | endTime360 := endTimeSelf.Add(2 * 24 * time.Hour) | 202 | endTime360 := endTimeSelf.Add(2 * 24 * time.Hour) |
@@ -42,4 +42,5 @@ type StaffAssessTaskRepository interface { | @@ -42,4 +42,5 @@ type StaffAssessTaskRepository interface { | ||
42 | FindOne(queryOptions map[string]interface{}) (*StaffAssessTask, error) | 42 | FindOne(queryOptions map[string]interface{}) (*StaffAssessTask, error) |
43 | Find(queryOptions map[string]interface{}) (int, []*StaffAssessTask, error) | 43 | Find(queryOptions map[string]interface{}) (int, []*StaffAssessTask, error) |
44 | RemoveByProjectId(id int) error | 44 | RemoveByProjectId(id int) error |
45 | + RemoveByCycleId(id int) error | ||
45 | } | 46 | } |
@@ -68,6 +68,7 @@ type SummaryEvaluationRepository interface { | @@ -68,6 +68,7 @@ type SummaryEvaluationRepository interface { | ||
68 | FindOne(queryOptions map[string]interface{}) (*SummaryEvaluation, error) | 68 | FindOne(queryOptions map[string]interface{}) (*SummaryEvaluation, error) |
69 | Find(queryOptions map[string]interface{}) (int, []*SummaryEvaluation, error) | 69 | Find(queryOptions map[string]interface{}) (int, []*SummaryEvaluation, error) |
70 | RemoveByProjectId(id int) error | 70 | RemoveByProjectId(id int) error |
71 | + RemoveByCycleId(id int64) error | ||
71 | } | 72 | } |
72 | 73 | ||
73 | // 计算总分。TotalScore 保留1位小数 | 74 | // 计算总分。TotalScore 保留1位小数 |
@@ -125,6 +125,7 @@ and staff_assess.evaluation_project_id in ( | @@ -125,6 +125,7 @@ and staff_assess.evaluation_project_id in ( | ||
125 | // hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否 (必填) | 125 | // hrbp 是否搜索HRBP角色的用户可以查看,1:是;-1:否 (必填) |
126 | func (d *StaffAssessDao) catchProjectIdByPermission(companyId int, cycleId int, operaterId int, hrbp int) string { | 126 | func (d *StaffAssessDao) catchProjectIdByPermission(companyId int, cycleId int, operaterId int, hrbp int) string { |
127 | withSql := ` | 127 | withSql := ` |
128 | + set time zone 'PRC'; | ||
128 | with | 129 | with |
129 | t_project_0 as( | 130 | t_project_0 as( |
130 | select evaluation_project.id as project_id, | 131 | select evaluation_project.id as project_id, |
@@ -153,3 +153,13 @@ func (repo *StaffAssessTaskRepository) RemoveByProjectId(id int) error { | @@ -153,3 +153,13 @@ func (repo *StaffAssessTaskRepository) RemoveByProjectId(id int) error { | ||
153 | Update() | 153 | Update() |
154 | return err | 154 | return err |
155 | } | 155 | } |
156 | + | ||
157 | +func (repo *StaffAssessTaskRepository) RemoveByCycleId(id int) error { | ||
158 | + tx := repo.transactionContext.PgTx | ||
159 | + nowTime := time.Now() | ||
160 | + _, err := tx.Model(&models.StaffAssessTask{}). | ||
161 | + Where("cycle_id=?", id). | ||
162 | + Set("deleted_at=?", nowTime). | ||
163 | + Update() | ||
164 | + return err | ||
165 | +} |
@@ -197,3 +197,13 @@ func (repo *SummaryEvaluationRepository) RemoveByProjectId(id int) error { | @@ -197,3 +197,13 @@ func (repo *SummaryEvaluationRepository) RemoveByProjectId(id int) error { | ||
197 | Update() | 197 | Update() |
198 | return err | 198 | return err |
199 | } | 199 | } |
200 | + | ||
201 | +func (repo *SummaryEvaluationRepository) RemoveByCycleId(id int64) error { | ||
202 | + tx := repo.transactionContext.PgTx | ||
203 | + nowTime := time.Now() | ||
204 | + _, err := tx.Model(&models.SummaryEvaluation{}). | ||
205 | + Where("cycle_id=?", id). | ||
206 | + Set("deleted_at=?", nowTime). | ||
207 | + Update() | ||
208 | + return err | ||
209 | +} |
sql/2023-04-03.sql
0 → 100644
-
请 注册 或 登录 后发表评论