正在显示
1 个修改的文件
包含
67 行增加
和
58 行删除
@@ -1373,88 +1373,97 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi | @@ -1373,88 +1373,97 @@ func (srv *SummaryEvaluationService) ConfirmScoreEvaluation(param *command.Confi | ||
1373 | return application.ThrowError(application.TRANSACTION_ERROR, "前面流程暂未完成提交评估内容") | 1373 | return application.ThrowError(application.TRANSACTION_ERROR, "前面流程暂未完成提交评估内容") |
1374 | } | 1374 | } |
1375 | 1375 | ||
1376 | - _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ | ||
1377 | - "companyId": result.CompanyId, | ||
1378 | - "cycleId": result.CycleId, | ||
1379 | - "targetUserId": result.TargetUser.UserId, | ||
1380 | - }) | ||
1381 | - if err != nil { | ||
1382 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1383 | - } | ||
1384 | - | ||
1385 | - var super *domain.SummaryEvaluation // 上级评估 | ||
1386 | - for i := range evaluationList { | ||
1387 | - it := evaluationList[i] | ||
1388 | - if it.Types == domain.EvaluationSuper { | ||
1389 | - super = it | ||
1390 | - break | ||
1391 | - } | ||
1392 | - } | ||
1393 | - | ||
1394 | - // 评估内容和值 | ||
1395 | - var itemList []*domain.EvaluationItemUsed | ||
1396 | - var itemValues []*domain.SummaryEvaluationValue | ||
1397 | - | ||
1398 | - // 获取自评模板内容 | ||
1399 | - _, itemList, err = evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment}) | 1376 | + // 按评估项优先级顺序(已确认考核结果 ->上级评估 ->HR或360评估或自评) |
1377 | + _, itemValues, err := itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": result.Id, "limit": 1}) | ||
1400 | if err != nil { | 1378 | if err != nil { |
1401 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1379 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1402 | } | 1380 | } |
1403 | - | ||
1404 | - // 按评估项优先级顺序(已确认考核结果 ->上级评估 ->HR或360评估或自评) | ||
1405 | - if super != nil { | ||
1406 | - _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": super.Id}) // 获取已填写的评估内容 | ||
1407 | - if err != nil { | ||
1408 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1409 | - } | ||
1410 | - // 更新填写值 | ||
1411 | - itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues, true) | 1381 | + // 如果已经存在考核结果分数,不再进行分数计算(如.超管多次修改员工多次确认) |
1382 | + if len(itemValues) > 0 { | ||
1383 | + // do nothing... | ||
1384 | + } else { | ||
1385 | + // 周期内所有评估类型 | ||
1386 | + _, evaluationList, err := evaluationRepo.Find(map[string]interface{}{ | ||
1387 | + "companyId": result.CompanyId, | ||
1388 | + "cycleId": result.CycleId, | ||
1389 | + "targetUserId": result.TargetUser.UserId, | ||
1390 | + }) | ||
1412 | if err != nil { | 1391 | if err != nil { |
1413 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1392 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1414 | } | 1393 | } |
1415 | - } else { | ||
1416 | - // 评估项ID(除考核结果和上级) | ||
1417 | - var evaluationIds = make([]int, 0) | 1394 | + |
1395 | + var super *domain.SummaryEvaluation // 上级评估 | ||
1418 | for i := range evaluationList { | 1396 | for i := range evaluationList { |
1419 | it := evaluationList[i] | 1397 | it := evaluationList[i] |
1420 | - if it.Types == domain.EvaluationSelf || it.Types == domain.Evaluation360 || it.Types == domain.EvaluationHrbp { | ||
1421 | - evaluationIds = append(evaluationIds, it.Id) | 1398 | + if it.Types == domain.EvaluationSuper { |
1399 | + super = it | ||
1400 | + break | ||
1422 | } | 1401 | } |
1423 | } | 1402 | } |
1424 | - if len(evaluationIds) > 0 { | ||
1425 | - // 获取已填写的评估内容 | ||
1426 | - _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds}) | 1403 | + |
1404 | + // 评估内容和值 | ||
1405 | + var itemList []*domain.EvaluationItemUsed | ||
1406 | + var itemValues []*domain.SummaryEvaluationValue | ||
1407 | + | ||
1408 | + // 获取自评模板 | ||
1409 | + _, itemList, err = evaluationItemRepo.Find(map[string]interface{}{"evaluationProjectId": result.EvaluationProjectId, "nodeType": domain.LinkNodeSelfAssessment}) | ||
1410 | + if err != nil { | ||
1411 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1412 | + } | ||
1413 | + | ||
1414 | + if super != nil { | ||
1415 | + _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationId": super.Id}) // 获取已填写的评估内容 | ||
1427 | if err != nil { | 1416 | if err != nil { |
1428 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1417 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1429 | } | 1418 | } |
1430 | - | ||
1431 | // 更新填写值 | 1419 | // 更新填写值 |
1432 | - itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues, false) | 1420 | + itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues, true) |
1433 | if err != nil { | 1421 | if err != nil { |
1434 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1422 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1435 | } | 1423 | } |
1424 | + } else { | ||
1425 | + // 评估项ID(除考核结果和上级) | ||
1426 | + var evaluationIds = make([]int, 0) | ||
1427 | + for i := range evaluationList { | ||
1428 | + it := evaluationList[i] | ||
1429 | + if it.Types == domain.EvaluationSelf || it.Types == domain.Evaluation360 || it.Types == domain.EvaluationHrbp { | ||
1430 | + evaluationIds = append(evaluationIds, it.Id) | ||
1431 | + } | ||
1432 | + } | ||
1433 | + if len(evaluationIds) > 0 { | ||
1434 | + // 已填写的评估内容 | ||
1435 | + _, itemValues, err = itemValueRepo.Find(map[string]interface{}{"summaryEvaluationIdList": evaluationIds}) | ||
1436 | + if err != nil { | ||
1437 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1438 | + } | ||
1439 | + | ||
1440 | + // 更新填写值 | ||
1441 | + itemValues, err = srv.updateItemValuePriority(result, itemList, itemValues, false) | ||
1442 | + if err != nil { | ||
1443 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1444 | + } | ||
1445 | + } | ||
1436 | } | 1446 | } |
1437 | - } | ||
1438 | - err = itemValueRepo.RemoveBySummaryEvaluationId(result.Id) | ||
1439 | - if err != nil { | ||
1440 | - return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1441 | - } | ||
1442 | - for i := range itemValues { | ||
1443 | - if err := itemValueRepo.Save(itemValues[i]); err != nil { | 1447 | + err = itemValueRepo.RemoveBySummaryEvaluationId(result.Id) |
1448 | + if err != nil { | ||
1444 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1449 | return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1445 | } | 1450 | } |
1446 | - } | ||
1447 | - //重置评级汇总 | ||
1448 | - result.TotalRating = nil | ||
1449 | - for i := range itemList { | ||
1450 | - result.ResetTotalRating(itemList[i]) | ||
1451 | - } | ||
1452 | - //存在 超级管理员直接修改填写 总分的情况,此时不重新计算总分 | ||
1453 | - if result.TotalScore == "0" || result.TotalScore == "" { | 1451 | + for i := range itemValues { |
1452 | + if err := itemValueRepo.Save(itemValues[i]); err != nil { | ||
1453 | + return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1454 | + } | ||
1455 | + } | ||
1456 | + // 重置评级汇总 | ||
1457 | + result.TotalRating = nil | ||
1458 | + for i := range itemList { | ||
1459 | + result.ResetTotalRating(itemList[i]) | ||
1460 | + } | ||
1461 | + // 计算分数 | ||
1454 | if err := result.EvaluationTotalScore(itemValues); err != nil { | 1462 | if err := result.EvaluationTotalScore(itemValues); err != nil { |
1455 | return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 1463 | return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
1456 | } | 1464 | } |
1457 | } | 1465 | } |
1466 | + | ||
1458 | result.CheckResult = domain.EvaluationCheckCompleted | 1467 | result.CheckResult = domain.EvaluationCheckCompleted |
1459 | if err := evaluationRepo.Save(result); err != nil { | 1468 | if err := evaluationRepo.Save(result); err != nil { |
1460 | return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 1469 | return application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
-
请 注册 或 登录 后发表评论