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