正在显示
5 个修改的文件
包含
465 行增加
和
498 行删除
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "time" | ||
5 | + | ||
6 | + "github.com/linmadan/egglib-go/core/application" | ||
7 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory" | ||
8 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/notify" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter" | ||
10 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" | ||
12 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/xredis" | ||
13 | + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log" | ||
14 | +) | ||
15 | + | ||
16 | +//编辑上级周期评估 | ||
17 | + | ||
18 | +// EditEvaluationSuper 更新上级评估内容 | ||
19 | +func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEvaluationValue) (interface{}, error) { | ||
20 | + // lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId) | ||
21 | + // err := lock.Lock() | ||
22 | + // if err != nil { | ||
23 | + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容") | ||
24 | + // } | ||
25 | + // defer func() { | ||
26 | + // lock.UnLock() | ||
27 | + // }() | ||
28 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
29 | + if err != nil { | ||
30 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
31 | + } | ||
32 | + if err := transactionContext.StartTransaction(); err != nil { | ||
33 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
34 | + } | ||
35 | + defer func() { | ||
36 | + _ = transactionContext.RollbackTransaction() | ||
37 | + }() | ||
38 | + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ | ||
39 | + "transactionContext": transactionContext, | ||
40 | + }) | ||
41 | + itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{ | ||
42 | + "transactionContext": transactionContext, | ||
43 | + }) | ||
44 | + | ||
45 | + itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{ | ||
46 | + "transactionContext": transactionContext, | ||
47 | + }) | ||
48 | + evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{ | ||
49 | + "id": param.SummaryEvaluationId, | ||
50 | + }) | ||
51 | + if err != nil { | ||
52 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
53 | + } | ||
54 | + if evaluationData.Types != domain.EvaluationSuper { | ||
55 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") | ||
56 | + } | ||
57 | + | ||
58 | + if evaluationData.Executor.UserId != param.ExecutorId { | ||
59 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") | ||
60 | + } | ||
61 | + | ||
62 | + if evaluationData.CompanyId != param.CompanyId { | ||
63 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") | ||
64 | + } | ||
65 | + //按照被评估人id ,加锁 | ||
66 | + lock := xredis.NewLockSummaryEvaluation(evaluationData.TargetUser.UserId) | ||
67 | + err = lock.Lock() | ||
68 | + if err != nil { | ||
69 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容") | ||
70 | + } | ||
71 | + defer func() { | ||
72 | + lock.UnLock() | ||
73 | + }() | ||
74 | + _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ | ||
75 | + "targetUserId": evaluationData.TargetUser.UserId, | ||
76 | + "typesList": []int{int(domain.EvaluationFinish)}, | ||
77 | + "cycleId": evaluationData.CycleId, | ||
78 | + "limit": 1, | ||
79 | + }) | ||
80 | + if err != nil { | ||
81 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
82 | + } | ||
83 | + // 如果目标员工已经确认考核结果,就不能在进行评估编辑 | ||
84 | + if len(evaluationList) > 0 && evaluationList[0].CheckResult == domain.EvaluationCheckCompleted { | ||
85 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户已经确认该周期的考核结果,不能再编辑!") | ||
86 | + } | ||
87 | + | ||
88 | + _, itemList, err := itemUsedRepo.Find(map[string]interface{}{ | ||
89 | + "evaluationProjectId": evaluationData.EvaluationProjectId, | ||
90 | + "nodeType": domain.LinkNodeSelfAssessment, | ||
91 | + }) | ||
92 | + if err != nil { | ||
93 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
94 | + } | ||
95 | + //获取已填写的评估内容 | ||
96 | + _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{ | ||
97 | + "summaryEvaluationId": evaluationData.Id, | ||
98 | + }) | ||
99 | + if err != nil { | ||
100 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
101 | + } | ||
102 | + //记录人资评估或者360评估的 填写项id | ||
103 | + hrbpOr360ItemValue, err := srv.getEvaluationSuperDefaultValue(transactionContext, evaluationData) | ||
104 | + if err != nil { | ||
105 | + return nil, err | ||
106 | + } | ||
107 | + | ||
108 | + err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, hrbpOr360ItemValue, param.IsTemporary) | ||
109 | + if err != nil { | ||
110 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
111 | + } | ||
112 | + if !param.IsTemporary { | ||
113 | + //变更评估状态为已填写 | ||
114 | + evaluationData.Status = domain.EvaluationCompleted | ||
115 | + } | ||
116 | + for _, v := range itemValueList { | ||
117 | + //保存填写值 | ||
118 | + err = itemValueRepo.Save(v) | ||
119 | + if err != nil { | ||
120 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
121 | + } | ||
122 | + } | ||
123 | + //保存填写值 | ||
124 | + err = evaluationRepo.Save(evaluationData) | ||
125 | + if err != nil { | ||
126 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
127 | + } | ||
128 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
129 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
130 | + } | ||
131 | + | ||
132 | + if !param.IsTemporary { | ||
133 | + err = srv.AfterCompletedEvaluationSuper(transactionContext, evaluationData, itemValueList) | ||
134 | + if err != nil { | ||
135 | + return nil, err | ||
136 | + } | ||
137 | + } | ||
138 | + | ||
139 | + itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList) | ||
140 | + return map[string][]adapter.EvaluationItemAdapter{ | ||
141 | + "EvaluationItems": itemValueAdapter, | ||
142 | + }, nil | ||
143 | +} | ||
144 | + | ||
145 | +// 员工提交上级评估后 | ||
146 | +// 生成考核结果 | ||
147 | +func (srv *SummaryEvaluationService) AfterCompletedEvaluationSuper( | ||
148 | + transactionContext application.TransactionContext, | ||
149 | + evaluationData *domain.SummaryEvaluation, | ||
150 | + evaluationValue []*domain.SummaryEvaluationValue, | ||
151 | +) error { | ||
152 | + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ | ||
153 | + "transactionContext": transactionContext, | ||
154 | + }) | ||
155 | + //没有上级评估 | ||
156 | + //直接进入考核结果阶段 | ||
157 | + _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ | ||
158 | + "targetUserId": evaluationData.TargetUser.UserId, | ||
159 | + "typesList": []int{int(domain.EvaluationFinish)}, | ||
160 | + "cycleId": evaluationData.CycleId, | ||
161 | + "limit": 1, | ||
162 | + }) | ||
163 | + if err != nil { | ||
164 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
165 | + } | ||
166 | + | ||
167 | + if len(evaluationList) > 0 { | ||
168 | + //调整考核结果的开始时间 | ||
169 | + nowTime := time.Now() | ||
170 | + if evaluationList[0].BeginTime.After(nowTime) { | ||
171 | + evaluationList[0].BeginTime = nowTime | ||
172 | + } | ||
173 | + evaluationList[0].Status = domain.EvaluationCompleted | ||
174 | + err = srv.syncEvaluationFinishValue(transactionContext, evaluationList[0], evaluationValue) | ||
175 | + if err != nil { | ||
176 | + return err | ||
177 | + } | ||
178 | + //添加确认绩效成绩提醒短信提醒 | ||
179 | + err = notify.AddNotifyConfirmEvaluationScore(evaluationList[0]) | ||
180 | + if err != nil { | ||
181 | + log.Logger.Error("添加确认绩效成绩提醒短信提醒失败:" + err.Error()) | ||
182 | + } | ||
183 | + } | ||
184 | + return nil | ||
185 | +} | ||
186 | + | ||
187 | +// 从其他评估那边同步考核结果的评估内容 | ||
188 | +// evaluationData 考核结果评估 | ||
189 | +// updateValue 更新评估项需要的值 | ||
190 | +func (srv *SummaryEvaluationService) syncEvaluationFinishValue( | ||
191 | + transactionContext application.TransactionContext, | ||
192 | + evaluationData *domain.SummaryEvaluation, | ||
193 | + updateValue []*domain.SummaryEvaluationValue, | ||
194 | +) error { | ||
195 | + if len(updateValue) == 0 { | ||
196 | + return nil | ||
197 | + } | ||
198 | + evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ | ||
199 | + "transactionContext": transactionContext, | ||
200 | + }) | ||
201 | + evaluationValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{ | ||
202 | + "transactionContext": transactionContext, | ||
203 | + }) | ||
204 | + itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{ | ||
205 | + "transactionContext": transactionContext, | ||
206 | + }) | ||
207 | + _, itemList, err := itemUsedRepo.Find(map[string]interface{}{ | ||
208 | + "evaluationProjectId": evaluationData.EvaluationProjectId, | ||
209 | + "nodeType": domain.LinkNodeSelfAssessment, | ||
210 | + }) | ||
211 | + if err != nil { | ||
212 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
213 | + } | ||
214 | + | ||
215 | + //填写项的map EvaluationItemId =>SummaryEvaluationValue | ||
216 | + oldEvaluationValue := map[int]*domain.SummaryEvaluationValue{} | ||
217 | + //查询已有的考核结果评估内容 | ||
218 | + _, evaluationValueList, err := evaluationValueRepo.Find(map[string]interface{}{"summaryEvaluationId": evaluationData.Id}) | ||
219 | + if err != nil { | ||
220 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
221 | + } | ||
222 | + for i, val := range evaluationValueList { | ||
223 | + oldEvaluationValue[val.EvaluationItemId] = evaluationValueList[i] | ||
224 | + } | ||
225 | + // 待更新的评估填写项map EvaluationItemId =>SummaryEvaluationValue | ||
226 | + updateValueMap := map[int]*domain.SummaryEvaluationValue{} | ||
227 | + for i, val := range updateValue { | ||
228 | + updateValueMap[val.EvaluationItemId] = updateValue[i] | ||
229 | + } | ||
230 | + | ||
231 | + //更新考核结果 | ||
232 | + for _, val := range itemList { | ||
233 | + oldValue, ok := oldEvaluationValue[val.Id] | ||
234 | + if !ok { | ||
235 | + //补全考核结果中可能缺失的评估项 | ||
236 | + newValue := &domain.SummaryEvaluationValue{} | ||
237 | + newValue.SetBlankValue(evaluationData, val) | ||
238 | + oldEvaluationValue[val.Id] = newValue | ||
239 | + oldValue = oldEvaluationValue[val.Id] | ||
240 | + } | ||
241 | + if item, ok := updateValueMap[val.Id]; ok { | ||
242 | + oldValue.Executor = item.Executor | ||
243 | + oldValue.Types = item.Types | ||
244 | + oldValue.Rating = item.Rating | ||
245 | + oldValue.Value = item.Value | ||
246 | + oldValue.Score = item.Score | ||
247 | + oldValue.Remark = item.Remark | ||
248 | + } | ||
249 | + } | ||
250 | + evaluationData.TotalRating = nil | ||
251 | + for i := range itemList { | ||
252 | + evaluationData.ResetTotalRating(itemList[i]) | ||
253 | + } | ||
254 | + | ||
255 | + newEvaluationValue := []*domain.SummaryEvaluationValue{} | ||
256 | + for _, val := range oldEvaluationValue { | ||
257 | + newEvaluationValue = append(newEvaluationValue, val) | ||
258 | + } | ||
259 | + | ||
260 | + evaluationData.EvaluationTotalScore(newEvaluationValue) | ||
261 | + | ||
262 | + err = evaluationRepo.Save(evaluationData) | ||
263 | + if err != nil { | ||
264 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, "同步考核结果"+err.Error()) | ||
265 | + } | ||
266 | + err = evaluationValueRepo.RemoveBySummaryEvaluationId(evaluationData.Id) | ||
267 | + if err != nil { | ||
268 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, "同步考核结果"+err.Error()) | ||
269 | + } | ||
270 | + for _, val := range newEvaluationValue { | ||
271 | + val.Id = 0 | ||
272 | + err = evaluationValueRepo.Save(val) | ||
273 | + if err != nil { | ||
274 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, "同步考核结果"+err.Error()) | ||
275 | + } | ||
276 | + } | ||
277 | + return nil | ||
278 | + | ||
279 | +} |
1 | -package service | ||
2 | - | ||
3 | -// sendSummaryEvaluafionTask 根据评估项目设置,确认是否下发评估任务 | ||
4 | -// project 需要处理的项目 | ||
5 | -// userList 全体的员工数据 map[id]=>domain.User | ||
6 | -// departmetList 全部的部门数据 map[id]=>domain.Department | ||
7 | -// func sendSummaryEvaluation(project *domain.EvaluationProject, | ||
8 | -// userMap map[int64]*domain.User, departmentMap map[int64]*domain.Department) ([]domain.SummaryEvaluation, error) { | ||
9 | -// //自评的时间范围 | ||
10 | -// beginTimeSelf := project.EndTime | ||
11 | -// endTimeSelf := dayZeroTime(project.EndTime).Add(4*24*time.Hour - time.Second) | ||
12 | -// //人资、360评估的时间范围 | ||
13 | -// beginTime360 := endTimeSelf | ||
14 | -// endTime360 := endTimeSelf.Add(2 * 24 * time.Hour) | ||
15 | -// //上级评估的是时间范围 | ||
16 | -// beginTimeSuper := endTime360 | ||
17 | -// endTimeSuper := endTime360.Add(2 * 24 * time.Hour) | ||
18 | -// // | ||
19 | -// transactionContext, err := factory.CreateTransactionContext(nil) | ||
20 | -// if err != nil { | ||
21 | -// return nil, err | ||
22 | -// } | ||
23 | -// if err := transactionContext.StartTransaction(); err != nil { | ||
24 | -// return nil, err | ||
25 | -// } | ||
26 | -// defer func() { | ||
27 | -// _ = transactionContext.RollbackTransaction() | ||
28 | -// }() | ||
29 | -// cycleRepo := factory.CreateEvaluationCycleRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
30 | - | ||
31 | -// evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
32 | - | ||
33 | -// cycleData, err := cycleRepo.FindOne(map[string]interface{}{"id": project.CycleId}) | ||
34 | -// if err != nil { | ||
35 | -// return nil, err | ||
36 | -// } | ||
37 | -// //确定 被评估的人 | ||
38 | -// targetUserId := []int64{} | ||
39 | -// for _, v := range project.Recipients { | ||
40 | -// id, err := strconv.ParseInt(v, 10, 64) | ||
41 | -// if err == nil { | ||
42 | -// targetUserId = append(targetUserId, id) | ||
43 | -// } | ||
44 | -// } | ||
45 | -// if len(targetUserId) == 0 { | ||
46 | -// return nil, nil | ||
47 | -// } | ||
48 | -// //被评估的员工 | ||
49 | -// targetUserMap := map[int64]*domain.User{} | ||
50 | - | ||
51 | -// for _, v := range targetUserId { | ||
52 | -// u, ok := userMap[v] | ||
53 | -// if ok { | ||
54 | -// targetUserMap[v] = u | ||
55 | -// } | ||
56 | -// } | ||
57 | -// //确定360评估的执行人 | ||
58 | -// _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": project.Id, "nodeType": int(domain.LinkNodeSelfAssessment)}) | ||
59 | -// if err != nil { | ||
60 | -// return nil, err | ||
61 | -// } | ||
62 | -// nodeId := 0 | ||
63 | -// executor360Map := map[int64]*domain.User{} | ||
64 | -// hrbpExist := false | ||
65 | -// for _, v := range itemList { | ||
66 | -// nodeId = v.NodeId | ||
67 | -// if v.EvaluatorId < 0 { | ||
68 | -// hrbpExist = true | ||
69 | -// } | ||
70 | -// if v.EvaluatorId <= 0 { | ||
71 | -// continue | ||
72 | -// } | ||
73 | -// if u, ok := userMap[int64(v.EvaluatorId)]; ok { | ||
74 | -// executor360Map[u.Id] = u | ||
75 | -// } | ||
76 | -// } | ||
77 | -// //创建周期评估任务 | ||
78 | -// var newEvaluationList []domain.SummaryEvaluation | ||
79 | -// evaluationTemp := domain.SummaryEvaluation{ | ||
80 | -// Id: 0, | ||
81 | -// CompanyId: int(project.CompanyId), | ||
82 | -// EvaluationProjectId: int(project.Id), | ||
83 | -// EvaluationProjectName: project.Name, | ||
84 | -// CycleId: cycleData.Id, | ||
85 | -// CycleName: cycleData.Name, | ||
86 | -// NodeId: nodeId, | ||
87 | -// TargetUser: domain.StaffDesc{}, | ||
88 | -// TargetDepartment: []domain.StaffDepartment{}, | ||
89 | -// Executor: domain.StaffDesc{}, | ||
90 | -// Types: 0, | ||
91 | -// Status: domain.EvaluationUncompleted, | ||
92 | -// CheckResult: domain.EvaluationCheckUncompleted, | ||
93 | -// BeginTime: time.Time{}, | ||
94 | -// EndTime: time.Time{}, | ||
95 | -// TotalScore: "", | ||
96 | -// CreatedAt: time.Now(), | ||
97 | -// UpdatedAt: time.Now(), | ||
98 | -// DeletedAt: nil, | ||
99 | -// } | ||
100 | - | ||
101 | -// //确定周期评估 | ||
102 | - | ||
103 | -// for _, v := range targetUserMap { | ||
104 | -// //处理自评 | ||
105 | -// evaluationTemp.TargetUser = domain.StaffDesc{ | ||
106 | -// UserId: int(v.Id), | ||
107 | -// Account: v.Account, | ||
108 | -// UserName: v.Name, | ||
109 | -// } | ||
110 | -// evaluationTemp.Executor = domain.StaffDesc{ | ||
111 | -// UserId: int(v.Id), | ||
112 | -// Account: v.Account, | ||
113 | -// UserName: v.Name, | ||
114 | -// } | ||
115 | -// evaluationTemp.BeginTime = beginTimeSelf | ||
116 | -// evaluationTemp.EndTime = endTimeSelf | ||
117 | -// evaluationTemp.TargetDepartment = []domain.StaffDepartment{} | ||
118 | -// evaluationTemp.Types = domain.EvaluationSelf | ||
119 | -// for _, departId := range v.DepartmentId { | ||
120 | -// depart, ok := departmentMap[int64(departId)] | ||
121 | -// if !ok { | ||
122 | -// continue | ||
123 | -// } | ||
124 | -// evaluationTemp.TargetDepartment = append(evaluationTemp.TargetDepartment, domain.StaffDepartment{ | ||
125 | -// DepartmentId: int(depart.Id), | ||
126 | -// DepartmentName: depart.Name, | ||
127 | -// }) | ||
128 | -// } | ||
129 | -// newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
130 | -// if hrbpExist { | ||
131 | -// //处理人资评估 | ||
132 | -// evaluationTemp.BeginTime = beginTime360 | ||
133 | -// evaluationTemp.EndTime = endTime360 | ||
134 | -// evaluationTemp.Executor = domain.StaffDesc{} | ||
135 | -// evaluationTemp.Types = domain.EvaluationHrbp | ||
136 | -// newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
137 | -// } | ||
138 | -// //处理360 评估 | ||
139 | -// for _, v2 := range executor360Map { | ||
140 | -// evaluationTemp.BeginTime = beginTime360 | ||
141 | -// evaluationTemp.EndTime = endTime360 | ||
142 | -// evaluationTemp.Executor = domain.StaffDesc{ | ||
143 | -// UserId: int(v2.Id), | ||
144 | -// Account: v2.Account, | ||
145 | -// UserName: v2.Name, | ||
146 | -// } | ||
147 | -// evaluationTemp.Types = domain.Evaluation360 | ||
148 | -// newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
149 | -// } | ||
150 | - | ||
151 | -// //处理上级评估 | ||
152 | -// superUser, ok := userMap[v.ParentId] | ||
153 | -// if ok { | ||
154 | -// evaluationTemp.Types = domain.EvaluationSuper | ||
155 | -// evaluationTemp.Executor = domain.StaffDesc{ | ||
156 | -// UserId: int(superUser.Id), | ||
157 | -// Account: superUser.Account, | ||
158 | -// UserName: superUser.Name, | ||
159 | -// } | ||
160 | -// evaluationTemp.BeginTime = beginTimeSuper | ||
161 | -// evaluationTemp.EndTime = endTimeSuper | ||
162 | -// //确定上级评估 | ||
163 | -// newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
164 | -// } | ||
165 | -// // 确定 考核结果 的评估记录 | ||
166 | -// evaluationTemp.Types = domain.EvaluationFinish | ||
167 | -// evaluationTemp.Executor = domain.StaffDesc{} | ||
168 | -// evaluationTemp.BeginTime = endTimeSuper | ||
169 | -// evaluationTemp.EndTime = endTimeSuper.Add(2 * 24 * time.Hour) | ||
170 | -// newEvaluationList = append(newEvaluationList, evaluationTemp) | ||
171 | -// } | ||
172 | -// summaryEvaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
173 | -// for i := range newEvaluationList { | ||
174 | -// err = summaryEvaluationRepo.Save(&newEvaluationList[i]) | ||
175 | -// if err != nil { | ||
176 | -// return nil, err | ||
177 | -// } | ||
178 | -// } | ||
179 | -// //回填 项目的状态 | ||
180 | -// projectDao := dao.NewEvaluationProjectDao(map[string]interface{}{"transactionContext": transactionContext}) | ||
181 | -// err = projectDao.UpdateSummaryState(project.Id, domain.ProjectSummaryStateYes) | ||
182 | -// if err != nil { | ||
183 | -// return nil, err | ||
184 | -// } | ||
185 | -// if err := transactionContext.CommitTransaction(); err != nil { | ||
186 | -// return nil, err | ||
187 | -// } | ||
188 | -// return newEvaluationList, nil | ||
189 | -// } | ||
190 | - | ||
191 | -// func dayZeroTime(t time.Time) time.Time { | ||
192 | -// y, m, d := t.Local().Date() | ||
193 | -// t2 := time.Date(y, m, d, 0, 0, 0, 0, time.Local) | ||
194 | -// return t2 | ||
195 | -// } | ||
196 | - | ||
197 | -// // 下发周期评估 | ||
198 | -// func TaskSendSummaryEvaluation() error { | ||
199 | -// nowTime := time.Now() | ||
200 | -// defer func() { | ||
201 | -// str := fmt.Sprintf("下发周期评估耗时%.2f s", time.Since(nowTime).Seconds()) | ||
202 | -// log.Logger.Info(str) | ||
203 | -// }() | ||
204 | -// transactionContext, err := factory.CreateTransactionContext(nil) | ||
205 | -// if err != nil { | ||
206 | -// return err | ||
207 | -// } | ||
208 | -// if err := transactionContext.StartTransaction(); err != nil { | ||
209 | -// return err | ||
210 | -// } | ||
211 | -// defer func() { | ||
212 | -// _ = transactionContext.RollbackTransaction() | ||
213 | -// }() | ||
214 | - | ||
215 | -// projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{ | ||
216 | -// "transactionContext": transactionContext, | ||
217 | -// }) | ||
218 | - | ||
219 | -// userRepo := factory.CreateUserRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
220 | - | ||
221 | -// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{"transactionContext": transactionContext}) | ||
222 | - | ||
223 | -// _, projectList, err := projectRepo.Find(map[string]interface{}{ | ||
224 | -// "endTime": time.Now(), | ||
225 | -// "summaryState": domain.ProjectSummaryStateNo, | ||
226 | -// "state": domain.ProjectStateEnable, | ||
227 | -// }, "template") | ||
228 | -// if err != nil { | ||
229 | -// return fmt.Errorf("获取可用的项目数据,%s", err) | ||
230 | -// } | ||
231 | -// companyIdMap := map[int64]struct{}{} | ||
232 | -// for _, v := range projectList { | ||
233 | -// companyIdMap[v.CompanyId] = struct{}{} | ||
234 | -// } | ||
235 | - | ||
236 | -// var createdEvalationList []domain.SummaryEvaluation | ||
237 | - | ||
238 | -// //获取可执行的项目 | ||
239 | -// for companyId := range companyIdMap { | ||
240 | -// //获取员工数据,部门数据 | ||
241 | -// _, userList, err := userRepo.Find(map[string]interface{}{"companyId": companyId}) | ||
242 | -// if err != nil { | ||
243 | -// log.Logger.Error("TaskSendSummaryEvaluation 获取员工数据:" + err.Error()) | ||
244 | -// continue | ||
245 | -// } | ||
246 | -// _, departmentList, err := departmentRepo.Find(map[string]interface{}{"companyId": companyId}) | ||
247 | -// if err != nil { | ||
248 | -// log.Logger.Error("TaskSendSummaryEvaluation 获取部门数据:" + err.Error()) | ||
249 | -// continue | ||
250 | -// } | ||
251 | -// //转map | ||
252 | -// userMap := map[int64]*domain.User{} | ||
253 | -// for _, v := range userList { | ||
254 | -// userMap[v.Id] = v | ||
255 | -// } | ||
256 | -// departmentMap := map[int64]*domain.Department{} | ||
257 | -// for _, v := range departmentList { | ||
258 | -// departmentMap[v.Id] = v | ||
259 | -// } | ||
260 | -// for _, v := range projectList { | ||
261 | -// if v.CompanyId != companyId { | ||
262 | -// continue | ||
263 | -// } | ||
264 | -// evalationList, err := sendSummaryEvaluation(v, userMap, departmentMap) | ||
265 | -// if err != nil { | ||
266 | -// log.Logger.Error("TaskSendSummaryEvaluation 下发评估任务:" + err.Error()) | ||
267 | -// continue | ||
268 | -// } | ||
269 | -// createdEvalationList = append(createdEvalationList, evalationList...) | ||
270 | -// } | ||
271 | -// } | ||
272 | -// if err := transactionContext.CommitTransaction(); err != nil { | ||
273 | -// return err | ||
274 | -// } | ||
275 | -// //添加待发送的短信通知 | ||
276 | -// err = sendSmsEvalation(createdEvalationList) | ||
277 | -// return err | ||
278 | -// } |
@@ -786,68 +786,70 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma | @@ -786,68 +786,70 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluation360Hrbp(param *doma | ||
786 | return nil | 786 | return nil |
787 | } | 787 | } |
788 | 788 | ||
789 | -// 员工提交上级评估后 | ||
790 | -// 生成考核结果 | ||
791 | -func (srv *SummaryEvaluationService) AfterCompletedEvaluationSuper(param *domain.SummaryEvaluation) error { | ||
792 | - lock := xredis.NewLockSummaryEvaluation(param.TargetUser.UserId) | ||
793 | - err := lock.Lock() | ||
794 | - if err != nil { | ||
795 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容") | ||
796 | - } | ||
797 | - defer func() { | ||
798 | - lock.UnLock() | ||
799 | - }() | ||
800 | - transactionContext, err := factory.CreateTransactionContext(nil) | ||
801 | - if err != nil { | ||
802 | - return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
803 | - } | ||
804 | - if err := transactionContext.StartTransaction(); err != nil { | ||
805 | - return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
806 | - } | ||
807 | - defer func() { | ||
808 | - _ = transactionContext.RollbackTransaction() | ||
809 | - }() | ||
810 | - | ||
811 | - evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ | ||
812 | - "transactionContext": transactionContext, | ||
813 | - }) | ||
814 | - //没有上级评估 | ||
815 | - //直接进入考核结果阶段 | ||
816 | - _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ | ||
817 | - "targetUserId": param.TargetUser.UserId, | ||
818 | - "typesList": []int{int(domain.EvaluationFinish)}, | ||
819 | - "cycleId": param.CycleId, | ||
820 | - "limit": 1, | ||
821 | - }) | ||
822 | - if err != nil { | ||
823 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
824 | - } | ||
825 | - | ||
826 | - if len(evaluationList) > 0 { | ||
827 | - //上级评估的结束时间 | ||
828 | - // evaluationList[0].BeginTime = param.EndTime | ||
829 | - nowTime := time.Now() | ||
830 | - if evaluationList[0].BeginTime.After(nowTime) { | ||
831 | - evaluationList[0].BeginTime = nowTime | ||
832 | - } | ||
833 | - evaluationList[0].Status = domain.EvaluationCompleted | ||
834 | - err = evaluationRepo.Save(evaluationList[0]) | ||
835 | - if err != nil { | ||
836 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error()) | ||
837 | - } | ||
838 | - //添加确认绩效成绩提醒短信提醒 | ||
839 | - err = notify.AddNotifyConfirmEvaluationScore(evaluationList[0]) | ||
840 | - if err != nil { | ||
841 | - return application.ThrowError(application.TRANSACTION_ERROR, "创建短信提醒失败"+err.Error()) | ||
842 | - } | ||
843 | - } | ||
844 | - | ||
845 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
846 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
847 | - } | ||
848 | - | ||
849 | - return nil | ||
850 | -} | 789 | +// // 员工提交上级评估后 |
790 | +// // 生成考核结果 | ||
791 | +// func (srv *SummaryEvaluationService) AfterCompletedEvaluationSuper(param *domain.SummaryEvaluation) error { | ||
792 | +// lock := xredis.NewLockSummaryEvaluation(param.TargetUser.UserId) | ||
793 | +// err := lock.Lock() | ||
794 | +// if err != nil { | ||
795 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容") | ||
796 | +// } | ||
797 | +// defer func() { | ||
798 | +// lock.UnLock() | ||
799 | +// }() | ||
800 | +// transactionContext, err := factory.CreateTransactionContext(nil) | ||
801 | +// if err != nil { | ||
802 | +// return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
803 | +// } | ||
804 | +// if err := transactionContext.StartTransaction(); err != nil { | ||
805 | +// return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
806 | +// } | ||
807 | +// defer func() { | ||
808 | +// _ = transactionContext.RollbackTransaction() | ||
809 | +// }() | ||
810 | + | ||
811 | +// evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ | ||
812 | +// "transactionContext": transactionContext, | ||
813 | +// }) | ||
814 | +// //没有上级评估 | ||
815 | +// //直接进入考核结果阶段 | ||
816 | +// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ | ||
817 | +// "targetUserId": param.TargetUser.UserId, | ||
818 | +// "typesList": []int{int(domain.EvaluationFinish)}, | ||
819 | +// "cycleId": param.CycleId, | ||
820 | +// "limit": 1, | ||
821 | +// }) | ||
822 | +// if err != nil { | ||
823 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
824 | +// } | ||
825 | + | ||
826 | +// if len(evaluationList) > 0 { | ||
827 | +// //上级评估的结束时间 | ||
828 | +// // evaluationList[0].BeginTime = param.EndTime | ||
829 | +// nowTime := time.Now() | ||
830 | +// if evaluationList[0].BeginTime.After(nowTime) { | ||
831 | +// evaluationList[0].BeginTime = nowTime | ||
832 | +// } | ||
833 | +// evaluationList[0].Status = domain.EvaluationCompleted | ||
834 | +// err = evaluationRepo.Save(evaluationList[0]) | ||
835 | +// if err != nil { | ||
836 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error()) | ||
837 | +// } | ||
838 | +// //TODO 更新考核成绩 | ||
839 | + | ||
840 | +// //添加确认绩效成绩提醒短信提醒 | ||
841 | +// err = notify.AddNotifyConfirmEvaluationScore(evaluationList[0]) | ||
842 | +// if err != nil { | ||
843 | +// return application.ThrowError(application.TRANSACTION_ERROR, "创建短信提醒失败"+err.Error()) | ||
844 | +// } | ||
845 | +// } | ||
846 | + | ||
847 | +// if err := transactionContext.CommitTransaction(); err != nil { | ||
848 | +// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
849 | +// } | ||
850 | + | ||
851 | +// return nil | ||
852 | +// } | ||
851 | 853 | ||
852 | // GetTargetUserCycleList | 854 | // GetTargetUserCycleList |
853 | // 获取周期列表,被评估的周期列表 | 855 | // 获取周期列表,被评估的周期列表 |
@@ -1195,124 +1197,124 @@ func (srv *SummaryEvaluationService) GetEvaluationSuperForAdmin(param *command.Q | @@ -1195,124 +1197,124 @@ func (srv *SummaryEvaluationService) GetEvaluationSuperForAdmin(param *command.Q | ||
1195 | return &result, nil | 1197 | return &result, nil |
1196 | } | 1198 | } |
1197 | 1199 | ||
1198 | -// EditEvaluationSuper 更新上级评估内容 | ||
1199 | -func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEvaluationValue) (interface{}, error) { | ||
1200 | - lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId) | ||
1201 | - err := lock.Lock() | ||
1202 | - if err != nil { | ||
1203 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容") | ||
1204 | - } | ||
1205 | - defer func() { | ||
1206 | - lock.UnLock() | ||
1207 | - }() | ||
1208 | - transactionContext, err := factory.CreateTransactionContext(nil) | ||
1209 | - if err != nil { | ||
1210 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1211 | - } | ||
1212 | - if err := transactionContext.StartTransaction(); err != nil { | ||
1213 | - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1214 | - } | ||
1215 | - defer func() { | ||
1216 | - _ = transactionContext.RollbackTransaction() | ||
1217 | - }() | ||
1218 | - evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ | ||
1219 | - "transactionContext": transactionContext, | ||
1220 | - }) | ||
1221 | - itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{ | ||
1222 | - "transactionContext": transactionContext, | ||
1223 | - }) | ||
1224 | - | ||
1225 | - itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{ | ||
1226 | - "transactionContext": transactionContext, | ||
1227 | - }) | ||
1228 | - evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{ | ||
1229 | - "id": param.SummaryEvaluationId, | ||
1230 | - }) | ||
1231 | - if err != nil { | ||
1232 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1233 | - } | ||
1234 | - if evaluationData.Types != domain.EvaluationSuper { | ||
1235 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") | ||
1236 | - } | ||
1237 | - | ||
1238 | - if evaluationData.Executor.UserId != param.ExecutorId { | ||
1239 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") | ||
1240 | - } | ||
1241 | - | ||
1242 | - if evaluationData.CompanyId != param.CompanyId { | ||
1243 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") | ||
1244 | - } | ||
1245 | - | ||
1246 | - _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ | ||
1247 | - "targetUserId": evaluationData.TargetUser.UserId, | ||
1248 | - "typesList": []int{int(domain.EvaluationFinish)}, | ||
1249 | - "cycleId": evaluationData.CycleId, | ||
1250 | - "limit": 1, | ||
1251 | - }) | ||
1252 | - if err != nil { | ||
1253 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1254 | - } | ||
1255 | - // 如果目标员工已经确认考核结果,就不能在进行评估编辑 | ||
1256 | - if len(evaluationList) > 0 && evaluationList[0].CheckResult == domain.EvaluationCheckCompleted { | ||
1257 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户已经确认该周期的考核结果,不能再编辑!") | ||
1258 | - } | ||
1259 | - | ||
1260 | - _, itemList, err := itemUsedRepo.Find(map[string]interface{}{ | ||
1261 | - "evaluationProjectId": evaluationData.EvaluationProjectId, | ||
1262 | - "nodeType": domain.LinkNodeSelfAssessment, | ||
1263 | - }) | ||
1264 | - if err != nil { | ||
1265 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1266 | - } | ||
1267 | - //获取已填写的评估内容 | ||
1268 | - _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{ | ||
1269 | - "summaryEvaluationId": evaluationData.Id, | ||
1270 | - }) | ||
1271 | - if err != nil { | ||
1272 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1273 | - } | ||
1274 | - //记录人资评估或者360评估的 填写项id | ||
1275 | - hrbpOr360ItemValue, err := srv.getEvaluationSuperDefaultValue(transactionContext, evaluationData) | ||
1276 | - if err != nil { | ||
1277 | - return nil, err | ||
1278 | - } | ||
1279 | - | ||
1280 | - err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, hrbpOr360ItemValue, param.IsTemporary) | ||
1281 | - if err != nil { | ||
1282 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1283 | - } | ||
1284 | - if !param.IsTemporary { | ||
1285 | - //变更评估状态为已填写 | ||
1286 | - evaluationData.Status = domain.EvaluationCompleted | ||
1287 | - } | ||
1288 | - for _, v := range itemValueList { | ||
1289 | - //保存填写值 | ||
1290 | - err = itemValueRepo.Save(v) | ||
1291 | - if err != nil { | ||
1292 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1293 | - } | ||
1294 | - } | ||
1295 | - //保存填写值 | ||
1296 | - err = evaluationRepo.Save(evaluationData) | ||
1297 | - if err != nil { | ||
1298 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1299 | - } | ||
1300 | - if err := transactionContext.CommitTransaction(); err != nil { | ||
1301 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1302 | - } | ||
1303 | - | ||
1304 | - if !param.IsTemporary { | ||
1305 | - err = srv.AfterCompletedEvaluationSuper(evaluationData) | ||
1306 | - if err != nil { | ||
1307 | - return nil, err | ||
1308 | - } | ||
1309 | - } | ||
1310 | - | ||
1311 | - itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList) | ||
1312 | - return map[string][]adapter.EvaluationItemAdapter{ | ||
1313 | - "EvaluationItems": itemValueAdapter, | ||
1314 | - }, nil | ||
1315 | -} | 1200 | +// // EditEvaluationSuper 更新上级评估内容 |
1201 | +// func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEvaluationValue) (interface{}, error) { | ||
1202 | +// lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId) | ||
1203 | +// err := lock.Lock() | ||
1204 | +// if err != nil { | ||
1205 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容") | ||
1206 | +// } | ||
1207 | +// defer func() { | ||
1208 | +// lock.UnLock() | ||
1209 | +// }() | ||
1210 | +// transactionContext, err := factory.CreateTransactionContext(nil) | ||
1211 | +// if err != nil { | ||
1212 | +// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1213 | +// } | ||
1214 | +// if err := transactionContext.StartTransaction(); err != nil { | ||
1215 | +// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1216 | +// } | ||
1217 | +// defer func() { | ||
1218 | +// _ = transactionContext.RollbackTransaction() | ||
1219 | +// }() | ||
1220 | +// evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{ | ||
1221 | +// "transactionContext": transactionContext, | ||
1222 | +// }) | ||
1223 | +// itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{ | ||
1224 | +// "transactionContext": transactionContext, | ||
1225 | +// }) | ||
1226 | + | ||
1227 | +// itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{ | ||
1228 | +// "transactionContext": transactionContext, | ||
1229 | +// }) | ||
1230 | +// evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{ | ||
1231 | +// "id": param.SummaryEvaluationId, | ||
1232 | +// }) | ||
1233 | +// if err != nil { | ||
1234 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1235 | +// } | ||
1236 | +// if evaluationData.Types != domain.EvaluationSuper { | ||
1237 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") | ||
1238 | +// } | ||
1239 | + | ||
1240 | +// if evaluationData.Executor.UserId != param.ExecutorId { | ||
1241 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") | ||
1242 | +// } | ||
1243 | + | ||
1244 | +// if evaluationData.CompanyId != param.CompanyId { | ||
1245 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限") | ||
1246 | +// } | ||
1247 | + | ||
1248 | +// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ | ||
1249 | +// "targetUserId": evaluationData.TargetUser.UserId, | ||
1250 | +// "typesList": []int{int(domain.EvaluationFinish)}, | ||
1251 | +// "cycleId": evaluationData.CycleId, | ||
1252 | +// "limit": 1, | ||
1253 | +// }) | ||
1254 | +// if err != nil { | ||
1255 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1256 | +// } | ||
1257 | +// // 如果目标员工已经确认考核结果,就不能在进行评估编辑 | ||
1258 | +// if len(evaluationList) > 0 && evaluationList[0].CheckResult == domain.EvaluationCheckCompleted { | ||
1259 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户已经确认该周期的考核结果,不能再编辑!") | ||
1260 | +// } | ||
1261 | + | ||
1262 | +// _, itemList, err := itemUsedRepo.Find(map[string]interface{}{ | ||
1263 | +// "evaluationProjectId": evaluationData.EvaluationProjectId, | ||
1264 | +// "nodeType": domain.LinkNodeSelfAssessment, | ||
1265 | +// }) | ||
1266 | +// if err != nil { | ||
1267 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1268 | +// } | ||
1269 | +// //获取已填写的评估内容 | ||
1270 | +// _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{ | ||
1271 | +// "summaryEvaluationId": evaluationData.Id, | ||
1272 | +// }) | ||
1273 | +// if err != nil { | ||
1274 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1275 | +// } | ||
1276 | +// //记录人资评估或者360评估的 填写项id | ||
1277 | +// hrbpOr360ItemValue, err := srv.getEvaluationSuperDefaultValue(transactionContext, evaluationData) | ||
1278 | +// if err != nil { | ||
1279 | +// return nil, err | ||
1280 | +// } | ||
1281 | + | ||
1282 | +// err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, hrbpOr360ItemValue, param.IsTemporary) | ||
1283 | +// if err != nil { | ||
1284 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1285 | +// } | ||
1286 | +// if !param.IsTemporary { | ||
1287 | +// //变更评估状态为已填写 | ||
1288 | +// evaluationData.Status = domain.EvaluationCompleted | ||
1289 | +// } | ||
1290 | +// for _, v := range itemValueList { | ||
1291 | +// //保存填写值 | ||
1292 | +// err = itemValueRepo.Save(v) | ||
1293 | +// if err != nil { | ||
1294 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1295 | +// } | ||
1296 | +// } | ||
1297 | +// //保存填写值 | ||
1298 | +// err = evaluationRepo.Save(evaluationData) | ||
1299 | +// if err != nil { | ||
1300 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1301 | +// } | ||
1302 | +// if err := transactionContext.CommitTransaction(); err != nil { | ||
1303 | +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1304 | +// } | ||
1305 | + | ||
1306 | +// if !param.IsTemporary { | ||
1307 | +// err = srv.AfterCompletedEvaluationSuper(evaluationData) | ||
1308 | +// if err != nil { | ||
1309 | +// return nil, err | ||
1310 | +// } | ||
1311 | +// } | ||
1312 | + | ||
1313 | +// itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList) | ||
1314 | +// return map[string][]adapter.EvaluationItemAdapter{ | ||
1315 | +// "EvaluationItems": itemValueAdapter, | ||
1316 | +// }, nil | ||
1317 | +// } | ||
1316 | 1318 | ||
1317 | // EditEvaluationSuperForAdmin 更新上级评估内容(超级管理员) | 1319 | // EditEvaluationSuperForAdmin 更新上级评估内容(超级管理员) |
1318 | func (srv *SummaryEvaluationService) EditEvaluationSuperForAdmin(param *command.EditEvaluationValue) (interface{}, error) { | 1320 | func (srv *SummaryEvaluationService) EditEvaluationSuperForAdmin(param *command.EditEvaluationValue) (interface{}, error) { |
@@ -1400,10 +1402,10 @@ func (srv *SummaryEvaluationService) EditEvaluationSuperForAdmin(param *command. | @@ -1400,10 +1402,10 @@ func (srv *SummaryEvaluationService) EditEvaluationSuperForAdmin(param *command. | ||
1400 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1402 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1401 | } | 1403 | } |
1402 | 1404 | ||
1403 | - err = srv.AfterCompletedEvaluationSuper(evaluationData) | ||
1404 | - if err != nil { | ||
1405 | - return nil, err | ||
1406 | - } | 1405 | + // err = srv.AfterCompletedEvaluationSuper(evaluationData) |
1406 | + // if err != nil { | ||
1407 | + // return nil, err | ||
1408 | + // } | ||
1407 | 1409 | ||
1408 | itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList) | 1410 | itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList) |
1409 | return map[string][]adapter.EvaluationItemAdapter{"EvaluationItems": itemValueAdapter}, nil | 1411 | return map[string][]adapter.EvaluationItemAdapter{"EvaluationItems": itemValueAdapter}, nil |
@@ -115,39 +115,3 @@ func (itemValue *SummaryEvaluationValue) valueTypeScore(item *EvaluationItemUsed | @@ -115,39 +115,3 @@ func (itemValue *SummaryEvaluationValue) valueTypeScore(item *EvaluationItemUsed | ||
115 | } | 115 | } |
116 | return nil | 116 | return nil |
117 | } | 117 | } |
118 | - | ||
119 | -// 填写综合自评 | ||
120 | -// func (itemValue *SummaryEvaluationValue) EvaluationSelfFillValue(item *EvaluationItemUsed, value string, remark string) error { | ||
121 | -// itemValue.Remark = remark | ||
122 | -// if item.Weight == 0 { | ||
123 | -// //使用评级的形式 | ||
124 | -// err := itemValue.valueTypeRating(item, value) | ||
125 | -// return err | ||
126 | -// } | ||
127 | -// //综合自评 评分的形式,特殊处理 | ||
128 | -// err := itemValue.valueTypeScoreEvaluationSelf(item, value) | ||
129 | -// return err | ||
130 | -// } | ||
131 | - | ||
132 | -// func (itemValue *SummaryEvaluationValue) valueTypeScoreEvaluationSelf(item *EvaluationItemUsed, value string) error { | ||
133 | -// if item.Weight <= 0 { | ||
134 | -// return errors.New("评分方式错误") | ||
135 | -// } | ||
136 | -// value = strings.TrimSpace(value) | ||
137 | -// itemValue.Value = value | ||
138 | -// //处理空值 | ||
139 | -// if len(value) == 0 { | ||
140 | -// itemValue.Score = "0" | ||
141 | -// return nil | ||
142 | -// } | ||
143 | -// valueNumber, err := strconv.ParseFloat(value, 64) | ||
144 | -// if err != nil { | ||
145 | -// return fmt.Errorf("条目%d:%s-%s评分值异常", item.Id, item.Category, item.Name) | ||
146 | -// } | ||
147 | - | ||
148 | -// // 分数保留2位小数 | ||
149 | -// score := valueNumber * item.Weight | ||
150 | -// itemValue.Score = fmt.Sprintf("%.2f", score) | ||
151 | - | ||
152 | -// return nil | ||
153 | -// } |
-
请 注册 或 登录 后发表评论