Blame view

fw-morax-server/src/main/java/cn/fw/morax/server/controller/app/EvalPoolController.java 12.4 KB
bf4d326c   姜超   feature(*): 控制器修改
1
2
3
4
5
6
7
8
9
10
  package cn.fw.morax.server.controller.app;
  
  
  import cn.fw.common.exception.BusinessException;
  import cn.fw.common.page.AppPage;
  import cn.fw.common.web.annotation.ControllerMethod;
  import cn.fw.common.web.auth.LoginAuthBean;
  import cn.fw.common.web.auth.annotation.CurrentUser;
  import cn.fw.data.base.domain.common.Message;
  import cn.fw.morax.common.utils.PublicUtil;
bf4d326c   姜超   feature(*): 控制器修改
11
  import cn.fw.morax.domain.dto.eval.EvalGroupIndicatorRankDTO;
a9445e72   姜超   feature(*): 查看考评详情
12
  import cn.fw.morax.domain.dto.eval.EvalUserRankDTO;
bf4d326c   姜超   feature(*): 控制器修改
13
  import cn.fw.morax.domain.dto.query.EvalPoolQueryDTO;
e1778851   姜超   feature(*): 计算考评调整
14
  import cn.fw.morax.domain.enums.EvalScopeEnum;
c043db4c   姜超   feature(*): 查看考评详情
15
  import cn.fw.morax.domain.vo.EvalPoolVO;
19325c46   姜超   feature(*): 查看考评详情
16
  import cn.fw.morax.domain.vo.EvalSelectorVO;
bf4d326c   姜超   feature(*): 控制器修改
17
18
  import cn.fw.morax.domain.vo.eval.*;
  import cn.fw.morax.domain.vo.kpi.KpiIndicatorRankVO;
bf4d326c   姜超   feature(*): 控制器修改
19
20
21
22
23
24
25
26
27
28
  import cn.fw.morax.service.biz.eval.*;
  import cn.fw.security.auth.client.annotation.Authorization;
  import cn.fw.security.auth.client.annotation.IgnoreAuth;
  import cn.fw.security.auth.client.annotation.IgnoreUserToken;
  import cn.fw.security.auth.client.enums.AuthType;
  import lombok.RequiredArgsConstructor;
  import lombok.extern.slf4j.Slf4j;
  import org.springframework.validation.annotation.Validated;
  import org.springframework.web.bind.annotation.*;
  
a9445e72   姜超   feature(*): 查看考评详情
29
  import javax.validation.Valid;
bf4d326c   姜超   feature(*): 控制器修改
30
31
32
  import javax.validation.constraints.NotNull;
  import java.time.LocalDate;
  import java.time.YearMonth;
5ff2c525   姜超   feature(*): 并列排名计算
33
  import java.util.List;
bf4d326c   姜超   feature(*): 控制器修改
34
  import java.util.Objects;
bf4d326c   姜超   feature(*): 控制器修改
35
  
5ff2c525   姜超   feature(*): 并列排名计算
36
  import static cn.fw.common.businessvalidator.Validator.BV;
