From 67b02c7e5b6a64942829bb525f1f1c9c0d4d11b6 Mon Sep 17 00:00:00 2001 From: dhb52 Date: Fri, 12 Apr 2024 22:15:24 +0800 Subject: [PATCH 01/21] =?UTF-8?q?feat:=20=E5=AE=A2=E6=88=B7=E6=88=90?= =?UTF-8?q?=E4=BA=A4=E5=91=A8=E6=9C=9F=E5=88=86=E6=9E=90(=E6=8C=89?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E3=80=81=E6=8C=89=E4=BA=A7=E5=93=81)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CrmStatisticsCustomerController.http | 10 ++++ .../CrmStatisticsCustomerController.java | 14 ++++- ...atisticsCustomerDealCycleByAreaRespVO.java | 24 +++++++++ ...sticsCustomerDealCycleByProductRespVO.java | 19 +++++++ .../CrmStatisticsCustomerMapper.java | 17 ++++++ .../CrmStatisticsCustomerService.java | 18 ++++++- .../CrmStatisticsCustomerServiceImpl.java | 49 +++++++++++++++++ .../CrmStatisticsCustomerMapper.xml | 52 ++++++++++++++++--- 8 files changed, 195 insertions(+), 8 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByAreaRespVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByProductRespVO.java diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.http b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.http index 389bf4ac9..6b960512d 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.http +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.http @@ -53,3 +53,13 @@ tenant-id: {{adminTenentId}} GET {{baseUrl}}/crm/statistics-customer/get-customer-deal-cycle-by-user?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 Authorization: Bearer {{token}} tenant-id: {{adminTenentId}} + +### 6.3 获取客户成交周期(按区域) +GET {{baseUrl}}/crm/statistics-customer/get-customer-deal-cycle-by-area?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 +Authorization: Bearer {{token}} +tenant-id: {{adminTenentId}} + +### 6.4 获取客户成交周期(按产品) +GET {{baseUrl}}/crm/statistics-customer/get-customer-deal-cycle-by-product?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 +Authorization: Bearer {{token}} +tenant-id: {{adminTenentId}} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.java index 51d149900..3539b5db5 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.java @@ -96,6 +96,18 @@ public class CrmStatisticsCustomerController { return success(customerService.getCustomerDealCycleByUser(reqVO)); } - // TODO dhb52:【成交周期分析】里,有按照员工(已实现)、地区(未实现)、产品(未实现),需要在看看哈;可以把 CustomerDealCycle 拆成 3 个 tab,员工客户成交周期分析、地区客户成交周期分析、产品客户成交周期分析; + @GetMapping("/get-customer-deal-cycle-by-area") + @Operation(summary = "获取客户成交周期(按用户)") + @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") + public CommonResult> getCustomerDealCycleByArea(@Valid CrmStatisticsCustomerReqVO reqVO) { + return success(customerService.getCustomerDealCycleByArea(reqVO)); + } + + @GetMapping("/get-customer-deal-cycle-by-product") + @Operation(summary = "获取客户成交周期(按用户)") + @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") + public CommonResult> getCustomerDealCycleByProduct(@Valid CrmStatisticsCustomerReqVO reqVO) { + return success(customerService.getCustomerDealCycleByProduct(reqVO)); + } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByAreaRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByAreaRespVO.java new file mode 100644 index 000000000..369837827 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByAreaRespVO.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "管理后台 - CRM 客户成交周期分析(按区域) VO") +@Data +public class CrmStatisticsCustomerDealCycleByAreaRespVO { + + @Schema(description = "省份编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @JsonIgnore + private Integer areaId; + + @Schema(description = "省份名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "浙江省") + private String areaName; + + @Schema(description = "成交周期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.0") + private Double customerDealCycle; + + @Schema(description = "成交客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Integer customerDealCount; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByProductRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByProductRespVO.java new file mode 100644 index 000000000..442c195aa --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByProductRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "管理后台 - CRM 客户成交周期分析(按产品) VO") +@Data +public class CrmStatisticsCustomerDealCycleByProductRespVO { + + @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "演示产品") + private String productName; + + @Schema(description = "成交周期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.0") + private Double customerDealCycle; + + @Schema(description = "成交客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Integer customerDealCount; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsCustomerMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsCustomerMapper.java index 458ef79c3..171d432b0 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsCustomerMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsCustomerMapper.java @@ -53,6 +53,7 @@ public interface CrmStatisticsCustomerMapper { /** * 合同总金额(按用户) + * * @return 统计数据@return 统计数据@param reqVO 请求参数 * @return 统计数据 */ @@ -191,4 +192,20 @@ public interface CrmStatisticsCustomerMapper { */ List selectCustomerDealCycleGroupByUser(CrmStatisticsCustomerReqVO reqVO); + /** + * 客户成交周期(按区域) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ + List selectCustomerDealCycleGroupByAreaId(CrmStatisticsCustomerReqVO reqVO); + + /** + * 客户成交周期(按产品) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ + List selectCustomerDealCycleGroupByProductId(CrmStatisticsCustomerReqVO reqVO); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java index 0e00e9c22..56ecf975e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java @@ -77,7 +77,7 @@ public interface CrmStatisticsCustomerService { /** * 客户成交周期(按日期) - * + *

