CRM:将 bi 调整成 statistics

This commit is contained in:
YunaiV 2024-02-24 22:26:24 +08:00
parent cd87f2e4aa
commit c726cd3aff
9 changed files with 103 additions and 103 deletions

View File

@ -1,9 +0,0 @@
### 合同金额排行榜
GET {{baseUrl}}/crm/bi-rank/get-contract-price-rank?deptId=100&times[0]=2022-12-12 00:00:00&times[1]=2024-12-12 23:59:59
Authorization: Bearer {{token}}
tenant-id: {{adminTenentId}}
### 回款金额排行榜
GET {{baseUrl}}/crm/bi-rank/get-receivable-price-rank?deptId=100&times[0]=2022-12-12 00:00:00&times[1]=2024-12-12 23:59:59
Authorization: Bearer {{token}}
tenant-id: {{adminTenentId}}

View File

@ -0,0 +1,9 @@
### 合同金额排行榜
GET {{baseUrl}}/crm/statistics-rank/get-contract-price-rank?deptId=100&times[0]=2022-12-12 00:00:00&times[1]=2024-12-12 23:59:59
Authorization: Bearer {{token}}
tenant-id: {{adminTenentId}}
### 回款金额排行榜
GET {{baseUrl}}/crm/statistics-rank/get-receivable-price-rank?deptId=100&times[0]=2022-12-12 00:00:00&times[1]=2024-12-12 23:59:59
Authorization: Bearer {{token}}
tenant-id: {{adminTenentId}}

View File

