作者 yangfu

部门统计修改

@@ -11,8 +11,8 @@ const ( @@ -11,8 +11,8 @@ const (
11 ) 11 )
12 12
13 const ( 13 const (
14 - StatisticApproved = 1 //统计已审核  
15 - StatisticApproving = 2 //统计审核中 14 + StatisticApproved = 0 //统计已审核
  15 + StatisticApproving = 0 //统计审核中
16 ) 16 )
17 17
18 /*Departments */ 18 /*Departments */
@@ -69,7 +69,7 @@ type Department struct { @@ -69,7 +69,7 @@ type Department struct {
69 /*DepartmentStatistics 部门统计*/ 69 /*DepartmentStatistics 部门统计*/
70 type DepartmentStatisticsRequest struct { 70 type DepartmentStatisticsRequest struct {
71 //DId int `json:"did"`//部门编号 //查询所有部门 查询特定部门 71 //DId int `json:"did"`//部门编号 //查询所有部门 查询特定部门
72 - Type int `json:"type"` //1:已审核 2:待审核 72 + Type int `json:"type"` //0:已审核 0:待审核
73 } 73 }
74 type DepartmentStatisticsResponse struct { 74 type DepartmentStatisticsResponse struct {
75 Total int `json:"total"` 75 Total int `json:"total"`
@@ -94,11 +94,7 @@ func DepartmentStatistics(header *protocol.RequestHeader, request *protocol.Depa @@ -94,11 +94,7 @@ func DepartmentStatistics(header *protocol.RequestHeader, request *protocol.Depa
94 Name: department.Name, 94 Name: department.Name,
95 } 95 }
96 rsp.List = append(rsp.List, item) 96 rsp.List = append(rsp.List, item)
97 - if request.Type == protocol.StatisticApproved {  
98 - rsp.Total += item.ChanceApprovedTotal + item.AchievementTotal  
99 - } else {  
100 - rsp.Total += item.ChanceApprovingTotal  
101 - } 97 + rsp.Total += item.ChanceApprovedTotal + item.AchievementTotal
102 } 98 }
103 } 99 }
104 switch request.Type { 100 switch request.Type {
@@ -109,16 +105,21 @@ func DepartmentStatistics(header *protocol.RequestHeader, request *protocol.Depa @@ -109,16 +105,21 @@ func DepartmentStatistics(header *protocol.RequestHeader, request *protocol.Depa
109 rsp.AchievementTotal, _ = agg.AchievementDepartmentStatic(header, 0, dIds) 105 rsp.AchievementTotal, _ = agg.AchievementDepartmentStatic(header, 0, dIds)
110 rsp.ChanceApprovedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, 0, d.DepartmentId, 0, 0, nil) 106 rsp.ChanceApprovedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, 0, d.DepartmentId, 0, 0, nil)
111 rsp.ACTotal = rsp.AchievementTotal + rsp.ChanceApprovedTotal 107 rsp.ACTotal = rsp.AchievementTotal + rsp.ChanceApprovedTotal
112 - return rsp  
113 - })  
114 - break  
115 - case protocol.StatisticApproving:  
116 - iterateDepartments(func(d *protocol.Department) *protocol.DepartmentStatistics {  
117 - rsp := &protocol.DepartmentStatistics{}  
118 rsp.ChanceApprovingTotal, _ = agg.ChanceApprovingStatistic(header, departmentsResponse.GetChildDepartmentIds(d, true)) 108 rsp.ChanceApprovingTotal, _ = agg.ChanceApprovingStatistic(header, departmentsResponse.GetChildDepartmentIds(d, true))
119 return rsp 109 return rsp
120 }) 110 })
121 break 111 break
  112 + //case protocol.StatisticApproving:
  113 + // iterateDepartments(func(d *protocol.Department) *protocol.DepartmentStatistics {
  114 + // rsp := &protocol.DepartmentStatistics{}
  115 + // dIds := departmentsResponse.GetChildDepartmentIds(d, true)
  116 + // rsp.AchievementTotal, _ = agg.AchievementDepartmentStatic(header, 0, dIds)
  117 + // rsp.ChanceApprovedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, 0, d.DepartmentId, 0, 0, nil)
  118 + // rsp.ACTotal = rsp.AchievementTotal + rsp.ChanceApprovedTotal
  119 + // rsp.ChanceApprovingTotal, _ = agg.ChanceApprovingStatistic(header, departmentsResponse.GetChildDepartmentIds(d, true))
  120 + // return rsp
  121 + // })
  122 + // break
122 default: 123 default:
123 err = protocol.NewErrWithMessage(2) 124 err = protocol.NewErrWithMessage(2)
124 return 125 return