作者 tangxvhui

调整 综合自评必填项检查

@@ -829,108 +829,6 @@ func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext a @@ -829,108 +829,6 @@ func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext a
829 return contentList, nil 829 return contentList, nil
830 } 830 }
831 831
832 -// 选择员工评估可邀请的用户  
833 -// func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessInviteUser) (map[string]interface{}, error) {  
834 -// transactionContext, err := factory.CreateTransactionContext(nil)  
835 -// if err != nil {  
836 -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
837 -// }  
838 -// if err := transactionContext.StartTransaction(); err != nil {  
839 -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
840 -// }  
841 -// defer func() {  
842 -// _ = transactionContext.RollbackTransaction()  
843 -// }()  
844 -// //获取被评估的目标用户  
845 -// userRepo := factory.CreateUserRepository(map[string]interface{}{  
846 -// "transactionContext": transactionContext,  
847 -// })  
848 -// //获取公司信息  
849 -// companyRepo := factory.CreateCompanyRepository(map[string]interface{}{  
850 -// "transactionContext": transactionContext,  
851 -// })  
852 -// companyInfo, _ := companyRepo.FindOne(map[string]interface{}{  
853 -// "id": param.CompanyId,  
854 -// })  
855 -// targetUser, err := userRepo.FindOne(map[string]interface{}{  
856 -// "id": param.TargetUserId,  
857 -// })  
858 -// if err != nil {  
859 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工信息"+err.Error())  
860 -// }  
861 -// //获取被评估的目标用户的部门  
862 -// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{  
863 -// "transactionContext": transactionContext,  
864 -// })  
865 -// var targetUserDepartment []*domain.Department  
866 -// if len(targetUser.DepartmentId) > 0 {  
867 -// _, targetUserDepartment, err = departmentRepo.Find(map[string]interface{}{  
868 -// "ids": targetUser.DepartmentId,  
869 -// })  
870 -// if err != nil {  
871 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())  
872 -// }  
873 -// }  
874 -// //获取部门主管的id  
875 -// targetUserCharge := map[int64]struct{}{}  
876 -// for _, v := range targetUserDepartment {  
877 -// for _, vv := range v.ChargeUserIds {  
878 -// targetUserCharge[vv] = struct{}{}  
879 -// }  
880 -// }  
881 -// //  
882 -// targetUserDepartmentMap := map[int64]struct{}{}  
883 -// for _, v := range targetUserDepartment {  
884 -// targetUserDepartmentMap[v.Id] = struct{}{}  
885 -// }  
886 -// //查询员工数据  
887 -// condition := map[string]interface{}{  
888 -// "companyId": param.CompanyId,  
889 -// "name": param.InviteUserName,  
890 -// "limit": 20,  
891 -// "status": 1,  
892 -// }  
893 -// if param.PageSize > 0 {  
894 -// condition["limit"] = param.PageSize  
895 -// }  
896 -// offset := (param.PageNumber - 1) * param.PageSize  
897 -// if offset > 0 {  
898 -// condition["offset"] = offset  
899 -// }  
900 -// cnt, userList, err := userRepo.Find(condition)  
901 -// if err != nil {  
902 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工列表信息"+err.Error())  
903 -// }  
904 -// if err := transactionContext.CommitTransaction(); err != nil {  
905 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
906 -// }  
907 -// listData := []adapter.SelectInviteUser{}  
908 -// companyName := ""  
909 -// if companyInfo != nil {  
910 -// companyName = companyInfo.Name  
911 -// }  
912 -// for _, v := range userList {  
913 -// item := adapter.SelectInviteUser{  
914 -// UserId: int(v.Id),  
915 -// UserName: v.Name,  
916 -// CompanyName: companyName,  
917 -// IsSupper: false,  
918 -// Types: 2, //默认是不同上级  
919 -// }  
920 -// if _, ok := targetUserCharge[v.Id]; ok {  
921 -// item.IsSupper = true  
922 -// }  
923 -// for _, vv := range v.DepartmentId {  
924 -// if _, ok := targetUserDepartmentMap[int64(vv)]; ok {  
925 -// item.Types = 1 //设为相同上级  
926 -// break  
927 -// }  
928 -// }  
929 -// listData = append(listData, item)  
930 -// }  
931 -// return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil  
932 -// }  
933 -  
934 // 根据staffAssessId 获取评估的填写信息 832 // 根据staffAssessId 获取评估的填写信息
935 func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) { 833 func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
936 transactionContext, err := factory.CreateTransactionContext(nil) 834 transactionContext, err := factory.CreateTransactionContext(nil)
@@ -1184,96 +1082,6 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma @@ -1184,96 +1082,6 @@ func (srv StaffAssessServeice) SaveAssessInfo(param *command.SaveAssessInfoComma
1184 } 1082 }
1185 1083
1186 // 获取员工的上级是谁 1084 // 获取员工的上级是谁
1187 -// func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]*domain.User, error) {  
1188 -// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{  
1189 -// "transactionContext": transactionContext,  
1190 -// })  
1191 -// userRepo := factory.CreateUserRepository(map[string]interface{}{  
1192 -// "transactionContext": transactionContext,  
1193 -// })  
1194 -  
1195 -// var departmemtList []*domain.Department  
1196 -// var err error  
1197 -// if len(targetUser.DepartmentId) > 0 {  
1198 -// _, departmemtList, err = departmentRepo.Find(map[string]interface{}{  
1199 -// "ids": targetUser.DepartmentId,  
1200 -// })  
1201 -// if err != nil {  
1202 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的部门列表"+err.Error())  
1203 -// }  
1204 -// }  
1205 -// if len(departmemtList) == 0 {  
1206 -// //找不到员工的部门  
1207 -// companyRepo := factory.CreateCompanyRepository(map[string]interface{}{  
1208 -// "transactionContext": transactionContext,  
1209 -// })  
1210 -// companyData, err := companyRepo.FindOne(map[string]interface{}{  
1211 -// "id": targetUser.CompanyId,  
1212 -// })  
1213 -// if err != nil {  
1214 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的公司"+err.Error())  
1215 -// }  
1216 -// //公司作为最顶级  
1217 -// departmemtList = append(departmemtList, &domain.Department{  
1218 -// Id: 0,  
1219 -// CompanyId: companyData.Id,  
1220 -// Level: 0,  
1221 -// Name: companyData.Name,  
1222 -// ParentId: 0,  
1223 -// ChargeUserIds: companyData.ChargeUserIds,  
1224 -// Path: "",  
1225 -// CreatedAt: time.Time{},  
1226 -// UpdatedAt: time.Time{},  
1227 -// DeletedAt: &time.Time{},  
1228 -// })  
1229 -  
1230 -// }  
1231 -// //获取部门管理员  
1232 -// var chargeUserIds []int64  
1233 -// var targetUserAsManager *domain.Department  
1234 -// loop:  
1235 -// for _, v := range departmemtList {  
1236 -// if len(v.ChargeUserIds) == 0 {  
1237 -// continue  
1238 -// }  
1239 -// //检查员工自身是否是管理员  
1240 -// for _, vv := range v.ChargeUserIds {  
1241 -// if vv == targetUser.Id {  
1242 -// targetUserAsManager = v  
1243 -// break loop  
1244 -// }  
1245 -// }  
1246 -// chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)  
1247 -// }  
1248 -// if targetUserAsManager != nil {  
1249 -// //清空原有的管理员  
1250 -// chargeUserIds = []int64{}  
1251 -// //员工自身是否是管理员,查找父级部门  
1252 -// _, parentDepartment, err := departmentRepo.Find(map[string]interface{}{  
1253 -// "id": targetUserAsManager.ParentId,  
1254 -// })  
1255 -// if err != nil {  
1256 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工现在部门的父级"+err.Error())  
1257 -// }  
1258 -// for _, v := range parentDepartment {  
1259 -// chargeUserIds = append(chargeUserIds, v.ChargeUserIds...)  
1260 -// }  
1261 -// }  
1262 -  
1263 -// var chargeUserList []*domain.User  
1264 -// if len(chargeUserIds) > 0 {  
1265 -// _, chargeUserList, err = userRepo.Find(map[string]interface{}{  
1266 -// "ids": chargeUserIds,  
1267 -// "status": 1, //正常的用户  
1268 -// })  
1269 -// if err != nil {  
1270 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取主管员工数据"+err.Error())  
1271 -// }  
1272 -// }  
1273 -// return chargeUserList, nil  
1274 -// }  
1275 -  
1276 -// 获取员工的上级是谁  
1277 func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]*domain.User, error) { 1085 func (srv StaffAssessServeice) getStaffSuper(transactionContext application.TransactionContext, targetUser domain.User) ([]*domain.User, error) {
1278 if targetUser.ParentId == 0 { 1086 if targetUser.ParentId == 0 {
1279 return nil, nil 1087 return nil, nil
@@ -705,7 +705,7 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA @@ -705,7 +705,7 @@ func (srv StaffAssessServeice) GetAssessSelfInfoV2(param *query.GetExecutorSelfA
705 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error()) 705 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
706 } 706 }
707 if len(assessList) == 0 { 707 if len(assessList) == 0 {
708 - return nil, application.ThrowError(application.BUSINESS_ERROR, "不存在员工的自评内容") 708 + return &adapter.AssessInfoResp{AssessId: -1}, nil
709 } 709 }
710 assessData := assessList[0] 710 assessData := assessList[0]
711 711
@@ -1612,9 +1612,16 @@ func (srv *SummaryEvaluationService) editEvaluationValue( @@ -1612,9 +1612,16 @@ func (srv *SummaryEvaluationService) editEvaluationValue(
1612 continue 1612 continue
1613 } 1613 }
1614 if !isTemporary { 1614 if !isTemporary {
1615 - // 评估项直接全部按必填项处理  
1616 - if len(v.Value) == 0 {  
1617 - return fmt.Errorf("%s-%s 未填写", evaluationItem.Category, evaluationItem.Name) 1615 + if evaluationData.Types != domain.EvaluationSelf {
  1616 + //除了综合自评,其他的评估任务 评估项直接全部按必填项处理
  1617 + if len(v.Value) == 0 {
  1618 + return fmt.Errorf("%s-%s 未填写", evaluationItem.Category, evaluationItem.Name)
  1619 + }
  1620 + } else if evaluationItem.Required == domain.NodeRequiredYes {
  1621 + // 综合自评 评估项必填项处理
  1622 + if len(v.Value) == 0 {
  1623 + return fmt.Errorf("%s-%s 未填写", evaluationItem.Category, evaluationItem.Name)
  1624 + }
1618 } 1625 }
1619 } 1626 }
1620 //填充评估填写值 1627 //填充评估填写值
@@ -20,7 +20,7 @@ type EvaluationItemUsed struct { @@ -20,7 +20,7 @@ type EvaluationItemUsed struct {
20 RuleType int //评估方式(0评级、1评分) 20 RuleType int //评估方式(0评级、1评分)
21 Rule EvaluationRule //评估的选项规则 21 Rule EvaluationRule //评估的选项规则
22 Weight float64 //"权重" 22 Weight float64 //"权重"
23 - Required int //必填项 23 + Required int //必填项 同 NodeContent.Required
24 EvaluatorId int //项目评估人ID ( 0=无评估人、-1=HRBP、 >0 =员工的id ) 24 EvaluatorId int //项目评估人ID ( 0=无评估人、-1=HRBP、 >0 =员工的id )
25 CreatedAt time.Time //数据创建时间 25 CreatedAt time.Time //数据创建时间
26 UpdatedAt time.Time //数据更新时间 26 UpdatedAt time.Time //数据更新时间