作者 tangxvhui

更新 周期评估详情

... ... @@ -71,6 +71,7 @@ type EvaluationBaseAdapter struct {
Status string `json:"status"` //完成状态
CheckResult string `json:"checkResult"` //确认绩效结果
TotalScore string `json:"totalScore"` //评估总分
Version string `json:"version"` //评估填写方式
}
// 自评估内容详情
... ...
package service
import (
"fmt"
"strings"
"time"
"github.com/linmadan/egglib-go/core/application"
... ... @@ -172,15 +174,11 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(
}
var evaluationFinish *domain.SummaryEvaluation
noSuper := true
//查找综合评估结果
for _, v := range evaluationList {
if v.Types == domain.EvaluationFinish {
evaluationFinish = v
}
if v.Types == domain.EvaluationSuper {
noSuper = false
}
}
if len(targetEvaluation) == 0 {
//没有上级评估、360评估、hrbp 评估
... ... @@ -203,45 +201,154 @@ func (srv *SummaryEvaluationService) AfterCompletedEvaluationSelf(
}
}
}
_ = noSuper
// if noSuper && evaluationFinish != nil {
//没有上级评估 同步数据到考核结果
// itemUsedRepo := factory.CreateEvaluationItemUsedRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// _, itemList, err := itemUsedRepo.Find(map[string]interface{}{
// "evaluationProjectId": evaluationData.EvaluationProjectId,
// "nodeType": domain.LinkNodeSelfAssessment,
// })
// if err != nil {
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
// }
// //提取非360,hrbp 的评估项
// updateValue := []*domain.SummaryEvaluationValue{}
// for _, val := range itemList {
// if val.EvaluatorId != 0 {
// continue
// }
// for _, val2 := range evaluationValue {
// if val.Id == val2.EvaluationItemId {
// updateValue = append(updateValue, val2)
// break
// }
// }
// }
// //同步数据
// err = srv.syncEvaluationFinishValue(transactionContext, evaluationFinish, updateValue)
// if err != nil {
// return err
// }
// } else if len(targetEvaluation) == 0 && evaluationFinish != nil {
// err = evaluationRepo.Save(evaluationFinish)
// if err != nil {
// return application.ThrowError(application.INTERNAL_SERVER_ERROR, "保存考核结果,"+err.Error())
// }
// }
return nil
}
// 编辑综合自评详情
func (srv *SummaryEvaluationService) EditEvaluationSelfV2(param *command.EditEvaluationValue) (map[string][]adapter.EvaluationItemAdapter, 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.EvaluationSelf {
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, "没有操作权限")
}
//按照 被评估人加锁
lock := xredis.NewLockSummaryEvaluation(evaluationData.TargetUser.UserId)
err = lock.Lock()
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未能完全提交评估内容")
}
defer func() {
lock.UnLock()
}()
_, 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())
}
//更新填写值
var evaluationValueSlice []*domain.SummaryEvaluationValue // 提交的填写值
{
evaluationItemMap := map[int]*domain.EvaluationItemUsed{} // 需要填写那些项 Id=>&domain.EvaluationItemUsed{}
evaluationValueMap := map[int]*domain.SummaryEvaluationValue{} // 提交的填写值 EvaluationItemId=>&domain.domain.SummaryEvaluationValue{}
evaluationData.TotalRating = nil // 清空评级数量统计
// 按照需要填写那些项 设置SummaryEvaluationValue的空白值
for _, v := range itemList {
newValue := &domain.SummaryEvaluationValue{}
newValue.SetBlankValue(evaluationData, v)
evaluationValueMap[v.Id] = newValue
evaluationItemMap[v.Id] = v
evaluationValueSlice = append(evaluationValueSlice, newValue)
}
//如果存在旧值
//新值的id 替换为旧值id
for _, v := range itemValueList {
if mValue, ok := evaluationValueMap[v.EvaluationItemId]; ok {
mValue.Id = v.Id
}
}
//填入提交的更新值
for _, v := range param.EvaluationItems {
v.Value = strings.TrimSpace(v.Value)
newItemValue, ok := evaluationValueMap[v.EvaluationItemId]
if !ok {
continue
}
evaluationItem, ok := evaluationItemMap[v.EvaluationItemId]
if !ok {
continue
}
if !param.IsTemporary {
//除了综合自评,其他的评估任务 评估项直接全部按必填项处理
if len(v.Value) == 0 {
e := fmt.Sprintf("%s-%s 未填写", evaluationItem.Category, evaluationItem.Name)
return nil, application.ThrowError(application.BUSINESS_ERROR, e)
}
}
//填充评估填写值
newItemValue.Remark = v.Remark
err := evaluationData.FillItemValue(evaluationItem, newItemValue, v.Value)
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
}
evaluationData.EvaluationTotalScore(evaluationValueSlice)
}
if !param.IsTemporary {
evaluationData.Status = domain.EvaluationCompleted
//删除旧的填写值,使用新的填写内容
err = itemValueRepo.RemoveBySummaryEvaluationId(evaluationData.Id)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
for _, val := range itemValueList {
val.Id = 0
}
}
err = evaluationRepo.Save(evaluationData)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
//保存填写值
for _, v := range itemValueList {
err = itemValueRepo.Save(v)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if !param.IsTemporary {
err = srv.AfterCompletedEvaluationSelf(transactionContext, evaluationData, itemValueList)
if err != nil {
return nil, err
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
itemValueAdapter := srv.buildSummaryItemValue(itemList, itemValueList)
return map[string][]adapter.EvaluationItemAdapter{
"EvaluationItems": itemValueAdapter,
}, nil
}
... ...
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// GetEvaluation360Complete 获取360综评详情(他人评估目标用户)(已完成状态)
func (srv *SummaryEvaluationService) GetEvaluation360CompleteV2(param *command.QueryEvaluation360) (*adapter.EvaluationInfoSelfAdapter, error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
return nil, err
}
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})
_, evaluations, err := evaluationRepo.Find(map[string]interface{}{
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"targetUserId": param.TargetUserId,
"types": domain.Evaluation360,
"status": domain.EvaluationCompleted,
"limit": 1000,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluations) == 0 {
list := make([]adapter.EvaluationItemAdapter, 0)
res := adapter.EvaluationInfoSelfAdapter{
EvaluationItems: list,
}
return &res, nil
}
executorMap := map[int]domain.StaffDesc{} // 执行人
evaluationIds := make([]int, 0) // 评估周期ID
for i := range evaluations {
executor := evaluations[i].Executor
executorMap[executor.UserId] = executor
evaluationIds = append(evaluationIds, evaluations[i].Id)
}
// 得到项目ID
evaluationProjectId := evaluations[0].EvaluationProjectId
// 360评估内容(自评模板)
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": evaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 评估内容对应的分数
_, itemValues, err := itemValueRepo.Find(map[string]interface{}{
"summaryEvaluationIdList": evaluationIds,
"types": domain.Evaluation360,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
filterItemList := make([]*domain.EvaluationItemUsed, 0) // 筛选有评估人的评估内容
for i := range itemList {
if itemList[i].EvaluatorId > 0 {
filterItemList = append(filterItemList, itemList[i])
}
}
// 获取组装基本信息
evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluations[0])
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
itemValuesAdapter := srv.buildSummaryItemValue(filterItemList, itemValues)
for i := range itemValuesAdapter { // 评估人名称赋值
if executor, ok := executorMap[itemValuesAdapter[i].EvaluatorId]; ok {
itemValuesAdapter[i].EvaluatorName = executor.UserName
}
}
result := adapter.EvaluationInfoSelfAdapter{
EvaluationBaseAdapter: evaluationBase,
EvaluationItems: itemValuesAdapter,
}
return &result, nil
}
... ...
package service
import (
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/summary_evaluation/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
// GetEvaluationHRBPComplete 获取人资综评详情(他人评估目标用户)(已完成状态)
func (srv *SummaryEvaluationService) GetEvaluationHRBPCompleteV2(param *command.QueryEvaluationHRBP) (*adapter.EvaluationInfoSelfAdapter, error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
return nil, err
}
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})
_, evaluations, err := evaluationRepo.Find(map[string]interface{}{
"limit": 2,
"companyId": param.CompanyId,
"cycleId": param.CycleId,
"targetUserId": param.TargetUserId,
"status": domain.EvaluationCompleted,
"types": domain.EvaluationHrbp},
)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if len(evaluations) == 0 {
list := make([]adapter.EvaluationItemAdapter, 0)
res := adapter.EvaluationInfoSelfAdapter{
EvaluationItems: list,
}
return &res, nil
}
evaluationIds := make([]int, 0) // 评估周期ID
for i := range evaluations {
evaluationIds = append(evaluationIds, evaluations[i].Id)
}
// 得到项目ID
evaluationProjectId := evaluations[0].EvaluationProjectId
// 自评评估内容(自评模板、筛选项目评估人)
_, itemList, err := evaluationItemRepo.Find(map[string]interface{}{
"evaluationProjectId": evaluationProjectId,
"nodeType": domain.LinkNodeSelfAssessment,
"evaluatorId": -1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 评估内容对应的分数
_, itemValues, err := itemValueRepo.Find(map[string]interface{}{
"summaryEvaluationIdList": evaluationIds,
"types": domain.EvaluationHrbp,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 获取组装基本信息
evaluationBase := srv.getSummaryEvaluation(transactionContext, evaluations[0])
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
itemValuesAdapter := srv.buildSummaryItemValue(itemList, itemValues)
for i := range itemValuesAdapter { // 评估人名称赋值
itemValuesAdapter[i].EvaluatorName = evaluations[0].Executor.UserName
}
result := adapter.EvaluationInfoSelfAdapter{
EvaluationBaseAdapter: evaluationBase,
EvaluationItems: itemValuesAdapter,
}
return &result, nil
}
... ...
... ... @@ -453,6 +453,7 @@ func (srv *SummaryEvaluationService) getSummaryEvaluation(transactionContext app
Status: string(evaluationData.Status),
CheckResult: string(evaluationData.CheckResult),
TotalScore: evaluationData.TotalScore,
Version: evaluationData.Version,
}
//获取用户信息
companyRepo := factory.CreateCompanyRepository(map[string]interface{}{"transactionContext": transactionContext})
... ...
... ... @@ -239,11 +239,11 @@ func (srv *SummaryEvaluationService) GetEvaluation360(param *command.QueryEvalua
}
// 评估项截止时间
endTime := sEvaluation.EndTime.Local().Format("2006-01-02 15:04:05")
return map[string]interface{}{"endTime": endTime, "list": itemValuesAdapter}, nil
return map[string]interface{}{"endTime": endTime, "version": sEvaluation.Version, "list": itemValuesAdapter}, nil
}
// GetEvaluation360Complete 获取360综评详情(他人评估目标用户)(已完成状态)
func (srv *SummaryEvaluationService) GetEvaluation360Complete(param *command.QueryEvaluation360) (*[]adapter.EvaluationItemAdapter, error) {
func (srv *SummaryEvaluationService) GetEvaluation360Complete(param *command.QueryEvaluation360) ([]adapter.EvaluationItemAdapter, error) {
transactionContext, err := factory.ValidateStartTransaction(param)
if err != nil {
return nil, err
... ... @@ -261,7 +261,7 @@ func (srv *SummaryEvaluationService) GetEvaluation360Complete(param *command.Que
"targetUserId": param.TargetUserId,
"types": domain.Evaluation360,
"status": domain.EvaluationCompleted,
"limit": 99999,
"limit": 1000,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -269,7 +269,7 @@ func (srv *SummaryEvaluationService) GetEvaluation360Complete(param *command.Que
if len(evaluations) == 0 {
list := make([]adapter.EvaluationItemAdapter, 0)
return &list, nil
return list, nil
}
executorMap := map[int]domain.StaffDesc{} // 执行人
... ... @@ -306,7 +306,6 @@ func (srv *SummaryEvaluationService) GetEvaluation360Complete(param *command.Que
filterItemList = append(filterItemList, itemList[i])
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -317,22 +316,7 @@ func (srv *SummaryEvaluationService) GetEvaluation360Complete(param *command.Que
itemValuesAdapter[i].EvaluatorName = executor.UserName
}
}
//result := adapter.EvaluationInfoAdapter{
// SummaryEvaluationId: sEvaluation.Id,
// CycleId: int(sEvaluation.CycleId),
// CycleName: sEvaluation.CycleName,
// EvaluationProjectId: sEvaluation.EvaluationProjectId,
// EvaluationProjectName: sEvaluation.EvaluationProjectName,
// LinkNodeId: sEvaluation.NodeId,
// BeginTime: sEvaluation.BeginTime.Format("2006-01-02 15:04:05"),
// EndTime: sEvaluation.EndTime.Format("2006-01-02 15:04:05"),
// TargetUserId: sEvaluation.TargetUser.UserId,
// TargetUserName: sEvaluation.TargetUser.UserName,
// Status: string(sEvaluation.Status),
// EvaluationItems: itemValuesAdapter,
//}
return &itemValuesAdapter, nil
return itemValuesAdapter, nil
}
// EvaluationHRBPList 获取人资综评列表
... ... @@ -549,7 +533,7 @@ func (srv *SummaryEvaluationService) GetEvaluationHRBP(param *command.QueryEvalu
// 评估项截止时间
endTime := sEvaluation.EndTime.Local().Format("2006-01-02 15:04:05")
return map[string]interface{}{"endTime": endTime, "list": itemValuesAdapter}, nil
return map[string]interface{}{"endTime": endTime, "version": sEvaluation.Version, "list": itemValuesAdapter}, nil
}
// GetEvaluationHRBPComplete 获取人资综评详情(已完成状态)
... ...
... ... @@ -25,7 +25,7 @@ type SummaryEvaluation struct {
EndTime time.Time `json:"endTime"` //截止时间
TotalScore string `json:"totalScore"` //最终上级评估得分.
TotalRating []RatingCodeNumber `json:"totalRating"` //汇总各个评级的数量
Version string `json:"version"` //填写评估值的规则版本 v1,v2
Version string `json:"version"` //填写评估值的规则版本 v1,v2 ,填写方式对应方法 SummaryEvaluation.FillItemValue
CreatedAt time.Time `json:"createdAt"` //数据创建时间
UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
DeletedAt *time.Time `json:"deletedAt"` //数据删除时间
... ...
... ... @@ -180,6 +180,21 @@ func (c *SummaryEvaluationController) GetEvaluation360Complete() {
c.Response(data, err)
}
func (c *SummaryEvaluationController) GetEvaluation360CompleteV2() {
srv := service.NewSummaryEvaluationService()
in := &command.QueryEvaluation360{}
err := c.BindJSON(in)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
in.CompanyId = int(userReq.CompanyId)
data, err := srv.GetEvaluation360CompleteV2(in)
c.Response(data, err)
}
func (c *SummaryEvaluationController) EditEvaluation360() {
srv := service.NewSummaryEvaluationService()
in := &command.EditEvaluationValue{}
... ... @@ -242,6 +257,21 @@ func (c *SummaryEvaluationController) GetEvaluationHRBPComplete() {
c.Response(data, err)
}
func (c *SummaryEvaluationController) GetEvaluationHRBPCompleteV2() {
srv := service.NewSummaryEvaluationService()
in := &command.QueryEvaluationHRBP{}
err := c.BindJSON(in)
if err != nil {
e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
c.Response(nil, e)
return
}
userReq := middlewares.GetUser(c.Ctx)
in.CompanyId = int(userReq.CompanyId)
data, err := srv.GetEvaluationHRBPCompleteV2(in)
c.Response(data, err)
}
func (c *SummaryEvaluationController) EditEvaluationHRBP() {
srv := service.NewSummaryEvaluationService()
in := &command.EditEvaluationValue{}
... ...
... ... @@ -42,6 +42,8 @@ func init() {
web.NSBefore(filters.AllowCors(), middlewares.CheckFontToken()),
web.NSCtrlPost("/self/summary", (*controllers.SummaryEvaluationController).CountEvaluationSelfLevelV2),
web.NSCtrlPost("/cycle_project/list", (*controllers.SummaryEvaluationController).ListCycleAndProject),
web.NSCtrlPost("/evaluation-360all", (*controllers.SummaryEvaluationController).GetEvaluation360CompleteV2),
web.NSCtrlPost("/evaluation-hrAll", (*controllers.SummaryEvaluationController).GetEvaluationHRBPCompleteV2),
)
web.AddNamespace(summaryV2)
}
... ...