作者 tangxvhui

修正一些错误

@@ -828,106 +828,106 @@ func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext a @@ -828,106 +828,106 @@ func (srv StaffAssessServeice) getAssessSelfInfoUncompleted(transactionContext a
828 } 828 }
829 829
830 // 选择员工评估可邀请的用户 830 // 选择员工评估可邀请的用户
831 -func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessInviteUser) (map[string]interface{}, error) {  
832 - transactionContext, err := factory.CreateTransactionContext(nil)  
833 - if err != nil {  
834 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
835 - }  
836 - if err := transactionContext.StartTransaction(); err != nil {  
837 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
838 - }  
839 - defer func() {  
840 - _ = transactionContext.RollbackTransaction()  
841 - }()  
842 - //获取被评估的目标用户  
843 - userRepo := factory.CreateUserRepository(map[string]interface{}{  
844 - "transactionContext": transactionContext,  
845 - })  
846 - //获取公司信息  
847 - companyRepo := factory.CreateCompanyRepository(map[string]interface{}{  
848 - "transactionContext": transactionContext,  
849 - })  
850 - companyInfo, _ := companyRepo.FindOne(map[string]interface{}{  
851 - "id": param.CompanyId,  
852 - })  
853 - targetUser, err := userRepo.FindOne(map[string]interface{}{  
854 - "id": param.TargetUserId,  
855 - })  
856 - if err != nil {  
857 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工信息"+err.Error())  
858 - }  
859 - //获取被评估的目标用户的部门  
860 - departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{  
861 - "transactionContext": transactionContext,  
862 - })  
863 - var targetUserDepartment []*domain.Department  
864 - if len(targetUser.DepartmentId) > 0 {  
865 - _, targetUserDepartment, err = departmentRepo.Find(map[string]interface{}{  
866 - "ids": targetUser.DepartmentId,  
867 - })  
868 - if err != nil {  
869 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())  
870 - }  
871 - }  
872 - //获取部门主管的id  
873 - targetUserCharge := map[int64]struct{}{}  
874 - for _, v := range targetUserDepartment {  
875 - for _, vv := range v.ChargeUserIds {  
876 - targetUserCharge[vv] = struct{}{}  
877 - }  
878 - }  
879 - //  
880 - targetUserDepartmentMap := map[int64]struct{}{}  
881 - for _, v := range targetUserDepartment {  
882 - targetUserDepartmentMap[v.Id] = struct{}{}  
883 - }  
884 - //查询员工数据  
885 - condition := map[string]interface{}{  
886 - "companyId": param.CompanyId,  
887 - "name": param.InviteUserName,  
888 - "limit": 20,  
889 - "status": 1,  
890 - }  
891 - if param.PageSize > 0 {  
892 - condition["limit"] = param.PageSize  
893 - }  
894 - offset := (param.PageNumber - 1) * param.PageSize  
895 - if offset > 0 {  
896 - condition["offset"] = offset  
897 - }  
898 - cnt, userList, err := userRepo.Find(condition)  
899 - if err != nil {  
900 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工列表信息"+err.Error())  
901 - }  
902 - if err := transactionContext.CommitTransaction(); err != nil {  
903 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
904 - }  
905 - listData := []adapter.SelectInviteUser{}  
906 - companyName := ""  
907 - if companyInfo != nil {  
908 - companyName = companyInfo.Name  
909 - }  
910 - for _, v := range userList {  
911 - item := adapter.SelectInviteUser{  
912 - UserId: int(v.Id),  
913 - UserName: v.Name,  
914 - CompanyName: companyName,  
915 - IsSupper: false,  
916 - Types: 2, //默认是不同上级  
917 - }  
918 - if _, ok := targetUserCharge[v.Id]; ok {  
919 - item.IsSupper = true  
920 - }  
921 - for _, vv := range v.DepartmentId {  
922 - if _, ok := targetUserDepartmentMap[int64(vv)]; ok {  
923 - item.Types = 1 //设为相同上级  
924 - break  
925 - }  
926 - }  
927 - listData = append(listData, item)  
928 - }  
929 - return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil  
930 -} 831 +// func (srv StaffAssessServeice) SelectAssessInviteUser(param *query.SelectAssessInviteUser) (map[string]interface{}, error) {
  832 +// transactionContext, err := factory.CreateTransactionContext(nil)
  833 +// if err != nil {
  834 +// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  835 +// }
  836 +// if err := transactionContext.StartTransaction(); err != nil {
  837 +// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  838 +// }
  839 +// defer func() {
  840 +// _ = transactionContext.RollbackTransaction()
  841 +// }()
  842 +// //获取被评估的目标用户
  843 +// userRepo := factory.CreateUserRepository(map[string]interface{}{
  844 +// "transactionContext": transactionContext,
  845 +// })
  846 +// //获取公司信息
  847 +// companyRepo := factory.CreateCompanyRepository(map[string]interface{}{
  848 +// "transactionContext": transactionContext,
  849 +// })
  850 +// companyInfo, _ := companyRepo.FindOne(map[string]interface{}{
  851 +// "id": param.CompanyId,
  852 +// })
  853 +// targetUser, err := userRepo.FindOne(map[string]interface{}{
  854 +// "id": param.TargetUserId,
  855 +// })
  856 +// if err != nil {
  857 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工信息"+err.Error())
  858 +// }
  859 +// //获取被评估的目标用户的部门
  860 +// departmentRepo := factory.CreateDepartmentRepository(map[string]interface{}{
  861 +// "transactionContext": transactionContext,
  862 +// })
  863 +// var targetUserDepartment []*domain.Department
  864 +// if len(targetUser.DepartmentId) > 0 {
  865 +// _, targetUserDepartment, err = departmentRepo.Find(map[string]interface{}{
  866 +// "ids": targetUser.DepartmentId,
  867 +// })
  868 +// if err != nil {
  869 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取部门信息"+err.Error())
  870 +// }
  871 +// }
  872 +// //获取部门主管的id
  873 +// targetUserCharge := map[int64]struct{}{}
  874 +// for _, v := range targetUserDepartment {
  875 +// for _, vv := range v.ChargeUserIds {
  876 +// targetUserCharge[vv] = struct{}{}
  877 +// }
  878 +// }
  879 +// //
  880 +// targetUserDepartmentMap := map[int64]struct{}{}
  881 +// for _, v := range targetUserDepartment {
  882 +// targetUserDepartmentMap[v.Id] = struct{}{}
  883 +// }
  884 +// //查询员工数据
  885 +// condition := map[string]interface{}{
  886 +// "companyId": param.CompanyId,
  887 +// "name": param.InviteUserName,
  888 +// "limit": 20,
  889 +// "status": 1,
  890 +// }
  891 +// if param.PageSize > 0 {
  892 +// condition["limit"] = param.PageSize
  893 +// }
  894 +// offset := (param.PageNumber - 1) * param.PageSize
  895 +// if offset > 0 {
  896 +// condition["offset"] = offset
  897 +// }
  898 +// cnt, userList, err := userRepo.Find(condition)
  899 +// if err != nil {
  900 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工列表信息"+err.Error())
  901 +// }
  902 +// if err := transactionContext.CommitTransaction(); err != nil {
  903 +// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  904 +// }
  905 +// listData := []adapter.SelectInviteUser{}
  906 +// companyName := ""
  907 +// if companyInfo != nil {
  908 +// companyName = companyInfo.Name
  909 +// }
  910 +// for _, v := range userList {
  911 +// item := adapter.SelectInviteUser{
  912 +// UserId: int(v.Id),
  913 +// UserName: v.Name,
  914 +// CompanyName: companyName,
  915 +// IsSupper: false,
  916 +// Types: 2, //默认是不同上级
  917 +// }
  918 +// if _, ok := targetUserCharge[v.Id]; ok {
  919 +// item.IsSupper = true
  920 +// }
  921 +// for _, vv := range v.DepartmentId {
  922 +// if _, ok := targetUserDepartmentMap[int64(vv)]; ok {
  923 +// item.Types = 1 //设为相同上级
  924 +// break
  925 +// }
  926 +// }
  927 +// listData = append(listData, item)
  928 +// }
  929 +// return tool_funs.SimpleWrapGridMap(int64(cnt), listData), nil
  930 +// }
