From f4ef6d1f4489e0d4cbba1845792945b924c16228 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 14 十月 2026 18:29:56 +0800
Subject: [PATCH] feat: 客户签订合同统计 + MES 首页质检合格率

---
 yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
index 5438515..7053219 100644
--- a/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
+++ b/yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
@@ -15,6 +15,7 @@
 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.*;
 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
 import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
+import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
 import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerPoolConfigService;
 import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
 import cn.iocoder.yudao.module.system.api.dept.DeptApi;
@@ -33,10 +34,12 @@
 import org.springframework.web.bind.annotation.*;
 
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.stream.Stream;
 
 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
@@ -56,6 +59,8 @@
     private CrmCustomerService customerService;
     @Resource
     private CrmCustomerPoolConfigService customerPoolConfigService;
+    @Resource
+    private CrmContractService contractService;
 
     @Resource
     private DeptApi deptApi;
@@ -139,6 +144,10 @@
         Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
         // 1.2 鑾峰彇璺濈杩涘叆鍏捣鐨勬椂闂�
         Map<Long, Long> poolDayMap = getPoolDayMap(list);
+        // 1.3 鑾峰彇銆屽凡绛捐鍚堝悓銆嶇殑鏁伴噺涓庨噾棰濆悎璁★紙鎸夋湰椤靛鎴锋壒閲忕粺璁★紝瀹℃牳閫氳繃鐨勫悎鍚屾墠绠楋級
+        Set<Long> customerIds = convertSet(list, CrmCustomerDO::getId);
+        Map<Long, Long> contractCountMap = contractService.getContractCountMapByCustomerIds(customerIds);
+        Map<Long, BigDecimal> contractPriceMap = contractService.getContractPriceMapByCustomerIds(customerIds);
         // 2. 杞崲鎴� VO
         return BeanUtils.toBean(list, CrmCustomerRespVO.class, customerVO -> {
             customerVO.setAreaName(AreaUtils.format(customerVO.getAreaId()));
@@ -153,6 +162,10 @@
             if (customerVO.getOwnerUserId() != null) {
                 customerVO.setPoolDay(poolDayMap.get(customerVO.getId()));
             }
+            // 2.3 璁剧疆宸茬璁㈠悎鍚岀殑鏁伴噺涓庨噾棰濆悎璁★紙娌℃湁鍚堝悓鐨勫鎴凤細鏁伴噺 0銆侀噾棰� null锛屽墠绔樉绀恒�屸�斻�嶏級
+            customerVO.setContractCount(
+                    contractCountMap.getOrDefault(customerVO.getId(), 0L).intValue());
+            customerVO.setContractTotalPrice(contractPriceMap.get(customerVO.getId()));
         });
     }
 

--
Gitblit v1.9.3