From 3f665136e270e321aa99416ac8c302607d9a132d Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期六, 22 八月 2026 16:25:26 +0800
Subject: [PATCH] refactor(database): 优化多处查询排序字段
---
src/main/resources/mapper/production/ProductionOperationTaskMapper.xml | 2 +-
src/main/resources/mapper/sales/SalesLedgerMapper.xml | 1 +
src/main/resources/mapper/stock/StockOutRecordMapper.xml | 2 +-
src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java | 1 +
src/main/resources/mapper/production/ProductionProductMainMapper.xml | 2 +-
src/main/resources/mapper/production/ProductionOrderMapper.xml | 2 +-
src/main/resources/mapper/production/ProductionPlanMapper.xml | 2 +-
src/main/resources/mapper/sales/ShippingInfoMapper.xml | 2 +-
8 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
index 7c25815..1b085ee 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
@@ -134,6 +134,7 @@
// 鍙煡璇㈠叆搴撳凡瀹℃壒閫氳繃鐨勯噰璐彴璐�
queryWrapper.inSql(PurchaseLedger::getId,
"SELECT DISTINCT record_id FROM stock_in_record WHERE approval_status = 1");
+ queryWrapper.orderByDesc(PurchaseLedger::getEntryDate);
return purchaseLedgerMapper.selectList(queryWrapper);
}
diff --git a/src/main/resources/mapper/production/ProductionOperationTaskMapper.xml b/src/main/resources/mapper/production/ProductionOperationTaskMapper.xml
index 5847f5f..5a1f415 100644
--- a/src/main/resources/mapper/production/ProductionOperationTaskMapper.xml
+++ b/src/main/resources/mapper/production/ProductionOperationTaskMapper.xml
@@ -71,7 +71,7 @@
and pot.work_order_no like concat('%', #{c.workOrderNo}, '%')
</if>
</where>
- order by pot.production_order_id desc, poro.drag_sort
+ order by pot.work_order_no desc, poro.drag_sort
</select>
<select id="selectTaskStatisticsByDate" resultType="com.ruoyi.home.dto.ProductionTaskStatisticsDto">
diff --git a/src/main/resources/mapper/production/ProductionOrderMapper.xml b/src/main/resources/mapper/production/ProductionOrderMapper.xml
index 67cc55b..74e80a9 100644
--- a/src/main/resources/mapper/production/ProductionOrderMapper.xml
+++ b/src/main/resources/mapper/production/ProductionOrderMapper.xml
@@ -134,7 +134,7 @@
<include refid="ProductionOrderVoColumns" />
<include refid="ProductionOrderVoFrom" />
<include refid="ProductionOrderWhere" />
- order by po.id desc
+ order by po.status , po.plan_complete_time desc
</select>
<select id="listProductionOrder" resultMap="ProductionOrderVoResultMap">
diff --git a/src/main/resources/mapper/production/ProductionPlanMapper.xml b/src/main/resources/mapper/production/ProductionPlanMapper.xml
index c42211c..724eb83 100644
--- a/src/main/resources/mapper/production/ProductionPlanMapper.xml
+++ b/src/main/resources/mapper/production/ProductionPlanMapper.xml
@@ -58,7 +58,7 @@
</if>
</if>
</where>
- ORDER BY COALESCE(pp.mps_no) DESC
+ ORDER BY pp.required_date DESC
</select>
<select id="selectWithMaterialByIds" resultType="com.ruoyi.production.bean.dto.ProductionPlanDto">
diff --git a/src/main/resources/mapper/production/ProductionProductMainMapper.xml b/src/main/resources/mapper/production/ProductionProductMainMapper.xml
index df585f9..a746bd3 100644
--- a/src/main/resources/mapper/production/ProductionProductMainMapper.xml
+++ b/src/main/resources/mapper/production/ProductionProductMainMapper.xml
@@ -82,7 +82,7 @@
and ppm.id = #{c.productMainId}
</if>
</where>
- order by ppm.create_time desc
+ order by ppm.product_no desc
</select>
<select id="getOrderByMainId" resultType="com.ruoyi.production.pojo.ProductionOrder">
diff --git a/src/main/resources/mapper/sales/SalesLedgerMapper.xml b/src/main/resources/mapper/sales/SalesLedgerMapper.xml
index 2d6b7f8..a8f934d 100644
--- a/src/main/resources/mapper/sales/SalesLedgerMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerMapper.xml
@@ -40,6 +40,7 @@
T1.customer_name LIKE CONCAT('%',#{salesLedgerDto.customerName},'%')
</if>
</where>
+ order by T1.entry_date desc
</select>
<select id="selectSalesLedgerListPage" resultType="com.ruoyi.sales.vo.SalesLedgerVo">
diff --git a/src/main/resources/mapper/sales/ShippingInfoMapper.xml b/src/main/resources/mapper/sales/ShippingInfoMapper.xml
index 8775933..6e600ad 100644
--- a/src/main/resources/mapper/sales/ShippingInfoMapper.xml
+++ b/src/main/resources/mapper/sales/ShippingInfoMapper.xml
@@ -48,7 +48,7 @@
<if test="req.expressNumber != null and req.expressNumber != ''">
AND s.express_number LIKE CONCAT('%',#{req.expressNumber},'%')
</if>
- order by create_time DESC
+ order by shipping_no DESC
</select>
<select id="listAll" resultType="com.ruoyi.sales.pojo.ShippingInfo">
SELECT
diff --git a/src/main/resources/mapper/stock/StockOutRecordMapper.xml b/src/main/resources/mapper/stock/StockOutRecordMapper.xml
index aa0507e..8a205a9 100644
--- a/src/main/resources/mapper/stock/StockOutRecordMapper.xml
+++ b/src/main/resources/mapper/stock/StockOutRecordMapper.xml
@@ -89,7 +89,7 @@
and sor.record_type = #{params.recordType}
</if>
</where>
- order by sor.id desc
+ order by sor.outbound_batches desc
</select>
<select id="listPageAccountSales" resultType="com.ruoyi.account.bean.vo.sales.SalesOutboundVo">
--
Gitblit v1.9.3