正在显示
3 个修改的文件
包含
24 行增加
和
23 行删除
| @@ -93,9 +93,9 @@ func (this *DepartmentStatisticsResponse) Less(i, j int) bool { | @@ -93,9 +93,9 @@ func (this *DepartmentStatisticsResponse) Less(i, j int) bool { | ||
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | //待审核 | 95 | //待审核 |
| 96 | - if this.List[i].ChanceApprovingTotal > this.List[j].ChanceApprovingTotal { | ||
| 97 | - return true | ||
| 98 | - } | 96 | + //if this.List[i].ChanceApprovingTotal > this.List[j].ChanceApprovingTotal { |
| 97 | + // return true | ||
| 98 | + //} | ||
| 99 | return false | 99 | return false |
| 100 | } | 100 | } |
| 101 | func (this *DepartmentStatisticsResponse) Swap(i, j int) { | 101 | func (this *DepartmentStatisticsResponse) Swap(i, j int) { |
| @@ -109,7 +109,7 @@ type DepartmentStatistics struct { | @@ -109,7 +109,7 @@ type DepartmentStatistics struct { | ||
| 109 | ChanceApprovingTotal int `json:"chanceApprovingTotal"` //待审核的机会 | 109 | ChanceApprovingTotal int `json:"chanceApprovingTotal"` //待审核的机会 |
| 110 | AchievementTotal int `json:"achievementTotal"` //已创建的成果 (显示) | 110 | AchievementTotal int `json:"achievementTotal"` //已创建的成果 (显示) |
| 111 | 111 | ||
| 112 | - ACTotal int `json:"-"` //机会成果总数 (显示) | 112 | + ACTotal int `json:"total"` //机会成果总数 (显示) |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | /*DepartmentStatistic 单部门统计*/ | 115 | /*DepartmentStatistic 单部门统计*/ |
| @@ -100,13 +100,13 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DepartmentStat | @@ -100,13 +100,13 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DepartmentStat | ||
| 100 | switch request.Type { | 100 | switch request.Type { |
| 101 | case protocol.StatisticApproved: | 101 | case protocol.StatisticApproved: |
| 102 | iterateDepartments(func(d *protocol.Department) *protocol.DepartmentStatistics { | 102 | iterateDepartments(func(d *protocol.Department) *protocol.DepartmentStatistics { |
| 103 | - rsp := &protocol.DepartmentStatistics{} | 103 | + item := &protocol.DepartmentStatistics{} |
| 104 | dIds := departmentsResponse.GetChildDepartmentIds(d, true) | 104 | dIds := departmentsResponse.GetChildDepartmentIds(d, true) |
| 105 | - rsp.AchievementTotal, _ = agg.AchievementDepartmentStatic(header, 0, dIds) | ||
| 106 | - rsp.ChanceApprovedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, 0, d.DepartmentId, true, 0, 0, nil) | ||
| 107 | - rsp.ACTotal = rsp.AchievementTotal + rsp.ChanceApprovedTotal | ||
| 108 | - rsp.ChanceApprovingTotal, _ = agg.ChanceApprovingStatistic(header, departmentsResponse.GetChildDepartmentIds(d, true)) | ||
| 109 | - return rsp | 105 | + item.AchievementTotal, _ = agg.AchievementDepartmentStatic(header, 0, dIds) |
| 106 | + item.ChanceApprovedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, 0, d.DepartmentId, true, 0, 0, nil) | ||
| 107 | + item.ACTotal = item.AchievementTotal + item.ChanceApprovedTotal | ||
| 108 | + item.ChanceApprovingTotal, _ = agg.ChanceApprovingStatistic(header, departmentsResponse.GetChildDepartmentIds(d, true)) | ||
| 109 | + return item | ||
| 110 | }) | 110 | }) |
| 111 | break | 111 | break |
| 112 | //case protocol.StatisticApproving: | 112 | //case protocol.StatisticApproving: |
| 1 | package department | 1 | package department |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/common" | ||
| 4 | "opp/protocol" | 5 | "opp/protocol" |
| 5 | "sort" | 6 | "sort" |
| 6 | "testing" | 7 | "testing" |
| @@ -33,21 +34,21 @@ func TestGetRootDepartment(t *testing.T) { | @@ -33,21 +34,21 @@ func TestGetRootDepartment(t *testing.T) { | ||
| 33 | //排序 | 34 | //排序 |
| 34 | func TestSortDepartmentStastics(t *testing.T) { | 35 | func TestSortDepartmentStastics(t *testing.T) { |
| 35 | s := &protocol.DepartmentStatisticsResponse{ | 36 | s := &protocol.DepartmentStatisticsResponse{ |
| 36 | - //List:[]*protocol.DepartmentStatistics{ | ||
| 37 | - // {ChanceApprovedTotal:10,AchievementTotal:10,ACTotal:20}, | ||
| 38 | - // {ChanceApprovedTotal:10,AchievementTotal:10,ACTotal:20}, | ||
| 39 | - // {ChanceApprovedTotal:20,AchievementTotal:10,ACTotal:30}, | ||
| 40 | - // {ChanceApprovedTotal:5,AchievementTotal:10,ACTotal:15}, | ||
| 41 | - //}, | ||
| 42 | List: []*protocol.DepartmentStatistics{ | 37 | List: []*protocol.DepartmentStatistics{ |
| 43 | - {ChanceApprovingTotal: 10}, | ||
| 44 | - {ChanceApprovingTotal: 10}, | ||
| 45 | - {ChanceApprovingTotal: 30}, | ||
| 46 | - {ChanceApprovingTotal: 40}, | ||
| 47 | - {ChanceApprovingTotal: 60}, | ||
| 48 | - {ChanceApprovingTotal: 50}, | 38 | + {ChanceApprovedTotal: 8, AchievementTotal: 12, ACTotal: 20}, |
| 39 | + {ChanceApprovedTotal: 12, AchievementTotal: 8, ACTotal: 20}, | ||
| 40 | + {ChanceApprovedTotal: 20, AchievementTotal: 20, ACTotal: 40}, | ||
| 41 | + {ChanceApprovedTotal: 5, AchievementTotal: 10, ACTotal: 15}, | ||
| 49 | }, | 42 | }, |
| 43 | + //List: []*protocol.DepartmentStatistics{ | ||
| 44 | + // {ChanceApprovingTotal: 10}, | ||
| 45 | + // {ChanceApprovingTotal: 10}, | ||
| 46 | + // {ChanceApprovingTotal: 30}, | ||
| 47 | + // {ChanceApprovingTotal: 40}, | ||
| 48 | + // {ChanceApprovingTotal: 60}, | ||
| 49 | + // {ChanceApprovingTotal: 50}, | ||
| 50 | + //}, | ||
| 50 | } | 51 | } |
| 51 | sort.Sort(s) | 52 | sort.Sort(s) |
| 52 | - //t.Log(common.AssertJson(s)) | 53 | + t.Log(common.AssertJson(s)) |
| 53 | } | 54 | } |
-
请 注册 或 登录 后发表评论