From 4a0ad205ae13ba7ca104dc5b75723a4d6b1a37f9 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 11 May 2024 22:30:37 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E8=AF=84=E5=AE=A1?= =?UTF-8?q?=E3=80=91CRM=EF=BC=9A=E4=BC=98=E5=8C=96=E5=91=98=E5=B7=A5?= =?UTF-8?q?=E4=B8=9A=E7=BB=A9=E7=BB=9F=E8=AE=A1=E7=9A=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CrmStatisticsPerformanceReqVO.java | 1 - .../CrmStatisticsPerformanceServiceImpl.java | 17 +++++++---------- .../CrmStatisticsPerformanceMapper.xml | 6 +++--- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/performance/CrmStatisticsPerformanceReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/performance/CrmStatisticsPerformanceReqVO.java index de76acbb3..bfb5c840f 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/performance/CrmStatisticsPerformanceReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/performance/CrmStatisticsPerformanceReqVO.java @@ -33,7 +33,6 @@ public class CrmStatisticsPerformanceReqVO { @Schema(description = "负责人用户 id 集合", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "2") private List userIds; - // TODO @scholar:应该传递的是 int year;年份 @Schema(description = "时间范围", requiredMode = Schema.RequiredMode.REQUIRED) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @NotEmpty(message = "时间范围不能为空") 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 07734e01d..1e7e3bbb2 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,7 +1,6 @@ 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; @@ -10,14 +9,16 @@ 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 org.springframework.validation.annotation.Validated; -import jakarta.annotation.Resource; - import java.math.BigDecimal; import java.time.LocalDateTime; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; import java.util.function.Function; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; @@ -40,7 +41,6 @@ public class CrmStatisticsPerformanceServiceImpl implements CrmStatisticsPerform @Resource private DeptApi deptApi; - @Override public List getContractCountPerformance(CrmStatisticsPerformanceReqVO performanceReqVO) { return getPerformance(performanceReqVO, performanceMapper::selectContractCountPerformance); @@ -77,11 +77,8 @@ public class CrmStatisticsPerformanceServiceImpl implements CrmStatisticsPerform performanceReqVO.setUserIds(userIds); // 2. 获得业绩数据 - int year = Integer.parseInt(LocalDateTimeUtil.format(performanceReqVO.getTimes()[0],"yyyy"));//获取查询的年份 - LocalDateTime[] timesRange = performanceReqVO.getTimes();//以时间段形式去数据库查询,时间段为所查询年份和前一年,两年时间的数据,便于计算同比数据 - timesRange[0] = performanceReqVO.getTimes()[0].minusYears(1);//查询的起始时间往前推一年 - timesRange[1] = performanceReqVO.getTimes()[1];//查询的结束时间 - performanceReqVO.setTimes(timesRange); + int year = performanceReqVO.getTimes()[0].getYear(); // 获取查询的年份 + performanceReqVO.getTimes()[0] = performanceReqVO.getTimes()[0].minusYears(1); List performanceList = performanceFunction.apply(performanceReqVO); Map performanceMap = convertMap(performanceList, CrmStatisticsPerformanceRespVO::getTime, CrmStatisticsPerformanceRespVO::getCurrentMonthCount); 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 f22b4fabe..81962cdae 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 @@ -7,7 +7,7 @@ SELECT DATE_FORMAT(order_date, '%Y%m') AS time, COUNT(1) AS currentMonthCount - FROM crm_contract + FROM crm_contract WHERE deleted = 0 AND audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status} AND owner_user_id in @@ -24,7 +24,7 @@ SELECT DATE_FORMAT(order_date, '%Y%m') AS time, IFNULL(SUM(total_price), 0) AS currentMonthCount - FROM crm_contract + FROM crm_contract WHERE deleted = 0 AND audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status} AND owner_user_id in @@ -41,7 +41,7 @@ SELECT DATE_FORMAT(return_time, '%Y%m') AS time, IFNULL(SUM(price), 0) AS currentMonthCount - FROM crm_receivable + FROM crm_receivable WHERE deleted = 0 AND audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status} AND owner_user_id in