|
@@ -1117,299 +1117,6 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval |
|
@@ -1117,299 +1117,6 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval |
1117
|
return &result, nil
|
1117
|
return &result, nil
|
1118
|
}
|
1118
|
}
|
1119
|
|
1119
|
|
1120
|
-// GetEvaluationSuperForAdmin 根据执行人获取上级评估详情(超级管理员特殊处理)
|
|
|
1121
|
-func (srv *SummaryEvaluationService) GetEvaluationSuperForAdmin(param *command.QueryEvaluationSuper) (*adapter.EvaluationInfoSuperAdapter, error) {
|
|
|
1122
|
- transactionContext, err := factory.StartTransaction()
|
|
|
1123
|
- if err != nil {
|
|
|
1124
|
- return nil, err
|
|
|
1125
|
- }
|
|
|
1126
|
- defer func() {
|
|
|
1127
|
- _ = transactionContext.RollbackTransaction()
|
|
|
1128
|
- }()
|
|
|
1129
|
-
|
|
|
1130
|
- // 只有超级管理员可以使用的功能
|
|
|
1131
|
- superAdmin, err := roleService.GetSuperAdmin(transactionContext, param.CompanyId, param.UserId)
|
|
|
1132
|
- if err != nil {
|
|
|
1133
|
- return nil, err
|
|
|
1134
|
- }
|
|
|
1135
|
- if superAdmin != domain.RoleTypeSuperAdmin {
|
|
|
1136
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
1137
|
- }
|
|
|
1138
|
-
|
|
|
1139
|
- evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
1140
|
- evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
1141
|
- itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
1142
|
- _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{"id": []int{param.SummaryEvaluationId}})
|
|
|
1143
|
- if err != nil {
|
|
|
1144
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1145
|
- }
|
|
|
1146
|
- if len(evaluationList) == 0 {
|
|
|
1147
|
- return &adapter.EvaluationInfoSuperAdapter{}, nil
|
|
|
1148
|
- }
|
|
|
1149
|
- evaluationData := evaluationList[0]
|
|
|
1150
|
-
|
|
|
1151
|
- if evaluationData.CompanyId != param.CompanyId {
|
|
|
1152
|
- return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
|
|
|
1153
|
- }
|
|
|
1154
|
- _, itemList, err := evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": evaluationData.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})
|
|
|
1155
|
- if err != nil {
|
|
|
1156
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1157
|
- }
|
|
|
1158
|
- // 获取已填写的评估内容
|
|
|
1159
|
- _, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": evaluationData.Id})
|
|
|
1160
|
- if err != nil {
|
|
|
1161
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1162
|
- }
|
|
|
1163
|
-
|
|
|
1164
|
- // 上级评估未填写或未填写完成,获取360/人资评估的填写值
|
|
|
1165
|
- if len(itemValues) == 0 || evaluationData.Status == domain.EvaluationUncompleted {
|
|
|
1166
|
- _, evaluationListOther, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
1167
|
- "typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)},
|
|
|
1168
|
- "targetUserId": evaluationData.TargetUser.UserId,
|
|
|
1169
|
- "cycleId": evaluationData.CycleId,
|
|
|
1170
|
- })
|
|
|
1171
|
- if err != nil {
|
|
|
1172
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1173
|
- }
|
|
|
1174
|
- var evaluationIds []int
|
|
|
1175
|
- for _, v := range evaluationListOther {
|
|
|
1176
|
- evaluationIds = append(evaluationIds, v.Id)
|
|
|
1177
|
- }
|
|
|
1178
|
- if len(evaluationIds) > 0 {
|
|
|
1179
|
- _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds})
|
|
|
1180
|
- if err != nil {
|
|
|
1181
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1182
|
- }
|
|
|
1183
|
- }
|
|
|
1184
|
- }
|
|
|
1185
|
- evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluationData)
|
|
|
1186
|
- if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
1187
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1188
|
- }
|
|
|
1189
|
- //组合 评估填写的值和评估项
|
|
|
1190
|
- itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
|
|
|
1191
|
-
|
|
|
1192
|
- result := adapter.EvaluationInfoSuperAdapter{
|
|
|
1193
|
- EvaluationBaseAdapter: evaluationBase,
|
|
|
1194
|
- EvaluationItems: itemValuesAdapter,
|
|
|
1195
|
- }
|
|
|
1196
|
- return &result, nil
|
|
|
1197
|
-}
|
|
|
1198
|
-
|
|
|
1199
|
-// // EditEvaluationSuper 更新上级评估内容
|
|
|
1200
|
-// func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEvaluationValue) (interface{}, error) {
|
|
|
1201
|
-// lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId)
|
|
|
1202
|
-// err := lock.Lock()
|
|
|
1203
|
-// if err != nil {
|
|
|
1204
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
|
|
|
1205
|
-// }
|
|
|
1206
|
-// defer func() {
|
|
|
1207
|
-// lock.UnLock()
|
|
|
1208
|
-// }()
|
|
|
1209
|
-// transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
1210
|
-// if err != nil {
|
|
|
1211
|
-// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1212
|
-// }
|
|
|
1213
|
-// if err := transactionContext.StartTransaction(); err != nil {
|
|
|
1214
|
-// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
1215
|
-// }
|
|
|
1216
|
-// defer func() {
|
|
|
1217
|
-// _ = transactionContext.RollbackTransaction()
|
|
|
1218
|
-// }()
|
|
|
1219
|
-// evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
1220
|
-// "transactionContext": transactionContext,
|
|
|
1221
|
-// })
|
|
|
1222
|
-// itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
|
|
|
1223
|
-// "transactionContext": transactionContext,
|
|
|
1224
|
-// })
|
|
|
1225
|
-
|
|
|
1226
|
-// itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
|
|
|
1227
|
-// "transactionContext": transactionContext,
|
|
|
1228
|
-// })
|
|
|
1229
|
-// evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{
|
|
|
1230
|
-// "id": param.SummaryEvaluationId,
|
|
|
1231
|
-// })
|
|
|
1232
|
-// if err != nil {
|
|
|
1233
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1234
|
-// }
|
|
|
1235
|
-// if evaluationData.Types != domain.EvaluationSuper {
|
|
|
1236
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
1237
|
-// }
|
|
|
1238
|
-
|
|
|
1239
|
-// if evaluationData.Executor.UserId != param.ExecutorId {
|
|
|
1240
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
1241
|
-// }
|
|
|
1242
|
-
|
|
|
1243
|
-// if evaluationData.CompanyId != param.CompanyId {
|
|
|
1244
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
1245
|
-// }
|
|
|
1246
|
-
|
|
|
1247
|
-// _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
1248
|
-// "targetUserId": evaluationData.TargetUser.UserId,
|
|
|
1249
|
-// "typesList": []int{int(domain.EvaluationFinish)},
|
|
|
1250
|
-// "cycleId": evaluationData.CycleId,
|
|
|
1251
|
-// "limit": 1,
|
|
|
1252
|
-// })
|
|
|
1253
|
-// if err != nil {
|
|
|
1254
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1255
|
-// }
|
|
|
1256
|
-// // 如果目标员工已经确认考核结果,就不能在进行评估编辑
|
|
|
1257
|
-// if len(evaluationList) > 0 && evaluationList[0].CheckResult == domain.EvaluationCheckCompleted {
|
|
|
1258
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户已经确认该周期的考核结果,不能再编辑!")
|
|
|
1259
|
-// }
|
|
|
1260
|
-
|
|
|
1261
|
-// _, itemList, err := itemUsedRepo.Find(map[string]interface{}{
|
|
|
1262
|
-// "evaluationProjectId": evaluationData.EvaluationProjectId,
|
|
|
1263
|
-// "nodeType": domain.LinkNodeSelfAssessment,
|
|
|
1264
|
-// })
|
|
|
1265
|
-// if err != nil {
|
|
|
1266
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1267
|
-// }
|
|
|
1268
|
-// //获取已填写的评估内容
|
|
|
1269
|
-// _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{
|
|
|
1270
|
-// "summaryEvaluationId": evaluationData.Id,
|
|
|
1271
|
-// })
|
|
|
1272
|
-// if err != nil {
|
|
|
1273
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1274
|
-// }
|
|
|
1275
|
-// //记录人资评估或者360评估的 填写项id
|
|
|
1276
|
-// hrbpOr360ItemValue, err := srv.getEvaluationSuperDefaultValue(transactionContext, evaluationData)
|
|
|
1277
|
-// if err != nil {
|
|
|
1278
|
-// return nil, err
|
|
|
1279
|
-// }
|
|
|
1280
|
-
|
|
|
1281
|
-// err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, hrbpOr360ItemValue, param.IsTemporary)
|
|
|
1282
|
-// if err != nil {
|
|
|
1283
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1284
|
-// }
|
|
|
1285
|
-// if !param.IsTemporary {
|
|
|
1286
|
-// //变更评估状态为已填写
|
|
|
1287
|
-// evaluationData.Status = domain.EvaluationCompleted
|
|
|
1288
|
-// }
|
|
|
1289
|
-// for _, v := range itemValueList {
|
|
|
1290
|
-// //保存填写值
|
|
|
1291
|
-// err = itemValueRepo.Save(v)
|
|
|
1292
|
-// if err != nil {
|
|
|
1293
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1294
|
-// }
|
|
|
1295
|
-// }
|
|
|
1296
|
-// //保存填写值
|
|
|
1297
|
-// err = evaluationRepo.Save(evaluationData)
|
|
|
1298
|
-// if err != nil {
|
|
|
1299
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1300
|
-// }
|
|
|
1301
|
-// if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
1302
|
-// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1303
|
-// }
|
|
|
1304
|
-
|
|
|
1305
|
-// if !param.IsTemporary {
|
|
|
1306
|
-// err = srv.AfterCompletedEvaluationSuper(evaluationData)
|
|
|
1307
|
-// if err != nil {
|
|
|
1308
|
-// return nil, err
|
|
|
1309
|
-// }
|
|
|
1310
|
-// }
|
|
|
1311
|
-
|
|
|
1312
|
-// itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
|
|
|
1313
|
-// return map[string][]adapter.EvaluationItemAdapter{
|
|
|
1314
|
-// "EvaluationItems": itemValueAdapter,
|
|
|
1315
|
-// }, nil
|
|
|
1316
|
-// }
|
|
|
1317
|
-
|
|
|
1318
|
-// EditEvaluationSuperForAdmin 更新上级评估内容(超级管理员)
|
|
|
1319
|
-func (srv *SummaryEvaluationService) EditEvaluationSuperForAdmin(param *command.EditEvaluationValue) (interface{}, error) {
|
|
|
1320
|
- // 超管不接收临时数据提交
|
|
|
1321
|
- if param.IsTemporary {
|
|
|
1322
|
- return nil, nil
|
|
|
1323
|
- }
|
|
|
1324
|
-
|
|
|
1325
|
- lock := xredis.NewLockSummaryEvaluationId(param.SummaryEvaluationId)
|
|
|
1326
|
- err := lock.Lock()
|
|
|
1327
|
- if err != nil {
|
|
|
1328
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
|
|
|
1329
|
- }
|
|
|
1330
|
- defer func() {
|
|
|
1331
|
- lock.UnLock()
|
|
|
1332
|
- }()
|
|
|
1333
|
-
|
|
|
1334
|
- transactionContext, err := factory.StartTransaction()
|
|
|
1335
|
- if err != nil {
|
|
|
1336
|
- return nil, err
|
|
|
1337
|
- }
|
|
|
1338
|
- defer func() {
|
|
|
1339
|
- _ = transactionContext.RollbackTransaction()
|
|
|
1340
|
- }()
|
|
|
1341
|
-
|
|
|
1342
|
- // 只有超级管理员可以使用的功能
|
|
|
1343
|
- superAdmin, err := roleService.GetSuperAdmin(transactionContext, param.CompanyId, param.ExecutorId)
|
|
|
1344
|
- if err != nil {
|
|
|
1345
|
- return nil, err
|
|
|
1346
|
- }
|
|
|
1347
|
- if superAdmin != domain.RoleTypeSuperAdmin {
|
|
|
1348
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
1349
|
- }
|
|
|
1350
|
-
|
|
|
1351
|
- evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
1352
|
- itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
1353
|
- itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
1354
|
- evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{"id": param.SummaryEvaluationId})
|
|
|
1355
|
- if err != nil {
|
|
|
1356
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1357
|
- }
|
|
|
1358
|
- if evaluationData.CompanyId != param.CompanyId {
|
|
|
1359
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
1360
|
- }
|
|
|
1361
|
- _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
1362
|
- "targetUserId": evaluationData.TargetUser.UserId,
|
|
|
1363
|
- "typesList": []int{int(domain.EvaluationFinish)},
|
|
|
1364
|
- "cycleId": evaluationData.CycleId,
|
|
|
1365
|
- "limit": 1,
|
|
|
1366
|
- })
|
|
|
1367
|
- if err != nil {
|
|
|
1368
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1369
|
- }
|
|
|
1370
|
- // 如果目标员工已经确认考核结果,就不能在进行评估编辑
|
|
|
1371
|
- if len(evaluationList) > 0 && evaluationList[0].CheckResult == domain.EvaluationCheckCompleted {
|
|
|
1372
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "用户已经确认该周期的考核结果,不能再编辑!")
|
|
|
1373
|
- }
|
|
|
1374
|
-
|
|
|
1375
|
- _, itemList, err := itemUsedRepo.Find(map[string]interface{}{"evaluationProjectId": evaluationData.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment})
|
|
|
1376
|
- if err != nil {
|
|
|
1377
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1378
|
- }
|
|
|
1379
|
- // 获取已填写的评估内容
|
|
|
1380
|
- _, itemValueList, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": evaluationData.Id})
|
|
|
1381
|
- if err != nil {
|
|
|
1382
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1383
|
- }
|
|
|
1384
|
- // 超级管理员编辑不限制截止时间、不校验填写项
|
|
|
1385
|
- err = srv.editEvaluationValueUnlimited(evaluationData, &itemValueList, itemList, param.EvaluationItems, nil, true)
|
|
|
1386
|
- if err != nil {
|
|
|
1387
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1388
|
- }
|
|
|
1389
|
- for _, v := range itemValueList {
|
|
|
1390
|
- err = itemValueRepo.Save(v) // 保存填写值
|
|
|
1391
|
- if err != nil {
|
|
|
1392
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1393
|
- }
|
|
|
1394
|
- }
|
|
|
1395
|
- evaluationData.Status = domain.EvaluationCompleted
|
|
|
1396
|
- err = evaluationRepo.Save(evaluationData)
|
|
|
1397
|
- if err != nil {
|
|
|
1398
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1399
|
- }
|
|
|
1400
|
- if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
1401
|
- return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
1402
|
- }
|
|
|
1403
|
-
|
|
|
1404
|
- // err = srv.AfterCompletedEvaluationSuper(evaluationData)
|
|
|
1405
|
- // if err != nil {
|
|
|
1406
|
- // return nil, err
|
|
|
1407
|
- // }
|
|
|
1408
|
-
|
|
|
1409
|
- itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
|
|
|
1410
|
- return map[string][]adapter.EvaluationItemAdapter{"EvaluationItems": itemValueAdapter}, nil
|
|
|
1411
|
-}
|
|
|
1412
|
-
|
|
|
1413
|
// getEvaluationSuperDefaultValue
|
1120
|
// getEvaluationSuperDefaultValue
|
1414
|
// 按照权限设置,是否获取上级评估内容的默认值
|
1121
|
// 按照权限设置,是否获取上级评估内容的默认值
|
1415
|
func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionContext application.TransactionContext, evaluationData *domain.SummaryEvaluation) (
|
1122
|
func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionContext application.TransactionContext, evaluationData *domain.SummaryEvaluation) (
|