...
|
...
|
@@ -306,10 +306,10 @@ func (srv *SummaryEvaluationService) GetEvaluationSelfByCycle(param *command.Que |
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"limit": 1,
|
|
|
"cycleId": param.CycleId,
|
|
|
"executorId": param.UserId,
|
|
|
"types": domain.EvaluationSelf,
|
|
|
"limit": 1,
|
|
|
"cycleId": param.CycleId,
|
|
|
"targetUserId": param.TargetUserId,
|
|
|
"types": domain.EvaluationSelf,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -318,6 +318,9 @@ func (srv *SummaryEvaluationService) GetEvaluationSelfByCycle(param *command.Que |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
evaluationData := evaluationList[0]
|
|
|
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),
|
...
|
...
|
@@ -462,54 +465,19 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
evaluationItemMap := map[int]*domain.EvaluationItemUsed{}
|
|
|
evaluationValueMap := map[int]*domain.SummaryEvaluationValue{}
|
|
|
evaluationData.TotalRating = nil //清空评级数量统计
|
|
|
for _, v := range itemList {
|
|
|
newValue := &domain.SummaryEvaluationValue{}
|
|
|
newValue.SetBlankValue(evaluationData, v)
|
|
|
evaluationValueMap[v.Id] = newValue
|
|
|
evaluationItemMap[v.Id] = v
|
|
|
//重置计数
|
|
|
evaluationData.ResetTotalRating(v)
|
|
|
|
|
|
err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, nil)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
evaluationData.Status = domain.EvaluationCompleted
|
|
|
//保存填写值
|
|
|
for _, v := range itemValueList {
|
|
|
if mValue, ok := evaluationValueMap[v.EvaluationItemId]; ok {
|
|
|
mValue.Id = v.Id
|
|
|
}
|
|
|
}
|
|
|
for _, v := range param.EvaluationItems {
|
|
|
updatedData, ok := evaluationValueMap[v.EvaluationItemId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
evaluationItem, ok := evaluationItemMap[v.EvaluationItemId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
//填充评估填写值
|
|
|
err = updatedData.FillValue(evaluationItem, v.Value, v.Remark)
|
|
|
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.Status = domain.EvaluationCompleted
|
|
|
//保存填写值
|
|
|
err = evaluationRepo.Save(evaluationData)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -517,7 +485,7 @@ func (srv *SummaryEvaluationService) EditEvaluationSelf(param *command.EditEvalu |
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
itemValueAdapter := srv.buildSummaryItemValue(itemList, evaluationValueList)
|
|
|
itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
|
|
|
return map[string][]adapter.EvaluationItemAdapter{
|
|
|
"EvaluationItems": itemValueAdapter,
|
|
|
}, nil
|
...
|
...
|
@@ -588,7 +556,7 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.Que |
|
|
assessDao := dao.NewStaffAssessDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
levelCodeCountList, err := assessDao.CountAssessContentLevelCode(param.UserId, domain.AssessSelf, param.CycleId)
|
|
|
levelCodeCountList, err := assessDao.CountAssessContentLevelCode(param.TargetUserId, domain.AssessSelf, param.CycleId)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
...
|
...
|
@@ -603,10 +571,10 @@ func (srv *SummaryEvaluationService) CountEvaluationSelfLevel(param *command.Que |
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"limit": 1,
|
|
|
"cycleId": param.CycleId,
|
|
|
"executorId": param.UserId,
|
|
|
"types": domain.EvaluationSelf,
|
|
|
"limit": 1,
|
|
|
"cycleId": param.CycleId,
|
|
|
"targetUserId": param.TargetUserId,
|
|
|
"types": domain.EvaluationSelf,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -764,24 +732,6 @@ func (srv *SummaryEvaluationService) GetEvaluationSuper(param *command.QueryEval |
|
|
}
|
|
|
//组合 评估填写的值和评估项
|
|
|
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,
|
...
|
...
|
@@ -849,62 +799,20 @@ func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEval |
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
evaluationItemMap := map[int]*domain.EvaluationItemUsed{}
|
|
|
evaluationValueMap := map[int]*domain.SummaryEvaluationValue{}
|
|
|
evaluationData.TotalRating = nil //清空评级数量统计
|
|
|
for _, v := range itemList {
|
|
|
newValue := &domain.SummaryEvaluationValue{}
|
|
|
//初始一个空白的value
|
|
|
newValue.SetBlankValue(evaluationData, v)
|
|
|
evaluationValueMap[v.Id] = newValue
|
|
|
evaluationItemMap[v.Id] = v
|
|
|
//重置评级统计数量
|
|
|
evaluationData.ResetTotalRating(v)
|
|
|
}
|
|
|
for _, v := range itemValueList {
|
|
|
if mValue, ok := evaluationValueMap[v.EvaluationItemId]; ok {
|
|
|
mValue.Id = v.Id
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for _, v := range param.EvaluationItems {
|
|
|
updatedData, ok := evaluationValueMap[v.EvaluationItemId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
evaluationItem, ok := evaluationItemMap[v.EvaluationItemId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
if defaultValue, ok := hrbpOr360ItemValue[v.EvaluationItemId]; ok {
|
|
|
//填充值
|
|
|
err = updatedData.FillValue(evaluationItem, defaultValue.Value, v.Remark)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
} else {
|
|
|
err = updatedData.FillValue(evaluationItem, v.Value, v.Remark)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
err = srv.editEvaluationValue(evaluationData, &itemValueList, itemList, param.EvaluationItems, hrbpOr360ItemValue)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
evaluationValueList := []*domain.SummaryEvaluationValue{}
|
|
|
for _, v := range evaluationValueMap {
|
|
|
//变更评估状态为已填写
|
|
|
evaluationData.Status = domain.EvaluationCompleted
|
|
|
for _, v := range itemValueList {
|
|
|
//保存填写值
|
|
|
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.Status = domain.EvaluationCompleted
|
|
|
//保存填写值
|
|
|
err = evaluationRepo.Save(evaluationData)
|
|
|
if err != nil {
|
...
|
...
|
@@ -913,7 +821,7 @@ func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEval |
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
itemValueAdapter := srv.buildSummaryItemValue(itemList, evaluationValueList)
|
|
|
itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
|
|
|
return map[string][]adapter.EvaluationItemAdapter{
|
|
|
"EvaluationItems": itemValueAdapter,
|
|
|
}, nil
|
...
|
...
|
@@ -922,7 +830,7 @@ func (srv *SummaryEvaluationService) EditEvaluationSuper(param *command.EditEval |
|
|
// getEvaluationSuperDefaultValue
|
|
|
// 按照权限设置,是否获取上级评估内容的默认值
|
|
|
func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionContext application.TransactionContext, evaluationData *domain.SummaryEvaluation) (
|
|
|
map[int]*domain.SummaryEvaluationValue, error) {
|
|
|
[]*domain.SummaryEvaluationValue, error) {
|
|
|
evaluationRepo := factory.CreateSummaryEvaluationRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
})
|
...
|
...
|
@@ -968,9 +876,7 @@ func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionC |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
// 记录人资评估或者360评估的 填写项id
|
|
|
hrbpOr360ItemValue := map[int]*domain.SummaryEvaluationValue{}
|
|
|
|
|
|
result := map[int]*domain.SummaryEvaluationValue{}
|
|
|
hrbpOr360ItemValue := []*domain.SummaryEvaluationValue{}
|
|
|
if permissionData.OptEvalScore == domain.PermissionOff {
|
|
|
//上级是否可以修改360°综评分数
|
|
|
//获取360综合评分
|
...
|
...
|
@@ -979,7 +885,7 @@ func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionC |
|
|
if v.Types != domain.Evaluation360 {
|
|
|
continue
|
|
|
}
|
|
|
hrbpOr360ItemValue[v.EvaluationItemId] = v
|
|
|
hrbpOr360ItemValue = append(hrbpOr360ItemValue, v)
|
|
|
}
|
|
|
}
|
|
|
if permissionData.OptHrScore == domain.PermissionOff {
|
...
|
...
|
@@ -991,10 +897,10 @@ func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionC |
|
|
continue
|
|
|
}
|
|
|
|
|
|
hrbpOr360ItemValue[v.EvaluationItemId] = v
|
|
|
hrbpOr360ItemValue = append(hrbpOr360ItemValue, v)
|
|
|
}
|
|
|
}
|
|
|
return result, nil
|
|
|
return hrbpOr360ItemValue, nil
|
|
|
}
|
|
|
|
|
|
// 获取执行人的上级评估的列表
|
...
|
...
|
@@ -1209,10 +1115,10 @@ func (srv *SummaryEvaluationService) GetTargetUserEvaluationSuper(param *command |
|
|
"transactionContext": transactionContext,
|
|
|
})
|
|
|
_, evaluationList, err := evaluationRepo.Find(map[string]interface{}{
|
|
|
"limit": 1,
|
|
|
"cycleId": param.CycleId,
|
|
|
"executorId": param.UserId,
|
|
|
"types": domain.EvaluationSuper,
|
|
|
"limit": 1,
|
|
|
"cycleId": param.CycleId,
|
|
|
"targetUserId": param.TargetUserId,
|
|
|
"types": domain.EvaluationSuper,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -1221,9 +1127,6 @@ func (srv *SummaryEvaluationService) GetTargetUserEvaluationSuper(param *command |
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "没有找到符合条件的数据")
|
|
|
}
|
|
|
evaluationData := evaluationList[0]
|
|
|
// if evaluationData.Types == domain.EvaluationSuper {
|
|
|
// return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
|
|
|
// }
|
|
|
if evaluationData.CompanyId == param.CompanyId {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "没有操作权限")
|
|
|
}
|
...
|
...
|
@@ -1402,3 +1305,78 @@ func (srv *SummaryEvaluationService) ListAllEvaluationSuper(param *command.Query |
|
|
result := tool_funs.SimpleWrapGridMap(int64(cnt), evaluationListAdapter)
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
// editEvaluationValue 编辑评估的填写值
|
|
|
// evaluationData 对应的评估任务
|
|
|
// evaluationItems 对应的评估项
|
|
|
// oldItemValue 旧的评估项填写的值
|
|
|
// updatedValue 新填的评估值
|
|
|
// defaultItemvalue 评估项保持的默认值
|
|
|
func (srv *SummaryEvaluationService) editEvaluationValue(
|
|
|
evaluationData *domain.SummaryEvaluation,
|
|
|
itemValueList *[]*domain.SummaryEvaluationValue,
|
|
|
evaluationItems []*domain.EvaluationItemUsed,
|
|
|
updatedValue []command.UpdatedItemValue,
|
|
|
defaultItemValue []*domain.SummaryEvaluationValue,
|
|
|
) error {
|
|
|
evaluationItemMap := map[int]*domain.EvaluationItemUsed{}
|
|
|
evaluationValueMap := map[int]*domain.SummaryEvaluationValue{}
|
|
|
evaluationData.TotalRating = nil //清空评级数量统计
|
|
|
for _, v := range evaluationItems {
|
|
|
newValue := &domain.SummaryEvaluationValue{}
|
|
|
newValue.SetBlankValue(evaluationData, v)
|
|
|
evaluationValueMap[v.Id] = newValue
|
|
|
evaluationItemMap[v.Id] = v
|
|
|
//重置计数
|
|
|
evaluationData.ResetTotalRating(v)
|
|
|
}
|
|
|
//新值的id 替换为旧值id
|
|
|
for _, v := range *itemValueList {
|
|
|
if mValue, ok := evaluationValueMap[v.EvaluationItemId]; ok {
|
|
|
mValue.Id = v.Id
|
|
|
}
|
|
|
}
|
|
|
//填入填写的更新值
|
|
|
for _, v := range updatedValue {
|
|
|
newItemValue, ok := evaluationValueMap[v.EvaluationItemId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
evaluationItem, ok := evaluationItemMap[v.EvaluationItemId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
//填充评估填写值
|
|
|
err := newItemValue.FillValue(evaluationItem, v.Value, v.Remark)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
// 填入固定的默认值
|
|
|
for _, v := range defaultItemValue {
|
|
|
newItemValue, ok := evaluationValueMap[v.EvaluationItemId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
evaluationItem, ok := evaluationItemMap[v.EvaluationItemId]
|
|
|
if !ok {
|
|
|
continue
|
|
|
}
|
|
|
//填充评估填写值
|
|
|
err := newItemValue.FillValue(evaluationItem, v.Value, v.Remark)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
}
|
|
|
//完全更新itemValueList
|
|
|
*itemValueList = (*itemValueList)[0:0]
|
|
|
for _, v := range evaluationValueMap {
|
|
|
*itemValueList = append(*itemValueList, v)
|
|
|
}
|
|
|
// 计算总得分
|
|
|
err := evaluationData.EvaluationTotalScore(nil)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
return nil
|
|
|
} |
...
|
...
|
|