Commit f591a04317925039963dc009800a42050aa8c0e9

Authored by YunaiV
1 parent 08c851ae

CRM:code review【员工业绩】的实现

yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsPerformanceController.java
... ... @@ -29,21 +29,21 @@ public class CrmStatisticsPerformanceController {
29 29 private CrmStatisticsPerformanceService performanceService;
30 30  
31 31 @GetMapping("/get-contract-count-performance")
32   - @Operation(summary = "员工业绩-签约合同数量")
  32 + @Operation(summary = "合同数量统计", description = "用于【合同数量分析】页面")
33 33 @PreAuthorize("@ss.hasPermission('crm:statistics-performance:query')")
34 34 public CommonResult<List<CrmStatisticsPerformanceRespVO>> getContractCountPerformance(@Valid CrmStatisticsPerformanceReqVO performanceReqVO) {
35 35 return success(performanceService.getContractCountPerformance(performanceReqVO));
36 36 }
37 37  
38 38 @GetMapping("/get-contract-price-performance")
39   - @Operation(summary = "员工业绩-获得合同金额")
  39 + @Operation(summary = "合同金额统计")
40 40 @PreAuthorize("@ss.hasPermission('crm:statistics-performance:query')")
41 41 public CommonResult<List<CrmStatisticsPerformanceRespVO>> getContractPriceStaffPerformance(@Valid CrmStatisticsPerformanceReqVO performanceReqVO) {
42 42 return success(performanceService.getContractPricePerformance(performanceReqVO));
43 43 }
44 44  
45 45 @GetMapping("/get-receivable-price-performance")
46   - @Operation(summary = "员工业绩-获得回款金额")
  46 + @Operation(summary = "回款金额统计")
47 47 @PreAuthorize("@ss.hasPermission('crm:statistics-performance:query')")
48 48 public CommonResult<List<CrmStatisticsPerformanceRespVO>> getReceivablePriceStaffPerformance(@Valid CrmStatisticsPerformanceReqVO performanceReqVO) {
49 49 return success(performanceService.getReceivablePricePerformance(performanceReqVO));
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/performance/CrmStatisticsPerformanceReqVO.java
... ... @@ -33,6 +33,7 @@ public class CrmStatisticsPerformanceReqVO {
33 33 @Schema(description = "负责人用户 id 集合", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "2")
34 34 private List<Long> userIds;
35 35  
  36 + // TODO @scholar:应该传递的是 int year;年份
36 37 @Schema(description = "时间范围", requiredMode = Schema.RequiredMode.REQUIRED)
37 38 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
38 39 @NotEmpty(message = "时间范围不能为空")
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java
... ... @@ -36,9 +36,12 @@ public class CrmStatisticsPerformanceServiceImpl implements CrmStatisticsPerform
36 36 @Resource
37 37 private DeptApi deptApi;
38 38  
39   -
40 39 @Override
41 40 public List<CrmStatisticsPerformanceRespVO> getContractCountPerformance(CrmStatisticsPerformanceReqVO performanceReqVO) {
  41 + // TODO @scholar:我们可以换个思路实现,减少数据库的计算量;
  42 + // 比如说,2024 年的合同数据,是不是 2022-12 到 2024-12-31,每个月的统计呢?
  43 + // 理解之后,我们可以数据 group by 年-月,20222-12 到 2024-12-31 的,然后内存在聚合出 CrmStatisticsPerformanceRespVO 这样
  44 + // 这样,我们就可以减少数据库的计算量,提升性能;同时 SQL 也会很简单,开发者理解起来也简单哈;
42 45 return getPerformance(performanceReqVO, performanceMapper::selectContractCountPerformance);
43 46 }
44 47  
... ...