...
|
...
|
@@ -264,6 +264,7 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev |
|
|
Value: "",
|
|
|
Score: "",
|
|
|
Remark: "",
|
|
|
EvaluatorId: v.EvaluatorId,
|
|
|
}
|
|
|
value, ok := valueMap[v.Id]
|
|
|
if ok {
|
...
|
...
|
@@ -277,7 +278,7 @@ func (srv *SummaryEvaluationService) buildSummaryItemValue(itemList []*domain.Ev |
|
|
}
|
|
|
|
|
|
// 获取综合自评详情
|
|
|
func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvaluation) (*adapter.EvaluationInfoAdapter, error) {
|
|
|
func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvaluation) (*adapter.EvaluationInfoSelfAdapter, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -299,7 +300,7 @@ func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvalu |
|
|
})
|
|
|
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"limit": 1,
|
|
|
"cycleId": param.CompanyId,
|
|
|
"cycleId": param.CycleId,
|
|
|
"executorId": param.UserId,
|
|
|
"types": domain.EvaluationSelf,
|
|
|
})
|
...
|
...
|
@@ -325,18 +326,23 @@ func (srv *SummaryEvaluationService) GetEvaluationSelf(param *command.QueryEvalu |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
result := srv.getSummaryEvaluation(transactionContext, evaluationData)
|
|
|
//获取组装基本信息
|
|
|
evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluationData)
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
|
|
|
|
|
|
result := adapter.EvaluationInfoSelfAdapter{
|
|
|
EvaluationBaseAdapter: evaluationBase,
|
|
|
}
|
|
|
result.EvaluationItems = itemValuesAdapter
|
|
|
return result, nil
|
|
|
return &result, nil
|
|
|
}
|
|
|
|
|
|
func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext application.TransactionContext, evaluationData *domain.SummaryEvaluation) *adapter.EvaluationInfoAdapter {
|
|
|
result := adapter.EvaluationInfoAdapter{
|
|
|
func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext application.TransactionContext, evaluationData *domain.SummaryEvaluation) adapter.EvaluationBaseAdapter {
|
|
|
result := adapter.EvaluationBaseAdapter{
|
|
|
SummaryEvaluationId: evaluationData.Id,
|
|
|
CycleId: int(evaluationData.CycleId),
|
|
|
CycleName: evaluationData.CycleName,
|
...
|
...
|
@@ -352,7 +358,6 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app |
|
|
SupperUser: "",
|
|
|
DutyTime: "",
|
|
|
Status: string(evaluationData.Status),
|
|
|
EvaluationItems: []adapter.EvaluationItemAdapter{},
|
|
|
}
|
|
|
//获取用户信息
|
|
|
companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
|
...
|
...
|
@@ -367,30 +372,30 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app |
|
|
})
|
|
|
|
|
|
if err != nil {
|
|
|
return &result
|
|
|
return result
|
|
|
}
|
|
|
|
|
|
userData, err := userRepo.FindOne(map[string]interface{}{
|
|
|
"id": evaluationData.TargetUser.UserId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return &result
|
|
|
return result
|
|
|
}
|
|
|
result.DutyTime = userData.EntryTime
|
|
|
result.CompanyLogo = companyData.Logo
|
|
|
result.CompanyName = companyData.Name
|
|
|
|
|
|
if userData.ParentId <= 0 {
|
|
|
return &result
|
|
|
return result
|
|
|
}
|
|
|
pUserData, err := userRepo.FindOne(map[string]interface{}{
|
|
|
"id": userData.ParentId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return &result
|
|
|
return result
|
|
|
}
|
|
|
result.SupperUser = pUserData.Name
|
|
|
return &result
|
|
|
return result
|
|
|
}
|
|
|
|
|
|
// 编辑综合自评详情
|
...
|
...
|
@@ -556,23 +561,7 @@ func (srv *SummaryEvaluationService) GetTargetUserCycleList(param *command.Query |
|
|
}
|
|
|
|
|
|
// 自评小结详情
|
|
|
func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.QueryEvaluation) (*adapter.EvaluationInfoAdapter, error) {
|
|
|
evaluationInfo, err := srv.GetEvaluationSelf(param)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
levelCodeMap := map[int][]adapter.LevalCodeCount{}
|
|
|
for _, v := range evaluationInfo.EvaluationItems {
|
|
|
codes := v.Rule.GetLevelCodes()
|
|
|
levelCode := []adapter.LevalCodeCount{}
|
|
|
for _, v2 := range codes {
|
|
|
levelCode = append(levelCode, adapter.LevalCodeCount{
|
|
|
Code: v2,
|
|
|
Number: 0,
|
|
|
})
|
|
|
}
|
|
|
levelCodeMap[v.EvaluationItemId] = levelCode
|
|
|
}
|
|
|
func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.QueryEvaluation) (*adapter.EvaluationInfoCountCodeAdapter, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
...
|
...
|
@@ -593,43 +582,396 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.Que |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"limit": 1,
|
|
|
"cycleId": param.CycleId,
|
|
|
"executorId": param.UserId,
|
|
|
"types": domain.EvaluationSelf,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(evaluationList) == 0 {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
evaluationData := evaluationList[0]
|
|
|
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|
|
|
"evaluationProjectId": evaluationData.EvaluationProjectId,
|
|
|
"nodeType": int(domain.LinkNodeSelfAssessment),
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
_, itemValues, err := itemValueRepo.Find(map[string]interface{}{
|
|
|
"summaryEvaluationId": evaluationData.Id,
|
|
|
})
|
|
|
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
// 获取组装基本信息
|
|
|
evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluationData)
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
evaluationItems := srv.buildSummaryItemValue(itemList, itemValues)
|
|
|
|
|
|
levelCodeMap := map[int][]adapter.LevalCodeCount{}
|
|
|
for _, v := range evaluationItems {
|
|
|
codes := v.Rule.GetLevelCodes()
|
|
|
levelCode := []adapter.LevalCodeCount{}
|
|
|
for _, v2 := range codes {
|
|
|
levelCode = append(levelCode, adapter.LevalCodeCount{
|
|
|
Code: v2,
|
|
|
Number: 0,
|
|
|
})
|
|
|
}
|
|
|
levelCodeMap[v.EvaluationItemId] = levelCode
|
|
|
}
|
|
|
levelCodeCountMap := map[string]int{}
|
|
|
for _, v := range levelCodeCountList {
|
|
|
key := fmt.Sprintf("%s-%s-%s", v.Category, v.Name, v.LevelValue)
|
|
|
levelCodeCountMap[key] = v.Cnt
|
|
|
}
|
|
|
|
|
|
for i := range evaluationInfo.EvaluationItems {
|
|
|
itemId := evaluationInfo.EvaluationItems[i].EvaluationItemId
|
|
|
evaluationItemCount := []adapter.EvaluationItemCountCodeAdapter{}
|
|
|
for i := range evaluationItems {
|
|
|
itemCount := adapter.EvaluationItemCountCodeAdapter{
|
|
|
EvaluationItemAdapter: evaluationItems[i],
|
|
|
LevelCount: []adapter.LevalCodeCount{},
|
|
|
}
|
|
|
evaluationItemCount = append(evaluationItemCount, itemCount)
|
|
|
itemId := evaluationItems[i].EvaluationItemId
|
|
|
levelCodes, ok := levelCodeMap[itemId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
evaluationInfo.EvaluationItems[i].LevelCount = levelCodes
|
|
|
evaluationItemCount[i].LevelCount = levelCodes
|
|
|
for i2 := range levelCodes {
|
|
|
key := fmt.Sprintf("%s-%s-%s",
|
|
|
evaluationInfo.EvaluationItems[i].Category,
|
|
|
evaluationInfo.EvaluationItems[i].Name,
|
|
|
evaluationItems[i].Category,
|
|
|
evaluationItems[i].Name,
|
|
|
levelCodes[i2].Code,
|
|
|
)
|
|
|
|
|
|
if mVal, ok := levelCodeCountMap[key]; ok {
|
|
|
levelCodes[i2].Number = mVal
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
evaluationInfo := adapter.EvaluationInfoCountCodeAdapter{
|
|
|
EvaluationBaseAdapter: evaluationBase,
|
|
|
EvaluationItems: evaluationItemCount,
|
|
|
}
|
|
|
return &evaluationInfo, nil
|
|
|
}
|
|
|
|
|
|
// GetEvaluationSuper 根据执行人获取上级评估详情
|
|
|
func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEvaluationSuper) (*adapter.EvaluationInfoSuperAdapter, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
evaluationItemRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{
|
|
|
"id": param.SummaryEvaluationId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if evaluationData.Types == domain.EvaluationSuper {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
|
|
|
}
|
|
|
if evaluationData.CompanyId == param.CompanyId {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
|
|
|
}
|
|
|
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
|
|
|
"evaluationProjectId": evaluationData.EvaluationProjectId,
|
|
|
"nodeType": int(domain.LinkNodeSelfAssessment),
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
//获取已填写的评估内容
|
|
|
_, itemValues, err := itemValueRepo.Find(map[string]interface{}{
|
|
|
"summaryEvaluationId": evaluationData.Id,
|
|
|
})
|
|
|
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(itemValues) == 0 {
|
|
|
//上级还未填写评估,获取 360 ,人资评估
|
|
|
_, evaluationListOther, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)},
|
|
|
"targetUserId": evaluationData.TargetUser.UserId,
|
|
|
"cycleId": evaluationData.CycleId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
evaluationIds := []int{}
|
|
|
for _, v := range evaluationListOther {
|
|
|
evaluationIds = append(evaluationIds, v.Id)
|
|
|
}
|
|
|
if len(evaluationIds) > 0 {
|
|
|
_, itemValues, err = itemValueRepo.Find(map[string]interface{}{
|
|
|
"summaryEvaluationIdList": evaluationIds,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluationData)
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
return evaluationInfo, nil
|
|
|
//组合 评估填写的值和评估项
|
|
|
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
|
|
|
codeList := []*adapter.LevalCodeCount{}
|
|
|
codeMap := map[string]*adapter.LevalCodeCount{}
|
|
|
for _, v := range itemValuesAdapter {
|
|
|
if v.Weight > 0 {
|
|
|
continue
|
|
|
}
|
|
|
if _, ok := codeMap[v.Value]; !ok {
|
|
|
code := &adapter.LevalCodeCount{
|
|
|
Code: v.Value,
|
|
|
Number: 0,
|
|
|
ItemList: []string{},
|
|
|
}
|
|
|
codeMap[v.Value] = code
|
|
|
codeList = append(codeList, code)
|
|
|
}
|
|
|
codeMap[v.Value].ItemList = append(codeMap[v.Value].ItemList, v.Name)
|
|
|
codeMap[v.Value].Number += 1
|
|
|
}
|
|
|
result := adapter.EvaluationInfoSuperAdapter{
|
|
|
EvaluationBaseAdapter: evaluationBase,
|
|
|
LevelCount: codeList,
|
|
|
EvaluationItems: itemValuesAdapter,
|
|
|
}
|
|
|
return &result, nil
|
|
|
}
|
|
|
|
|
|
// GetEvaluationSuper 根据执行人获取上级评估详情
|
|
|
func (srv *SummaryEvaluationService) GetEvaluationSuper() {
|
|
|
// EditEvaluationSuper 更新上级评估内容
|
|
|
func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEvaluationValue) (interface{}, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.StartTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
defer func() {
|
|
|
_ = transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
evaluationData, err := evaluationRepo.FindOne(map[string]interface{}{
|
|
|
"id": param.SummaryEvaluationId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if evaluationData.Types != domain.EvaluationSuper {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
}
|
|
|
|
|
|
if evaluationData.Executor.UserId != param.ExecutorId {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
}
|
|
|
|
|
|
if evaluationData.CompanyId != param.CompanyId {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有操作权限")
|
|
|
}
|
|
|
|
|
|
_, itemList, err := itemUsedRepo.Find(map[string]interface{}{
|
|
|
"evaluationProjectId": evaluationData.EvaluationProjectId,
|
|
|
"nodeType": domain.LinkNodeSelfAssessment,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
//获取已填写的评估内容
|
|
|
_, itemValueList, err := itemValueRepo.Find(map[string]interface{}{
|
|
|
"summaryEvaluationId": evaluationData.Id,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
//记录人资评估或者360评估的 填写项id
|
|
|
hrbpOr360ItemValue, err := srv.getEvaluationSuperDefaultValue(transactionContext, evaluationData)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
evaluationValueMap := map[int]*domain.SummaryEvaluationValue{}
|
|
|
for _, v := range itemList {
|
|
|
newValue := &domain.SummaryEvaluationValue{}
|
|
|
newValue.SetBlankValue(evaluationData, v)
|
|
|
evaluationValueMap[v.Id] = newValue
|
|
|
}
|
|
|
for _, v := range itemValueList {
|
|
|
if mValue, ok := evaluationValueMap[v.EvaluationItemId]; ok {
|
|
|
mValue.Id = v.Id
|
|
|
}
|
|
|
}
|
|
|
nowTime := time.Now()
|
|
|
for _, v := range param.EvaluationItems {
|
|
|
updatedData, ok := evaluationValueMap[v.EvaluationItemId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
if defaultValue, ok := hrbpOr360ItemValue[v.EvaluationItemId]; ok {
|
|
|
updatedData.Value = defaultValue.Value
|
|
|
} else {
|
|
|
updatedData.Value = v.Value
|
|
|
}
|
|
|
updatedData.UpdatedAt = nowTime
|
|
|
updatedData.Remark = v.Remark
|
|
|
//计算得分
|
|
|
err = updatedData.SummaryEvaluationScore()
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
evaluationValueList := []*domain.SummaryEvaluationValue{}
|
|
|
for _, v := range evaluationValueMap {
|
|
|
//保存填写值
|
|
|
err = itemValueRepo.Save(v)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
evaluationValueList = append(evaluationValueList, v)
|
|
|
}
|
|
|
//计算总得分
|
|
|
err = evaluationData.EvaluationTotalScore(evaluationValueList)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
evaluationData.UpdatedAt = nowTime
|
|
|
evaluationData.Status = domain.EvaluationCompleted
|
|
|
//保存填写值
|
|
|
err = evaluationRepo.Save(evaluationData)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
itemValueAdapter := srv.buildSummaryItemValue(itemList, evaluationValueList)
|
|
|
return map[string][]adapter.EvaluationItemAdapter{
|
|
|
"EvaluationItems": itemValueAdapter,
|
|
|
}, nil
|
|
|
}
|
|
|
|
|
|
// EditEvaluationSuper 更新上级评估
|
|
|
func (srv *SummaryEvaluationService) EditEvaluationSuper() {
|
|
|
// getEvaluationSuperDefaultValue
|
|
|
// 按照权限设置,是否获取上级评估内容的默认值
|
|
|
func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionContext application.TransactionContext, evaluationData *domain.SummaryEvaluation) (
|
|
|
map[int]*domain.SummaryEvaluationValue, error) {
|
|
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
itemValueRepo := factory.CreateSummaryEvaluationValueRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
|
|
|
permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})
|
|
|
// 获取权限配置
|
|
|
_, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": evaluationData.CompanyId})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if len(permissionList) == 0 {
|
|
|
return nil, nil
|
|
|
}
|
|
|
permissionData := permissionList[0]
|
|
|
if permissionData.OptEvalScore == domain.PermissionOn && permissionData.OptHrScore == domain.PermissionOn {
|
|
|
return nil, nil
|
|
|
}
|
|
|
// 获取360评估,人资评估填写的值
|
|
|
_, evaluationListOther, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"typesList": []int{int(domain.Evaluation360), int(domain.EvaluationHrbp)},
|
|
|
"targetUserId": evaluationData.TargetUser.UserId,
|
|
|
"cycleId": evaluationData.CycleId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
evaluationIds := []int{}
|
|
|
for _, v := range evaluationListOther {
|
|
|
evaluationIds = append(evaluationIds, v.Id)
|
|
|
}
|
|
|
if len(evaluationIds) == 0 {
|
|
|
return nil, nil
|
|
|
}
|
|
|
// 将360评估,人资评估填写的值 作为默认值
|
|
|
_, itemValuesOther, err := itemValueRepo.Find(map[string]interface{}{
|
|
|
"summaryEvaluationIdList": evaluationIds,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
// 记录人资评估或者360评估的 填写项id
|
|
|
hrbpOr360ItemValue := map[int]*domain.SummaryEvaluationValue{}
|
|
|
|
|
|
result := map[int]*domain.SummaryEvaluationValue{}
|
|
|
if permissionData.OptEvalScore == domain.PermissionOff {
|
|
|
//上级是否可以修改360°综评分数
|
|
|
//获取360综合评分
|
|
|
for _, v := range itemValuesOther {
|
|
|
//记录人资评估或者360评估的填写值
|
|
|
if v.Types != domain.Evaluation360 {
|
|
|
continue
|
|
|
}
|
|
|
hrbpOr360ItemValue[v.EvaluationItemId] = v
|
|
|
}
|
|
|
}
|
|
|
if permissionData.OptHrScore == domain.PermissionOff {
|
|
|
//上级是否可以修改人资综评分数
|
|
|
//获取人资综合评分
|
|
|
for _, v := range itemValuesOther {
|
|
|
//记录人资评估或者360评估的填写值
|
|
|
if v.Types != domain.EvaluationHrbp {
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
hrbpOr360ItemValue[v.EvaluationItemId] = v
|
|
|
}
|
|
|
}
|
|
|
return result, nil
|
|
|
} |
...
|
...
|
|