Commit 0386820a1c80354917afe20e31cc5048a1f5be3d

Authored by dhb52
1 parent a23ea456

feat: 增加[客户行业、客户来源]等字段显示,重构代码

yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
... ... @@ -142,7 +142,7 @@ public class CrmCustomerController {
142 142 return java.util.Collections.emptyList();
143 143 }
144 144 // 1.1 获取创建人、负责人列表
145   - Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(list,
  145 + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSetByFlatMap(list,
146 146 contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId())));
147 147 Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
148 148 // 1.2 获取距离进入公海的时间
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerByUserBaseRespVO.java
1 1 package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer;
2 2  
  3 +import com.fasterxml.jackson.annotation.JsonIgnore;
3 4 import io.swagger.v3.oas.annotations.media.Schema;
4 5 import lombok.Data;
5 6  
... ... @@ -10,6 +11,7 @@ import lombok.Data;
10 11 public class CrmStatisticsCustomerByUserBaseRespVO {
11 12  
12 13 @Schema(description = "负责人ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  14 + @JsonIgnore
13 15 private Long ownerUserId;
14 16  
15 17 @Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerContractSummaryRespVO.java
1 1 package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer;
2 2  
3 3  
  4 +import com.fasterxml.jackson.annotation.JsonFormat;
  5 +import com.fasterxml.jackson.annotation.JsonIgnore;
4 6 import io.swagger.v3.oas.annotations.media.Schema;
5 7 import lombok.Data;
  8 +import org.springframework.format.annotation.DateTimeFormat;
6 9  
7 10 import java.math.BigDecimal;
8 11 import java.time.LocalDate;
9 12 import java.time.LocalDateTime;
10 13  
  14 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
  15 +
11 16 @Schema(description = "管理后台 - CRM 客户转化率分析 VO")
12 17 @Data
13 18 public class CrmStatisticsCustomerContractSummaryRespVO {
... ... @@ -24,20 +29,30 @@ public class CrmStatisticsCustomerContractSummaryRespVO {
24 29 @Schema(description = "回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1200.00")
25 30 private BigDecimal receivablePrice;
26 31  
  32 + @Schema(description = "客户行业ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
  33 + @JsonIgnore
  34 + private String industryId;
  35 +
27 36 @Schema(description = "客户行业", requiredMode = Schema.RequiredMode.REQUIRED, example = "金融")
28   - private String customerType;
  37 + private String industryName;
  38 +
  39 + @Schema(description = "客户来源ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  40 + @JsonIgnore
  41 + private String source;
29 42  
30 43 @Schema(description = "客户来源", requiredMode = Schema.RequiredMode.REQUIRED, example = "外呼")
31   - private String customerSource;
  44 + private String sourceName;
32 45  
33 46 @Schema(description = "负责人ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  47 + @JsonIgnore
34 48 private Long ownerUserId;
35 49  
36 50 @Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道源码")
37 51 private String ownerUserName;
38 52  
39 53 @Schema(description = "创建人ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
40   - private Long creatorUserId;
  54 + @JsonIgnore
  55 + private String creatorUserId;
41 56  
42 57 @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED, example = "源码")
43 58 private String creatorUserName;
... ... @@ -46,6 +61,7 @@ public class CrmStatisticsCustomerContractSummaryRespVO {
46 61 private LocalDateTime createTime;
47 62  
48 63 @Schema(description = "下单日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-02-02 00:00:00")
  64 + @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY, timezone = TIME_ZONE_DEFAULT)
49 65 private LocalDate orderDate;
50 66  
51 67 }
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerSummaryByUserRespVO.java
... ... @@ -16,9 +16,9 @@ public class CrmStatisticsCustomerSummaryByUserRespVO extends CrmStatisticsCusto
16 16 private Integer customerDealCount = 0;
17 17  
18 18 @Schema(description = "合同总金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
19   - private BigDecimal contractPrice = BigDecimal.valueOf(0);
  19 + private BigDecimal contractPrice = BigDecimal.ZERO;
20 20  
21 21 @Schema(description = "回款金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
22   - private BigDecimal receivablePrice = BigDecimal.valueOf(0);
  22 + private BigDecimal receivablePrice = BigDecimal.ZERO;
23 23  
24 24 }
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java
... ... @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
4 4 import cn.hutool.core.date.LocalDateTimeUtil;
5 5 import cn.hutool.core.util.ObjUtil;
6 6 import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
  7 +import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
7 8 import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.*;
8 9 import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsCustomerMapper;
9 10 import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
... ... @@ -19,9 +20,14 @@ import org.springframework.validation.annotation.Validated;
19 20  
20 21 import java.math.BigDecimal;
21 22 import java.time.LocalDateTime;
22   -import java.util.*;
  23 +import java.util.ArrayList;
  24 +import java.util.Collections;
  25 +import java.util.List;
  26 +import java.util.Map;
  27 +import java.util.stream.Stream;
23 28  
24 29 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
  30 +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.*;
25 31  
26 32 /**
27 33 * CRM 客户分析 Service 实现类
... ... @@ -68,16 +74,20 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe
68 74 final List<String> times = generateTimeSeries(reqVO.getTimes()[0], reqVO.getTimes()[1]);
69 75  
70 76 // 4. 合并统计数据
71   - List<CrmStatisticsCustomerSummaryByDateRespVO> result = new ArrayList<>(times.size());
72   - final Map<String, Integer> customerCreateCountMap = convertMap(customerCreateCount, CrmStatisticsCustomerSummaryByDateRespVO::getTime, CrmStatisticsCustomerSummaryByDateRespVO::getCustomerCreateCount);
73   - final Map<String, Integer> customerDealCountMap = convertMap(customerDealCount, CrmStatisticsCustomerSummaryByDateRespVO::getTime, CrmStatisticsCustomerSummaryByDateRespVO::getCustomerDealCount);
74   - times.forEach(time -> result.add(
  77 + List<CrmStatisticsCustomerSummaryByDateRespVO> respVoList = new ArrayList<>(times.size());
  78 + final Map<String, Integer> customerCreateCountMap = convertMap(customerCreateCount,
  79 + CrmStatisticsCustomerSummaryByDateRespVO::getTime,
  80 + CrmStatisticsCustomerSummaryByDateRespVO::getCustomerCreateCount);
  81 + final Map<String, Integer> customerDealCountMap = convertMap(customerDealCount,
  82 + CrmStatisticsCustomerSummaryByDateRespVO::getTime,
  83 + CrmStatisticsCustomerSummaryByDateRespVO::getCustomerDealCount);
  84 + times.forEach(time -> respVoList.add(
75 85 new CrmStatisticsCustomerSummaryByDateRespVO().setTime(time)
76 86 .setCustomerCreateCount(customerCreateCountMap.getOrDefault(time, 0))
77 87 .setCustomerDealCount(customerDealCountMap.getOrDefault(time, 0))
78 88 ));
79 89  
80   - return result;
  90 + return respVoList;
81 91 }
82 92  
83 93 @Override
... ... @@ -96,25 +106,33 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe
96 106 final List<CrmStatisticsCustomerSummaryByUserRespVO> receivablePrice = customerMapper.selectReceivablePriceGroupbyUser(reqVO);
97 107  
98 108 // 3. 合并统计数据
99   - final Map<Long, Integer> customerCreateCountMap = convertMap(customerCreateCount, CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, CrmStatisticsCustomerSummaryByUserRespVO::getCustomerCreateCount);
100   - final Map<Long, Integer> customerDealCountMap = convertMap(customerDealCount, CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, CrmStatisticsCustomerSummaryByUserRespVO::getCustomerDealCount);
101   - final Map<Long, BigDecimal> contractPriceMap = convertMap(contractPrice, CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, CrmStatisticsCustomerSummaryByUserRespVO::getContractPrice);
102   - final Map<Long, BigDecimal> receivablePriceMap = convertMap(receivablePrice, CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, CrmStatisticsCustomerSummaryByUserRespVO::getReceivablePrice);
103   - List<CrmStatisticsCustomerSummaryByUserRespVO> result = new ArrayList<>(userIds.size());
  109 + final Map<Long, Integer> customerCreateCountMap = convertMap(customerCreateCount,
  110 + CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId,
  111 + CrmStatisticsCustomerSummaryByUserRespVO::getCustomerCreateCount);
  112 + final Map<Long, Integer> customerDealCountMap = convertMap(customerDealCount,
  113 + CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId,
  114 + CrmStatisticsCustomerSummaryByUserRespVO::getCustomerDealCount);
  115 + final Map<Long, BigDecimal> contractPriceMap = convertMap(contractPrice,
  116 + CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId,
  117 + CrmStatisticsCustomerSummaryByUserRespVO::getContractPrice);
  118 + final Map<Long, BigDecimal> receivablePriceMap = convertMap(receivablePrice,
  119 + CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId,
  120 + CrmStatisticsCustomerSummaryByUserRespVO::getReceivablePrice);
  121 + List<CrmStatisticsCustomerSummaryByUserRespVO> respVoList = new ArrayList<>(userIds.size());
104 122 userIds.forEach(userId -> {
105   - final CrmStatisticsCustomerSummaryByUserRespVO respVO = new CrmStatisticsCustomerSummaryByUserRespVO();
106   - respVO.setOwnerUserId(userId);
107   - respVO.setCustomerCreateCount(customerCreateCountMap.getOrDefault(userId, 0))
  123 + final CrmStatisticsCustomerSummaryByUserRespVO vo = new CrmStatisticsCustomerSummaryByUserRespVO();
  124 + vo.setOwnerUserId(userId);
  125 + vo.setCustomerCreateCount(customerCreateCountMap.getOrDefault(userId, 0))
108 126 .setCustomerDealCount(customerDealCountMap.getOrDefault(userId, 0))
109   - .setContractPrice(contractPriceMap.getOrDefault(userId, BigDecimal.valueOf(0)))
110   - .setReceivablePrice(receivablePriceMap.getOrDefault(userId, BigDecimal.valueOf(0)));
111   - result.add(respVO);
  127 + .setContractPrice(contractPriceMap.getOrDefault(userId, BigDecimal.ZERO))
  128 + .setReceivablePrice(receivablePriceMap.getOrDefault(userId, BigDecimal.ZERO));
  129 + respVoList.add(vo);
112 130 });
113 131  
114 132 // 4. 拼接用户信息
115   - appendUserInfo(result);
  133 + appendUserInfo(respVoList);
116 134  
117   - return result;
  135 + return respVoList;
118 136 }
119 137  
120 138 @Override
... ... @@ -136,16 +154,20 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe
136 154 final List<String> times = generateTimeSeries(reqVO.getTimes()[0], reqVO.getTimes()[1]);
137 155  
138 156 // 4. 合并统计数据
139   - List<CrmStatisticsFollowupSummaryByDateRespVO> result = new ArrayList<>(times.size());
140   - final Map<String, Integer> followupRecordCountMap = convertMap(followupRecordCount, CrmStatisticsFollowupSummaryByDateRespVO::getTime, CrmStatisticsFollowupSummaryByDateRespVO::getFollowupRecordCount);
141   - final Map<String, Integer> followupCustomerCountMap = convertMap(followupCustomerCount, CrmStatisticsFollowupSummaryByDateRespVO::getTime, CrmStatisticsFollowupSummaryByDateRespVO::getFollowupCustomerCount);
142   - times.forEach(time -> result.add(
  157 + List<CrmStatisticsFollowupSummaryByDateRespVO> respVoList = new ArrayList<>(times.size());
  158 + final Map<String, Integer> followupRecordCountMap = convertMap(followupRecordCount,
  159 + CrmStatisticsFollowupSummaryByDateRespVO::getTime,
  160 + CrmStatisticsFollowupSummaryByDateRespVO::getFollowupRecordCount);
  161 + final Map<String, Integer> followupCustomerCountMap = convertMap(followupCustomerCount,
  162 + CrmStatisticsFollowupSummaryByDateRespVO::getTime,
  163 + CrmStatisticsFollowupSummaryByDateRespVO::getFollowupCustomerCount);
  164 + times.forEach(time -> respVoList.add(
143 165 new CrmStatisticsFollowupSummaryByDateRespVO().setTime(time)
144 166 .setFollowupRecordCount(followupRecordCountMap.getOrDefault(time, 0))
145 167 .setFollowupCustomerCount(followupCustomerCountMap.getOrDefault(time, 0))
146 168 ));
147 169  
148   - return result;
  170 + return respVoList;
149 171 }
150 172  
151 173 @Override
... ... @@ -163,21 +185,25 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe
163 185 final List<CrmStatisticsFollowupSummaryByUserRespVO> followupCustomerCount = customerMapper.selectFollowupCustomerCountGroupbyUser(reqVO);
164 186  
165 187 // 3. 合并统计数据
166   - final Map<Long, Integer> followupRecordCountMap = convertMap(followupRecordCount, CrmStatisticsFollowupSummaryByUserRespVO::getOwnerUserId, CrmStatisticsFollowupSummaryByUserRespVO::getFollowupRecordCount);
167   - final Map<Long, Integer> followupCustomerCountMap = convertMap(followupCustomerCount, CrmStatisticsFollowupSummaryByUserRespVO::getOwnerUserId, CrmStatisticsFollowupSummaryByUserRespVO::getFollowupCustomerCount);
168   - List<CrmStatisticsFollowupSummaryByUserRespVO> result = new ArrayList<>(userIds.size());
  188 + final Map<Long, Integer> followupRecordCountMap = convertMap(followupRecordCount,
  189 + CrmStatisticsFollowupSummaryByUserRespVO::getOwnerUserId,
  190 + CrmStatisticsFollowupSummaryByUserRespVO::getFollowupRecordCount);
  191 + final Map<Long, Integer> followupCustomerCountMap = convertMap(followupCustomerCount,
  192 + CrmStatisticsFollowupSummaryByUserRespVO::getOwnerUserId,
  193 + CrmStatisticsFollowupSummaryByUserRespVO::getFollowupCustomerCount);
  194 + List<CrmStatisticsFollowupSummaryByUserRespVO> respVoList = new ArrayList<>(userIds.size());
169 195 userIds.forEach(userId -> {
170   - final CrmStatisticsFollowupSummaryByUserRespVO stat = new CrmStatisticsFollowupSummaryByUserRespVO()
  196 + final CrmStatisticsFollowupSummaryByUserRespVO vo = new CrmStatisticsFollowupSummaryByUserRespVO()
171 197 .setFollowupRecordCount(followupRecordCountMap.getOrDefault(userId, 0))
172 198 .setFollowupCustomerCount(followupCustomerCountMap.getOrDefault(userId, 0));
173   - stat.setOwnerUserId(userId);
174   - result.add(stat);
  199 + vo.setOwnerUserId(userId);
  200 + respVoList.add(vo);
175 201 });
176 202  
177 203 // 4. 拼接用户信息
178   - appendUserInfo(result);
  204 + appendUserInfo(respVoList);
179 205  
180   - return result;
  206 + return respVoList;
181 207 }
182 208  
183 209 @Override
... ... @@ -191,16 +217,17 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe
191 217  
192 218 // 2. 获得排行数据
193 219 reqVO.setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType());
194   - List<CrmStatisticsFollowupSummaryByTypeRespVO> stats = customerMapper.selectFollowupRecordCountGroupbyType(reqVO);
  220 + List<CrmStatisticsFollowupSummaryByTypeRespVO> respVoList = customerMapper.selectFollowupRecordCountGroupbyType(reqVO);
195 221  
196 222 // 3. 获取字典数据
197   - List<DictDataRespDTO> followUpTypes = dictDataApi.getDictDataList("crm_follow_up_type");
198   - final Map<String, String> followUpTypeMap = convertMap(followUpTypes, DictDataRespDTO::getValue, DictDataRespDTO::getLabel);
199   - stats.forEach(stat -> {
200   - stat.setFollowupType(followUpTypeMap.get(stat.getFollowupType()));
  223 + List<DictDataRespDTO> followUpTypes = dictDataApi.getDictDataList(CRM_FOLLOW_UP_TYPE);
  224 + final Map<String, String> followUpTypeMap = convertMap(followUpTypes,
  225 + DictDataRespDTO::getValue, DictDataRespDTO::getLabel);
  226 + respVoList.forEach(vo -> {
  227 + vo.setFollowupType(followUpTypeMap.get(vo.getFollowupType()));
201 228 });
202 229  
203   - return stats;
  230 + return respVoList;
204 231 }
205 232  
206 233 @Override
... ... @@ -212,17 +239,29 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe
212 239 }
213 240 reqVO.setUserIds(userIds);
214 241  
215   - List<CrmStatisticsCustomerContractSummaryRespVO> contractSummary = customerMapper.selectContractSummary(reqVO);
216   -
217   - // 2. 拼接用户信息
218   - final Set<Long> userIdSet = new HashSet<>();
219   - userIdSet.addAll(userIds);
220   - userIdSet.addAll(convertSet(contractSummary, CrmStatisticsCustomerContractSummaryRespVO::getCreatorUserId));
221   - final Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIdSet);
222   - contractSummary.forEach(contract -> contract.setCreatorUserName(userMap.get(contract.getCreatorUserId()).getNickname())
223   - .setOwnerUserName(userMap.get(contract.getOwnerUserId()).getNickname()));
  242 + // 2. 获取统计数据
  243 + List<CrmStatisticsCustomerContractSummaryRespVO> respVoList = customerMapper.selectContractSummary(reqVO);
  244 +
  245 + // 3. 设置 创建人、负责人、行业、来源
  246 + // 获取客户所属行业
  247 + Map<String, String> industryMap = convertMap(dictDataApi.getDictDataList(CRM_CUSTOMER_INDUSTRY),
  248 + DictDataRespDTO::getValue, DictDataRespDTO::getLabel);
  249 + // 获取客户来源
  250 + Map<String, String> sourceMap = convertMap(dictDataApi.getDictDataList(CRM_CUSTOMER_SOURCE),
  251 + DictDataRespDTO::getValue, DictDataRespDTO::getLabel);
  252 + // 获取创建人、负责人列表
  253 + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSetByFlatMap(respVoList,
  254 + vo -> Stream.of(NumberUtils.parseLong(vo.getCreatorUserId()), vo.getOwnerUserId())));
  255 +
  256 + respVoList.forEach(vo -> {
  257 + MapUtils.findAndThen(industryMap, vo.getIndustryId(), vo::setIndustryName);
  258 + MapUtils.findAndThen(sourceMap, vo.getSource(), vo::setSourceName);
  259 + MapUtils.findAndThen(userMap, NumberUtils.parseLong(vo.getCreatorUserId()),
  260 + user -> vo.setCreatorUserName(user.getNickname()));
  261 + MapUtils.findAndThen(userMap, vo.getOwnerUserId(), user -> vo.setOwnerUserName(user.getNickname()));
  262 + });
224 263  
225   - return contractSummary;
  264 + return respVoList;
226 265 }
227 266  
228 267 @Override
... ... @@ -243,14 +282,16 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe
243 282 final List<String> times = generateTimeSeries(reqVO.getTimes()[0], reqVO.getTimes()[1]);
244 283  
245 284 // 4. 合并统计数据
246   - List<CrmStatisticsCustomerDealCycleByDateRespVO> result = new ArrayList<>(times.size());
247   - final Map<String, Double> customerDealCycleMap = convertMap(customerDealCycle, CrmStatisticsCustomerDealCycleByDateRespVO::getTime, CrmStatisticsCustomerDealCycleByDateRespVO::getCustomerDealCycle);
248   - times.forEach(time -> result.add(
  285 + List<CrmStatisticsCustomerDealCycleByDateRespVO> respVoList = new ArrayList<>(times.size());
  286 + final Map<String, Double> customerDealCycleMap = convertMap(customerDealCycle,
  287 + CrmStatisticsCustomerDealCycleByDateRespVO::getTime,
  288 + CrmStatisticsCustomerDealCycleByDateRespVO::getCustomerDealCycle);
  289 + times.forEach(time -> respVoList.add(
249 290 new CrmStatisticsCustomerDealCycleByDateRespVO().setTime(time)
250   - .setCustomerDealCycle(customerDealCycleMap.getOrDefault(time, Double.valueOf(0)))
  291 + .setCustomerDealCycle(customerDealCycleMap.getOrDefault(time, 0D))
251 292 ));
252 293  
253   - return result;
  294 + return respVoList;
254 295 }
255 296  
256 297 @Override
... ... @@ -268,33 +309,37 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe
268 309 final List<CrmStatisticsCustomerSummaryByUserRespVO> customerDealCount = customerMapper.selectCustomerDealCountGroupbyUser(reqVO);
269 310  
270 311 // 3. 合并统计数据
271   - final Map<Long, Double> customerDealCycleMap = convertMap(customerDealCycle, CrmStatisticsCustomerDealCycleByUserRespVO::getOwnerUserId, CrmStatisticsCustomerDealCycleByUserRespVO::getCustomerDealCycle);
272   - final Map<Long, Integer> customerDealCountMap = convertMap(customerDealCount, CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId, CrmStatisticsCustomerSummaryByUserRespVO::getCustomerDealCount);
273   - List<CrmStatisticsCustomerDealCycleByUserRespVO> result = new ArrayList<>(userIds.size());
  312 + final Map<Long, Double> customerDealCycleMap = convertMap(customerDealCycle,
  313 + CrmStatisticsCustomerDealCycleByUserRespVO::getOwnerUserId,
  314 + CrmStatisticsCustomerDealCycleByUserRespVO::getCustomerDealCycle);
  315 + final Map<Long, Integer> customerDealCountMap = convertMap(customerDealCount,
  316 + CrmStatisticsCustomerSummaryByUserRespVO::getOwnerUserId,
  317 + CrmStatisticsCustomerSummaryByUserRespVO::getCustomerDealCount);
  318 + List<CrmStatisticsCustomerDealCycleByUserRespVO> respVoList = new ArrayList<>(userIds.size());
274 319 userIds.forEach(userId -> {
275   - final CrmStatisticsCustomerDealCycleByUserRespVO stat = new CrmStatisticsCustomerDealCycleByUserRespVO()
  320 + final CrmStatisticsCustomerDealCycleByUserRespVO vo = new CrmStatisticsCustomerDealCycleByUserRespVO()
276 321 .setCustomerDealCycle(customerDealCycleMap.getOrDefault(userId, 0.0))
277 322 .setCustomerDealCount(customerDealCountMap.getOrDefault(userId, 0));
278   - stat.setOwnerUserId(userId);
279   - result.add(stat);
  323 + vo.setOwnerUserId(userId);
  324 + respVoList.add(vo);
280 325 });
281 326  
282 327 // 4. 拼接用户信息
283   - appendUserInfo(result);
  328 + appendUserInfo(respVoList);
284 329  
285   - return result;
  330 + return respVoList;
286 331 }
287 332  
288 333 /**
289 334 * 拼接用户信息(昵称)
290 335 *
291   - * @param stats 统计数据
  336 + * @param respVoList 统计数据
292 337 */
293   - private <T extends CrmStatisticsCustomerByUserBaseRespVO> void appendUserInfo(List<T> stats) {
294   - Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(stats, CrmStatisticsCustomerByUserBaseRespVO::getOwnerUserId));
295   - stats.forEach(stat -> MapUtils.findAndThen(userMap, stat.getOwnerUserId(), user -> {
296   - stat.setOwnerUserName(user.getNickname());
297   - }));
  338 + private <T extends CrmStatisticsCustomerByUserBaseRespVO> void appendUserInfo(List<T> respVoList) {
  339 + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(respVoList,
  340 + CrmStatisticsCustomerByUserBaseRespVO::getOwnerUserId));
  341 + respVoList.forEach(vo -> MapUtils.findAndThen(userMap,
  342 + vo.getOwnerUserId(), user -> vo.setOwnerUserName(user.getNickname())));
298 343 }
299 344  
300 345 /**
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml
... ... @@ -180,8 +180,10 @@
180 180 SELECT
181 181 a.`name` AS customer_name,
182 182 b.`name` AS contract_name,
183   - b.total_price AS contract_price,
  183 + b.total_price,
184 184 IFNULL( c.price, 0 ) AS receivable_price,
  185 + a.industry_id,
  186 + a.source,
185 187 a.owner_user_id,
186 188 a.creator AS creator_user_id,
187 189 a.create_time,
... ...