@ -1,9 +1,9 @@
package cn.iocoder.yudao.module.crm.controller.admin.bi; package cn.iocoder.yudao.module.crm.controller.admin.statistics;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRankReqVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRankReqVO;
import cn.iocoder.yudao.module.crm.service.bi.CrmBiRankingService; import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsRankingService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
@ -19,68 +19,68 @@ import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - CRM BI 排行榜") @Tag(name = "管理后台 - CRM 排行榜统计")
@RestController @RestController
@RequestMapping("/crm/bi-rank") @RequestMapping("/crm/statistics-rank")
@Validated @Validated
public class CrmBiRankController { public class CrmStatisticsRankController {
@Resource @Resource
private CrmBiRankingService rankingService; private CrmStatisticsRankingService rankingService;
@GetMapping("/get-contract-price-rank") @GetMapping("/get-contract-price-rank")
@Operation(summary = "获得合同金额排行榜") @Operation(summary = "获得合同金额排行榜")
@PreAuthorize("@ss.hasPermission('crm:bi-rank:query')") @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')")
public CommonResult<List<CrmBiRanKRespVO>> getContractPriceRank(@Valid CrmBiRankReqVO rankingReqVO) { public CommonResult<List<CrmStatisticsRanKRespVO>> getContractPriceRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
return success(rankingService.getContractPriceRank(rankingReqVO)); return success(rankingService.getContractPriceRank(rankingReqVO));
} }
@GetMapping("/get-receivable-price-rank") @GetMapping("/get-receivable-price-rank")
@Operation(summary = "获得回款金额排行榜") @Operation(summary = "获得回款金额排行榜")
@PreAuthorize("@ss.hasPermission('crm:bi-rank:query')") @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')")
public CommonResult<List<CrmBiRanKRespVO>> getReceivablePriceRank(@Valid CrmBiRankReqVO rankingReqVO) { public CommonResult<List<CrmStatisticsRanKRespVO>> getReceivablePriceRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
return success(rankingService.getReceivablePriceRank(rankingReqVO)); return success(rankingService.getReceivablePriceRank(rankingReqVO));
} }
@GetMapping("/get-contract-count-rank") @GetMapping("/get-contract-count-rank")
@Operation(summary = "获得签约合同数量排行榜") @Operation(summary = "获得签约合同数量排行榜")
@PreAuthorize("@ss.hasPermission('crm:bi-rank:query')") @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')")
public CommonResult<List<CrmBiRanKRespVO>> getContractCountRank(@Valid CrmBiRankReqVO rankingReqVO) { public CommonResult<List<CrmStatisticsRanKRespVO>> getContractCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
return success(rankingService.getContractCountRank(rankingReqVO)); return success(rankingService.getContractCountRank(rankingReqVO));
} }
@GetMapping("/get-product-sales-rank") @GetMapping("/get-product-sales-rank")
@Operation(summary = "获得产品销量排行榜") @Operation(summary = "获得产品销量排行榜")
@PreAuthorize("@ss.hasPermission('crm:bi-rank:query')") @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')")
public CommonResult<List<CrmBiRanKRespVO>> getProductSalesRank(@Valid CrmBiRankReqVO rankingReqVO) { public CommonResult<List<CrmStatisticsRanKRespVO>> getProductSalesRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
return success(rankingService.getProductSalesRank(rankingReqVO)); return success(rankingService.getProductSalesRank(rankingReqVO));
} }
@GetMapping("/get-customer-count-rank") @GetMapping("/get-customer-count-rank")
@Operation(summary = "获得新增客户数排行榜") @Operation(summary = "获得新增客户数排行榜")
@PreAuthorize("@ss.hasPermission('crm:bi-rank:query')") @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')")
public CommonResult<List<CrmBiRanKRespVO>> getCustomerCountRank(@Valid CrmBiRankReqVO rankingReqVO) { public CommonResult<List<CrmStatisticsRanKRespVO>> getCustomerCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
return success(rankingService.getCustomerCountRank(rankingReqVO)); return success(rankingService.getCustomerCountRank(rankingReqVO));
} }
@GetMapping("/get-contacts-count-rank") @GetMapping("/get-contacts-count-rank")
@Operation(summary = "获得新增联系人数排行榜") @Operation(summary = "获得新增联系人数排行榜")
@PreAuthorize("@ss.hasPermission('crm:bi-rank:query')") @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')")
public CommonResult<List<CrmBiRanKRespVO>> getContactsCountRank(@Valid CrmBiRankReqVO rankingReqVO) { public CommonResult<List<CrmStatisticsRanKRespVO>> getContactsCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
return success(rankingService.getContactsCountRank(rankingReqVO)); return success(rankingService.getContactsCountRank(rankingReqVO));
} }
@GetMapping("/get-follow-count-rank") @GetMapping("/get-follow-count-rank")
@Operation(summary = "获得跟进次数排行榜") @Operation(summary = "获得跟进次数排行榜")
@PreAuthorize("@ss.hasPermission('crm:bi-rank:query')") @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')")
public CommonResult<List<CrmBiRanKRespVO>> getFollowCountRank(@Valid CrmBiRankReqVO rankingReqVO) { public CommonResult<List<CrmStatisticsRanKRespVO>> getFollowCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
return success(rankingService.getFollowCountRank(rankingReqVO)); return success(rankingService.getFollowCountRank(rankingReqVO));
} }
@GetMapping("/get-follow-customer-count-rank") @GetMapping("/get-follow-customer-count-rank")
@Operation(summary = "获得跟进客户数排行榜") @Operation(summary = "获得跟进客户数排行榜")
@PreAuthorize("@ss.hasPermission('crm:bi-rank:query')") @PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')")
public CommonResult<List<CrmBiRanKRespVO>> getFollowCustomerCountRank(@Valid CrmBiRankReqVO rankingReqVO) { public CommonResult<List<CrmStatisticsRanKRespVO>> getFollowCustomerCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
return success(rankingService.getFollowCustomerCountRank(rankingReqVO)); return success(rankingService.getFollowCustomerCountRank(rankingReqVO));
} }

View File

