作者 yangfu

机会池 成果池按部门统计修改

@@ -32,6 +32,7 @@ func (this *AchievementController) AchievementPool() { @@ -32,6 +32,7 @@ func (this *AchievementController) AchievementPool() {
32 return 32 return
33 } 33 }
34 header := controllers.GetRequestHeader(this.Ctx) 34 header := controllers.GetRequestHeader(this.Ctx)
  35 + request.IncludeSubDepartment = false
35 msg = protocol.NewReturnResponse(chance.AchievementPool(header, request)) 36 msg = protocol.NewReturnResponse(chance.AchievementPool(header, request))
36 } 37 }
37 38
@@ -611,7 +611,7 @@ func (this *ChanceController) ChancePool() { @@ -611,7 +611,7 @@ func (this *ChanceController) ChancePool() {
611 msg = m 611 msg = m
612 return 612 return
613 } 613 }
614 - request.IncludeSubDepartment = true 614 + request.IncludeSubDepartment = false
615 header := controllers.GetRequestHeader(this.Ctx) 615 header := controllers.GetRequestHeader(this.Ctx)
616 msg = protocol.NewReturnResponse(chance.ChancePool(header, request)) 616 msg = protocol.NewReturnResponse(chance.ChancePool(header, request))
617 } 617 }
@@ -85,9 +85,9 @@ func GetRankRanges(companyId int, rankTypeId int) (v []*RankRange, err error) { @@ -85,9 +85,9 @@ func GetRankRanges(companyId int, rankTypeId int) (v []*RankRange, err error) {
85 if companyId > 0 { 85 if companyId > 0 {
86 sql.Where(fmt.Sprintf("company_id=%v", companyId)) 86 sql.Where(fmt.Sprintf("company_id=%v", companyId))
87 } 87 }
88 - if rankTypeId > 0 {  
89 - sql.Where(fmt.Sprintf("rank_type_id=%v", rankTypeId))  
90 - } 88 + //if rankTypeId > 0 {
  89 + sql.Where(fmt.Sprintf("rank_type_id=%v", rankTypeId))
  90 + //}
91 sql.Order("sort_num") 91 sql.Order("sort_num")
92 _, err = sql.Querys(&v) 92 _, err = sql.Querys(&v)
93 return 93 return
@@ -47,11 +47,12 @@ type AchievementCommonListItem struct { @@ -47,11 +47,12 @@ type AchievementCommonListItem struct {
47 47
48 /*AchievementPool 成果池*/ 48 /*AchievementPool 成果池*/
49 type AchievementPoolRequest struct { 49 type AchievementPoolRequest struct {
50 - UserId int64 `json:"userId"`  
51 - LastId int64 `json:"lastId"`  
52 - PageSize int `json:"pageSize" valid:"Required"`  
53 - ChanceTypeId int `json:"chanceTypeId"` //0:所有机会 编号:对应机会类型编号的机会  
54 - DepartmentId int `json:"departmentId"` 50 + UserId int64 `json:"userId"`
  51 + LastId int64 `json:"lastId"`
  52 + PageSize int `json:"pageSize" valid:"Required"`
  53 + ChanceTypeId int `json:"chanceTypeId"` //0:所有机会 编号:对应机会类型编号的机会
  54 + DepartmentId int `json:"departmentId"`
  55 + IncludeSubDepartment bool
55 } 56 }
56 type AchievementPoolResponse struct { 57 type AchievementPoolResponse struct {
57 List []*AchievementCommonListItem `json:"list"` 58 List []*AchievementCommonListItem `json:"list"`
@@ -53,7 +53,7 @@ type RankType struct { @@ -53,7 +53,7 @@ type RankType struct {
53 53
54 /*GetRankRange */ 54 /*GetRankRange */
55 type GetRankRangeRequest struct { 55 type GetRankRangeRequest struct {
56 - RankTypeId int `json:"rankTypeId" valid:"Required"` 56 + RankTypeId int `json:"rankTypeId"` // valid:"Required"
57 } 57 }
58 type GetRankRangeResponse struct { 58 type GetRankRangeResponse struct {
59 List []RankRange `json:"rankRanges"` 59 List []RankRange `json:"rankRanges"`
@@ -66,7 +66,7 @@ type RankRange struct { @@ -66,7 +66,7 @@ type RankRange struct {
66 66
67 /*GetRankPeriods 获取榜单竞争范围列表*/ 67 /*GetRankPeriods 获取榜单竞争范围列表*/
68 type GetRankPeriodsRequest struct { 68 type GetRankPeriodsRequest struct {
69 - RankTypeId int `json:"rankTypeId" valid:"Required"` 69 + RankTypeId int `json:"rankTypeId"`
70 } 70 }
71 type GetRankPeriodsResponse struct { 71 type GetRankPeriodsResponse struct {
72 List []RankPeriod `json:"rankPeriods"` 72 List []RankPeriod `json:"rankPeriods"`
@@ -88,7 +88,7 @@ type ComputeRankScoreResponse struct { @@ -88,7 +88,7 @@ type ComputeRankScoreResponse struct {
88 88
89 /*GetRankSortItems */ 89 /*GetRankSortItems */
90 type GetRankSortItemsRequest struct { 90 type GetRankSortItemsRequest struct {
91 - RankTypeId int `json:"rankTypeId" valid:"Required"` 91 + RankTypeId int `json:"rankTypeId"`
92 } 92 }
93 type GetRankSortItemsResponse struct { 93 type GetRankSortItemsResponse struct {
94 RankSortItems []RankSortItem `json:"rankSortItems"` 94 RankSortItems []RankSortItem `json:"rankSortItems"`
@@ -19,7 +19,7 @@ func AchievementPool(header *protocol.RequestHeader, request *protocol.Achieveme @@ -19,7 +19,7 @@ func AchievementPool(header *protocol.RequestHeader, request *protocol.Achieveme
19 ) 19 )
20 rsp = &protocol.AchievementPoolResponse{} 20 rsp = &protocol.AchievementPoolResponse{}
21 rsp.List = make([]*protocol.AchievementCommonListItem, 0) 21 rsp.List = make([]*protocol.AchievementCommonListItem, 0)
22 - if request.DepartmentId > 0 { 22 + if request.DepartmentId > 0 && request.IncludeSubDepartment {
23 if d, e := models.GetDepartmentById(request.DepartmentId); e != nil { 23 if d, e := models.GetDepartmentById(request.DepartmentId); e != nil {
24 log.Error(err) 24 log.Error(err)
25 err = e 25 err = e
@@ -30,6 +30,10 @@ func AchievementPool(header *protocol.RequestHeader, request *protocol.Achieveme @@ -30,6 +30,10 @@ func AchievementPool(header *protocol.RequestHeader, request *protocol.Achieveme
30 return 30 return
31 } 31 }
32 } 32 }
  33 + } else {
  34 + if request.DepartmentId > 0 {
  35 + departmentIds = []int{request.DepartmentId}
  36 + }
33 } 37 }
34 if total, err = models.GetAchievementAll(request.UserId, header.CompanyId, request.ChanceTypeId, request.LastId, departmentIds, request.PageSize, &ormItems); err != nil { 38 if total, err = models.GetAchievementAll(request.UserId, header.CompanyId, request.ChanceTypeId, request.LastId, departmentIds, request.PageSize, &ormItems); err != nil {
35 if err == orm.ErrNoRows { 39 if err == orm.ErrNoRows {
@@ -125,6 +125,9 @@ func GetRankType(header *protocol.RequestHeader, request *protocol.GetRankTypeRe @@ -125,6 +125,9 @@ func GetRankType(header *protocol.RequestHeader, request *protocol.GetRankTypeRe
125 var ( 125 var (
126 lists []*models.RankType 126 lists []*models.RankType
127 ) 127 )
  128 + rsp = &protocol.GetRankTypeResponse{
  129 + List: make([]protocol.NameItem, 0),
  130 + }
128 if lists, err = models.GetRankTypes(header.CompanyId); err != nil { 131 if lists, err = models.GetRankTypes(header.CompanyId); err != nil {
129 if err == orm.ErrNoRows { 132 if err == orm.ErrNoRows {
130 err = nil 133 err = nil
@@ -133,7 +136,7 @@ func GetRankType(header *protocol.RequestHeader, request *protocol.GetRankTypeRe @@ -133,7 +136,7 @@ func GetRankType(header *protocol.RequestHeader, request *protocol.GetRankTypeRe
133 log.Error(err) 136 log.Error(err)
134 return 137 return
135 } 138 }
136 - rsp = &protocol.GetRankTypeResponse{} 139 +
137 for i := range lists { 140 for i := range lists {
138 rsp.List = append(rsp.List, protocol.NameItem{Id: lists[i].Id, Name: lists[i].Name}) 141 rsp.List = append(rsp.List, protocol.NameItem{Id: lists[i].Id, Name: lists[i].Name})
139 } 142 }
@@ -148,6 +151,9 @@ func GetRankRange(header *protocol.RequestHeader, request *protocol.GetRankRange @@ -148,6 +151,9 @@ func GetRankRange(header *protocol.RequestHeader, request *protocol.GetRankRange
148 rsp = &protocol.GetRankRangeResponse{ 151 rsp = &protocol.GetRankRangeResponse{
149 List: make([]protocol.RankRange, 0), 152 List: make([]protocol.RankRange, 0),
150 } 153 }
  154 + if request.RankTypeId == 0 {
  155 + return
  156 + }
151 if lists, err = models.GetRankRanges(int(header.CompanyId), request.RankTypeId); err != nil { 157 if lists, err = models.GetRankRanges(int(header.CompanyId), request.RankTypeId); err != nil {
152 if err == orm.ErrNoRows { 158 if err == orm.ErrNoRows {
153 err = nil 159 err = nil
@@ -177,6 +183,9 @@ func GetRankPeriods(header *protocol.RequestHeader, request *protocol.GetRankPer @@ -177,6 +183,9 @@ func GetRankPeriods(header *protocol.RequestHeader, request *protocol.GetRankPer
177 lists []*models.RankPeriod 183 lists []*models.RankPeriod
178 ) 184 )
179 rsp = &protocol.GetRankPeriodsResponse{List: make([]protocol.RankPeriod, 0)} 185 rsp = &protocol.GetRankPeriodsResponse{List: make([]protocol.RankPeriod, 0)}
  186 + if request.RankTypeId == 0 {
  187 + return
  188 + }
180 if lists, err = models.GetRankPeriods(int(header.CompanyId), request.RankTypeId, []int{protocol.RankPeriodBegin, protocol.RankPeriodEnd}); err != nil { 189 if lists, err = models.GetRankPeriods(int(header.CompanyId), request.RankTypeId, []int{protocol.RankPeriodBegin, protocol.RankPeriodEnd}); err != nil {
181 if err == orm.ErrNoRows { 190 if err == orm.ErrNoRows {
182 err = nil 191 err = nil
@@ -205,6 +214,9 @@ func GetRankSortItems(header *protocol.RequestHeader, request *protocol.GetRankS @@ -205,6 +214,9 @@ func GetRankSortItems(header *protocol.RequestHeader, request *protocol.GetRankS
205 rsp = &protocol.GetRankSortItemsResponse{ 214 rsp = &protocol.GetRankSortItemsResponse{
206 RankSortItems: make([]protocol.RankSortItem, 0), 215 RankSortItems: make([]protocol.RankSortItem, 0),
207 } 216 }
  217 + if request.RankTypeId == 0 {
  218 + return
  219 + }
208 if err = models.GetRankItems(header.CompanyId, request.RankTypeId, &sortItems); err != nil { 220 if err = models.GetRankItems(header.CompanyId, request.RankTypeId, &sortItems); err != nil {
209 if err == orm.ErrNoRows { 221 if err == orm.ErrNoRows {
210 err = nil 222 err = nil