作者 Your Name

更新

@@ -22,5 +22,4 @@ type AssessContent struct { @@ -22,5 +22,4 @@ type AssessContent struct {
22 PromptTitle string `json:"promptTitle" comment:"提示项标题"` 22 PromptTitle string `json:"promptTitle" comment:"提示项标题"`
23 PromptText string `json:"promptText" comment:"提示项正文"` 23 PromptText string `json:"promptText" comment:"提示项正文"`
24 EntryItems []domain.EntryItem `json:"entryItems" comment:"填写项"` 24 EntryItems []domain.EntryItem `json:"entryItems" comment:"填写项"`
25 - RuleId string  
26 } 25 }
  1 +package query
  2 +
  3 +type AssessInfoQuery struct {
  4 + AssessTaskId int `json:"assessTaskId"` //StaffAssess 的id
  5 + TargetUserId int `json:"targetUserId"` //被评估的人id
  6 + CompanyId int `json:"companyId"` //公司id
  7 +
  8 +}
1 -package query  
2 -  
3 -type AssessSelfInfo struct {  
4 - AssessId int `json:"assessId"` //StaffAssess 的id  
5 - UserId int `json:"userId"`  
6 - CompanyId int `json:"companyId"`  
7 -}  
@@ -660,6 +660,9 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv @@ -660,6 +660,9 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
660 targetUser, err := userRepo.FindOne(map[string]interface{}{ 660 targetUser, err := userRepo.FindOne(map[string]interface{}{
661 "id": param.TargetUserId, 661 "id": param.TargetUserId,
662 }) 662 })
  663 + if err != nil {
  664 + return nil, application.ThrowError(application.ARG_ERROR, "获取被评估员工"+err.Error())
  665 + }
663 //被评估人的部门 666 //被评估人的部门
664 var targetUserDepartment []domain.StaffDepartment 667 var targetUserDepartment []domain.StaffDepartment
665 if len(targetUser.DepartmentId) > 0 { 668 if len(targetUser.DepartmentId) > 0 {
@@ -676,7 +679,7 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv @@ -676,7 +679,7 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
676 }) 679 })
677 } 680 }
678 } 681 }
679 - //相同上级的员工 682 + //邀请的相同上级的员工
680 var inviteSameSuper []domain.StaffDesc 683 var inviteSameSuper []domain.StaffDesc
681 if len(inviteSameSuperId) > 0 { 684 if len(inviteSameSuperId) > 0 {
682 _, userList, err := userRepo.Find(map[string]interface{}{ 685 _, userList, err := userRepo.Find(map[string]interface{}{
@@ -693,22 +696,27 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv @@ -693,22 +696,27 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
693 }) 696 })
694 } 697 }
695 } 698 }
  699 + //邀请的不同上级的员工
696 var inviteDiffSuper []domain.StaffDesc 700 var inviteDiffSuper []domain.StaffDesc
697 if len(InviteDiffSuperId) > 0 { 701 if len(InviteDiffSuperId) > 0 {
698 _, userList, err := userRepo.Find(map[string]interface{}{ 702 _, userList, err := userRepo.Find(map[string]interface{}{
699 - "ids": inviteSameSuperId, 703 + "ids": InviteDiffSuperId,
700 }) 704 })
701 if err != nil { 705 if err != nil {
702 return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error()) 706 return nil, application.ThrowError(application.ARG_ERROR, "获取用户信息"+err.Error())
703 } 707 }
704 for _, v := range userList { 708 for _, v := range userList {
705 - inviteSameSuper = append(inviteSameSuper, domain.StaffDesc{ 709 + inviteDiffSuper = append(inviteDiffSuper, domain.StaffDesc{
706 UserId: int(v.Id), 710 UserId: int(v.Id),
707 UserName: v.Name, 711 UserName: v.Name,
708 Account: v.Account, 712 Account: v.Account,
709 }) 713 })
710 } 714 }
711 } 715 }
  716 + _ = assessReps
  717 + _ = inviteSameSuper
  718 + _ = inviteDiffSuper
  719 + _ = targetUserDepartment
712 // _, assessList, err := assessReps.Find(map[string]interface{}{ 720 // _, assessList, err := assessReps.Find(map[string]interface{}{
713 // "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)}, 721 // "typesList": []string{string(domain.AssessInviteDiffSuper), string(domain.AssessInviteSameSuper)},
714 // "staffAssessTaskId": param.AssessTaskId, 722 // "staffAssessTaskId": param.AssessTaskId,
@@ -717,6 +725,7 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv @@ -717,6 +725,7 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
717 // if err != nil { 725 // if err != nil {
718 // return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error()) 726 // return nil, application.ThrowError(application.ARG_ERROR, "获取个人评估任务"+err.Error())
719 // } 727 // }
  728 + // TODO
