作者 yangfu

部门统计修改

... ... @@ -11,8 +11,8 @@ const (
)
const (
StatisticApproved = 1 //统计已审核
StatisticApproving = 2 //统计审核中
StatisticApproved = 0 //统计已审核
StatisticApproving = 0 //统计审核中
)
/*Departments */
... ... @@ -69,7 +69,7 @@ type Department struct {
/*DepartmentStatistics 部门统计*/
type DepartmentStatisticsRequest struct {
//DId int `json:"did"`//部门编号 //查询所有部门 查询特定部门
Type int `json:"type"` //1:已审核 2:待审核
Type int `json:"type"` //0:已审核 0:待审核
}
type DepartmentStatisticsResponse struct {
Total int `json:"total"`
... ...
... ... @@ -94,11 +94,7 @@ func DepartmentStatistics(header *protocol.RequestHeader, request *protocol.Depa
Name: department.Name,
}
rsp.List = append(rsp.List, item)
if request.Type == protocol.StatisticApproved {
rsp.Total += item.ChanceApprovedTotal + item.AchievementTotal
} else {
rsp.Total += item.ChanceApprovingTotal
}
}
}
switch request.Type {
... ... @@ -109,16 +105,21 @@ func DepartmentStatistics(header *protocol.RequestHeader, request *protocol.Depa
rsp.AchievementTotal, _ = agg.AchievementDepartmentStatic(header, 0, dIds)
rsp.ChanceApprovedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, 0, d.DepartmentId, 0, 0, nil)
rsp.ACTotal = rsp.AchievementTotal + rsp.ChanceApprovedTotal
return rsp
})
break
case protocol.StatisticApproving:
iterateDepartments(func(d *protocol.Department) *protocol.DepartmentStatistics {
rsp := &protocol.DepartmentStatistics{}
rsp.ChanceApprovingTotal, _ = agg.ChanceApprovingStatistic(header, departmentsResponse.GetChildDepartmentIds(d, true))
return rsp
})
break
//case protocol.StatisticApproving:
// iterateDepartments(func(d *protocol.Department) *protocol.DepartmentStatistics {
// rsp := &protocol.DepartmentStatistics{}
// dIds := departmentsResponse.GetChildDepartmentIds(d, true)
// rsp.AchievementTotal, _ = agg.AchievementDepartmentStatic(header, 0, dIds)
// rsp.ChanceApprovedTotal, _ = agg.GetChancePool(header.UserId, header.CompanyId, 0, d.DepartmentId, 0, 0, nil)
// rsp.ACTotal = rsp.AchievementTotal + rsp.ChanceApprovedTotal
// rsp.ChanceApprovingTotal, _ = agg.ChanceApprovingStatistic(header, departmentsResponse.GetChildDepartmentIds(d, true))
// return rsp
// })
// break
default:
err = protocol.NewErrWithMessage(2)
return
... ...