mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-29 18:51:53 +08:00
【代码评审】CRM:优化员工业绩统计的实现
This commit is contained in:
parent
95a8aa9ba9
commit
4a0ad205ae
@ -33,7 +33,6 @@ public class CrmStatisticsPerformanceReqVO {
|
||||
@Schema(description = "负责人用户 id 集合", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "2")
|
||||
private List<Long> userIds;
|
||||
|
||||
// TODO @scholar:应该传递的是 int year;年份
|
||||
@Schema(description = "时间范围", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@NotEmpty(message = "时间范围不能为空")
|
||||
|
@ -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<CrmStatisticsPerformanceRespVO> 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<CrmStatisticsPerformanceRespVO> performanceList = performanceFunction.apply(performanceReqVO);
|
||||
Map<String, BigDecimal> performanceMap = convertMap(performanceList, CrmStatisticsPerformanceRespVO::getTime,
|
||||
CrmStatisticsPerformanceRespVO::getCurrentMonthCount);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user