* 成交周期的定义:客户 customer 在创建出来,到合同 contract 第一次成交的时间差 * * @param reqVO 请求参数 @@ -93,4 +93,20 @@ public interface CrmStatisticsCustomerService { */ List getCustomerDealCycleByUser(CrmStatisticsCustomerReqVO reqVO); + /** + * 客户成交周期(按区域) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ + List getCustomerDealCycleByArea(CrmStatisticsCustomerReqVO reqVO); + + /** + * 客户成交周期(按产品) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ + List getCustomerDealCycleByProduct(CrmStatisticsCustomerReqVO reqVO); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java index f4787b20f..c5b933c43 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java @@ -4,6 +4,9 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; import cn.iocoder.yudao.framework.common.util.number.NumberUtils; +import cn.iocoder.yudao.framework.ip.core.Area; +import cn.iocoder.yudao.framework.ip.core.enums.AreaTypeEnum; +import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.*; import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsCustomerMapper; import cn.iocoder.yudao.module.system.api.dept.DeptApi; @@ -19,6 +22,7 @@ import java.time.LocalDateTime; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.function.Function; import java.util.stream.Stream; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; @@ -290,6 +294,51 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe return summaryList; } + @Override + public List getCustomerDealCycleByArea(CrmStatisticsCustomerReqVO reqVO) { + // 1. 获得用户编号数组 + List userIds = getUserIds(reqVO); + if (CollUtil.isEmpty(userIds)) { + return Collections.emptyList(); + } + reqVO.setUserIds(userIds); + + // 2. 获取客户地区统计数据 + List dealCycleByAreaList = customerMapper.selectCustomerDealCycleGroupByAreaId(reqVO); + if (CollUtil.isEmpty(dealCycleByAreaList)) { + return Collections.emptyList(); + } + + // 3. 拼接数据 + Map areaMap = convertMap(AreaUtils.getByType(AreaTypeEnum.PROVINCE, Function.identity()), + Area::getId); + return convertList(dealCycleByAreaList, vo -> { + if (vo.getAreaId() != null) { + Integer parentId = AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE); + findAndThen(areaMap, parentId, area -> vo.setAreaId(parentId).setAreaName(area.getName())); + } + return vo; + }); + } + + @Override + public List getCustomerDealCycleByProduct(CrmStatisticsCustomerReqVO reqVO) { + // 1. 获得用户编号数组 + List userIds = getUserIds(reqVO); + if (CollUtil.isEmpty(userIds)) { + return Collections.emptyList(); + } + reqVO.setUserIds(userIds); + + // 2. 获取客户产品统计数据 + List dealCycleByProductList = customerMapper.selectCustomerDealCycleGroupByProductId(reqVO); + if (CollUtil.isEmpty(dealCycleByProductList)) { + return Collections.emptyList(); + } + + return dealCycleByProductList; + } + /** * 拼接用户信息(昵称) * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml index 44c6c4b84..e850a0c88 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml @@ -19,17 +19,18 @@ @@ -53,13 +54,14 @@ COUNT(DISTINCT customer.id) AS customer_deal_count FROM crm_customer AS customer LEFT JOIN crm_contract AS contract ON contract.customer_id = customer.id - WHERE customer.deleted = 0 AND contract.deleted = 0 + WHERE customer.deleted = 0 + AND contract.deleted = 0 AND contract.audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status} AND customer.owner_user_id IN #{userId} - AND contract.create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime} + AND customer.create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime} GROUP BY customer.owner_user_id @@ -221,4 +223,42 @@ GROUP BY customer.owner_user_id + + + + From 6c9a3b0e119bd924b5201dd3e359e5fc306628ed Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sat, 13 Apr 2024 23:30:11 +0800 Subject: [PATCH 02/21] =?UTF-8?q?CRM:=20=E5=AE=8C=E5=96=84=E9=94=80?= =?UTF-8?q?=E5=94=AE=E6=BC=8F=E6=96=97=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../util/collection/CollectionUtils.java | 4 + .../CrmStatisticsFunnelController.java | 46 ++++++++ .../CrmStatisticBusinessEndStatusRespVO.java | 25 +++++ .../vo/funnel/CrmStatisticFunnelRespVO.java | 23 ++++ .../vo/funnel/CrmStatisticsFunnelReqVO.java | 42 +++++++ .../dal/mysql/business/CrmBusinessMapper.java | 19 +++- .../dal/mysql/customer/CrmCustomerMapper.java | 8 ++ .../statistics/CrmStatisticsFunnelMapper.java | 14 +++ .../service/business/CrmBusinessService.java | 19 ++++ .../business/CrmBusinessServiceImpl.java | 16 +++ .../service/customer/CrmCustomerService.java | 21 +++- .../customer/CrmCustomerServiceImpl.java | 9 ++ .../CrmStatisticsFunnelService.java | 32 ++++++ .../CrmStatisticsFunnelServiceImpl.java | 105 ++++++++++++++++++ .../CrmStatisticsPortraitServiceImpl.java | 14 ++- .../statistics/CrmStatisticsFunnelMapper.xml | 5 + 16 files changed, 388 insertions(+), 14 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticBusinessEndStatusRespVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticFunnelRespVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtils.java index 0d06bc799..91f534788 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtils.java @@ -97,6 +97,10 @@ public class CollectionUtils { .collect(Collectors.toList()); } + public static Set convertSet(Collection from) { + return convertSet(from, v -> v); + } + public static Set convertSet(Collection from, Function func) { if (CollUtil.isEmpty(from)) { return new HashSet<>(); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java new file mode 100644 index 000000000..cbcd95265 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java @@ -0,0 +1,46 @@ +package cn.iocoder.yudao.module.crm.controller.admin.statistics; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticBusinessEndStatusRespVO; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticFunnelRespVO; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; +import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsFunnelService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.validation.Valid; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - CRM 销售漏斗") +@RestController +@RequestMapping("/crm/statistics-funnel") +@Validated +public class CrmStatisticsFunnelController { + + @Resource + private CrmStatisticsFunnelService crmStatisticsFunnelService; + + @GetMapping("/get-funnel-summary") + @Operation(summary = "获取销售漏斗统计数据", description = "用于【销售漏斗】页面") + @PreAuthorize("@ss.hasPermission('crm:statistics-funnel:query')") + public CommonResult getFunnelSummary(@Valid CrmStatisticsFunnelReqVO reqVO) { + return success(crmStatisticsFunnelService.getFunnelSummary(reqVO)); + } + + + @GetMapping("/get-business-end-status-summary") + @Operation(summary = "获取商机结束状态统计", description = "用于【销售漏斗】页面") + @PreAuthorize("@ss.hasPermission('crm:statistics-funnel:query')") + public CommonResult> getBusinessEndStatusSummary(@Valid CrmStatisticsFunnelReqVO reqVO) { + return success(crmStatisticsFunnelService.getBusinessEndStatusSummary(reqVO)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticBusinessEndStatusRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticBusinessEndStatusRespVO.java new file mode 100644 index 000000000..fbec539d9 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticBusinessEndStatusRespVO.java @@ -0,0 +1,25 @@ +package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +@Schema(description = "管理后台 - CRM 商机结束状态统计 Response VO") +@NoArgsConstructor +@AllArgsConstructor +@Data +public class CrmStatisticBusinessEndStatusRespVO { + + @Schema(description = "结束状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Integer endStatus; + + @Schema(description = "商机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Long businessCount; + + @Schema(description = "商机总金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private BigDecimal totalPrice; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticFunnelRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticFunnelRespVO.java new file mode 100644 index 000000000..b2e36d406 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticFunnelRespVO.java @@ -0,0 +1,23 @@ +package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Schema(description = "管理后台 - CRM 销售漏斗 Response VO") +@NoArgsConstructor +@AllArgsConstructor +@Data +public class CrmStatisticFunnelRespVO { + + @Schema(description = "客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Long customerCount; + + @Schema(description = "商机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Long businessCount; + + @Schema(description = "赢单数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Long winCount; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java new file mode 100644 index 000000000..7edc6c59c --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java @@ -0,0 +1,42 @@ +package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - CRM 销售漏斗 Request VO") +@Data +public class CrmStatisticsFunnelReqVO { + + @Schema(description = "部门 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "部门 id 不能为空") + private Long deptId; + + /** + * 负责人用户 id, 当用户为空, 则计算部门下用户 + */ + @Schema(description = "负责人用户 id", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1") + private Long userId; + + /** + * userIds 目前不用前端传递,目前是方便后端通过 deptId 读取编号后,设置回来 + * 后续,可能会支持选择部分用户进行查询 + */ + @Schema(description = "负责人用户 id 集合", hidden = true, example = "2") + private List userIds; + + /** + * 前端如果选择自定义时间, 那么前端传递起始-终止时间, 如果选择其他时间间隔类型, 则由后台计算起始-终止时间 + * 并作为参数传递给Mapper + */ + @Schema(description = "时间范围", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] times; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java index fc5b070f4..88cfaa9fb 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java @@ -6,14 +6,15 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import org.apache.ibatis.annotations.Mapper; +import java.time.LocalDateTime; import java.util.Collection; import java.util.List; +import java.util.Set; /** * 商机 Mapper @@ -59,10 +60,24 @@ public interface CrmBusinessMapper extends BaseMapperX { return selectCount(CrmBusinessDO::getStatusTypeId, statusTypeId); } - default List selectListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId){ + default List selectListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId) { return selectList(new LambdaQueryWrapperX() .eq(CrmBusinessDO::getCustomerId, customerId) .eq(CrmBusinessDO::getOwnerUserId, ownerUserId)); } + default Long selectCountByOwnerUserIdsAndEndStatus(Collection ownerUserIds, LocalDateTime[] times, Integer endStatus) { + return selectCount(new LambdaQueryWrapperX() + .in(CrmBusinessDO::getOwnerUserId, ownerUserIds) + .eqIfPresent(CrmBusinessDO::getEndStatus, endStatus) + .betweenIfPresent(CrmBusinessDO::getCreateTime, times)); + } + + default List selectListByOwnerUserIdsAndEndStatusNotNull(Collection ownerUserIds, LocalDateTime[] times){ + return selectList(new LambdaQueryWrapperX() + .in(CrmBusinessDO::getOwnerUserId, ownerUserIds) + .betweenIfPresent(CrmBusinessDO::getCreateTime, times) + .isNotNull(CrmBusinessDO::getEndStatus)); + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java index 615783950..b61dbeba2 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java @@ -19,9 +19,11 @@ import org.apache.ibatis.annotations.Mapper; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import javax.management.ObjectName; import java.time.LocalDateTime; import java.util.Collection; import java.util.List; +import java.util.Set; /** * 客户 Mapper @@ -186,4 +188,10 @@ public interface CrmCustomerMapper extends BaseMapperX { return selectCount(query); } + default Long selectCountByOwnerUserIds(Collection ownerUserIds, LocalDateTime[] times){ + return selectCount(new LambdaQueryWrapperX() + .in(CrmCustomerDO::getOwnerUserId, ownerUserIds) + .betweenIfPresent(CrmCustomerDO::getCreateTime, times)); + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java new file mode 100644 index 000000000..bd19c7539 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.statistics; + +import org.apache.ibatis.annotations.Mapper; + +/** + * CRM 销售漏斗 Mapper + * + * @author HUIHUI + */ +@Mapper +public interface CrmStatisticsFunnelMapper { + + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java index 7bd899b64..9ea281399 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java @@ -194,4 +194,23 @@ public interface CrmBusinessService { */ List getBusinessListByCustomerIdOwnerUserId(Long customerId, Long ownerUserId); + /** + * 获得商机数 + * + * @param ownerUserIds 负责人编号 + * @param times 时间范围 + * @param endStatus 商机结束状态 + * @return 商机数 + */ + Long getBusinessCountByOwnerUserIdsAndEndStatus(List ownerUserIds, LocalDateTime[] times, Integer endStatus); + + /** + * 获得商机列表【数据统计】 + * + * @param ownerUserIds 负责人编号 + * @param times 时间范围 + * @return 商机列表 + */ + List getBusinessListByOwnerUserIdsAndEndStatusNotNull(List ownerUserIds, LocalDateTime[] times); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java index 26f02b2f0..f94d27e85 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java @@ -375,4 +375,20 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { return businessMapper.selectListByCustomerIdOwnerUserId(customerId, ownerUserId); } + @Override + public Long getBusinessCountByOwnerUserIdsAndEndStatus(List ownerUserIds, LocalDateTime[] times, Integer endStatus) { + if (CollUtil.isEmpty(ownerUserIds)) { + return 0L; + } + return businessMapper.selectCountByOwnerUserIdsAndEndStatus(convertSet(ownerUserIds), times, endStatus); + } + + @Override + public List getBusinessListByOwnerUserIdsAndEndStatusNotNull(List ownerUserIds, LocalDateTime[] times) { + if (CollUtil.isEmpty(ownerUserIds)) { + return Collections.emptyList(); + } + return businessMapper.selectListByOwnerUserIdsAndEndStatusNotNull(convertSet(ownerUserIds), times); + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java index a99269e08..0307dd890 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java @@ -39,7 +39,7 @@ public interface CrmCustomerService { /** * 更新客户的跟进状态 * - * @param id 编号 + * @param id 编号 * @param dealStatus 跟进状态 */ void updateCustomerDealStatus(Long id, Boolean dealStatus); @@ -47,8 +47,8 @@ public interface CrmCustomerService { /** * 更新客户相关的跟进信息 * - * @param id 编号 - * @param contactNextTime 下次联系时间 + * @param id 编号 + * @param contactNextTime 下次联系时间 * @param contactLastContent 最后联系内容 */ void updateCustomerFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent); @@ -99,8 +99,8 @@ public interface CrmCustomerService { /** * 获得放入公海提醒的客户分页 * - * @param pageVO 分页查询 - * @param userId 用户编号 + * @param pageVO 分页查询 + * @param userId 用户编号 * @return 客户分页 */ PageResult getPutPoolRemindCustomerPage(CrmCustomerPageReqVO pageVO, Long userId); @@ -108,7 +108,7 @@ public interface CrmCustomerService { /** * 获得待进入公海的客户数量 * - * @param userId 用户编号 + * @param userId 用户编号 * @return 提醒数量 */ Long getPutPoolRemindCustomerCount(Long userId); @@ -195,4 +195,13 @@ public interface CrmCustomerService { */ int autoPutCustomerPool(); + /** + * 获得客户数 + * + * @param ownerUserIds 负责人编号 + * @param times 时间范围 + * @return 客户数 + */ + Long getCustomerCountByOwnerUserIds(List ownerUserIds, LocalDateTime[] times); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java index cdb7a32d9..be708d3e3 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java @@ -47,6 +47,7 @@ import java.time.LocalDateTime; import java.util.*; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; @@ -650,6 +651,14 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { } } + @Override + public Long getCustomerCountByOwnerUserIds(List ownerUserIds, LocalDateTime[] times) { + if (CollUtil.isEmpty(ownerUserIds)) { + return 0L; + } + return customerMapper.selectCountByOwnerUserIds(convertSet(ownerUserIds), times); + } + /** * 获得自身的代理对象,解决 AOP 生效问题 * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java new file mode 100644 index 000000000..d3d0b6d4c --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.crm.service.statistics; + +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticBusinessEndStatusRespVO; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticFunnelRespVO; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; + +import java.util.List; + +/** + * CRM 销售漏斗分析 Service + * + * @author HUIHUI + */ +public interface CrmStatisticsFunnelService { + + /** + * 获得销售漏斗数据 + * + * @param reqVO 请求 + * @return 销售漏斗数据 + */ + CrmStatisticFunnelRespVO getFunnelSummary(CrmStatisticsFunnelReqVO reqVO); + + /** + * 获得商机结束状态统计 + * + * @param reqVO 请求 + * @return 商机结束状态统计 + */ + List getBusinessEndStatusSummary(CrmStatisticsFunnelReqVO reqVO); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java new file mode 100644 index 000000000..8dedb1c71 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java @@ -0,0 +1,105 @@ +package cn.iocoder.yudao.module.crm.service.statistics; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjUtil; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticBusinessEndStatusRespVO; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticFunnelRespVO; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; +import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsFunnelMapper; +import cn.iocoder.yudao.module.crm.enums.business.CrmBusinessEndStatusEnum; +import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; +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.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; + +/** + * CRM 销售漏斗分析 Service 实现类 + * + * @author HUIHUI + */ +@Service +public class CrmStatisticsFunnelServiceImpl implements CrmStatisticsFunnelService { + + @Resource + private CrmStatisticsFunnelMapper funnelMapper; + + @Resource + private AdminUserApi adminUserApi; + @Resource + private CrmCustomerService customerService; + @Resource + private CrmBusinessService businessService; + @Resource + private DeptApi deptApi; + + @Override + public CrmStatisticFunnelRespVO getFunnelSummary(CrmStatisticsFunnelReqVO reqVO) { + // 1. 获得用户编号数组 + List userIds = getUserIds(reqVO); + if (CollUtil.isEmpty(userIds)) { + return null; + } + reqVO.setUserIds(userIds); + + // 2. 获得漏斗数据 + return new CrmStatisticFunnelRespVO( + customerService.getCustomerCountByOwnerUserIds(userIds, reqVO.getTimes()), + businessService.getBusinessCountByOwnerUserIdsAndEndStatus(userIds, reqVO.getTimes(), null), + businessService.getBusinessCountByOwnerUserIdsAndEndStatus(userIds, reqVO.getTimes(), CrmBusinessEndStatusEnum.WIN.getStatus()) + ); + } + + @Override + public List getBusinessEndStatusSummary(CrmStatisticsFunnelReqVO reqVO) { + // 1. 获得用户编号数组 + List userIds = getUserIds(reqVO); + if (CollUtil.isEmpty(userIds)) { + return null; + } + reqVO.setUserIds(userIds); + + // 2.1 获得用户负责的商机 + List businessList = businessService.getBusinessListByOwnerUserIdsAndEndStatusNotNull(userIds, reqVO.getTimes()); + // 2.2 统计各阶段数据 + Map> businessMap = convertMultiMap(businessList, CrmBusinessDO::getEndStatus); + return convertList(CrmBusinessEndStatusEnum.values(), endStatusEnum -> { + List list = businessMap.get(endStatusEnum.getStatus()); + if (CollUtil.isEmpty(list)) { + return new CrmStatisticBusinessEndStatusRespVO(endStatusEnum.getStatus(), 0L, BigDecimal.ZERO); + } + return new CrmStatisticBusinessEndStatusRespVO(endStatusEnum.getStatus(), (long) list.size(), + getSumValue(list, CrmBusinessDO::getTotalPrice, BigDecimal::add)); + }); + } + + /** + * 获取用户编号数组。如果用户编号为空, 则获得部门下的用户编号数组,包括子部门的所有用户编号 + * + * @param reqVO 请求参数 + * @return 用户编号数组 + */ + private List getUserIds(CrmStatisticsFunnelReqVO reqVO) { + // 情况一:选中某个用户 + if (ObjUtil.isNotNull(reqVO.getUserId())) { + return List.of(reqVO.getUserId()); + } + // 情况二:选中某个部门 + // 2.1 获得部门列表 + List deptIds = convertList(deptApi.getChildDeptList(reqVO.getDeptId()), DeptRespDTO::getId); + deptIds.add(reqVO.getDeptId()); + // 2.2 获得用户编号 + return convertList(adminUserApi.getUserListByDeptIds(deptIds), AdminUserRespDTO::getId); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitServiceImpl.java index eae012866..83cbb53e7 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPortraitServiceImpl.java @@ -20,7 +20,6 @@ import java.util.Map; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; /** * CRM 客户画像 Service 实现类 @@ -55,15 +54,18 @@ public class CrmStatisticsPortraitServiceImpl implements CrmStatisticsPortraitSe // 3. 拼接数据 List areaList = AreaUtils.getByType(AreaTypeEnum.PROVINCE, area -> area); - areaList.add(new Area().setId(null).setName("未知")); // TODO @puhui999:是不是 65 find 的逻辑改下;不用 findAndThen,直接从 areaMap 拿;拿到就设置,不拿到就设置 null 和 未知;这样,58 本行可以删除掉完事了;这样代码更简单和一致 Map areaMap = convertMap(areaList, Area::getId); return convertList(list, item -> { Integer parentId = AreaUtils.getParentIdByType(item.getAreaId(), AreaTypeEnum.PROVINCE); - if (parentId == null) { // 找不到,归到未知 - return item.setAreaId(null).setAreaName("未知"); + if (parentId != null) { + Area area = areaMap.get(parentId); + if (area != null) { + item.setAreaId(parentId).setAreaName(area.getName()); + return item; + } } - findAndThen(areaMap, parentId, area -> item.setAreaId(parentId).setAreaName(area.getName())); - return item; + // 找不到,归到未知 + return item.setAreaId(null).setAreaName("未知"); }); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml new file mode 100644 index 000000000..8f68be501 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml @@ -0,0 +1,5 @@ + + + + + From 20b4bfd1b03fbcca713aa7d107491f53d592be9f Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sun, 14 Apr 2024 16:31:53 +0800 Subject: [PATCH 03/21] =?UTF-8?q?CRM:=20=E5=AE=8C=E5=96=84=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=95=86=E6=9C=BA=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CrmStatisticsFunnelController.java | 86 +++++++++++++- .../funnel/CrmStatisticsBusinessRespVO.java | 109 ++++++++++++++++++ ...StatisticsBusinessSummaryByDateRespVO.java | 21 ++++ .../vo/funnel/CrmStatisticsFunnelReqVO.java | 13 ++- .../dal/mysql/business/CrmBusinessMapper.java | 16 ++- .../statistics/CrmStatisticsFunnelMapper.java | 6 + .../service/business/CrmBusinessService.java | 19 +++ .../business/CrmBusinessServiceImpl.java | 14 +++ .../CrmStatisticsFunnelService.java | 19 +++ .../CrmStatisticsFunnelServiceImpl.java | 59 +++++++++- .../statistics/CrmStatisticsFunnelMapper.xml | 14 +++ 11 files changed, 367 insertions(+), 9 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessRespVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java index cbcd95265..0880b12a1 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java @@ -1,10 +1,28 @@ package cn.iocoder.yudao.module.crm.controller.admin.statistics; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; +import cn.iocoder.yudao.framework.common.util.number.NumberUtils; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticBusinessEndStatusRespVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticFunnelRespVO; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByDateRespVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; +import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; +import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusService; +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsFunnelService; +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.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; @@ -15,9 +33,14 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.stream.Stream; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; @Tag(name = "管理后台 - CRM 销售漏斗") @RestController @@ -27,6 +50,19 @@ public class CrmStatisticsFunnelController { @Resource private CrmStatisticsFunnelService crmStatisticsFunnelService; + @Resource + private CrmBusinessService businessService; + @Resource + private CrmCustomerService customerService; + @Resource + private CrmBusinessStatusService businessStatusTypeService; + @Resource + private CrmBusinessStatusService businessStatusService; + + @Resource + private AdminUserApi adminUserApi; + @Resource + private DeptApi deptApi; @GetMapping("/get-funnel-summary") @Operation(summary = "获取销售漏斗统计数据", description = "用于【销售漏斗】页面") @@ -35,7 +71,6 @@ public class CrmStatisticsFunnelController { return success(crmStatisticsFunnelService.getFunnelSummary(reqVO)); } - @GetMapping("/get-business-end-status-summary") @Operation(summary = "获取商机结束状态统计", description = "用于【销售漏斗】页面") @PreAuthorize("@ss.hasPermission('crm:statistics-funnel:query')") @@ -43,4 +78,53 @@ public class CrmStatisticsFunnelController { return success(crmStatisticsFunnelService.getBusinessEndStatusSummary(reqVO)); } + @GetMapping("/get-business-summary-by-date") + @Operation(summary = "获取新增商机分析(按日期)", description = "用于【销售漏斗】页面") + @PreAuthorize("@ss.hasPermission('crm:statistics-funnel:query')") + public CommonResult> getBusinessSummaryByDate(@Valid CrmStatisticsFunnelReqVO reqVO) { + return success(crmStatisticsFunnelService.getBusinessSummaryByDate(reqVO)); + } + + @GetMapping("/get-business-page-by-date") + @Operation(summary = "获得商机分页(按日期)", description = "用于【销售漏斗】页面") + @PreAuthorize("@ss.hasPermission('crm:business:query')") + public CommonResult> getBusinessPageByDate(@Valid CrmStatisticsFunnelReqVO pageVO) { + PageResult pageResult = crmStatisticsFunnelService.getBusinessPageByDate(pageVO); + return success(new PageResult<>(buildBusinessDetailList(pageResult.getList()), pageResult.getTotal())); + } + + private List buildBusinessDetailList(List list) { + if (CollUtil.isEmpty(list)) { + return Collections.emptyList(); + } + // 1.1 获取客户列表 + Map customerMap = customerService.getCustomerMap( + convertSet(list, CrmBusinessDO::getCustomerId)); + // 1.2 获取创建人、负责人列表 + Map userMap = adminUserApi.getUserMap(convertListByFlatMap(list, + contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); + Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); + // 1.3 获得商机状态组 + Map statusTypeMap = businessStatusTypeService.getBusinessStatusTypeMap( + convertSet(list, CrmBusinessDO::getStatusTypeId)); + Map statusMap = businessStatusService.getBusinessStatusMap( + convertSet(list, CrmBusinessDO::getStatusId)); + // 2. 拼接数据 + return BeanUtils.toBean(list, CrmBusinessRespVO.class, businessVO -> { + // 2.1 设置客户名称 + MapUtils.findAndThen(customerMap, businessVO.getCustomerId(), customer -> businessVO.setCustomerName(customer.getName())); + // 2.2 设置创建人、负责人名称 + MapUtils.findAndThen(userMap, NumberUtils.parseLong(businessVO.getCreator()), + user -> businessVO.setCreatorName(user.getNickname())); + MapUtils.findAndThen(userMap, businessVO.getOwnerUserId(), user -> { + businessVO.setOwnerUserName(user.getNickname()); + MapUtils.findAndThen(deptMap, user.getDeptId(), dept -> businessVO.setOwnerUserDeptName(dept.getName())); + }); + // 2.3 设置商机状态 + MapUtils.findAndThen(statusTypeMap, businessVO.getStatusTypeId(), statusType -> businessVO.setStatusTypeName(statusType.getName())); + MapUtils.findAndThen(statusMap, businessVO.getStatusId(), status -> businessVO.setStatusName( + businessService.getBusinessStatusName(businessVO.getEndStatus(), status))); + }); + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessRespVO.java new file mode 100644 index 000000000..48e4817ac --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessRespVO.java @@ -0,0 +1,109 @@ +package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; + +@Schema(description = "管理后台 - CRM 商机 Response VO") +@Data +@ExcelIgnoreUnannotated +public class CrmStatisticsBusinessRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "商机名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") + @ExcelProperty("商机名称") + private String name; + + @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10299") + private Long customerId; + @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") + @ExcelProperty("客户名称") + private String customerName; + + @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example ="true") + @ExcelProperty("跟进状态") + private Boolean followUpStatus; + + @Schema(description = "最后跟进时间") + @ExcelProperty("最后跟进时间") + private LocalDateTime contactLastTime; + + @Schema(description = "下次联系时间") + @ExcelProperty("下次联系时间") + private LocalDateTime contactNextTime; + + @Schema(description = "负责人的用户编号", example = "25682") + @ExcelProperty("负责人的用户编号") + private Long ownerUserId; + @Schema(description = "负责人名字", example = "25682") + @ExcelProperty("负责人名字") + private String ownerUserName; + @Schema(description = "负责人部门") + @ExcelProperty("负责人部门") + private String ownerUserDeptName; + + @Schema(description = "商机状态组编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25714") + private Long statusTypeId; + @Schema(description = "商机状组名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "进行中") + @ExcelProperty("商机状态组") + private String statusTypeName; + + @Schema(description = "商机状态编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") + private Long statusId; + @Schema(description = "状态名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "跟进中") + @ExcelProperty("商机状态") + private String statusName; + + @Schema + @ExcelProperty("结束状态") + private Integer endStatus; + + @ExcelProperty("结束时的备注") + private String endRemark; + + @Schema(description = "预计成交日期") + @ExcelProperty("预计成交日期") + private LocalDateTime dealTime; + + @Schema(description = "产品总金额", example = "12025") + @ExcelProperty("产品总金额") + private BigDecimal totalProductPrice; + + @Schema(description = "整单折扣") + @ExcelProperty("整单折扣") + private BigDecimal discountPercent; + + @Schema(description = "商机总金额", example = "12371") + @ExcelProperty("商机总金额") + private BigDecimal totalPrice; + + @Schema(description = "备注", example = "随便") + @ExcelProperty("备注") + private String remark; + + @Schema(description = "创建人", example = "1024") + @ExcelProperty("创建人") + private String creator; + @Schema(description = "创建人名字", example = "芋道源码") + @ExcelProperty("创建人名字") + private String creatorName; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("更新时间") + private LocalDateTime updateTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java new file mode 100644 index 000000000..7e5323525 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java @@ -0,0 +1,21 @@ +package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +@Schema(description = "管理后台 - CRM 新增商机分析(按日期) VO") +@Data +public class CrmStatisticsBusinessSummaryByDateRespVO { + + @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") + private String time; + + @Schema(description = "新增商机数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Integer businessCreateCount; + + @Schema(description = "新增商机金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private BigDecimal businessDealCount; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java index 7edc6c59c..fe15bc499 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java @@ -1,8 +1,13 @@ package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; +import cn.iocoder.yudao.framework.common.enums.DateIntervalEnum; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.validation.InEnum; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; @@ -12,7 +17,9 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Schema(description = "管理后台 - CRM 销售漏斗 Request VO") @Data -public class CrmStatisticsFunnelReqVO { +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmStatisticsFunnelReqVO extends PageParam { @Schema(description = "部门 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @NotNull(message = "部门 id 不能为空") @@ -31,6 +38,10 @@ public class CrmStatisticsFunnelReqVO { @Schema(description = "负责人用户 id 集合", hidden = true, example = "2") private List userIds; + @Schema(description = "时间间隔类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @InEnum(value = DateIntervalEnum.class, message = "时间间隔类型,必须是 {value}") + private Integer interval; + /** * 前端如果选择自定义时间, 那么前端传递起始-终止时间, 如果选择其他时间间隔类型, 则由后台计算起始-终止时间 * 并作为参数传递给Mapper diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java index 88cfaa9fb..5ee0908dc 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.crm.dal.mysql.business; +import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; @@ -14,7 +15,6 @@ import org.apache.ibatis.annotations.Mapper; import java.time.LocalDateTime; import java.util.Collection; import java.util.List; -import java.util.Set; /** * 商机 Mapper @@ -73,11 +73,23 @@ public interface CrmBusinessMapper extends BaseMapperX { .betweenIfPresent(CrmBusinessDO::getCreateTime, times)); } - default List selectListByOwnerUserIdsAndEndStatusNotNull(Collection ownerUserIds, LocalDateTime[] times){ + default List selectListByOwnerUserIdsAndEndStatusNotNull(Collection ownerUserIds, LocalDateTime[] times) { return selectList(new LambdaQueryWrapperX() .in(CrmBusinessDO::getOwnerUserId, ownerUserIds) .betweenIfPresent(CrmBusinessDO::getCreateTime, times) .isNotNull(CrmBusinessDO::getEndStatus)); } + default List selectListByOwnerUserIdsAndDate(Collection ownerUserIds, LocalDateTime[] times) { + return selectList(new LambdaQueryWrapperX() + .in(CrmBusinessDO::getOwnerUserId, ownerUserIds) + .betweenIfPresent(CrmBusinessDO::getCreateTime, times)); + } + + default PageResult selectPage(Collection ownerUserIds, LocalDateTime[] times, Integer pageNo, Integer pageSize) { + return selectPage(new PageParam().setPageNo(pageNo).setPageSize(pageSize), new LambdaQueryWrapperX() + .in(CrmBusinessDO::getOwnerUserId, ownerUserIds) + .betweenIfPresent(CrmBusinessDO::getCreateTime, times)); + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java index bd19c7539..db84c0a50 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java @@ -1,7 +1,12 @@ package cn.iocoder.yudao.module.crm.dal.mysql.statistics; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerSummaryByDateRespVO; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByDateRespVO; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + /** * CRM 销售漏斗 Mapper * @@ -10,5 +15,6 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface CrmStatisticsFunnelMapper { + List selectBusinessCreateCountGroupByDate(CrmStatisticsFunnelReqVO reqVO); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java index 9ea281399..950993d9b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java @@ -213,4 +213,23 @@ public interface CrmBusinessService { */ List getBusinessListByOwnerUserIdsAndEndStatusNotNull(List ownerUserIds, LocalDateTime[] times); + /** + * 获得商机列表【数据统计】 + * + * @param ownerUserIds 负责人编号 + * @param times 时间范围 + * @return 商机列表 + */ + List getBusinessListByOwnerUserIdsAndDate(List ownerUserIds, LocalDateTime[] times); + + /** + * 商机分页【数据统计】 + * @param ownerUserIds 负责人编号 + * @param times 时间范围 + * @param pageNo 页码 + * @param pageSize 数量 + * @return 商机分页 + */ + PageResult getBusinessPageByDate(List ownerUserIds, LocalDateTime[] times, Integer pageNo, Integer pageSize); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java index f94d27e85..30debf324 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java @@ -391,4 +391,18 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { return businessMapper.selectListByOwnerUserIdsAndEndStatusNotNull(convertSet(ownerUserIds), times); } + @Override + public List getBusinessListByOwnerUserIdsAndDate(List ownerUserIds, LocalDateTime[] times) { + if (CollUtil.isEmpty(ownerUserIds)) { + return Collections.emptyList(); + } + + return businessMapper.selectListByOwnerUserIdsAndDate(convertSet(ownerUserIds), times); + } + + @Override + public PageResult getBusinessPageByDate(List ownerUserIds, LocalDateTime[] times, Integer pageNo, Integer pageSize) { + return businessMapper.selectPage(ownerUserIds, times, pageNo, pageSize); + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java index d3d0b6d4c..04fcada70 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java @@ -1,8 +1,11 @@ package cn.iocoder.yudao.module.crm.service.statistics; +import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticBusinessEndStatusRespVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticFunnelRespVO; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByDateRespVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; import java.util.List; @@ -29,4 +32,20 @@ public interface CrmStatisticsFunnelService { */ List getBusinessEndStatusSummary(CrmStatisticsFunnelReqVO reqVO); + /** + * 获取新增商机分析(按日期) + * + * @param reqVO 请求 + * @return 新增商机分析 + */ + List getBusinessSummaryByDate(CrmStatisticsFunnelReqVO reqVO); + + /** + * 获得商机分页(按日期) + * + * @param pageVO 请求 + * @return 商机分页 + */ + PageResult getBusinessPageByDate(CrmStatisticsFunnelReqVO pageVO); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java index 8dedb1c71..03aac4aa9 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java @@ -2,8 +2,11 @@ package cn.iocoder.yudao.module.crm.service.statistics; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjUtil; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticBusinessEndStatusRespVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticFunnelRespVO; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByDateRespVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsFunnelMapper; @@ -18,10 +21,15 @@ import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; /** * CRM 销售漏斗分析 Service 实现类 @@ -63,14 +71,13 @@ public class CrmStatisticsFunnelServiceImpl implements CrmStatisticsFunnelServic @Override public List getBusinessEndStatusSummary(CrmStatisticsFunnelReqVO reqVO) { // 1. 获得用户编号数组 - List userIds = getUserIds(reqVO); - if (CollUtil.isEmpty(userIds)) { - return null; + reqVO.setUserIds(getUserIds(reqVO)); + if (CollUtil.isEmpty(reqVO.getUserIds())) { + return Collections.emptyList(); } - reqVO.setUserIds(userIds); // 2.1 获得用户负责的商机 - List businessList = businessService.getBusinessListByOwnerUserIdsAndEndStatusNotNull(userIds, reqVO.getTimes()); + List businessList = businessService.getBusinessListByOwnerUserIdsAndEndStatusNotNull(reqVO.getUserIds(), reqVO.getTimes()); // 2.2 统计各阶段数据 Map> businessMap = convertMultiMap(businessList, CrmBusinessDO::getEndStatus); return convertList(CrmBusinessEndStatusEnum.values(), endStatusEnum -> { @@ -83,6 +90,48 @@ public class CrmStatisticsFunnelServiceImpl implements CrmStatisticsFunnelServic }); } + @Override + public List getBusinessSummaryByDate(CrmStatisticsFunnelReqVO reqVO) { + // 1. 获得用户编号数组 + reqVO.setUserIds(getUserIds(reqVO)); + if (CollUtil.isEmpty(reqVO.getUserIds())) { + return Collections.emptyList(); + } + + // 2. 按天统计,获取分项统计数据 + List businessCreateCountList = funnelMapper.selectBusinessCreateCountGroupByDate(reqVO); + List businessList = businessService.getBusinessListByOwnerUserIdsAndDate(reqVO.getUserIds(), reqVO.getTimes()); + Map businessDealCountMap = businessList.stream().collect(Collectors.groupingBy(business -> + business.getCreateTime().format(DateTimeFormatter.ofPattern(FORMAT_YEAR_MONTH_DAY)), + Collectors.reducing(BigDecimal.ZERO, CrmBusinessDO::getTotalPrice, BigDecimal::add))); + + // 3. 按照日期间隔,合并数据 + List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); + return convertList(timeRanges, times -> { + Integer businessCreateCount = businessCreateCountList.stream() + .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) + .mapToInt(CrmStatisticsBusinessSummaryByDateRespVO::getBusinessCreateCount).sum(); + BigDecimal businessDealCount = businessDealCountMap.entrySet().stream() + .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getKey())) + .map(Map.Entry::getValue) + .reduce(BigDecimal.ZERO, BigDecimal::add); + return new CrmStatisticsBusinessSummaryByDateRespVO() + .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) + .setBusinessCreateCount(businessCreateCount).setBusinessDealCount(businessDealCount); + }); + } + + @Override + public PageResult getBusinessPageByDate(CrmStatisticsFunnelReqVO pageVO) { + // 1. 获得用户编号数组 + pageVO.setUserIds(getUserIds(pageVO)); + if (CollUtil.isEmpty(pageVO.getUserIds())) { + return PageResult.empty(); + } + + return businessService.getBusinessPageByDate(pageVO.getUserIds(), pageVO.getTimes(), pageVO.getPageNo(), pageVO.getPageSize()); + } + /** * 获取用户编号数组。如果用户编号为空, 则获得部门下的用户编号数组,包括子部门的所有用户编号 * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml index 8f68be501..c01cf1ddc 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml @@ -2,4 +2,18 @@ + + From 5159da30b4b5cf0fe290b8a1f411709ade6bcdd4 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 14 Apr 2024 20:13:31 +0800 Subject: [PATCH 04/21] =?UTF-8?q?crm=EF=BC=9Acode=20review=20=E5=91=98?= =?UTF-8?q?=E5=B7=A5=E5=AE=A2=E6=88=B7=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../statistics/CrmStatisticsCustomerService.java | 2 +- .../statistics/CrmStatisticsCustomerServiceImpl.java | 11 +++-------- .../mapper/statistics/CrmStatisticsCustomerMapper.xml | 1 - 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java index 56ecf975e..70c720b9e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java @@ -77,7 +77,7 @@ public interface CrmStatisticsCustomerService { /** * 客户成交周期(按日期) - *

+ * * 成交周期的定义:客户 customer 在创建出来,到合同 contract 第一次成交的时间差 * * @param reqVO 请求参数 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java index c5b933c43..b7b9a08d1 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java @@ -310,8 +310,7 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe } // 3. 拼接数据 - Map areaMap = convertMap(AreaUtils.getByType(AreaTypeEnum.PROVINCE, Function.identity()), - Area::getId); + Map areaMap = convertMap(AreaUtils.getByType(AreaTypeEnum.PROVINCE, Function.identity()), Area::getId); return convertList(dealCycleByAreaList, vo -> { if (vo.getAreaId() != null) { Integer parentId = AreaUtils.getParentIdByType(vo.getAreaId(), AreaTypeEnum.PROVINCE); @@ -331,12 +330,8 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe reqVO.setUserIds(userIds); // 2. 获取客户产品统计数据 - List dealCycleByProductList = customerMapper.selectCustomerDealCycleGroupByProductId(reqVO); - if (CollUtil.isEmpty(dealCycleByProductList)) { - return Collections.emptyList(); - } - - return dealCycleByProductList; + // TODO @dhb52:未读取产品名 + return customerMapper.selectCustomerDealCycleGroupByProductId(reqVO); } /** diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml index e850a0c88..7c1016dff 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml @@ -16,7 +16,6 @@ GROUP BY time - - SELECT DATE_FORMAT(create_time, '%Y-%m-%d') AS time, COUNT(*) AS businessCreateCount + SELECT + DATE_FORMAT(create_time, '%Y-%m-%d') AS time, + COUNT(*) AS businessCreateCount FROM crm_business WHERE deleted = 0 AND owner_user_id IN - - #{userId} - - AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND - #{times[1],javaType=java.time.LocalDateTime} + + #{userId} + + AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime} GROUP BY time From 488f99b512390f497556f31a7909cb5804c1343c Mon Sep 17 00:00:00 2001 From: dhb52 Date: Sun, 14 Apr 2024 21:55:45 +0800 Subject: [PATCH 06/21] =?UTF-8?q?fix:=20selectCustomerDealCycleGroupByProd?= =?UTF-8?q?uctId=E4=BD=BF=E7=94=A8LEFT=20JOIN=E6=9B=BF=E6=8D=A2=E5=AD=90?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/statistics/CrmStatisticsCustomerMapper.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml index 7c1016dff..dc10f1221 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml @@ -243,14 +243,17 @@ + SELECT COUNT(*) + FROM crm_customer + WHERE deleted = 0 + AND owner_user_id IN + + #{userId} + + AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND + #{times[1],javaType=java.time.LocalDateTime} + + + + + + + From c573585e75a292a9e35d5c73a4ec3bee015eedd2 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 15 Apr 2024 16:40:36 +0800 Subject: [PATCH 10/21] =?UTF-8?q?CRM:=20=E6=96=B0=E5=A2=9E=E5=95=86?= =?UTF-8?q?=E6=9C=BA=E8=B5=A2=E5=8D=95=E8=BD=AC=E5=8C=96=E7=8E=87=E5=88=86?= =?UTF-8?q?=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CrmStatisticsFunnelController.java | 12 ++++--- ...inessInversionRateSummaryByDateRespVO.java | 21 ++++++++++++ ...StatisticsBusinessSummaryByDateRespVO.java | 2 +- .../statistics/CrmStatisticsFunnelMapper.java | 3 ++ .../CrmStatisticsFunnelService.java | 13 ++++--- .../CrmStatisticsFunnelServiceImpl.java | 34 +++++++++++++++---- .../statistics/CrmStatisticsFunnelMapper.xml | 17 ++++++++++ 7 files changed, 87 insertions(+), 15 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessInversionRateSummaryByDateRespVO.java diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java index 2750c211e..85e0c3d4e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java @@ -5,10 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.crm.controller.admin.business.CrmBusinessController; import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByEndStatusRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticFunnelSummaryRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByDateRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.*; import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsFunnelService; import io.swagger.v3.oas.annotations.Operation; @@ -55,6 +52,13 @@ public class CrmStatisticsFunnelController { return success(funnelService.getBusinessSummaryByDate(reqVO)); } + @GetMapping("/get-business-inversion-rate-summary-by-date") + @Operation(summary = "获取商机转化率分析(按日期)", description = "用于【销售漏斗】页面") + @PreAuthorize("@ss.hasPermission('crm:statistics-funnel:query')") + public CommonResult> getBusinessInversionRateSummaryByDate(@Valid CrmStatisticsFunnelReqVO reqVO) { + return success(funnelService.getBusinessInversionRateSummaryByDate(reqVO)); + } + @GetMapping("/get-business-page-by-date") @Operation(summary = "获得商机分页(按日期)", description = "用于【销售漏斗】页面的【新增商机分析】") @PreAuthorize("@ss.hasPermission('crm:business:query')") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessInversionRateSummaryByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessInversionRateSummaryByDateRespVO.java new file mode 100644 index 000000000..b7650a91d --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessInversionRateSummaryByDateRespVO.java @@ -0,0 +1,21 @@ +package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; + +@Schema(description = "管理后台 - CRM 商机转化率分析(按日期) VO") +@Data +public class CrmStatisticsBusinessInversionRateSummaryByDateRespVO { + + @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") + private String time; + + @Schema(description = "商机数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Long businessCount; + + @Schema(description = "赢单商机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Long businessWinCount; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java index f364409d9..1f8056c46 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java @@ -13,7 +13,7 @@ public class CrmStatisticsBusinessSummaryByDateRespVO { private String time; @Schema(description = "新增商机数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer businessCreateCount; + private Long businessCreateCount; @Schema(description = "新增商机金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") private BigDecimal totalPrice; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java index e300b6636..d69fa6290 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.crm.dal.mysql.statistics; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessInversionRateSummaryByDateRespVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByDateRespVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByEndStatusRespVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; @@ -24,4 +25,6 @@ public interface CrmStatisticsFunnelMapper { List selectBusinessSummaryGroupByDate(CrmStatisticsFunnelReqVO reqVO); + List selectBusinessInversionRateSummaryByDate(CrmStatisticsFunnelReqVO reqVO); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java index 141ba068a..10458daac 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java @@ -1,10 +1,7 @@ package cn.iocoder.yudao.module.crm.service.statistics; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByEndStatusRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticFunnelSummaryRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByDateRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.*; import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; import java.util.List; @@ -40,6 +37,14 @@ public interface CrmStatisticsFunnelService { */ List getBusinessSummaryByDate(CrmStatisticsFunnelReqVO reqVO); + /** + * 获得商机转化率分析(按日期) + * + * @param reqVO 请求 + * @return 商机转化率分析 + */ + List getBusinessInversionRateSummaryByDate(CrmStatisticsFunnelReqVO reqVO); + /** * 获得商机分页(按日期) * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java index 5f5efb046..635f577d1 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java @@ -4,10 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticFunnelSummaryRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByDateRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByEndStatusRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.*; import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsFunnelMapper; import cn.iocoder.yudao.module.crm.enums.business.CrmBusinessEndStatusEnum; @@ -85,9 +82,9 @@ public class CrmStatisticsFunnelServiceImpl implements CrmStatisticsFunnelServic // 3. 按照日期间隔,合并数据 List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); return convertList(timeRanges, times -> { - Integer businessCreateCount = businessSummaryList.stream() + Long businessCreateCount = businessSummaryList.stream() .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToInt(CrmStatisticsBusinessSummaryByDateRespVO::getBusinessCreateCount).sum(); + .mapToLong(CrmStatisticsBusinessSummaryByDateRespVO::getBusinessCreateCount).sum(); BigDecimal businessDealCount = businessSummaryList.stream() .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) .map(CrmStatisticsBusinessSummaryByDateRespVO::getTotalPrice) @@ -98,6 +95,31 @@ public class CrmStatisticsFunnelServiceImpl implements CrmStatisticsFunnelServic }); } + @Override + public List getBusinessInversionRateSummaryByDate(CrmStatisticsFunnelReqVO reqVO) { + // 1. 获得用户编号数组 + reqVO.setUserIds(getUserIds(reqVO)); + if (CollUtil.isEmpty(reqVO.getUserIds())) { + return Collections.emptyList(); + } + + // 2. 按天统计,获取分项统计数据 + List businessSummaryList = funnelMapper.selectBusinessInversionRateSummaryByDate(reqVO); + // 3. 按照日期间隔,合并数据 + List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); + return convertList(timeRanges, times -> { + Long businessCount = businessSummaryList.stream() + .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) + .mapToLong(CrmStatisticsBusinessInversionRateSummaryByDateRespVO::getBusinessCount).sum(); + Long businessWinCount = businessSummaryList.stream() + .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) + .mapToLong(CrmStatisticsBusinessInversionRateSummaryByDateRespVO::getBusinessWinCount).sum(); + return new CrmStatisticsBusinessInversionRateSummaryByDateRespVO() + .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) + .setBusinessCount(businessCount).setBusinessWinCount(businessWinCount); + }); + } + @Override public PageResult getBusinessPageByDate(CrmStatisticsFunnelReqVO pageVO) { // 1. 获得用户编号数组 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml index 27c205de9..f61b4dfc2 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml @@ -60,4 +60,21 @@ GROUP BY time + + From 1d239c98776b22d055550a8b4db708e3d974efd7 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 16 Apr 2024 09:17:11 +0800 Subject: [PATCH 11/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20rabbitmq=20=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96=E6=96=B9=E5=BC=8F=EF=BC=8C=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=20Jackson2JsonMessageConverter=20=E6=9B=BF=E4=BB=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YudaoRabbitMQAutoConfiguration.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/rabbitmq/config/YudaoRabbitMQAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/rabbitmq/config/YudaoRabbitMQAutoConfiguration.java index 770c50ff7..af1467376 100644 --- a/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/rabbitmq/config/YudaoRabbitMQAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/rabbitmq/config/YudaoRabbitMQAutoConfiguration.java @@ -1,12 +1,11 @@ package cn.iocoder.yudao.framework.mq.rabbitmq.config; -import cn.hutool.core.util.ReflectUtil; import lombok.extern.slf4j.Slf4j; -import org.springframework.amqp.utils.SerializationUtils; +import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; +import org.springframework.amqp.support.converter.MessageConverter; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; - -import java.lang.reflect.Field; +import org.springframework.context.annotation.Bean; /** * RabbitMQ 消息队列配置类 @@ -18,12 +17,12 @@ import java.lang.reflect.Field; @ConditionalOnClass(name = "org.springframework.amqp.rabbit.core.RabbitTemplate") public class YudaoRabbitMQAutoConfiguration { - static { - // 强制设置 SerializationUtils 的 TRUST_ALL 为 true,避免 RabbitMQ Consumer 反序列化消息报错 - // 为什么不通过设置 spring.amqp.deserialization.trust.all 呢?因为可能在 SerializationUtils static 初始化后 - Field trustAllField = ReflectUtil.getField(SerializationUtils.class, "TRUST_ALL"); - ReflectUtil.removeFinalModify(trustAllField); - ReflectUtil.setFieldValue(SerializationUtils.class, trustAllField, true); + /** + * Jackson2JsonMessageConverter Bean:使用 jackson 序列化消息 + */ + @Bean + public MessageConverter createMessageConverter() { + return new Jackson2JsonMessageConverter(); } } From b5af357dfc7ec6426f6a427ddb7d1411c61e1933 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 14 Apr 2024 22:09:11 +0800 Subject: [PATCH 12/21] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=9A=84=20bugfix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/crm/service/clue/CrmClueServiceImpl.java | 2 +- .../service/comment/ProductCommentServiceImpl.java | 2 +- .../system/controller/admin/dept/vo/dept/DeptRespVO.java | 2 +- .../controller/admin/dept/vo/dept/DeptSaveReqVO.java | 2 +- .../system/controller/admin/dept/vo/post/PostRespVO.java | 2 +- .../controller/admin/dept/vo/post/PostSaveReqVO.java | 2 +- .../controller/admin/dict/vo/data/DictDataRespVO.java | 2 +- .../controller/admin/dict/vo/data/DictDataSaveReqVO.java | 2 +- .../controller/admin/permission/vo/menu/MenuRespVO.java | 2 +- .../controller/admin/permission/vo/menu/MenuSaveVO.java | 2 +- .../controller/admin/permission/vo/role/RoleRespVO.java | 2 +- .../admin/permission/vo/role/RoleSaveReqVO.java | 2 +- .../system/service/permission/MenuServiceImpl.java | 9 +++++++-- 13 files changed, 19 insertions(+), 14 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java index 70ebeb44d..9724eeaf2 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java @@ -120,7 +120,7 @@ public class CrmClueServiceImpl implements CrmClueService { } @Override - @LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_FOLLOW_UP_SUB_TYPE, bizNo = "{{#id}", + @LogRecord(type = CRM_CLUE_TYPE, subType = CRM_CLUE_FOLLOW_UP_SUB_TYPE, bizNo = "{{#id}}", success = CRM_CLUE_FOLLOW_UP_SUCCESS) @CrmPermission(bizType = CrmBizTypeEnum.CRM_CLUE, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) public void updateClueFollowUp(Long id, LocalDateTime contactNextTime, String contactLastContent) { diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java index a089e2673..83c8e93a1 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java @@ -113,7 +113,7 @@ public class ProductCommentServiceImpl implements ProductCommentService { // 更新可见状态 productCommentMapper.updateById(new ProductCommentDO().setId(updateReqVO.getId()) - .setVisible(true)); + .setVisible(updateReqVO.getVisible())); } @Override diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/dept/DeptRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/dept/DeptRespVO.java index 777cb75de..83e6ed085 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/dept/DeptRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/dept/DeptRespVO.java @@ -18,7 +18,7 @@ public class DeptRespVO { @Schema(description = "父部门 ID", example = "1024") private Long parentId; - @Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") private Integer sort; @Schema(description = "负责人的用户编号", example = "2048") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/dept/DeptSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/dept/DeptSaveReqVO.java index 7b395dac8..4d25b7cfb 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/dept/DeptSaveReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/dept/DeptSaveReqVO.java @@ -25,7 +25,7 @@ public class DeptSaveReqVO { @Schema(description = "父部门 ID", example = "1024") private Long parentId; - @Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @NotNull(message = "显示顺序不能为空") private Integer sort; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/post/PostRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/post/PostRespVO.java index a037a132a..dde6f9509 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/post/PostRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/post/PostRespVO.java @@ -27,7 +27,7 @@ public class PostRespVO { @ExcelProperty("岗位编码") private String code; - @Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @ExcelProperty("岗位排序") private Integer sort; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/post/PostSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/post/PostSaveReqVO.java index 91f69e545..5ac2be372 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/post/PostSaveReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/vo/post/PostSaveReqVO.java @@ -26,7 +26,7 @@ public class PostSaveReqVO { @Size(max = 64, message = "岗位编码长度不能超过64个字符") private String code; - @Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @NotNull(message = "显示顺序不能为空") private Integer sort; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/vo/data/DictDataRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/vo/data/DictDataRespVO.java index e0b940a58..8857a7059 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/vo/data/DictDataRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/vo/data/DictDataRespVO.java @@ -19,7 +19,7 @@ public class DictDataRespVO { @ExcelProperty("字典编码") private Long id; - @Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @ExcelProperty("字典排序") private Integer sort; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/vo/data/DictDataSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/vo/data/DictDataSaveReqVO.java index 8e4ee4f27..ca71572ac 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/vo/data/DictDataSaveReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/vo/data/DictDataSaveReqVO.java @@ -16,7 +16,7 @@ public class DictDataSaveReqVO { @Schema(description = "字典数据编号", example = "1024") private Long id; - @Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @NotNull(message = "显示顺序不能为空") private Integer sort; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuRespVO.java index 39e752942..8dff186e0 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuRespVO.java @@ -28,7 +28,7 @@ public class MenuRespVO { @NotNull(message = "菜单类型不能为空") private Integer type; - @Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @NotNull(message = "显示顺序不能为空") private Integer sort; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuSaveVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuSaveVO.java index beb4b3869..9f96f19ad 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuSaveVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuSaveVO.java @@ -27,7 +27,7 @@ public class MenuSaveVO { @NotNull(message = "菜单类型不能为空") private Integer type; - @Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @NotNull(message = "显示顺序不能为空") private Integer sort; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleRespVO.java index f249406fa..e7b48c8bc 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleRespVO.java @@ -30,7 +30,7 @@ public class RoleRespVO { @ExcelProperty("角色标志") private String code; - @Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @ExcelProperty("角色排序") private Integer sort; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleSaveReqVO.java index dc97bc276..ee5951fc0 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleSaveReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/role/RoleSaveReqVO.java @@ -27,7 +27,7 @@ public class RoleSaveReqVO { @DiffLogField(name = "角色标志") private String code; - @Schema(description = "显示顺序不能为空", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") @NotNull(message = "显示顺序不能为空") @DiffLogField(name = "显示顺序") private Integer sort; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java index 694a64d2f..beee296d1 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/MenuServiceImpl.java @@ -2,14 +2,16 @@ package cn.iocoder.yudao.module.system.service.permission; import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.module.system.controller.admin.permission.vo.menu.MenuSaveVO; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.menu.MenuListReqVO; +import cn.iocoder.yudao.module.system.controller.admin.permission.vo.menu.MenuSaveVO; import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO; import cn.iocoder.yudao.module.system.dal.mysql.permission.MenuMapper; import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; import cn.iocoder.yudao.module.system.enums.permission.MenuTypeEnum; import cn.iocoder.yudao.module.system.service.tenant.TenantService; import com.google.common.annotations.VisibleForTesting; +import com.google.common.collect.Lists; +import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; @@ -17,7 +19,6 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import jakarta.annotation.Resource; import java.util.Collection; import java.util.List; @@ -130,6 +131,10 @@ public class MenuServiceImpl implements MenuService { @Override public List getMenuList(Collection ids) { + // 当 ids 为空时,返回一个空的实例对象 + if (CollUtil.isEmpty(ids)) { + return Lists.newArrayList(); + } return menuMapper.selectBatchIds(ids); } From 98743db4806d34a84947d0ffdd65756b5fdeeaa4 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 15 Apr 2024 12:34:06 +0800 Subject: [PATCH 13/21] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20rocketmq=20=E5=9C=A8?= =?UTF-8?q?=20spring=20boot=203.x=20=E7=9A=84=E5=85=BC=E5=AE=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-dependencies/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yudao-dependencies/pom.xml b/yudao-dependencies/pom.xml index f5a03a90b..025269a4f 100644 --- a/yudao-dependencies/pom.xml +++ b/yudao-dependencies/pom.xml @@ -31,7 +31,7 @@ 3.26.0 8.1.3.62 - 2.2.3 + 2.3.0 2.2.7 2.1.0 From 222afd48af6f7f435ec92b6fa86597e25175bbb6 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 16 Apr 2024 09:17:11 +0800 Subject: [PATCH 14/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20rabbitmq=20=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E5=8C=96=E6=96=B9=E5=BC=8F=EF=BC=8C=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=20Jackson2JsonMessageConverter=20=E6=9B=BF=E4=BB=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../YudaoRabbitMQAutoConfiguration.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/rabbitmq/config/YudaoRabbitMQAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/rabbitmq/config/YudaoRabbitMQAutoConfiguration.java index 770c50ff7..af1467376 100644 --- a/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/rabbitmq/config/YudaoRabbitMQAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-mq/src/main/java/cn/iocoder/yudao/framework/mq/rabbitmq/config/YudaoRabbitMQAutoConfiguration.java @@ -1,12 +1,11 @@ package cn.iocoder.yudao.framework.mq.rabbitmq.config; -import cn.hutool.core.util.ReflectUtil; import lombok.extern.slf4j.Slf4j; -import org.springframework.amqp.utils.SerializationUtils; +import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; +import org.springframework.amqp.support.converter.MessageConverter; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; - -import java.lang.reflect.Field; +import org.springframework.context.annotation.Bean; /** * RabbitMQ 消息队列配置类 @@ -18,12 +17,12 @@ import java.lang.reflect.Field; @ConditionalOnClass(name = "org.springframework.amqp.rabbit.core.RabbitTemplate") public class YudaoRabbitMQAutoConfiguration { - static { - // 强制设置 SerializationUtils 的 TRUST_ALL 为 true,避免 RabbitMQ Consumer 反序列化消息报错 - // 为什么不通过设置 spring.amqp.deserialization.trust.all 呢?因为可能在 SerializationUtils static 初始化后 - Field trustAllField = ReflectUtil.getField(SerializationUtils.class, "TRUST_ALL"); - ReflectUtil.removeFinalModify(trustAllField); - ReflectUtil.setFieldValue(SerializationUtils.class, trustAllField, true); + /** + * Jackson2JsonMessageConverter Bean:使用 jackson 序列化消息 + */ + @Bean + public MessageConverter createMessageConverter() { + return new Jackson2JsonMessageConverter(); } } From b20ff55511c2206a0b78d8081aeeb8e3895ecb3b Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 18 Apr 2024 09:19:07 +0800 Subject: [PATCH 15/21] =?UTF-8?q?code=20review=EF=BC=9A=E9=94=80=E5=94=AE?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../statistics/CrmStatisticsFunnelMapper.xml | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml index f61b4dfc2..a07406259 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml @@ -3,19 +3,23 @@ - SELECT end_status AS endStatus,COUNT(*) AS businessCount, SUM(total_price) AS totalPrice + SELECT + end_status AS endStatus, + COUNT(*) AS businessCount, + SUM(total_price) AS totalPrice FROM crm_business WHERE deleted = 0 AND end_status IS NOT NULL AND owner_user_id IN @@ -46,9 +53,9 @@ SELECT - DATE_FORMAT(create_time, '%Y-%m-%d') AS time, - COUNT(*) AS businessCount, - SUM(IF(end_status = 1, 1, 0)) AS businessWinCount + DATE_FORMAT(create_time, '%Y-%m-%d') AS time, + COUNT(*) AS businessCount, + SUM(IF(end_status = 1, 1, 0)) AS businessWinCount FROM crm_business WHERE deleted = 0 AND owner_user_id IN From 9e6474a123fd6fec6be055002ca309abe2a012f2 Mon Sep 17 00:00:00 2001 From: scholar <1145227973@qq.com> Date: Fri, 19 Apr 2024 17:09:12 +0800 Subject: [PATCH 16/21] =?UTF-8?q?1=EF=BC=8C=E4=BC=98=E5=8C=96mapper.xml?= =?UTF-8?q?=E7=9A=84sql=E8=AF=AD=E5=8F=A5=EF=BC=9B=202=EF=BC=8C=E5=AF=B9?= =?UTF-8?q?=E4=BA=8E=E6=97=A0=E9=94=80=E5=94=AE=E6=95=B0=E6=8D=AE=E7=9A=84?= =?UTF-8?q?=E6=9C=88=E4=BB=BD=EF=BC=8C=E6=8F=92=E5=85=A5=E9=94=80=E5=94=AE?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E4=B8=BA0=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CrmStatisticsPerformanceServiceImpl.java | 81 ++++++++++-- .../CrmStatisticsPerformanceMapper.xml | 116 ++---------------- 2 files changed, 83 insertions(+), 114 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java index 067be4f43..c93951f81 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.crm.service.statistics; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceReqVO; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.performance.CrmStatisticsPerformanceRespVO; @@ -13,8 +14,9 @@ import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import jakarta.annotation.Resource; -import java.util.Collections; -import java.util.List; + +import java.math.BigDecimal; +import java.util.*; import java.util.function.Function; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; @@ -56,24 +58,87 @@ public class CrmStatisticsPerformanceServiceImpl implements CrmStatisticsPerform * 获得员工业绩数据 * * @param performanceReqVO 参数 - * @param performanceFunction 排行榜方法 - * @return 排行版数据 + * @param performanceFunction 员工业绩统计方法 + * @return 员工业绩数据 */ private List getPerformance(CrmStatisticsPerformanceReqVO performanceReqVO, Function> performanceFunction) { + List performanceRespVOList; + // 1. 获得用户编号数组 final List userIds = getUserIds(performanceReqVO); if (CollUtil.isEmpty(userIds)) { return Collections.emptyList(); } performanceReqVO.setUserIds(userIds); - // 2. 获得排行数据 + // 2. 获得业绩数据 List performance = performanceFunction.apply(performanceReqVO); - if (CollUtil.isEmpty(performance)) { - return Collections.emptyList(); + + // 获取查询的年份 + String currentYear = LocalDateTimeUtil.format(performanceReqVO.getTimes()[0],"yyyy"); + + // 构造查询当年和前一年,每年12个月的年月组合 + List allMonths = new ArrayList<>(); + for (int year = Integer.parseInt(currentYear)-1; year <= Integer.parseInt(currentYear); year++) { + for (int month = 1; month <= 12; month++) { + allMonths.add(String.format("%d%02d", year, month)); + } } - return performance; + + List computedList = new ArrayList<>(); + List respVOList = new ArrayList<>(); + + // 生成computedList基础数据 + // 构造完整的2*12个月的数据,如果某月数据缺失,需要补上0,一年12个月不能有缺失 + for (String month : allMonths) { + CrmStatisticsPerformanceRespVO foundData = performance.stream() + .filter(data -> data.getTime().equals(month)) + .findFirst() + .orElse(null); + + if (foundData != null) { + computedList.add(foundData); + } else { + CrmStatisticsPerformanceRespVO missingData = new CrmStatisticsPerformanceRespVO(); + missingData.setTime(month); + missingData.setCurrentMonthCount(BigDecimal.ZERO); + missingData.setLastMonthCount(BigDecimal.ZERO); + missingData.setLastYearCount(BigDecimal.ZERO); + computedList.add(missingData); + } + } + //根据查询年份和前一年的数据,计算查询年份的同比环比数据 + for (CrmStatisticsPerformanceRespVO currentData : computedList) { + String currentMonth = currentData.getTime(); + + // 根据当年和前一年的月销售数据,计算currentYear的完整数据 + if (currentMonth.startsWith(currentYear)) { + // 计算 LastMonthCount + int currentIndex = computedList.indexOf(currentData); + if (currentIndex > 0) { + CrmStatisticsPerformanceRespVO lastMonthData = computedList.get(currentIndex - 1); + currentData.setLastMonthCount(lastMonthData.getCurrentMonthCount()); + } else { + currentData.setLastMonthCount(BigDecimal.ZERO); // 第一个月的 LastMonthCount 设为0 + } + + // 计算 LastYearCount + String lastYearMonth = String.valueOf(Integer.parseInt(currentMonth) - 100); + CrmStatisticsPerformanceRespVO lastYearData = computedList.stream() + .filter(data -> data.getTime().equals(lastYearMonth)) + .findFirst() + .orElse(null); + + if (lastYearData != null) { + currentData.setLastYearCount(lastYearData.getCurrentMonthCount()); + } else { + currentData.setLastYearCount(BigDecimal.ZERO); // 如果去年同月数据不存在,设为0 + } + respVOList.add(currentData);//给前端只需要返回查询当年的数据,不需要前一年数据 + } + } + return respVOList; } /** diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPerformanceMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPerformanceMapper.xml index 10b952bac..ee9ec4e44 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPerformanceMapper.xml +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPerformanceMapper.xml @@ -5,27 +5,8 @@ + - From 9ab53ee2637a8e04a2134642b62421c879e5d779 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 23 Apr 2024 23:12:36 +0800 Subject: [PATCH 17/21] =?UTF-8?q?crm=EF=BC=9Acode=20review=20=E5=91=98?= =?UTF-8?q?=E5=B7=A5=E4=B8=9A=E7=BB=A9=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CrmStatisticsPerformanceServiceImpl.java | 10 +++++++++- .../CrmStatisticsPerformanceMapper.xml | 20 +++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java index 4c4193f7b..fcd7267a8 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsPerformanceServiceImpl.java @@ -40,7 +40,7 @@ public class CrmStatisticsPerformanceServiceImpl implements CrmStatisticsPerform @Override public List getContractCountPerformance(CrmStatisticsPerformanceReqVO performanceReqVO) { - // TODO @scholar:我们可以换个思路实现,减少数据库的计算量; + // TODO @scholar:可以把下面这个注释,你理解后,重新整理下,写到 getPerformance 里; // 比如说,2024 年的合同数据,是不是 2022-12 到 2024-12-31,每个月的统计呢? // 理解之后,我们可以数据 group by 年-月,20222-12 到 2024-12-31 的,然后内存在聚合出 CrmStatisticsPerformanceRespVO 这样 // 这样,我们就可以减少数据库的计算量,提升性能;同时 SQL 也会很简单,开发者理解起来也简单哈; @@ -57,6 +57,7 @@ public class CrmStatisticsPerformanceServiceImpl implements CrmStatisticsPerform return getPerformance(performanceReqVO, performanceMapper::selectReceivablePricePerformance); } + // TODO @scholar:代码注释,应该有 3 个变量哈; /** * 获得员工业绩数据 * @@ -64,9 +65,11 @@ public class CrmStatisticsPerformanceServiceImpl implements CrmStatisticsPerform * @param performanceFunction 员工业绩统计方法 * @return 员工业绩数据 */ + // TODO @scholar:下面一行的变量,超过一行了,阅读不美观;可以考虑每一行一个变量; private List getPerformance(CrmStatisticsPerformanceReqVO performanceReqVO, Function> performanceFunction) { + // TODO @scholar:没使用到的变量,建议删除; List performanceRespVOList; // 1. 获得用户编号数组 @@ -75,10 +78,15 @@ public class CrmStatisticsPerformanceServiceImpl implements CrmStatisticsPerform return Collections.emptyList(); } performanceReqVO.setUserIds(userIds); + // TODO @scholar:1. 和 2. 之间,可以考虑换一行;保证每一块逻辑的间隔; // 2. 获得业绩数据 + // TODO @scholar:复数变量,建议使用 s 或者 list 结果;这里用 performanceList 好列; List performance = performanceFunction.apply(performanceReqVO); // 获取查询的年份 + // TODO @scholar:逻辑可以简化一下; + // TODO 1)把 performance 转换成 map;key 是 time,value 是 count + // TODO 2)当前年,遍历 1-12 月份,去 map 拿到 count;接着月份 -1,去 map 拿 count;再年份 -1,拿 count String currentYear = LocalDateTimeUtil.format(performanceReqVO.getTimes()[0],"yyyy"); // 构造查询当年和前一年,每年12个月的年月组合 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPerformanceMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPerformanceMapper.xml index ee9ec4e44..79ff45471 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPerformanceMapper.xml +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsPerformanceMapper.xml @@ -5,20 +5,23 @@ + +