bf4d326c   姜超   feature(*): 控制器修改
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  import static cn.fw.common.web.util.ResultBuilder.success;
  
  /**
   * 考评池
   *
   * @author jiangchao
   * @since 2022-11-09
   */
  @Slf4j
  @RequiredArgsConstructor
  @Authorization(AuthType.APP)
  @Validated
  @IgnoreAuth
  @RestController
  @RequestMapping("/app/eval-pool")
  public class EvalPoolController {
  
      private final EvalPoolService evalPoolService;
      private final EvalGroupPoolService evalGroupPoolService;
bf4d326c   姜超   feature(*): 控制器修改
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  
      /**
       * 人员考评池列表
       *
       * @param dto
       * @return
       * @ignoreParams currentUser
       */
      @GetMapping("/staffs")
      @ControllerMethod("人员考评池列表")
      public Message<AppPage<EvalUserPoolVO>> queryUserPool(@Validated EvalPoolQueryDTO dto) {
          if (PublicUtil.isEmpty(dto.getMonthly())) {
              dto.setMonthly(YearMonth.now());
          }
          return success(evalPoolService.queryUserPool(dto));
      }
  
      /**
bf4d326c   姜超   feature(*): 控制器修改
74
75
76
77
       * 本月可查看的其他考评池选项
       *
       * @param user      用户id
       * @param userId    用户id [管理层查看人员薪酬详情时需传值]
b5babc65   姜超   feature(*): 参数修改
78
       * @param monthly 月度 [员工人查看自己的酬详情时需传值]
bf4d326c   姜超   feature(*): 控制器修改
79
80
81
82
83
84
       * @return 薪酬池选项
       * @ignoreParams user
       */
      @GetMapping("/staff-selector")
      @IgnoreUserToken
      @ControllerMethod("本月可查看的其他考评池选项")
c043db4c   姜超   feature(*): 查看考评详情
85
86
      public Message<EvalPoolVO> evalPoolSelector(@CurrentUser LoginAuthBean user, Long userId,
                                                  @RequestParam(required = false) YearMonth monthly) {
b5babc65   姜超   feature(*): 参数修改
87
88
          if (Objects.isNull(monthly)) {
              monthly = YearMonth.now();
bf4d326c   姜超   feature(*): 控制器修改
89
90
91
92
          }
          if (Objects.isNull(userId)) {
              userId = user.getUserId();
          }
ee5d1873   姜超   feature(*): 修改个人考评
93
94
  //        return success(evalGroupPoolService.evalPoolSelector(userId, monthly));
          return success();
bf4d326c   姜超   feature(*): 控制器修改
95
96
      }
  
ee5d1873   姜超   feature(*): 修改个人考评
97
98
99
100
101
102
103
104
105
106
107
  //    /**
  //     * 考评详情查询 (查看自己考评详情)
  //     */
  //    @GetMapping("/own-detail")
  //    @ControllerMethod("考评详情查询")
  //    public Message<List<EvalUserRankStageVO>> evalPoolOwnDetail(@CurrentUser Long userId,
  //                                                                @Valid EvalUserRankDTO dto) {
  //        dto.initMonthly();
  //        dto.setUserId(userId);
  //        return success(evalGroupPoolService.queryRankStagePools(dto));
  //    }
bf4d326c   姜超   feature(*): 控制器修改
108
109
      /**
       * 考评详情查询 (查看自己考评详情)
bf4d326c   姜超   feature(*): 控制器修改
110
111
112
       */
      @GetMapping("/own-detail")
      @ControllerMethod("考评详情查询")
ee5d1873   姜超   feature(*): 修改个人考评
113
114
      public Message<List<EvalUserRankStageVO>> evalPoolOwnDetail(@CurrentUser Long userId) {
          return success();
bf4d326c   姜超   feature(*): 控制器修改
115
116
117
118
119
      }
  
      /**
       * 考评详情查询 (查看他人考评详情)
       *
bf4d326c   姜超   feature(*): 控制器修改
120
       */
a9445e72   姜超   feature(*): 查看考评详情
121
      @GetMapping("/detail")
bf4d326c   姜超   feature(*): 控制器修改
122
      @ControllerMethod("考评详情查询")
ee5d1873   姜超   feature(*): 修改个人考评
123
124
      public Message<List<EvalUserRankStageVO>> evalPoolDetail() {
          return success();
bf4d326c   姜超   feature(*): 控制器修改
125
      }
ee5d1873   姜超   feature(*): 修改个人考评
126
127
128
129
130
131
132
133
134
135
136
137
138
  //    /**
  //     * 考评详情查询 (查看他人考评详情)
  //     *
  //     */
  //    @GetMapping("/detail")
  //    @ControllerMethod("考评详情查询")
  //    public Message<List<EvalUserRankStageVO>> evalPoolDetail(@Valid EvalUserRankDTO dto) {
  //        dto.initMonthly();
  //        if (PublicUtil.isEmpty(dto.getUserId())) {
  //            throw new BusinessException("人员信息不能为空");
  //        }
  //        return success(evalGroupPoolService.queryRankStagePools(dto));
  //    }
bf4d326c   姜超   feature(*): 控制器修改
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
  
      /**
       * 员工考评得分详情
       *
       * @param evalPoolId
       * @param evalGroupIndicatorId
       * @return
       */
      @GetMapping("/staff/score-detail")
      @IgnoreAuth
      @ControllerMethod("员工考评得分详情")
      public Message<EvalPoolIndicatorDetailVO> getStaffHitIndicatorDetail(@NotNull(message = "考评池id不能为空") Long evalPoolId,
                                                                      @NotNull(message = "指标id不能为空") Long evalGroupIndicatorId,
                                                                      @NotNull(message = "日期不能为空") @RequestParam("dataDate") LocalDate dataDate) {
          return success(evalGroupPoolService.staffHitIndicatorDetail(evalPoolId, evalGroupIndicatorId, dataDate));
      }
  
      /**
       * 员工奖惩详情
       *
       * @param evalPoolId
       * @param evalGroupRewardId
       * @return
       */
      @GetMapping("/staff/reward-detail")
      @IgnoreAuth
      @ControllerMethod("员工奖惩详情")
      public Message<EvalPoolRewardDetailVO> getStaffRewardDetail(@NotNull(message = "考评池id不能为空") Long evalPoolId,
                                                                  @NotNull(message = "指标id不能为空") Long evalGroupRewardId,
                                                                  @NotNull(message = "日期不能为空") @RequestParam("dataDate") LocalDate dataDate) {
          return success(evalGroupPoolService.staffHitRewardDetail(evalPoolId, evalGroupRewardId, dataDate));
      }
  
      /**
       * 人员考评指标排名
       *
       * @param dto
       * @return
       */
      @GetMapping("/staff-indicator-rank")
      @ControllerMethod("人员考评指标排名")
      public Message<KpiIndicatorRankVO> queryKpiIndicatorRank(@Validated EvalGroupIndicatorRankDTO dto) {
e1778851   姜超   feature(*): 计算考评调整
181
182
          if (dto.getIsEvalGroupIndicator() && PublicUtil.isEmpty(dto.getEvalGroupIndicatorParamId()) &&
                  PublicUtil.isEmpty(dto.getEvalGroupIndicatorPreconditionId())) {
bf4d326c   姜超   feature(*): 控制器修改
183
                  throw new BusinessException("参数错误");
f90ec7e4   姜超   feature(*): 新增台阶类型
184
185
186
          }
          if (! dto.getIsEvalGroupIndicator() && PublicUtil.isEmpty(dto.getEvalGroupRewardParamId()) &&
                  PublicUtil.isEmpty(dto.getEvalGroupRewardPreconditionId())) {
bf4d326c   姜超   feature(*): 控制器修改
187
                  throw new BusinessException("参数错误");
bf4d326c   姜超   feature(*): 控制器修改
188
          }
e1778851   姜超   feature(*): 计算考评调整
189
          return success(evalGroupPoolService.queryIndicatorRank(dto, EvalScopeEnum.STAFF));
bf4d326c   姜超   feature(*): 控制器修改
190
191
192
      }
  
      /**
e1778851   姜超   feature(*): 计算考评调整
193
194
195
196
197
198
199
200
201
202
203
       * 门店考评指标排名
       *
       * @param dto
       * @return
       */
      @GetMapping("/shop-indicator-rank")
      @ControllerMethod("门店考评指标排名")
      public Message<KpiIndicatorRankVO> queryShopIndicatorRank(@Validated EvalGroupIndicatorRankDTO dto) {
          if (dto.getIsEvalGroupIndicator() && PublicUtil.isEmpty(dto.getEvalGroupIndicatorParamId()) &&
                  PublicUtil.isEmpty(dto.getEvalGroupIndicatorPreconditionId())) {
              throw new BusinessException("参数错误");
f90ec7e4   姜超   feature(*): 新增台阶类型
204
205
206
          }
          if (! dto.getIsEvalGroupIndicator() && PublicUtil.isEmpty(dto.getEvalGroupRewardParamId()) &&
                  PublicUtil.isEmpty(dto.getEvalGroupRewardPreconditionId())) {
e1778851   姜超   feature(*): 计算考评调整
207
208
209
210
211
              throw new BusinessException("参数错误");
          }
          return success(evalGroupPoolService.queryIndicatorRank(dto, EvalScopeEnum.SHOP));
      }
  
5ff2c525   姜超   feature(*): 并列排名计算
212
      /**
c4a10f17   姜超   feature(*): 保存排名名次修改
213
       *  门店、人员考评条件指标排名(排名条件使用)
5ff2c525   姜超   feature(*): 并列排名计算
214
215
216
217
218
219
220
221
222
223
224
225
226
       *
       * @param preconditionId
       * @param dataDate
       * @return
       */
      @GetMapping("/reward-cond-rank")
      @ControllerMethod("门店、人员考评条件指标排名")
      public Message<List<EvalGroupRewardRankLogVO>> queryRewardCondRank(Long preconditionId,
                                                                         @NotNull(message = "日期不能为空") @RequestParam("dataDate") LocalDate dataDate) {
          return success(evalGroupPoolService.getRewardCondRankLogs(preconditionId, dataDate));
      }
  
      /**
c4a10f17   姜超   feature(*): 保存排名名次修改
227
       *  门店、人员考评提成指标排名(排名计算使用)
5ff2c525   姜超   feature(*): 并列排名计算
228
       *
220b9724   姜超   feature(*): 代码调整
229
       * @param evalGroupRewardId
5ff2c525   姜超   feature(*): 并列排名计算
230
231
232
       * @param dataDate
       * @return
       */
220b9724   姜超   feature(*): 代码调整
233
234
235
      @GetMapping("/reward-rank")
      @ControllerMethod("门店、人员考评奖惩排名")
      public Message<List<EvalGroupRewardRankLogVO>> queryRewardCommissionRank(Long evalGroupRewardId,
5ff2c525   姜超   feature(*): 并列排名计算
236
                                                                               @NotNull(message = "日期不能为空") @RequestParam("dataDate") LocalDate dataDate) {
220b9724   姜超   feature(*): 代码调整
237
          return success(evalGroupPoolService.queryRewardCommissionRank(evalGroupRewardId, dataDate));
5ff2c525   姜超   feature(*): 并列排名计算
238
239
      }
  
c4a10f17   姜超   feature(*): 保存排名名次修改
240
241
242
243
244
245
246
247
248
      /**
       *  门店、人员考评奖惩占比(占比计算使用)
       *
       * @param evalGroupRewardId
       * @param dataDate
       * @return
       */
      @GetMapping("/reward-proportion")
      @ControllerMethod("门店、人员考评奖惩占比")
9161579f   姜超   feature(*): 排名返回名称
249
250
      public Message<List<EvalGroupRewardHitLogVO>> queryUserRewardProportion(@NotNull(message = "奖惩id不能为空") Long evalGroupRewardId,
                                                                              @NotNull(message = "类型不能为空") Integer scopeType,
c4a10f17   姜超   feature(*): 保存排名名次修改
251
                                                                               @NotNull(message = "日期不能为空") @RequestParam("dataDate") LocalDate dataDate) {
9161579f   姜超   feature(*): 排名返回名称
252
253
254
          EvalScopeEnum scopeTypeEnum = EvalScopeEnum.ofValue(scopeType);
          BV.notNull(scopeTypeEnum, "参数错误");
          return success(evalGroupPoolService.queryRewardProportion(scopeTypeEnum, evalGroupRewardId, dataDate));
c4a10f17   姜超   feature(*): 保存排名名次修改
255
      }
5ff2c525   姜超   feature(*): 并列排名计算
256
  
e1778851   姜超   feature(*): 计算考评调整
257
  
9161579f   姜超   feature(*): 排名返回名称
258
  
e1778851   姜超   feature(*): 计算考评调整
259
      /**
bf4d326c   姜超   feature(*): 控制器修改
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
       * 门店考评池列表
       *
       * @param dto
       * @return
       * @ignoreParams currentUser
       */
      @GetMapping("/shops")
      @ControllerMethod("门店考评池列表")
      public Message<AppPage<EvalShopPoolVO>> queryShopPool(@Validated EvalPoolQueryDTO dto) {
          if (PublicUtil.isEmpty(dto.getMonthly())) {
              dto.setMonthly(YearMonth.now());
          }
          return success(evalPoolService.queryShopPool(dto));
      }
  
      /**
       * 门店考评详情查询
       *
       * @param evalPoolId    用户id
       * @return 绩效池详情
       * @ignoreParams userId
       */
      @GetMapping("/shop")
      @ControllerMethod("门店考评详情查询")
      public Message<EvalShopPoolVO> queryShopPoolDetail(@NotNull(message = "考评池id不能为空") Long evalPoolId) {
          return success(evalGroupPoolService.queryShopPoolDetail(evalPoolId));
      }
  
      /**
       * 门店考评得分详情
       *
       * @param evalPoolId
       * @param evalGroupIndicatorId
       * @return
       */
      @GetMapping("/shop/score-detail")
      @IgnoreAuth
      @ControllerMethod("门店考评得分详情")
      public Message<EvalPoolIndicatorDetailVO> getShopHitIndicatorDetail(@NotNull(message = "考评池id不能为空") Long evalPoolId,
                                                                           @NotNull(message = "指标id不能为空") Long evalGroupIndicatorId,
                                                                           @NotNull(message = "日期不能为空") @RequestParam("dataDate") LocalDate dataDate) {
          return success(evalGroupPoolService.shopHitIndicatorDetail(evalPoolId, evalGroupIndicatorId, dataDate));
      }
  
          /**
       * 门店奖惩详情
       *
       * @param evalPoolId
       * @param evalGroupRewardId
       * @return
       */
      @GetMapping("/shop/reward-detail")
      @IgnoreAuth
      @ControllerMethod("门店奖惩详情")
      public Message<EvalPoolRewardDetailVO> getShopRewardDetail(@NotNull(message = "考评池id不能为空") Long evalPoolId,
                                                                  @NotNull(message = "指标id不能为空") Long evalGroupRewardId,
                                                                  @NotNull(message = "日期不能为空") @RequestParam("dataDate") LocalDate dataDate) {
          return success(evalGroupPoolService.shopHitRewardDetail(evalPoolId, evalGroupRewardId, dataDate));
      }
  
  }