931 931
932 // 根据staffAssessId 获取评估的填写信息 932 // 根据staffAssessId 获取评估的填写信息
933 func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) { 933 func (srv StaffAssessServeice) GetAssessInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
@@ -32,4 +32,6 @@ type EvaluationItemAdapter struct { @@ -32,4 +32,6 @@ type EvaluationItemAdapter struct {
32 Value string `json:"value"` //评估填写的评分 32 Value string `json:"value"` //评估填写的评分
33 Score string `json:"score"` //计算的评定得分 33 Score string `json:"score"` //计算的评定得分
34 Remark string `json:"remark"` //填写的内容反馈 34 Remark string `json:"remark"` //填写的内容反馈
  35 + //
  36 + //
35 } 37 }
@@ -416,19 +416,38 @@ func (srv *SummaryEvaluationServeice) EditEvaluationSelf(param *command.EditEval @@ -416,19 +416,38 @@ func (srv *SummaryEvaluationServeice) EditEvaluationSelf(param *command.EditEval
416 for _, v := range param.EvaluationItems { 416 for _, v := range param.EvaluationItems {
417 updatedData, ok := evaluationValueMap[v.EvaluationItemId] 417 updatedData, ok := evaluationValueMap[v.EvaluationItemId]
418 if !ok { 418 if !ok {
419 - updatedData.UpdatedAt = nowTime  
420 - updatedData.Value = v.Value  
421 - updatedData.Remark = v.Remark 419 + continue
  420 + }
  421 + updatedData.UpdatedAt = nowTime
  422 + updatedData.Value = v.Value
  423 + updatedData.Remark = v.Remark
  424 + //计算得分
  425 + err = updatedData.SummaryEvaluationScore()
  426 + if err != nil {
  427 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
422 } 428 }
423 } 429 }
  430 +
424 evaluationValueList := []*domain.SummaryEvaluationValue{} 431 evaluationValueList := []*domain.SummaryEvaluationValue{}
425 for _, v := range evaluationValueMap { 432 for _, v := range evaluationValueMap {
  433 + //保存填写值
426 err = itemValueRepo.Save(v) 434 err = itemValueRepo.Save(v)
427 if err != nil { 435 if err != nil {
428 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 436 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
429 } 437 }
430 evaluationValueList = append(evaluationValueList, v) 438 evaluationValueList = append(evaluationValueList, v)
431 } 439 }
  440 + //计算总得分
  441 + err = evaluationData.EvaluationTotalScore(evaluationValueList)
  442 + if err != nil {
  443 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  444 + }
  445 + evaluationData.UpdatedAt = nowTime
  446 + //保存填写值
  447 + err = evaluationRepo.Save(evaluationData)
  448 + if err != nil {
  449 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  450 + }
432 if err := transactionContext.CommitTransaction(); err != nil { 451 if err := transactionContext.CommitTransaction(); err != nil {
433 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 452 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
434 } 453 }
@@ -71,6 +71,6 @@ func (evaluation *SummaryEvaluation) EvaluationTotalScore(valueList []*SummaryEv @@ -71,6 +71,6 @@ func (evaluation *SummaryEvaluation) EvaluationTotalScore(valueList []*SummaryEv
71 71
72 totalScore += score 72 totalScore += score
73 } 73 }
74 - evaluation.TotalScore = fmt.Sprintf("%.2f", totalScore) 74 + evaluation.TotalScore = fmt.Sprintf("%.1f", totalScore)
75 return nil 75 return nil
76 } 76 }