正在显示
1 个修改的文件
包含
21 行增加
和
25 行删除
@@ -585,44 +585,39 @@ func (srv StaffAssessServeice) createStaffAssessSupper( | @@ -585,44 +585,39 @@ func (srv StaffAssessServeice) createStaffAssessSupper( | ||
585 | userList []*domain.User, userDepartmentMap map[int64][]*domain.Department, | 585 | userList []*domain.User, userDepartmentMap map[int64][]*domain.Department, |
586 | ) ([]domain.StaffAssess, error) { | 586 | ) ([]domain.StaffAssess, error) { |
587 | var assessList []domain.StaffAssess | 587 | var assessList []domain.StaffAssess |
588 | - // 获取员工的上级用户 | ||
589 | - userRepo := factory.CreateUserRepository(map[string]interface{}{ | ||
590 | - "transactionContext": transactionContext, | ||
591 | - }) | ||
592 | for _, v := range userList { | 588 | for _, v := range userList { |
593 | - departmentList, ok := userDepartmentMap[v.Id] | ||
594 | - if !ok { | ||
595 | - continue | ||
596 | - } | ||
597 | - for _, vv2 := range departmentList { | ||
598 | - if len(vv2.ChargeUserIds) == 0 { | ||
599 | - continue | ||
600 | - } | ||
601 | - //获取部门的主管 | ||
602 | - _, chargeUserList, err := userRepo.Find(map[string]interface{}{ | ||
603 | - "ids": vv2.ChargeUserIds, | ||
604 | - "limit": 40, | ||
605 | - }) | 589 | + //获取上级 |
590 | + chargeUserList, err := srv.getStaffSuper(transactionContext, *v) | ||
606 | if err != nil { | 591 | if err != nil { |
607 | - return nil, application.ThrowError(application.ARG_ERROR, "获取部门主管信息"+err.Error()) | 592 | + return nil, err |
608 | } | 593 | } |
609 | - for _, vvv3 := range chargeUserList { | ||
610 | - assessTemp.TargetDepartment = []domain.StaffDepartment{ | ||
611 | - {DepartmentId: int(vv2.Id), DepartmentName: vv2.Name}, | 594 | + if len(chargeUserList) == 0 { |
595 | + continue | ||
612 | } | 596 | } |
597 | + for _, v2 := range chargeUserList { | ||
613 | assessTemp.TargetUser = domain.StaffDesc{ | 598 | assessTemp.TargetUser = domain.StaffDesc{ |
614 | UserId: int(v.Id), | 599 | UserId: int(v.Id), |
615 | Account: v.Account, | 600 | Account: v.Account, |
616 | UserName: v.Name, | 601 | UserName: v.Name, |
617 | } | 602 | } |
618 | assessTemp.Executor = domain.StaffDesc{ | 603 | assessTemp.Executor = domain.StaffDesc{ |
619 | - UserId: int(vvv3.Id), | ||
620 | - Account: vvv3.Account, | ||
621 | - UserName: vvv3.Name, | 604 | + UserId: int(v2.Id), |
605 | + Account: v2.Account, | ||
606 | + UserName: v2.Name, | ||
607 | + } | ||
608 | + targetDepartment := []domain.StaffDepartment{} | ||
609 | + if departmentList, ok := userDepartmentMap[v.Id]; ok { | ||
610 | + for _, department := range departmentList { | ||
611 | + targetDepartment = append(targetDepartment, domain.StaffDepartment{ | ||
612 | + DepartmentId: int(department.Id), | ||
613 | + DepartmentName: department.Name, | ||
614 | + }) | ||
622 | } | 615 | } |
623 | - assessList = append(assessList, assessTemp) | ||
624 | } | 616 | } |
617 | + assessTemp.TargetDepartment = targetDepartment | ||
618 | + assessList = append(assessList, assessTemp) | ||
625 | } | 619 | } |
620 | + | ||
626 | } | 621 | } |
627 | return assessList, nil | 622 | return assessList, nil |
628 | } | 623 | } |
@@ -1792,6 +1787,7 @@ func (srv StaffAssessServeice) getStaffSuper(transactionContext application.Tran | @@ -1792,6 +1787,7 @@ func (srv StaffAssessServeice) getStaffSuper(transactionContext application.Tran | ||
1792 | } | 1787 | } |
1793 | } | 1788 | } |
1794 | if len(departmemtList) == 0 { | 1789 | if len(departmemtList) == 0 { |
1790 | + //找不到员工的部门 | ||
1795 | companyRepo := factory.CreateCompanyRepository(map[string]interface{}{ | 1791 | companyRepo := factory.CreateCompanyRepository(map[string]interface{}{ |
1796 | "transactionContext": transactionContext, | 1792 | "transactionContext": transactionContext, |
1797 | }) | 1793 | }) |
-
请 注册 或 登录 后发表评论