From dc22724f61e0b792d327fa812895f6dc4fcf129d Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期三, 08 四月 2026 15:04:11 +0800
Subject: [PATCH] fix:groupBy

---
 src/main/resources/mapper/sales/SalesLedgerProductMapper.xml                   |   17 ++------
 src/main/resources/mapper/account/AccountExpenseMapper.xml                     |    4 +-
 src/main/resources/mapper/production/SalesLedgerProductionAccountingMapper.xml |    4 -
 src/main/resources/mapper/account/AccountIncomeMapper.xml                      |    7 +--
 src/main/resources/mapper/staff/PersonalShiftMapper.xml                        |   14 +++---
 src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml               |   18 ++++----
 6 files changed, 27 insertions(+), 37 deletions(-)

diff --git a/src/main/resources/mapper/account/AccountExpenseMapper.xml b/src/main/resources/mapper/account/AccountExpenseMapper.xml
index 1a8d34b..459a584 100644
--- a/src/main/resources/mapper/account/AccountExpenseMapper.xml
+++ b/src/main/resources/mapper/account/AccountExpenseMapper.xml
@@ -44,7 +44,7 @@
         sdd.dict_label typeName,
         sum(expense_money) account
         FROM account_expense ae
-        left join sys_dict_data sdd on ae.expense_type = sdd.dict_value and  sdd.dict_type='expense_types'
+        left join sys_dict_data sdd on ae.expense_type = sdd.dict_value and sdd.dict_type='expense_types'
         where
         1=1
         <if test="dateQueryDto.entryDateStart != null and dateQueryDto.entryDateStart != '' ">
