作者 tangxvhui

调整 综合自评必填项检查

... ... @@ -829,108 +829,6 @@ func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext a
return contentList, nil
}
// 选择员工评估可邀请的用户
// func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessInviteUser) (map[string]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()
// }()
// //获取被评估的目标用户
// userRepo := factory.CreateUserRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// //获取公司信息
// companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// companyInfo, _ := companyRepo.FindOne(map[string]interface{}{
// "id": param.CompanyId,
// })
// targetUser, err := userRepo.FindOne(map[string]interface{}{
// "id": param.TargetUserId,
// })
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工信息"+err.Error())
// }
// //获取被评估的目标用户的部门
// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// var targetUserDepartment []*domain.Department
// if len(targetUser.DepartmentId) > 0 {
// _, targetUserDepartment, err = departmentRepo.Find(map[string]interface{}{
// "ids": targetUser.DepartmentId,
// })
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())
// }
// }
// //获取部门主管的id
// targetUserCharge := map[int64]struct{}{}
// for _, v := range targetUserDepartment {
// for _, vv := range v.ChargeUserIds {
// targetUserCharge[vv] = struct{}{}
// }
// }
// //
// targetUserDepartmentMap := map[int64]struct{}{}
// for _, v := range targetUserDepartment {
// targetUserDepartmentMap[v.Id] = struct{}{}
// }
// //查询员工数据
// condition := map[string]interface{}{
// "companyId": param.CompanyId,
// "name": param.InviteUserName,
// "limit": 20,
// "status": 1,
// }
// if param.PageSize > 0 {
// condition["limit"] = param.PageSize
// }
// offset := (param.PageNumber - 1) * param.PageSize
// if offset > 0 {
// condition["offset"] = offset
// }
// cnt, userList, err := userRepo.Find(condition)
// 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())
// }
// listData := []adapter.SelectInviteUser{}
// companyName := ""
// if companyInfo != nil {
// companyName = companyInfo.Name
// }
// for _, v := range userList {
// item := adapter.SelectInviteUser{
// UserId: int(v.Id),
// UserName: v.Name,
// CompanyName: companyName,
// IsSupper: false,
// Types: 2, //默认是不同上级
// }
// if _, ok := targetUserCharge[v.Id]; ok {
// item.IsSupper = true
// }
// for _, vv := range v.DepartmentId {
// if _, ok := targetUserDepartmentMap[int64(vv)]; ok {
// item.Types = 1 //设为相同上级
// break
// }
// }
// listData = append(listData, item)
// }
// return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
// }
// 根据staffAssessId 获取评估的填写信息
func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
... ... @@ -1184,96 +1082,6 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
}
// 获取员工的上级是谁
// func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]*domain.User, error) {
// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// userRepo := factory.CreateUserRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// var departmemtList []*domain.Department
// var err error
// if len(targetUser.DepartmentId) > 0 {
// _, departmemtList, err = departmentRepo.Find(map[string]interface{}{
// "ids": targetUser.DepartmentId,
// })
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的部门列表"+err.Error())
// }
// }
// if len(departmemtList) == 0 {
// //找不到员工的部门
// companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// })
// companyData, err := companyRepo.FindOne(map[string]interface{}{
// "id": targetUser.CompanyId,
// })
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的公司"+err.Error())
// }
// //公司作为最顶级
// departmemtList = append(departmemtList, &domain.Department{
// Id: 0,
// CompanyId: companyData.Id,
// Level: 0,
// Name: companyData.Name,
// ParentId: 0,
// ChargeUserIds: companyData.ChargeUserIds,
// Path: "",
// CreatedAt: time.Time{},
// UpdatedAt: time.Time{},
// DeletedAt: &time.Time{},
// })
// }
// //获取部门管理员
// var chargeUserIds []int64
// var targetUserAsManager *domain.Department
// loop:
// for _, v := range departmemtList {
// if len(v.ChargeUserIds) == 0 {
// continue
// }
// //检查员工自身是否是管理员
// for _, vv := range v.ChargeUserIds {
// if vv == targetUser.Id {
// targetUserAsManager = v
// break loop
// }
// }
// chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)
// }
// if targetUserAsManager != nil {
// //清空原有的管理员
// chargeUserIds = []int64{}
// //员工自身是否是管理员,查找父级部门
// _, parentDepartment, err := departmentRepo.Find(map[string]interface{}{
// "id": targetUserAsManager.ParentId,
// })
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工现在部门的父级"+err.Error())
// }
// for _, v := range parentDepartment {
// chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)
// }
// }
// var chargeUserList []*domain.User
// if len(chargeUserIds) > 0 {
// _, chargeUserList, err = userRepo.Find(map[string]interface{}{
// "ids": chargeUserIds,
// "status": 1, //正常的用户
// })
// if err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取主管员工数据"+err.Error())
// }
// }
// return chargeUserList, nil
// }
// 获取员工的上级是谁
func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]*domain.User, error) {
if targetUser.ParentId == 0 {
return nil, nil
... ...
... ... @@ -705,7 +705,7 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
}
if len(assessList) == 0 {
return nil, application.ThrowError(application.BUSINESS_ERROR, "不存在员工的自评内容")
return &adapter.AssessInfoResp{AssessId: -1}, nil
}
assessData := assessList[0]
... ...
... ... @@ -1612,10 +1612,17 @@ func (srv *SummaryEvaluationService) editEvaluationValue(
continue
}
if !isTemporary {
// 评估项直接全部按必填项处理
if evaluationData.Types != domain.EvaluationSelf {
//除了综合自评,其他的评估任务 评估项直接全部按必填项处理
if len(v.Value) == 0 {
return fmt.Errorf("%s-%s 未填写", evaluationItem.Category, evaluationItem.Name)
}
} else if evaluationItem.Required == domain.NodeRequiredYes {
// 综合自评 评估项必填项处理
if len(v.Value) == 0 {
return fmt.Errorf("%s-%s 未填写", evaluationItem.Category, evaluationItem.Name)
}
}
}
//填充评估填写值
err := newItemValue.FillValue(evaluationItem, v.Value, v.Remark)
... ...
... ... @@ -20,7 +20,7 @@ type EvaluationItemUsed struct {
RuleType int //评估方式(0评级、1评分)
Rule EvaluationRule //评估的选项规则
Weight float64 //"权重"
Required int //必填项
Required int //必填项 同 NodeContent.Required
EvaluatorId int //项目评估人ID ( 0=无评估人、-1=HRBP、 >0 =员工的id )
CreatedAt time.Time //数据创建时间
UpdatedAt time.Time //数据更新时间
... ...