@ -1,12 +1,12 @@
package cn.iocoder.yudao.module.crm.controller.admin.bi.vo; package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
@Schema(description = "管理后台 - CRM BI 排行榜 Response VO") @Schema(description = "管理后台 - CRM BI 排行榜统计 Response VO")
@Data @Data
public class CrmBiRanKRespVO { public class CrmStatisticsRanKRespVO {
@Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long ownerUserId; private Long ownerUserId;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.controller.admin.bi.vo; package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
@ -11,9 +11,9 @@ import java.util.List;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - CRM BI 排行榜 Request VO") @Schema(description = "管理后台 - CRM 排行榜统计 Request VO")
@Data @Data
public class CrmBiRankReqVO { public class CrmStatisticsRankReqVO {
@Schema(description = "部门 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "部门 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "部门 id 不能为空") @NotNull(message = "部门 id 不能为空")

View File

@ -1,18 +1,18 @@
package cn.iocoder.yudao.module.crm.dal.mysql.bi; package cn.iocoder.yudao.module.crm.dal.mysql.statistics;
import cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRankReqVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRankReqVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List; import java.util.List;
/** /**
* CRM BI 排行榜 Mapper * CRM 排行榜统计 Mapper
* *
* @author anhaohao * @author anhaohao
*/ */
@Mapper @Mapper
public interface CrmBiRankingMapper { public interface CrmStatisticsRankingMapper {
/** /**
* 查询合同金额排行榜 * 查询合同金额排行榜
@ -20,7 +20,7 @@ public interface CrmBiRankingMapper {
* @param rankReqVO 参数 * @param rankReqVO 参数
* @return 合同金额排行榜 * @return 合同金额排行榜
*/ */
List<CrmBiRanKRespVO> selectContractPriceRank(CrmBiRankReqVO rankReqVO); List<CrmStatisticsRanKRespVO> selectContractPriceRank(CrmStatisticsRankReqVO rankReqVO);
/** /**
* 查询回款金额排行榜 * 查询回款金额排行榜
@ -28,7 +28,7 @@ public interface CrmBiRankingMapper {
* @param rankReqVO 参数 * @param rankReqVO 参数
* @return 回款金额排行榜 * @return 回款金额排行榜
*/ */
List<CrmBiRanKRespVO> selectReceivablePriceRank(CrmBiRankReqVO rankReqVO); List<CrmStatisticsRanKRespVO> selectReceivablePriceRank(CrmStatisticsRankReqVO rankReqVO);
/** /**
* 查询签约合同数量排行榜 * 查询签约合同数量排行榜
@ -36,7 +36,7 @@ public interface CrmBiRankingMapper {
* @param rankReqVO 参数 * @param rankReqVO 参数
* @return 签约合同数量排行榜 * @return 签约合同数量排行榜
*/ */
List<CrmBiRanKRespVO> selectContractCountRank(CrmBiRankReqVO rankReqVO); List<CrmStatisticsRanKRespVO> selectContractCountRank(CrmStatisticsRankReqVO rankReqVO);
/** /**
* 查询产品销量排行榜 * 查询产品销量排行榜
@ -44,7 +44,7 @@ public interface CrmBiRankingMapper {
* @param rankReqVO 参数 * @param rankReqVO 参数
* @return 产品销量排行榜 * @return 产品销量排行榜
*/ */
List<CrmBiRanKRespVO> selectProductSalesRank(CrmBiRankReqVO rankReqVO); List<CrmStatisticsRanKRespVO> selectProductSalesRank(CrmStatisticsRankReqVO rankReqVO);
/** /**
* 查询新增客户数排行榜 * 查询新增客户数排行榜
@ -52,7 +52,7 @@ public interface CrmBiRankingMapper {
* @param rankReqVO 参数 * @param rankReqVO 参数
* @return 新增客户数排行榜 * @return 新增客户数排行榜
*/ */
List<CrmBiRanKRespVO> selectCustomerCountRank(CrmBiRankReqVO rankReqVO); List<CrmStatisticsRanKRespVO> selectCustomerCountRank(CrmStatisticsRankReqVO rankReqVO);
/** /**
* 查询联系人数量排行榜 * 查询联系人数量排行榜
@ -60,7 +60,7 @@ public interface CrmBiRankingMapper {
* @param rankReqVO 参数 * @param rankReqVO 参数
* @return 联系人数量排行榜 * @return 联系人数量排行榜
*/ */
List<CrmBiRanKRespVO> selectContactsCountRank(CrmBiRankReqVO rankReqVO); List<CrmStatisticsRanKRespVO> selectContactsCountRank(CrmStatisticsRankReqVO rankReqVO);
/** /**
* 查询跟进次数排行榜 * 查询跟进次数排行榜
@ -68,7 +68,7 @@ public interface CrmBiRankingMapper {
* @param rankReqVO 参数 * @param rankReqVO 参数
* @return 跟进次数排行榜 * @return 跟进次数排行榜
*/ */
List<CrmBiRanKRespVO> selectFollowCountRank(CrmBiRankReqVO rankReqVO); List<CrmStatisticsRanKRespVO> selectFollowCountRank(CrmStatisticsRankReqVO rankReqVO);
/** /**
* 查询跟进客户数排行榜 * 查询跟进客户数排行榜
@ -76,6 +76,6 @@ public interface CrmBiRankingMapper {
* @param rankReqVO 参数 * @param rankReqVO 参数
* @return 跟进客户数排行榜 * @return 跟进客户数排行榜
*/ */
List<CrmBiRanKRespVO> selectFollowCustomerCountRank(CrmBiRankReqVO rankReqVO); List<CrmStatisticsRanKRespVO> selectFollowCustomerCountRank(CrmStatisticsRankReqVO rankReqVO);
} }

View File

@ -1,17 +1,17 @@
package cn.iocoder.yudao.module.crm.service.bi; package cn.iocoder.yudao.module.crm.service.statistics;
import cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRankReqVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRankReqVO;
import java.util.List; import java.util.List;
/** /**
* CRM BI 排行榜 Service 接口 * CRM 排行榜统计 Service 接口
* *
* @author anhaohao * @author anhaohao
*/ */
public interface CrmBiRankingService { public interface CrmStatisticsRankingService {
/** /**
* 获得合同金额排行榜 * 获得合同金额排行榜
@ -19,7 +19,7 @@ public interface CrmBiRankingService {
* @param rankReqVO 排行参数 * @param rankReqVO 排行参数
* @return 合同金额排行榜 * @return 合同金额排行榜
*/ */
List<CrmBiRanKRespVO> getContractPriceRank(CrmBiRankReqVO rankReqVO); List<CrmStatisticsRanKRespVO> getContractPriceRank(CrmStatisticsRankReqVO rankReqVO);
/** /**
* 获得回款金额排行榜 * 获得回款金额排行榜
@ -27,7 +27,7 @@ public interface CrmBiRankingService {
* @param rankReqVO 排行参数 * @param rankReqVO 排行参数
* @return 回款金额排行榜 * @return 回款金额排行榜
*/ */
List<CrmBiRanKRespVO> getReceivablePriceRank(CrmBiRankReqVO rankReqVO); List<CrmStatisticsRanKRespVO> getReceivablePriceRank(CrmStatisticsRankReqVO rankReqVO);
/** /**
* 获得签约合同数量排行榜 * 获得签约合同数量排行榜
@ -35,7 +35,7 @@ public interface CrmBiRankingService {
* @param rankReqVO 排行参数 * @param rankReqVO 排行参数
* @return 签约合同数量排行榜 * @return 签约合同数量排行榜
*/ */
List<CrmBiRanKRespVO> getContractCountRank(CrmBiRankReqVO rankReqVO); List<CrmStatisticsRanKRespVO> getContractCountRank(CrmStatisticsRankReqVO rankReqVO);
/** /**
* 获得产品销量排行榜 * 获得产品销量排行榜
@ -43,7 +43,7 @@ public interface CrmBiRankingService {
* @param rankReqVO 排行参数 * @param rankReqVO 排行参数
* @return 产品销量排行榜 * @return 产品销量排行榜
*/ */
List<CrmBiRanKRespVO> getProductSalesRank(CrmBiRankReqVO rankReqVO); List<CrmStatisticsRanKRespVO> getProductSalesRank(CrmStatisticsRankReqVO rankReqVO);
/** /**
* 获得新增客户数排行榜 * 获得新增客户数排行榜
@ -51,7 +51,7 @@ public interface CrmBiRankingService {
* @param rankReqVO 排行参数 * @param rankReqVO 排行参数
* @return 新增客户数排行榜 * @return 新增客户数排行榜
*/ */
List<CrmBiRanKRespVO> getCustomerCountRank(CrmBiRankReqVO rankReqVO); List<CrmStatisticsRanKRespVO> getCustomerCountRank(CrmStatisticsRankReqVO rankReqVO);
/** /**
* 获得联系人数量排行榜 * 获得联系人数量排行榜
@ -59,7 +59,7 @@ public interface CrmBiRankingService {
* @param rankReqVO 排行参数 * @param rankReqVO 排行参数
* @return 联系人数量排行榜 * @return 联系人数量排行榜
*/ */
List<CrmBiRanKRespVO> getContactsCountRank(CrmBiRankReqVO rankReqVO); List<CrmStatisticsRanKRespVO> getContactsCountRank(CrmStatisticsRankReqVO rankReqVO);
/** /**
* 获得跟进次数排行榜 * 获得跟进次数排行榜
@ -67,7 +67,7 @@ public interface CrmBiRankingService {
* @param rankReqVO 排行参数 * @param rankReqVO 排行参数
* @return 跟进次数排行榜 * @return 跟进次数排行榜
*/ */
List<CrmBiRanKRespVO> getFollowCountRank(CrmBiRankReqVO rankReqVO); List<CrmStatisticsRanKRespVO> getFollowCountRank(CrmStatisticsRankReqVO rankReqVO);
/** /**
* 获得跟进客户数排行榜 * 获得跟进客户数排行榜
@ -75,6 +75,6 @@ public interface CrmBiRankingService {
* @param rankReqVO 排行参数 * @param rankReqVO 排行参数
* @return 跟进客户数排行榜 * @return 跟进客户数排行榜
*/ */
List<CrmBiRanKRespVO> getFollowCustomerCountRank(CrmBiRankReqVO rankReqVO); List<CrmStatisticsRanKRespVO> getFollowCustomerCountRank(CrmStatisticsRankReqVO rankReqVO);
} }

View File

@ -1,10 +1,10 @@
package cn.iocoder.yudao.module.crm.service.bi; package cn.iocoder.yudao.module.crm.service.statistics;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils; import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRankReqVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRankReqVO;
import cn.iocoder.yudao.module.crm.dal.mysql.bi.CrmBiRankingMapper; import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsRankingMapper;
import cn.iocoder.yudao.module.system.api.dept.DeptApi; import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
@ -23,16 +23,16 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
/** /**
* CRM BI 排行榜 Service 实现类 * CRM 排行榜统计 Service 实现类
* *
* @author anhaohao * @author anhaohao
*/ */
@Service @Service
@Validated @Validated
public class CrmBiRankingServiceImpl implements CrmBiRankingService { public class CrmStatisticsRankingServiceImpl implements CrmStatisticsRankingService {
@Resource @Resource
private CrmBiRankingMapper biRankingMapper; private CrmStatisticsRankingMapper rankMapper;
@Resource @Resource
private AdminUserApi adminUserApi; private AdminUserApi adminUserApi;
@ -40,43 +40,43 @@ public class CrmBiRankingServiceImpl implements CrmBiRankingService {
private DeptApi deptApi; private DeptApi deptApi;
@Override @Override
public List<CrmBiRanKRespVO> getContractPriceRank(CrmBiRankReqVO rankReqVO) { public List<CrmStatisticsRanKRespVO> getContractPriceRank(CrmStatisticsRankReqVO rankReqVO) {
return getRank(rankReqVO, biRankingMapper::selectContractPriceRank); return getRank(rankReqVO, rankMapper::selectContractPriceRank);
} }
@Override @Override
public List<CrmBiRanKRespVO> getReceivablePriceRank(CrmBiRankReqVO rankReqVO) { public List<CrmStatisticsRanKRespVO> getReceivablePriceRank(CrmStatisticsRankReqVO rankReqVO) {
return getRank(rankReqVO, biRankingMapper::selectReceivablePriceRank); return getRank(rankReqVO, rankMapper::selectReceivablePriceRank);
} }
@Override @Override
public List<CrmBiRanKRespVO> getContractCountRank(CrmBiRankReqVO rankReqVO) { public List<CrmStatisticsRanKRespVO> getContractCountRank(CrmStatisticsRankReqVO rankReqVO) {
return getRank(rankReqVO, biRankingMapper::selectContractCountRank); return getRank(rankReqVO, rankMapper::selectContractCountRank);
} }
@Override @Override
public List<CrmBiRanKRespVO> getProductSalesRank(CrmBiRankReqVO rankReqVO) { public List<CrmStatisticsRanKRespVO> getProductSalesRank(CrmStatisticsRankReqVO rankReqVO) {
return getRank(rankReqVO, biRankingMapper::selectProductSalesRank); return getRank(rankReqVO, rankMapper::selectProductSalesRank);
} }
@Override @Override
public List<CrmBiRanKRespVO> getCustomerCountRank(CrmBiRankReqVO rankReqVO) { public List<CrmStatisticsRanKRespVO> getCustomerCountRank(CrmStatisticsRankReqVO rankReqVO) {
return getRank(rankReqVO, biRankingMapper::selectCustomerCountRank); return getRank(rankReqVO, rankMapper::selectCustomerCountRank);
} }
@Override @Override
public List<CrmBiRanKRespVO> getContactsCountRank(CrmBiRankReqVO rankReqVO) { public List<CrmStatisticsRanKRespVO> getContactsCountRank(CrmStatisticsRankReqVO rankReqVO) {
return getRank(rankReqVO, biRankingMapper::selectContactsCountRank); return getRank(rankReqVO, rankMapper::selectContactsCountRank);
} }
@Override @Override
public List<CrmBiRanKRespVO> getFollowCountRank(CrmBiRankReqVO rankReqVO) { public List<CrmStatisticsRanKRespVO> getFollowCountRank(CrmStatisticsRankReqVO rankReqVO) {
return getRank(rankReqVO, biRankingMapper::selectFollowCountRank); return getRank(rankReqVO, rankMapper::selectFollowCountRank);
} }
@Override @Override
public List<CrmBiRanKRespVO> getFollowCustomerCountRank(CrmBiRankReqVO rankReqVO) { public List<CrmStatisticsRanKRespVO> getFollowCustomerCountRank(CrmStatisticsRankReqVO rankReqVO) {
return getRank(rankReqVO, biRankingMapper::selectFollowCustomerCountRank); return getRank(rankReqVO, rankMapper::selectFollowCustomerCountRank);
} }
/** /**
@ -86,18 +86,18 @@ public class CrmBiRankingServiceImpl implements CrmBiRankingService {
* @param rankFunction 排行榜方法 * @param rankFunction 排行榜方法
* @return 排行版数据 * @return 排行版数据
*/ */
private List<CrmBiRanKRespVO> getRank(CrmBiRankReqVO rankReqVO, Function<CrmBiRankReqVO, List<CrmBiRanKRespVO>> rankFunction) { private List<CrmStatisticsRanKRespVO> getRank(CrmStatisticsRankReqVO rankReqVO, Function<CrmStatisticsRankReqVO, List<CrmStatisticsRanKRespVO>> rankFunction) {
// 1. 获得用户编号数组 // 1. 获得用户编号数组
rankReqVO.setUserIds(getUserIds(rankReqVO.getDeptId())); rankReqVO.setUserIds(getUserIds(rankReqVO.getDeptId()));
if (CollUtil.isEmpty(rankReqVO.getUserIds())) { if (CollUtil.isEmpty(rankReqVO.getUserIds())) {
return Collections.emptyList(); return Collections.emptyList();
} }
// 2. 获得排行数据 // 2. 获得排行数据
List<CrmBiRanKRespVO> ranks = rankFunction.apply(rankReqVO); List<CrmStatisticsRanKRespVO> ranks = rankFunction.apply(rankReqVO);
if (CollUtil.isEmpty(ranks)) { if (CollUtil.isEmpty(ranks)) {
return Collections.emptyList(); return Collections.emptyList();
} }
ranks.sort(Comparator.comparing(CrmBiRanKRespVO::getCount).reversed()); ranks.sort(Comparator.comparing(CrmStatisticsRanKRespVO::getCount).reversed());
// 3. 拼接用户信息 // 3. 拼接用户信息
appendUserInfo(ranks); appendUserInfo(ranks);
return ranks; return ranks;
@ -108,8 +108,8 @@ public class CrmBiRankingServiceImpl implements CrmBiRankingService {
* *
* @param ranks 排行榜数据 * @param ranks 排行榜数据
*/ */
private void appendUserInfo(List<CrmBiRanKRespVO> ranks) { private void appendUserInfo(List<CrmStatisticsRanKRespVO> ranks) {
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(ranks, CrmBiRanKRespVO::getOwnerUserId)); Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(ranks, CrmStatisticsRanKRespVO::getOwnerUserId));
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
ranks.forEach(rank -> MapUtils.findAndThen(userMap, rank.getOwnerUserId(), user -> { ranks.forEach(rank -> MapUtils.findAndThen(userMap, rank.getOwnerUserId(), user -> {
rank.setNickname(user.getNickname()); rank.setNickname(user.getNickname());

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.bi.CrmBiRankingMapper"> <mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsRankingMapper">
<select id="selectContractPriceRank" <select id="selectContractPriceRank"
resultType="cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO"> resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO">
SELECT IFNULL(SUM(price), 0) AS count, owner_user_id SELECT IFNULL(SUM(total_price), 0) AS count, owner_user_id
FROM crm_contract FROM crm_contract
WHERE deleted = 0 WHERE deleted = 0
AND audit_status = 20 AND audit_status = 20
@ -18,7 +18,7 @@
</select> </select>
<select id="selectReceivablePriceRank" <select id="selectReceivablePriceRank"
resultType="cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO"> resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO">
SELECT IFNULL(SUM(price), 0) AS count, owner_user_id SELECT IFNULL(SUM(price), 0) AS count, owner_user_id
FROM crm_receivable FROM crm_receivable
WHERE deleted = 0 WHERE deleted = 0
@ -33,7 +33,7 @@
</select> </select>
<select id="selectContractCountRank" <select id="selectContractCountRank"
resultType="cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO"> resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO">
SELECT COUNT(1) AS count, owner_user_id SELECT COUNT(1) AS count, owner_user_id
FROM crm_contract FROM crm_contract
WHERE deleted = 0 WHERE deleted = 0
@ -49,7 +49,7 @@
<!-- TODO 待定 这里是否需要关联 crm_contract_product 表,计算销售额 --> <!-- TODO 待定 这里是否需要关联 crm_contract_product 表,计算销售额 -->
<select id="selectProductSalesRank" <select id="selectProductSalesRank"
resultType="cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO"> resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO">
SELECT COUNT(1) AS count, owner_user_id SELECT COUNT(1) AS count, owner_user_id
FROM crm_contract FROM crm_contract
WHERE deleted = 0 WHERE deleted = 0
@ -64,7 +64,7 @@
</select> </select>
<select id="selectCustomerCountRank" <select id="selectCustomerCountRank"
resultType="cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO"> resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO">
SELECT COUNT(1) AS count, owner_user_id SELECT COUNT(1) AS count, owner_user_id
FROM crm_customer FROM crm_customer
WHERE deleted = 0 WHERE deleted = 0
@ -78,7 +78,7 @@
</select> </select>
<select id="selectContactsCountRank" <select id="selectContactsCountRank"
resultType="cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO"> resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO">
SELECT COUNT(1) AS count, owner_user_id SELECT COUNT(1) AS count, owner_user_id
FROM crm_contact FROM crm_contact
WHERE deleted = 0 WHERE deleted = 0
@ -92,7 +92,7 @@
</select> </select>
<select id="selectFollowCountRank" <select id="selectFollowCountRank"
resultType="cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO"> resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO">
SELECT COUNT(1) AS count, cc.owner_user_id SELECT COUNT(1) AS count, cc.owner_user_id
FROM crm_follow_up_record AS cfur FROM crm_follow_up_record AS cfur
LEFT JOIN crm_contact AS cc ON FIND_IN_SET(cc.id, cfur.contact_ids) LEFT JOIN crm_contact AS cc ON FIND_IN_SET(cc.id, cfur.contact_ids)
@ -108,7 +108,7 @@
</select> </select>
<select id="selectFollowCustomerCountRank" <select id="selectFollowCustomerCountRank"
resultType="cn.iocoder.yudao.module.crm.controller.admin.bi.vo.CrmBiRanKRespVO"> resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO">
SELECT COUNT(DISTINCT cc.id) AS count, cc.owner_user_id SELECT COUNT(DISTINCT cc.id) AS count, cc.owner_user_id
FROM crm_follow_up_record AS cfur FROM crm_follow_up_record AS cfur
LEFT JOIN crm_contact AS cc ON FIND_IN_SET(cc.id, cfur.contact_ids) LEFT JOIN crm_contact AS cc ON FIND_IN_SET(cc.id, cfur.contact_ids)