720 729
721 if err := transactionContext.CommitTransaction(); err != nil { 730 if err := transactionContext.CommitTransaction(); err != nil {
722 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 731 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -745,3 +754,94 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv @@ -745,3 +754,94 @@ func (srv StaffAssessServeice) SaveAssessInviteUser(param *command.SaveAssessInv
745 // } 754 // }
746 return &result, nil 755 return &result, nil
747 } 756 }
  757 +
  758 +// 获取员工自评的评估内容详情
  759 +func (srv StaffAssessServeice) GetAssessSelfInfo(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
  760 + transactionContext, err := factory.CreateTransactionContext(nil)
  761 + if err != nil {
  762 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  763 + }
  764 + if err := transactionContext.StartTransaction(); err != nil {
  765 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  766 + }
  767 + defer func() {
  768 + _ = transactionContext.RollbackTransaction()
  769 + }()
  770 + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
  771 + "transactionContext": transactionContext,
  772 + })
  773 +
  774 + //获取员工的评估
  775 + _, assessList, err := assessReps.Find(map[string]interface{}{
  776 + "companyId": param.CompanyId,
  777 + "staffAssessTaskId": param.AssessTaskId,
  778 + "targetUserId": param.TargetUserId,
  779 + "typesList": []string{string(domain.AssessSelf)},
  780 + })
  781 + if err != nil {
  782 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
  783 + }
  784 + if len(assessList) == 0 {
  785 + return &adapter.AssessInfoResp{}, nil
  786 + }
  787 + assessData := assessList[0]
  788 + projectRepo := factory.CreateEvaluationProjectRepository(map[string]interface{}{
  789 + "transactionContext": transactionContext,
  790 + })
  791 + projectData, err := projectRepo.FindOne(map[string]interface{}{
  792 + "id": assessData.EvaluationProjectId,
  793 + })
  794 + if err != nil {
  795 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目评估配置"+err.Error())
  796 + }
  797 + if projectData.Template == nil {
  798 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获取到项目评估配置模板")
  799 + }
  800 + var selfLinkNode *domain.LinkNode
  801 + for _, v := range projectData.Template.LinkNodes {
  802 + if v.Type == domain.LinkNodeSelfAssessment {
  803 + selfLinkNode = v
  804 + break
  805 + }
  806 + }
  807 + if selfLinkNode == nil {
  808 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未获取到项目评估自评配置")
  809 + }
  810 + //获取员工评估的填写内容
  811 + // assessContentReps := factory.CreateStaffAssessContentRepository(map[string]interface{}{
  812 + // "transactionContext": transactionContext,
  813 + // })
  814 + // _, assessContentList, err := assessContentReps.Find(map[string]interface{}{
  815 + // "staffAssessId": assessData.Id,
  816 + // })
  817 + // if err != nil {
  818 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目评估员工填写的内容"+err.Error())
  819 + // }
  820 + if err := transactionContext.CommitTransaction(); err != nil {
  821 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  822 + }
  823 +
  824 + result := adapter.AssessInfoResp{
  825 + CycleId: assessData.CycleId,
  826 + CycleName: assessData.CycleName,
  827 + EvaluationProjectId: assessData.EvaluationProjectId,
  828 + EvaluationProjectName: assessData.EvaluationProjectName,
  829 + BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"),
  830 + EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"),
  831 + Status: string(assessData.Status),
  832 + TargetUserId: assessData.TargetUser.UserId,
  833 + TargetUserName: assessData.TargetUser.UserName,
  834 + AssessContent: nil,
  835 + }
  836 + assessContent := make([]adapter.AssessContent, 0)
  837 + for _, v := range selfLinkNode.NodeContents {
  838 + assessContent = append(assessContent, adapter.AssessContent{
  839 + Category: v.Category,
  840 + Name: v.Name,
  841 + PromptTitle: v.PromptTitle,
  842 + PromptText: v.PromptText,
  843 + })
  844 + }
  845 + result.AssessContent = assessContent
  846 + return &result, nil
  847 +}
@@ -17,6 +17,11 @@ type StaffAssessContent struct { @@ -17,6 +17,11 @@ type StaffAssessContent struct {
17 //TODO 17 //TODO
18 } 18 }
19 19
  20 +type AssessContemtRemark struct {
  21 + Title string `json:"title"` //comment:"填写标题"
  22 + RemarkText string `json:"hintText"` // comment:"填写文本内容"
  23 +}
  24 +
20 type StaffAssessContentRepository interface { 25 type StaffAssessContentRepository interface {
21 Save(param *StaffAssessContent) (*StaffAssessContent, error) 26 Save(param *StaffAssessContent) (*StaffAssessContent, error)
22 Remove(id int) error 27 Remove(id int) error
@@ -89,7 +89,9 @@ func (repo *StaffAssessContentRepository) Find(queryOptions map[string]interface @@ -89,7 +89,9 @@ func (repo *StaffAssessContentRepository) Find(queryOptions map[string]interface
89 if v, ok := queryOptions["offset"].(int); ok { 89 if v, ok := queryOptions["offset"].(int); ok {
90 query.Offset(v) 90 query.Offset(v)
91 } 91 }
92 - 92 + if v, ok := queryOptions["staffAssessId"]; ok {
  93 + query.Where("staff_assess_id=?", v)
  94 + }
93 count, err := query.SelectAndCount() 95 count, err := query.SelectAndCount()
94 if err != nil { 96 if err != nil {
95 return 0, nil, err 97 return 0, nil, err