From 615c83a15cdccd2f64b87224b49058744b0c99ad Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期四, 03 九月 2026 11:55:16 +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 +-
src/main/resources/mapper/stock/StockInRecordMapper.xml | 2 +-
9 files changed, 9 insertions(+), 7 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 db7f289..c881eba 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
@@ -129,6 +129,7 @@
if (purchaseLedger.getApprovalStatus() != null) {
queryWrapper.eq(PurchaseLedger::getApprovalStatus, purchaseLedger.getApprovalStatus());
}
+ 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 0a8cb29..26449e0 100644
--- a/src/main/resources/mapper/production/ProductionOperationTaskMapper.xml
+++ b/src/main/resources/mapper/production/ProductionOperationTaskMapper.xml
@@ -74,7 +74,7 @@
and (pot.user_ids is null or pot.user_ids = '' or pot.user_ids = '[]' or json_contains(pot.user_ids, json_quote(cast(#{c.currentUserId} as char))))
</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 7ca1bce..0bd6af2 100644
--- a/src/main/resources/mapper/production/ProductionOrderMapper.xml
+++ b/src/main/resources/mapper/production/ProductionOrderMapper.xml
@@ -125,7 +125,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 69ccd36..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.id) 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 556a4a3..0924e23 100644
--- a/src/main/resources/mapper/production/ProductionProductMainMapper.xml
+++ b/src/main/resources/mapper/production/ProductionProductMainMapper.xml
@@ -87,7 +87,7 @@
and (pot.user_ids is null or pot.user_ids = '' or pot.user_ids = '[]' or json_contains(pot.user_ids, json_quote(cast(#{c.currentUserId} as char))))
</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 a5650f9..698b191 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 762c2d4..91d8f5e 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/StockInRecordMapper.xml b/src/main/resources/mapper/stock/StockInRecordMapper.xml
index a3bf3f9..4f8c583 100644
--- a/src/main/resources/mapper/stock/StockInRecordMapper.xml
+++ b/src/main/resources/mapper/stock/StockInRecordMapper.xml
@@ -132,7 +132,7 @@
and p.id in (select id from product_tree)
</if>
</where>
- order by sir.id desc
+ order by sir.inbound_batches desc
</select>
<select id="listStockInRecordExportData" resultType="com.ruoyi.stock.execl.StockInRecordExportData">
SELECT
diff --git a/src/main/resources/mapper/stock/StockOutRecordMapper.xml b/src/main/resources/mapper/stock/StockOutRecordMapper.xml
index 33e42ec..b36f443 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