From 7393716069d0b58879fa41dc8f91cb8f492c8f06 Mon Sep 17 00:00:00 2001 From: lizhenhua <1075222162@qq.com> Date: Thu, 11 Dec 2025 18:48:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A3=85=E5=A4=87=E7=AE=A1=E7=90=86=20youhua?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../material/equipment/SysDeptMapper.xml | 53 +++++++++++++++++-- .../mapper/material/owner/OwnerMapper.xml | 25 +++++++-- 2 files changed, 72 insertions(+), 6 deletions(-) diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/SysDeptMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/SysDeptMapper.xml index 4d3e4a6..d251963 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/SysDeptMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/SysDeptMapper.xml @@ -187,6 +187,7 @@ SUM(config_value) AS config_value, SUM(if(config_rate='/',0,config_rate)) AS config_rate FROM ma_dept_config + where jiju_type =1 GROUP BY dept_id, type_id, config_type ) grouped LEFT JOIN sys_dept sd ON sd.dept_id = grouped.dept_id @@ -196,8 +197,8 @@ LEFT JOIN ( SELECT sd.dept_id AS dept_id, - mt2.type_id AS parent_type_id, - COUNT(md.ma_id) AS order_count + mt.type_id AS parent_type_id, + COUNT(md.num) AS order_count FROM ma_order_details md LEFT JOIN ma_order_info moi ON md.order_id = moi.order_id @@ -205,10 +206,56 @@ LEFT JOIN ma_type mt ON mdi.type_id = mt.type_id LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id LEFT JOIN sys_dept sd ON moi.buyer_company = sd.dept_id - GROUP BY sd.dept_id, mt2.type_id + where devType =0 + GROUP BY sd.dept_id, mt.type_id ) order_stat ON order_stat.dept_id = grouped.dept_id AND order_stat.parent_type_id = grouped.type_id + + UNION + + SELECT + my.type_name AS deptName, + my.type_id AS typeId, + sd.dept_name AS companyName, + grouped.dept_id AS companyId, + grouped.config_type AS configType, + grouped.config_value AS configValue, + if(grouped.config_rate='/',0,grouped.config_rate) AS configRate, + IFNULL(order_stat.order_count, 0) AS orderCount + FROM + ( + SELECT + dept_id, + type_id, + config_type, + SUM(config_value) AS config_value, + SUM(if(config_rate='/',0,config_rate)) AS config_rate + FROM ma_dept_config + where jiju_type =2 + GROUP BY dept_id, type_id, config_type + ) grouped + LEFT JOIN sys_dept sd ON sd.dept_id = grouped.dept_id + LEFT JOIN tool_type my ON my.type_id = grouped.type_id + + -- 设备订单数量子查询 + LEFT JOIN ( + SELECT + sd.dept_id AS dept_id, + mt.type_id AS parent_type_id, + COUNT(md.num) AS order_count + FROM + ma_order_details md + LEFT JOIN ma_order_info moi ON md.order_id = moi.order_id + LEFT JOIN ma_dev_info mdi ON md.ma_id = mdi.ma_id + LEFT JOIN tool_type mt ON mdi.type_id = mt.type_id + LEFT JOIN tool_type mt2 ON mt.parent_id = mt2.type_id + LEFT JOIN sys_dept sd ON moi.buyer_company = sd.dept_id + where devType =1 + GROUP BY sd.dept_id, mt.type_id + ) order_stat + ON order_stat.dept_id = grouped.dept_id + AND order_stat.parent_type_id = grouped.type_id;