Merge remote-tracking branch 'origin/1.2.4' into 1.2.4
正在显示
6 个修改的文件
包含
205 行增加
和
92 行删除
@@ -17,6 +17,7 @@ import ( | @@ -17,6 +17,7 @@ import ( | ||
17 | func main() { | 17 | func main() { |
18 | startNodeTask() | 18 | startNodeTask() |
19 | startSummaryEvaluation() | 19 | startSummaryEvaluation() |
20 | + startConfirmEvaluationScore() | ||
20 | go notify.RunTaskSmsNotify() | 21 | go notify.RunTaskSmsNotify() |
21 | go consumer.Run() | 22 | go consumer.Run() |
22 | web.Run() | 23 | web.Run() |
@@ -63,3 +64,23 @@ func startSummaryEvaluation() { | @@ -63,3 +64,23 @@ func startSummaryEvaluation() { | ||
63 | } | 64 | } |
64 | }() | 65 | }() |
65 | } | 66 | } |
67 | + | ||
68 | +// 定时自动确认周期评估考核结果 | ||
69 | +func startConfirmEvaluationScore() { | ||
70 | + go func() { | ||
71 | + var duration time.Duration | ||
72 | + if constant.Env == "prd" { | ||
73 | + duration = time.Minute * 5 | ||
74 | + } else { | ||
75 | + duration = time.Minute * 1 | ||
76 | + } | ||
77 | + timer := time.NewTimer(duration) | ||
78 | + for { | ||
79 | + <-timer.C | ||
80 | + if err := serviceSummary.TaskConfirmScore(); err != nil { | ||
81 | + log.Logger.Error(err.Error()) | ||
82 | + } | ||
83 | + timer.Reset(duration) // 重置定时 | ||
84 | + } | ||
85 | + }() | ||
86 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "strconv" | ||
6 | + "time" | ||
7 | + | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | ||
13 | +) | ||
14 | + | ||
15 | +// 定时自动确认周期评估考核结果 | ||
16 | +func TaskConfirmScore() error { | ||
17 | + nowTime := time.Now() | ||
18 | + defer func() { | ||
19 | + str := fmt.Sprintf("自动确认周期评估考核结果耗时%.2f s", time.Since(nowTime).Seconds()) | ||
20 | + log.Logger.Info(str) | ||
21 | + }() | ||
22 | + | ||
23 | + evaluationList, err := catchEvaluation() | ||
24 | + if err != nil { | ||
25 | + log.Logger.Error(fmt.Sprintf("获取周期考核结果%s", err.Error())) | ||
26 | + } | ||
27 | + if len(evaluationList) == 0 { | ||
28 | + return nil | ||
29 | + } | ||
30 | + evluationSrv := NewSummaryEvaluationService() | ||
31 | + for _, val := range evaluationList { | ||
32 | + permissionData, err := getPermission(val.CompanyId) | ||
33 | + if err != nil { | ||
34 | + log.Logger.Error(fmt.Sprintf("获取公司的权限配置失败%s", err.Error())) | ||
35 | + } | ||
36 | + if permissionData.OptConfirmPerf != domain.PermissionOn { | ||
37 | + continue | ||
38 | + } | ||
39 | + | ||
40 | + targetUserId, err := strconv.Atoi(val.TargetUserId) | ||
41 | + if err != nil { | ||
42 | + log.Logger.Error(fmt.Sprintf("获取员工id%s", err)) | ||
43 | + continue | ||
44 | + } | ||
45 | + err = evluationSrv.ConfirmScoreEvaluation(&command.ConfirmScore{ | ||
46 | + SummaryEvaluationId: val.SummaryEvaluationId, | ||
47 | + UserId: targetUserId, | ||
48 | + }) | ||
49 | + if err != nil { | ||
50 | + log.Logger.Error(fmt.Sprintf("确认周期考核结果%s", err.Error())) | ||
51 | + } | ||
52 | + } | ||
53 | + return nil | ||
54 | +} | ||
55 | + | ||
56 | +func catchEvaluation() ([]dao.SummaryEvaluationData1, error) { | ||
57 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
58 | + if err != nil { | ||
59 | + return nil, err | ||
60 | + } | ||
61 | + if err := transactionContext.StartTransaction(); err != nil { | ||
62 | + return nil, err | ||
63 | + } | ||
64 | + defer func() { | ||
65 | + _ = transactionContext.RollbackTransaction() | ||
66 | + }() | ||
67 | + evaluationDao := dao.NewSummaryEvaluationDao(map[string]interface{}{ | ||
68 | + "transactionContext": transactionContext, | ||
69 | + }) | ||
70 | + evaluationList, err := evaluationDao.ListEvaluationFinishNoResult() | ||
71 | + if err != nil { | ||
72 | + return nil, fmt.Errorf("获取综合评估数据%s", err) | ||
73 | + } | ||
74 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
75 | + return nil, err | ||
76 | + } | ||
77 | + return evaluationList, nil | ||
78 | +} |
@@ -35,6 +35,12 @@ func TaskSendSummaryEvaluationV2() error { | @@ -35,6 +35,12 @@ func TaskSendSummaryEvaluationV2() error { | ||
35 | return nil | 35 | return nil |
36 | } | 36 | } |
37 | 37 | ||
38 | +func dayEndTime(t time.Time) time.Time { | ||
39 | + y, m, d := t.Local().Date() | ||
40 | + t2 := time.Date(y, m, d, 23, 59, 59, 0, time.Local) | ||
41 | + return t2 | ||
42 | +} | ||
43 | + | ||
38 | // 获取周期 | 44 | // 获取周期 |
39 | func getPrepareEvaluationCycle() ([]*domain.EvaluationCycle, error) { | 45 | func getPrepareEvaluationCycle() ([]*domain.EvaluationCycle, error) { |
40 | transactionContext, err := factory.CreateTransactionContext(nil) | 46 | transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -58,37 +64,6 @@ func getPrepareEvaluationCycle() ([]*domain.EvaluationCycle, error) { | @@ -58,37 +64,6 @@ func getPrepareEvaluationCycle() ([]*domain.EvaluationCycle, error) { | ||
58 | return cycleList, nil | 64 | return cycleList, nil |
59 | } | 65 | } |
60 | 66 | ||
61 | -// 获取可用的项目 | ||
62 | -// func getPrepareSummaryEvaluation(cycleId int) ([]*domain.EvaluationProject, error) { | ||
63 | -// transactionContext, err := factory.CreateTransactionContext(nil) | ||
64 | -// if err != nil { | ||
65 | -// return nil, err | ||
66 | -// } | ||
67 | -// if err := transactionContext.StartTransaction(); err != nil { | ||
68 | -// return nil, err | ||
69 | -// } | ||
70 | -// defer func() { | ||
71 | -// _ = transactionContext.RollbackTransaction() | ||
72 | -// }() | ||
73 | -// projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{ | ||
74 | -// "transactionContext": transactionContext, | ||
75 | -// }) | ||
76 | -// // 获取项目数据总数 | ||
77 | -// _, projectList, err := projectRepo.Find(map[string]interface{}{ | ||
78 | -// "cycleId": cycleId, | ||
79 | -// "summaryState": domain.ProjectSummaryStateNo, | ||
80 | -// "state": domain.ProjectStateEnable, | ||
81 | -// "limit": 200, | ||
82 | -// }, "template") | ||
83 | -// if err != nil { | ||
84 | -// return nil, fmt.Errorf("获取可用的项目数据,%s", err) | ||
85 | -// } | ||
86 | -// if err := transactionContext.CommitTransaction(); err != nil { | ||
87 | -// return nil, err | ||
88 | -// } | ||
89 | -// return projectList, nil | ||
90 | -// } | ||
91 | - | ||
92 | // 按周期下发 综合评估任务 | 67 | // 按周期下发 综合评估任务 |
93 | func sendSummaryEvaluationByCycle(cycleParam *domain.EvaluationCycle) error { | 68 | func sendSummaryEvaluationByCycle(cycleParam *domain.EvaluationCycle) error { |
94 | transactionContext, err := factory.CreateTransactionContext(nil) | 69 | transactionContext, err := factory.CreateTransactionContext(nil) |
@@ -115,10 +90,14 @@ func sendSummaryEvaluationByCycle(cycleParam *domain.EvaluationCycle) error { | @@ -115,10 +90,14 @@ func sendSummaryEvaluationByCycle(cycleParam *domain.EvaluationCycle) error { | ||
115 | if err != nil { | 90 | if err != nil { |
116 | return fmt.Errorf("获取可用的项目数据,%s", err) | 91 | return fmt.Errorf("获取可用的项目数据,%s", err) |
117 | } | 92 | } |
93 | + permissionData, err := getPermission(cycleParam.CompanyId) | ||
94 | + if err != nil { | ||
95 | + return fmt.Errorf("获取公司的周期评估设置项,%s", err) | ||
96 | + } | ||
118 | var newEvaluationList []domain.SummaryEvaluation | 97 | var newEvaluationList []domain.SummaryEvaluation |
119 | newPublisher := summaryEvaluationPublisher{} | 98 | newPublisher := summaryEvaluationPublisher{} |
120 | for _, val := range projectList { | 99 | for _, val := range projectList { |
121 | - evaluationList, err := newPublisher.sendSummaryEvaluationV2(transactionContext, val, cycleParam) | 100 | + evaluationList, err := newPublisher.sendSummaryEvaluationV2(transactionContext, val, cycleParam, *permissionData) |
122 | if err != nil { | 101 | if err != nil { |
123 | return fmt.Errorf("按项目下发综合评估任务数据,%s", err) | 102 | return fmt.Errorf("按项目下发综合评估任务数据,%s", err) |
124 | } | 103 | } |
@@ -148,18 +127,10 @@ type summaryEvaluationPublisher struct { | @@ -148,18 +127,10 @@ type summaryEvaluationPublisher struct { | ||
148 | 127 | ||
149 | func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | 128 | func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( |
150 | transactionContext application.TransactionContext, | 129 | transactionContext application.TransactionContext, |
151 | - projectParam *domain.EvaluationProject, cycleData *domain.EvaluationCycle, | 130 | + projectParam *domain.EvaluationProject, |
131 | + cycleData *domain.EvaluationCycle, | ||
132 | + permissioData domain.Permission, | ||
152 | ) ([]domain.SummaryEvaluation, error) { | 133 | ) ([]domain.SummaryEvaluation, error) { |
153 | - // transactionContext, err := factory.CreateTransactionContext(nil) | ||
154 | - // if err != nil { | ||
155 | - // return err | ||
156 | - // } | ||
157 | - // if err := transactionContext.StartTransaction(); err != nil { | ||
158 | - // return err | ||
159 | - // } | ||
160 | - // defer func() { | ||
161 | - // _ = transactionContext.RollbackTransaction() | ||
162 | - // }() | ||
163 | userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | 134 | userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) |
164 | departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext}) | 135 | departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext}) |
165 | evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) | 136 | evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) |
@@ -193,16 +164,31 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | @@ -193,16 +164,31 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | ||
193 | if cycleData.TimeEnd == nil { | 164 | if cycleData.TimeEnd == nil { |
194 | return nil, fmt.Errorf("周期%d:%s 结束时间错误", cycleData.Id, cycleData.Name) | 165 | return nil, fmt.Errorf("周期%d:%s 结束时间错误", cycleData.Id, cycleData.Name) |
195 | } | 166 | } |
167 | + | ||
196 | //自评的时间范围 | 168 | //自评的时间范围 |
197 | - beginTimeSelf := *cycleData.TimeEnd | 169 | + beginTimeSelf := *cycleData.TimeEnd // |
170 | + beginDay := dayEndTime(beginTimeSelf) | ||
198 | //修改 周期结束时间那天的第二天开始计算 | 171 | //修改 周期结束时间那天的第二天开始计算 |
199 | - endTimeSelf := dayZeroTime(beginTimeSelf).Add(4*24*time.Hour - time.Second) | 172 | + endTimeSelf := beginDay.Add(time.Duration(permissioData.CycleDeadLine.AssessmentSelf.Hour) * time.Hour). |
173 | + Add(time.Duration(permissioData.CycleDeadLine.AssessmentSelf.Minute) * time.Minute) | ||
200 | //人资、360评估的时间范围 | 174 | //人资、360评估的时间范围 |
201 | beginTime360 := endTimeSelf | 175 | beginTime360 := endTimeSelf |
202 | - endTime360 := endTimeSelf.Add(2 * 24 * time.Hour) | 176 | + endTime360 := beginDay.Add(time.Duration(permissioData.CycleDeadLine.AssessmentAll.Hour) * time.Hour). |
177 | + Add(time.Duration(permissioData.CycleDeadLine.AssessmentAll.Minute) * time.Minute) | ||
178 | + //人资评估的时间范围 | ||
179 | + beginTimeHr := endTimeSelf | ||
180 | + endTimeHr := beginDay.Add(time.Duration(permissioData.CycleDeadLine.AssessmentHr.Hour) * time.Hour). | ||
181 | + Add(time.Duration(permissioData.CycleDeadLine.AssessmentHr.Minute) * time.Minute) | ||
182 | + | ||
203 | //上级评估的是时间范围 | 183 | //上级评估的是时间范围 |
204 | - beginTimeSuper := endTime360 | ||
205 | - endTimeSuper := endTime360.Add(2 * 24 * time.Hour) | 184 | + beginTimeSuper := endTimeHr |
185 | + endTimeSuper := beginDay.Add(time.Duration(permissioData.CycleDeadLine.AssessmentSuperior.Hour) * time.Hour). | ||
186 | + Add(time.Duration(permissioData.CycleDeadLine.AssessmentSuperior.Minute) * time.Minute) | ||
187 | + | ||
188 | + //考核结果的时间范围 | ||
189 | + beginTimeFinish := endTimeSuper | ||
190 | + endTimeFinish := beginDay.Add(time.Duration(permissioData.CycleDeadLine.ViewMyPerf.Hour) * time.Hour). | ||
191 | + Add(time.Duration(permissioData.CycleDeadLine.ViewMyPerf.Minute) * time.Minute) | ||
206 | // 创建周期评估任务 | 192 | // 创建周期评估任务 |
207 | var newEvaluationList []domain.SummaryEvaluation | 193 | var newEvaluationList []domain.SummaryEvaluation |
208 | evaluationTemp := domain.SummaryEvaluation{ | 194 | evaluationTemp := domain.SummaryEvaluation{ |
@@ -287,8 +273,8 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | @@ -287,8 +273,8 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | ||
287 | { | 273 | { |
288 | if hrbpExist { | 274 | if hrbpExist { |
289 | //处理人资评估 | 275 | //处理人资评估 |
290 | - evaluationTemp.BeginTime = beginTime360 | ||
291 | - evaluationTemp.EndTime = endTime360 | 276 | + evaluationTemp.BeginTime = beginTimeHr |
277 | + evaluationTemp.EndTime = endTimeHr | ||
292 | evaluationTemp.Executor = domain.StaffDesc{} | 278 | evaluationTemp.Executor = domain.StaffDesc{} |
293 | evaluationTemp.Types = domain.EvaluationHrbp | 279 | evaluationTemp.Types = domain.EvaluationHrbp |
294 | newEvaluationList = append(newEvaluationList, evaluationTemp) | 280 | newEvaluationList = append(newEvaluationList, evaluationTemp) |
@@ -314,8 +300,8 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | @@ -314,8 +300,8 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | ||
314 | { | 300 | { |
315 | evaluationTemp.Types = domain.EvaluationFinish | 301 | evaluationTemp.Types = domain.EvaluationFinish |
316 | evaluationTemp.Executor = domain.StaffDesc{} | 302 | evaluationTemp.Executor = domain.StaffDesc{} |
317 | - evaluationTemp.BeginTime = endTimeSuper | ||
318 | - evaluationTemp.EndTime = endTimeSuper.Add(2 * 24 * time.Hour) | 303 | + evaluationTemp.BeginTime = beginTimeFinish |
304 | + evaluationTemp.EndTime = endTimeFinish | ||
319 | newEvaluationList = append(newEvaluationList, evaluationTemp) | 305 | newEvaluationList = append(newEvaluationList, evaluationTemp) |
320 | } | 306 | } |
321 | } | 307 | } |
@@ -332,30 +318,9 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | @@ -332,30 +318,9 @@ func (se *summaryEvaluationPublisher) sendSummaryEvaluationV2( | ||
332 | if err != nil { | 318 | if err != nil { |
333 | return nil, fmt.Errorf("保存项目状态%s", err) | 319 | return nil, fmt.Errorf("保存项目状态%s", err) |
334 | } | 320 | } |
335 | - // if err := transactionContext.CommitTransaction(); err != nil { | ||
336 | - // return err | ||
337 | - // } | ||
338 | return newEvaluationList, nil | 321 | return newEvaluationList, nil |
339 | } | 322 | } |
340 | 323 | ||
341 | -// 获取周期设置数据 | ||
342 | -// func (se *summaryEvaluationPublisher) getCycleData(cycleRepo domain.EvaluationCycleRepository, cycleId int64) (*domain.EvaluationCycle, error) { | ||
343 | -// var cycleData *domain.EvaluationCycle | ||
344 | -// if val, ok := se.cycleCache[cycleId]; ok { | ||
345 | -// cycleData = val | ||
346 | -// } else { | ||
347 | -// _, cycleList, err := cycleRepo.Find(map[string]interface{}{"id": cycleId}) | ||
348 | -// if err != nil { | ||
349 | -// return nil, err | ||
350 | -// } | ||
351 | -// if len(cycleList) == 0 { | ||
352 | -// return nil, nil | ||
353 | -// } | ||
354 | -// cycleData = cycleList[0] | ||
355 | -// } | ||
356 | -// return cycleData, nil | ||
357 | -// } | ||
358 | - | ||
359 | // 获取用户数据 | 324 | // 获取用户数据 |
360 | func (se *summaryEvaluationPublisher) getUserData(userRepo domain.UserRepository, userId int64) (*domain.User, error) { | 325 | func (se *summaryEvaluationPublisher) getUserData(userRepo domain.UserRepository, userId int64) (*domain.User, error) { |
361 | if userId == 0 { | 326 | if userId == 0 { |
@@ -1015,11 +1015,15 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval | @@ -1015,11 +1015,15 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval | ||
1015 | itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{ | 1015 | itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{ |
1016 | "transactionContext": transactionContext, | 1016 | "transactionContext": transactionContext, |
1017 | }) | 1017 | }) |
1018 | - permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext}) | 1018 | + // permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext}) |
1019 | // 获取权限配置 | 1019 | // 获取权限配置 |
1020 | - _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": param.CompanyId}) | 1020 | + // _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": param.CompanyId}) |
1021 | + // if err != nil { | ||
1022 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1023 | + // } | ||
1024 | + permissinData, err := getPermission(int64(param.CompanyId)) | ||
1021 | if err != nil { | 1025 | if err != nil { |
1022 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1026 | + return nil, err |
1023 | } | 1027 | } |
1024 | evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{ | 1028 | evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{ |
1025 | "id": param.SummaryEvaluationId, | 1029 | "id": param.SummaryEvaluationId, |
@@ -1078,15 +1082,13 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval | @@ -1078,15 +1082,13 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval | ||
1078 | //组合 评估填写的值和评估项 | 1082 | //组合 评估填写的值和评估项 |
1079 | itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues) | 1083 | itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues) |
1080 | for i, v := range itemValuesAdapter { | 1084 | for i, v := range itemValuesAdapter { |
1081 | - if len(permissionList) > 0 { | ||
1082 | - if permissionList[0].OptEvalScore == domain.PermissionOff && | ||
1083 | - v.EvaluatorId > 0 { | ||
1084 | - itemValuesAdapter[i].ForbidEdit = true | ||
1085 | - } | ||
1086 | - if permissionList[0].OptHrScore == domain.PermissionOff && | ||
1087 | - v.EvaluatorId < 0 { | ||
1088 | - itemValuesAdapter[i].ForbidEdit = true | ||
1089 | - } | 1085 | + if permissinData.OptEvalScore == domain.PermissionOff && |
1086 | + v.EvaluatorId > 0 { | ||
1087 | + itemValuesAdapter[i].ForbidEdit = true | ||
1088 | + } | ||
1089 | + if permissinData.OptHrScore == domain.PermissionOff && | ||
1090 | + v.EvaluatorId < 0 { | ||
1091 | + itemValuesAdapter[i].ForbidEdit = true | ||
1090 | } | 1092 | } |
1091 | } | 1093 | } |
1092 | result := adapter.EvaluationInfoSuperAdapter{ | 1094 | result := adapter.EvaluationInfoSuperAdapter{ |
@@ -1214,16 +1216,19 @@ func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionC | @@ -1214,16 +1216,19 @@ func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionC | ||
1214 | "transactionContext": transactionContext, | 1216 | "transactionContext": transactionContext, |
1215 | }) | 1217 | }) |
1216 | 1218 | ||
1217 | - permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
1218 | - // 获取权限配置 | ||
1219 | - _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": evaluationData.CompanyId}) | 1219 | + // permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext}) |
1220 | + // // 获取权限配置 | ||
1221 | + // _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": evaluationData.CompanyId}) | ||
1222 | + // if err != nil { | ||
1223 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1224 | + // } | ||
1225 | + // if len(permissionList) == 0 { | ||
1226 | + // return nil, nil | ||
1227 | + // } | ||
1228 | + permissionData, err := getPermission(int64(evaluationData.CompanyId)) | ||
1220 | if err != nil { | 1229 | if err != nil { |
1221 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1230 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1222 | } | 1231 | } |
1223 | - if len(permissionList) == 0 { | ||
1224 | - return nil, nil | ||
1225 | - } | ||
1226 | - permissionData := permissionList[0] | ||
1227 | if permissionData.OptEvalScore == domain.PermissionOn && permissionData.OptHrScore == domain.PermissionOn { | 1232 | if permissionData.OptEvalScore == domain.PermissionOn && permissionData.OptHrScore == domain.PermissionOn { |
1228 | return nil, nil | 1233 | return nil, nil |
1229 | } | 1234 | } |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + permissionSrv "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission" | ||
5 | + permissionCmd "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/permission/command" | ||
6 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
7 | +) | ||
8 | + | ||
9 | +func getPermission(companyId int64) (*domain.Permission, error) { | ||
10 | + srv := &permissionSrv.PermissionService{} | ||
11 | + permissionData, err := srv.Get(&permissionCmd.GetPermissionCommand{ | ||
12 | + CompanyId: companyId, | ||
13 | + }) | ||
14 | + if err != nil { | ||
15 | + return nil, err | ||
16 | + } | ||
17 | + return permissionData, nil | ||
18 | +} |
@@ -151,3 +151,29 @@ func (d *SummaryEvaluationDao) UpdateBeginTime(ids []int, beginTime time.Time) e | @@ -151,3 +151,29 @@ func (d *SummaryEvaluationDao) UpdateBeginTime(ids []int, beginTime time.Time) e | ||
151 | _, err := tx.Exec(sqlStr, condition...) | 151 | _, err := tx.Exec(sqlStr, condition...) |
152 | return err | 152 | return err |
153 | } | 153 | } |
154 | + | ||
155 | +type SummaryEvaluationData1 struct { | ||
156 | + SummaryEvaluationId int `pg:"summary_evaluation_id"` | ||
157 | + TargetUserId string `pg:"target_user_id"` | ||
158 | + CompanyId int64 `pg:"company_id"` | ||
159 | +} | ||
160 | + | ||
161 | +// 查询周期考核结果 | ||
162 | +// 条件:已过截止时间,并且还没确认周期考核结果 | ||
163 | +func (d *SummaryEvaluationDao) ListEvaluationFinishNoResult() ([]SummaryEvaluationData1, error) { | ||
164 | + sqlStr := `select | ||
165 | + summary_evaluation.id as summary_evaluation_id, | ||
166 | + summary_evaluation.target_user ->>'userName' as target_user_name, | ||
167 | + summary_evaluation.company_id | ||
168 | + from summary_evaluation | ||
169 | + where 1=1 | ||
170 | + and summary_evaluation."types" = 5 | ||
171 | + and summary_evaluation.status ='completed' | ||
172 | + and summary_evaluation.check_result ='uncompleted' | ||
173 | + and summary_evaluation.end_time <=now() | ||
174 | + ` | ||
175 | + result := []SummaryEvaluationData1{} | ||
176 | + tx := d.transactionContext.PgTx | ||
177 | + _, err := tx.Query(&result, sqlStr) | ||
178 | + return result, err | ||
179 | +} |
-
请 注册 或 登录 后发表评论