@@ -53,7 +53,7 @@
         <if test="dateQueryDto.entryDateEnd != null and dateQueryDto.entryDateEnd != '' ">
             AND expense_date &lt;= DATE_FORMAT(#{dateQueryDto.entryDateEnd},'%Y-%m-%d')
         </if>
-        group by expense_type
+        group by sdd.dict_label, ae.expense_type
     </select>
 
     <select id="report1" resultType="java.math.BigDecimal">
diff --git a/src/main/resources/mapper/account/AccountIncomeMapper.xml b/src/main/resources/mapper/account/AccountIncomeMapper.xml
index e4f3361..3bb4da1 100644
--- a/src/main/resources/mapper/account/AccountIncomeMapper.xml
+++ b/src/main/resources/mapper/account/AccountIncomeMapper.xml
@@ -45,16 +45,15 @@
         sdd.dict_label typeName,
         ifnull(sum(income_money),0) account
         FROM account_income ai
-        left join sys_dict_data sdd on ai.income_type = sdd.dict_value and  sdd.dict_type='income_types'
-        where
-        1=1
+        LEFT JOIN sys_dict_data sdd ON ai.income_type = sdd.dict_value AND sdd.dict_type = 'income_types'
+        WHERE 1=1
         <if test="dateQueryDto.entryDateStart != null and dateQueryDto.entryDateStart != '' ">
             AND income_date &gt;= DATE_FORMAT(#{dateQueryDto.entryDateStart},'%Y-%m-%d')
         </if>
         <if test="dateQueryDto.entryDateEnd != null and dateQueryDto.entryDateEnd != '' ">
             AND income_date &lt;= DATE_FORMAT(#{dateQueryDto.entryDateEnd},'%Y-%m-%d')
         </if>
-        group by income_type
+        GROUP BY sdd.dict_label, ai.income_type
     </select>
     <select id="report1" resultType="java.math.BigDecimal">
         SELECT
diff --git a/src/main/resources/mapper/production/SalesLedgerProductionAccountingMapper.xml b/src/main/resources/mapper/production/SalesLedgerProductionAccountingMapper.xml
index d9ddde7..fc27323 100644
--- a/src/main/resources/mapper/production/SalesLedgerProductionAccountingMapper.xml
+++ b/src/main/resources/mapper/production/SalesLedgerProductionAccountingMapper.xml
@@ -82,10 +82,8 @@
                 and slpa.scheduling_date >= #{ew.entryDateStart}
                 and slpa.scheduling_date &lt; DATE_ADD(DATE(#{ew.entryDateEnd}), INTERVAL 1 DAY)
             </if>
-
         </where>
-        GROUP BY slpa.scheduling_user_name
-
+        GROUP BY slpa.scheduling_user_id, slpa.scheduling_user_name
     </select>
 
     <select id="selectDailyWagesStats" resultType="java.util.Map">
diff --git a/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml b/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml
index c5c007e..428700c 100644
--- a/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml
+++ b/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml
@@ -188,8 +188,8 @@
         T1.supplier_id,
         T1.supplier_name,
         SUM(contract_amount) AS invoiceAmount,
-        IFNULL( SUM(T2.current_payment_amount) , 0 ) AS paymentAmount,
-        IFNULL((IFNULL(SUM(contract_amount),0)  - IFNULL(SUM(T2.current_payment_amount),0)),0) AS payableAmount
+        IFNULL(SUM(T2.current_payment_amount), 0) AS paymentAmount,
+        IFNULL((IFNULL(SUM(contract_amount), 0) - IFNULL(SUM(T2.current_payment_amount), 0)), 0) AS payableAmount
         FROM purchase_ledger T1
         LEFT JOIN payment_registration T2 ON T1.id = T2.purchase_ledger_id
         <where>
@@ -197,27 +197,27 @@
                 T1.supplier_name LIKE CONCAT ('%',#{req.supplierName},'%')
             </if>
         </where>
-        GROUP BY T1.supplier_name
+        GROUP BY T1.supplier_id, T1.supplier_name
     </select>
 
     <select id="supplierNameListPageDetails" resultType="com.ruoyi.purchase.dto.PaymentRegistrationDto">
         SELECT
         T1.supplier_id,
         T1.supplier_name,
-        SUM(contract_amount) AS invoiceAmount,
-        IFNULL( SUM(T2.current_payment_amount) , 0 ) AS paymentAmount,
-        IFNULL((IFNULL(SUM(contract_amount),0)  - IFNULL(SUM(T2.current_payment_amount),0)),0) AS payableAmount,
         T1.purchase_contract_number,
-        T2.payment_date
+        T2.payment_date,
+        SUM(T1.contract_amount) AS invoiceAmount,
+        IFNULL(SUM(T2.current_payment_amount), 0) AS paymentAmount,
+        IFNULL((IFNULL(SUM(T1.contract_amount), 0) - IFNULL(SUM(T2.current_payment_amount), 0)), 0) AS payableAmount
         FROM purchase_ledger T1
         INNER JOIN payment_registration T2 ON T1.id = T2.purchase_ledger_id
         <where>
             T1.supplier_id = #{req.supplierId}
             <if test="req.supplierName != null and req.supplierName != '' ">
-                T1.supplier_name LIKE CONCAT ('%',#{req.supplierName},'%')
+                AND T1.supplier_name LIKE CONCAT ('%',#{req.supplierName},'%')
             </if>
         </where>
-        GROUP BY  T1.purchase_contract_number,T2.payment_date
+        GROUP BY T1.supplier_id, T1.supplier_name, T1.purchase_contract_number, T2.payment_date
     </select>
 
 </mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
index 712124a..84f04e2 100644
--- a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
@@ -111,29 +111,22 @@
         SUM(slp.quantity) AS purchaseNum,
         SUM(slp.tax_inclusive_total_price) AS purchaseAmount,
         COUNT(DISTINCT slp.sales_ledger_id) AS purchaseTimes,
-        <!-- 骞冲潎鍗曚环 = 鎬婚噰璐噾棰�/鎬婚噰璐暟閲忥紝淇濈暀2浣嶅皬鏁帮紝閬垮厤闄�0 -->
         ROUND(IF(SUM(slp.quantity) = 0, 0, SUM(slp.tax_inclusive_total_price) / SUM(slp.quantity)), 2) AS averagePrice,
-        <!-- 璇ヤ骇鍝佸ぇ绫讳笅鏈�鍚庝竴涓綍鍏ユ棩鏈燂紙鍙栧彴璐︿富琛ㄧ殑entry_date锛� -->
         MAX(sl.entry_date) AS entryDate,
         COALESCE(NULLIF(SUM(t1.return_quantity), 0), 0) AS return_quantity,
         COALESCE(SUM(t2.total_amount), 0) AS return_amount
         FROM sales_ledger_product slp
-        <!-- 鍏宠仈鍙拌处涓昏〃锛氳幏鍙栧綍鍏ユ棩鏈焑ntry_date -->
         LEFT JOIN purchase_ledger sl ON slp.sales_ledger_id = sl.id
-        left join purchase_return_order_products as t1 on t1.sales_ledger_product_id = slp.id
-        left join purchase_return_orders as t2 on t2.id = t1.purchase_return_order_id
-        WHERE slp.type = 2 <!-- 鍥哄畾绛涢�夛細閲囪喘鍙拌处锛坱ype=2锛� -->
-        <!-- 閲囪喘鏃ユ湡绛涢�夛細鍙�夋潯浠� -->
+        LEFT JOIN purchase_return_order_products t1 ON t1.sales_ledger_product_id = slp.id
+        LEFT JOIN purchase_return_orders t2 ON t2.id = t1.purchase_return_order_id
+        WHERE slp.type = 2
         <if test="req.entryDateStart != null and req.entryDateEnd != null">
-            AND sl.entry_date BETWEEN #{req.entryDateStart} AND #{req.entryDateEnd} <!-- 鏃堕棿鑼冨洿锛氶潪绌烘湁鏁� -->
+            AND sl.entry_date BETWEEN #{req.entryDateStart} AND #{req.entryDateEnd}
         </if>
-        <!-- 浜у搧澶х被绛涢�夛細鍙�夋潯浠� -->
         <if test="req.productCategory != null and req.productCategory != ''">
             AND slp.product_category = #{req.productCategory}
         </if>
-        <!-- 鎸変骇鍝佸ぇ绫诲垎缁勮仛鍚� -->
-        GROUP BY slp.product_category
-        <!-- 鎸変骇鍝佸ぇ绫绘帓搴� -->
+        GROUP BY slp.product_category, slp.specification_model, sl.supplier_name
         ORDER BY slp.product_category
     </select>
     <select id="selectProductBomStructure" resultType="com.ruoyi.sales.dto.LossProductModelDto">
diff --git a/src/main/resources/mapper/staff/PersonalShiftMapper.xml b/src/main/resources/mapper/staff/PersonalShiftMapper.xml
index d8ddb1d..69bcae3 100644
--- a/src/main/resources/mapper/staff/PersonalShiftMapper.xml
+++ b/src/main/resources/mapper/staff/PersonalShiftMapper.xml
@@ -12,26 +12,26 @@
         <result column="work_time" property="workTime" />
     </resultMap>
     <select id="performanceShiftPage" resultType="com.ruoyi.staff.dto.PerformanceShiftMapDto">
-         SELECT
+        SELECT
         u.staff_name name,
-        GROUP_CONCAT(s.work_time, '锛�', IFNULL(palc.shift, ''), '锛�', s.id order by s.work_time SEPARATOR ';') AS shift_time,
-                u.id user_id
+        GROUP_CONCAT(s.work_time, '锛�', IFNULL(palc.shift, ''), '锛�', s.id ORDER BY s.work_time SEPARATOR ';') AS shift_time,
+        u.id user_id
         FROM personal_shift s
         LEFT JOIN staff_on_job u ON u.id = s.staff_on_job_id
         LEFT JOIN personal_attendance_location_config palc ON palc.id = s.personal_attendance_location_config_id
         <where>
-             <if test="sysDeptId != null and sysDeptId != ''">
+            <if test="sysDeptId != null and sysDeptId != ''">
                 and u.sys_dept_id = #{sysDeptId}
             </if>
             <if test="time != null and time != ''">
-                and DATE_FORMAT(s.work_time, '%Y-%m') = DATE_FORMAT(#{time}, '%Y-%m' )
+                and DATE_FORMAT(s.work_time, '%Y-%m') = DATE_FORMAT(#{time}, '%Y-%m')
             </if>
             <if test="userName != null and userName != ''">
                 and u.staff_name like concat('%', #{userName}, '%')
             </if>
         </where>
-        GROUP BY u.id
-        order by s.create_time
+        GROUP BY u.id, u.staff_name
+        ORDER BY MAX(s.create_time)
     </select>
    
     <select id="performanceShiftYear" resultType="java.util.Map">

--
Gitblit v1.9.3