From 276357baf4a50ef132321e7a36fe52bf74c1d9c8 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期二, 12 五月 2026 13:34:56 +0800
Subject: [PATCH] refactor(dto): 为日期字段添加Spring日期格式化注解规范了日期范围查询SQL语句
---
src/main/java/com/ruoyi/account/bean/dto/PurchaseReturnDto.java | 3 +++
src/main/java/com/ruoyi/account/bean/dto/SalesReturnDto.java | 3 +++
src/main/resources/mapper/procurementrecord/ReturnManagementMapper.xml | 4 ++--
src/main/resources/mapper/stock/StockOutRecordMapper.xml | 6 +++---
src/main/java/com/ruoyi/procurementrecord/controller/ReturnManagementController.java | 9 ++-------
src/main/java/com/ruoyi/sales/dto/ShippingInfoDto.java | 3 +++
src/main/resources/mapper/sales/ShippingInfoMapper.xml | 6 ++++--
src/main/resources/mapper/stock/StockInRecordMapper.xml | 10 +++++-----
src/main/java/com/ruoyi/account/bean/dto/SalesOutboundDto.java | 3 +++
src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java | 2 +-
src/main/resources/mapper/purchase/PurchaseReturnOrdersMapper.xml | 5 ++---
11 files changed, 31 insertions(+), 23 deletions(-)
diff --git a/src/main/java/com/ruoyi/account/bean/dto/PurchaseReturnDto.java b/src/main/java/com/ruoyi/account/bean/dto/PurchaseReturnDto.java
index d521422..c238990 100644
--- a/src/main/java/com/ruoyi/account/bean/dto/PurchaseReturnDto.java
+++ b/src/main/java/com/ruoyi/account/bean/dto/PurchaseReturnDto.java
@@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@@ -18,9 +19,11 @@
@Schema(description = "寮�濮嬫棩鏈�")
@JsonFormat(pattern = "yyyy-MM-dd")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
private Date startDate;
@Schema(description = "缁撴潫鏃ユ湡")
@JsonFormat(pattern = "yyyy-MM-dd")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
private Date endDate;
}
diff --git a/src/main/java/com/ruoyi/account/bean/dto/SalesOutboundDto.java b/src/main/java/com/ruoyi/account/bean/dto/SalesOutboundDto.java
index a30e035..33bc1b9 100644
--- a/src/main/java/com/ruoyi/account/bean/dto/SalesOutboundDto.java
+++ b/src/main/java/com/ruoyi/account/bean/dto/SalesOutboundDto.java
@@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@@ -18,9 +19,11 @@
@Schema(description = "寮�濮嬫棩鏈�")
@JsonFormat(pattern = "yyyy-MM-dd")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
private Date startDate;
@Schema(description = "缁撴潫鏃ユ湡")
@JsonFormat(pattern = "yyyy-MM-dd")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
private Date endDate;
}
diff --git a/src/main/java/com/ruoyi/account/bean/dto/SalesReturnDto.java b/src/main/java/com/ruoyi/account/bean/dto/SalesReturnDto.java
index d635408..b7ebae2 100644
--- a/src/main/java/com/ruoyi/account/bean/dto/SalesReturnDto.java
+++ b/src/main/java/com/ruoyi/account/bean/dto/SalesReturnDto.java
@@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@@ -18,9 +19,11 @@
@Schema(description = "寮�濮嬫棩鏈�")
@JsonFormat(pattern = "yyyy-MM-dd")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
private Date startDate;
@Schema(description = "缁撴潫鏃ユ湡")
@JsonFormat(pattern = "yyyy-MM-dd")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
private Date endDate;
}
diff --git a/src/main/java/com/ruoyi/procurementrecord/controller/ReturnManagementController.java b/src/main/java/com/ruoyi/procurementrecord/controller/ReturnManagementController.java
index 22882f4..e165b08 100644
--- a/src/main/java/com/ruoyi/procurementrecord/controller/ReturnManagementController.java
+++ b/src/main/java/com/ruoyi/procurementrecord/controller/ReturnManagementController.java
@@ -4,21 +4,16 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.ruoyi.common.utils.OrderUtils;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.procurementrecord.dto.ReturnManagementDto;
-import com.ruoyi.procurementrecord.mapper.ReturnManagementMapper;
-import com.ruoyi.procurementrecord.pojo.ReturnManagement;
import com.ruoyi.procurementrecord.pojo.ReturnSaleProduct;
import com.ruoyi.procurementrecord.service.ReturnManagementService;
import com.ruoyi.procurementrecord.service.ReturnSaleProductService;
-import com.ruoyi.procurementrecord.service.impl.ReturnSaleProductServiceImpl;
import com.ruoyi.sales.dto.SalesLedgerDto;
-import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
@@ -87,7 +82,7 @@
}
@GetMapping("/getByShippingId")
- @Operation(summary = "閿�鍞��璐�-鏍规嵁鍑哄簱鍗曟煡璇㈤攢鍞鍗曚互鍙婁骇鍝佷俊鎭�")
+ @Operation(summary = "閿�鍞��璐�-鏍规嵁鍑哄簱鍗曟煡璇㈤攢鍞鍗曚互鍙婂彂璐т骇鍝佷俊鎭�")
public AjaxResult getByShippingId(Long shippingId) {
SalesLedgerDto salesLedgerDto = returnManagementService.getReturnManagementDtoByShippingIdId(shippingId);
return success(salesLedgerDto);
diff --git a/src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java b/src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java
index 0257f2a..f707b5b 100644
--- a/src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java
+++ b/src/main/java/com/ruoyi/sales/controller/ShippingInfoController.java
@@ -116,7 +116,7 @@
@GetMapping("/getByCustomerName")
- @Operation(summary = "閫氳繃瀹㈡埛鍚嶇О鏌ヨ")
+ @Operation(summary = "閫氳繃瀹㈡埛鍚嶇О鏌ヨ鍏宠仈鐨勫彂璐у崟鍙�")
public AjaxResult getByCustomerName(String customerName) {
return AjaxResult.success(shippingInfoService.getShippingInfoByCustomerName(customerName));
}
diff --git a/src/main/java/com/ruoyi/sales/dto/ShippingInfoDto.java b/src/main/java/com/ruoyi/sales/dto/ShippingInfoDto.java
index e12149f..05c41f9 100644
--- a/src/main/java/com/ruoyi/sales/dto/ShippingInfoDto.java
+++ b/src/main/java/com/ruoyi/sales/dto/ShippingInfoDto.java
@@ -40,6 +40,9 @@
private List<Long> batchNo;
private List<ShippingProductDetail> batchNoDetailList;
+ //鍏宠仈鐨勫嚭搴撳崟鍙�
+ private String outboundBatches;
+
}
diff --git a/src/main/resources/mapper/procurementrecord/ReturnManagementMapper.xml b/src/main/resources/mapper/procurementrecord/ReturnManagementMapper.xml
index a06b4f0..f380717 100644
--- a/src/main/resources/mapper/procurementrecord/ReturnManagementMapper.xml
+++ b/src/main/resources/mapper/procurementrecord/ReturnManagementMapper.xml
@@ -53,7 +53,7 @@
left join sales_ledger sl on si.sales_ledger_id = sl.id
where rm.id = #{id}
</select>
- <select id="listPageBySalesReturn" resultType="com.ruoyi.account.bean.vo.SalesReturnVo">
+ <select id="listPageAccountSalesReturn" resultType="com.ruoyi.account.bean.vo.SalesReturnVo">
select rm.id,
rm.return_no,
c.customer_name,
@@ -75,7 +75,7 @@
and c.customer_name like concat('%',#{req.customerName},'%')
</if>
<if test="req.startDate != null and req.endDate != null">
- AND DATE_FORMAT(rm.make_time, '%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
+ AND DATE_FORMAT(rm.make_time, '%Y-%m-%d') BETWEEN #{req.startDate} AND #{req.endDate}
</if>
order by rm.id DESC
</select>
diff --git a/src/main/resources/mapper/purchase/PurchaseReturnOrdersMapper.xml b/src/main/resources/mapper/purchase/PurchaseReturnOrdersMapper.xml
index dca2c47..2152244 100644
--- a/src/main/resources/mapper/purchase/PurchaseReturnOrdersMapper.xml
+++ b/src/main/resources/mapper/purchase/PurchaseReturnOrdersMapper.xml
@@ -58,7 +58,6 @@
select pro.id,
pro.no returnNo,
sm.supplier_name,
-
pro.prepared_at,
pro.total_amount,
CASE pro.return_type WHEN 0 THEN '閫�璐ч��娆�' WHEN 1 THEN '鎷掓敹' END AS returnType,
@@ -66,7 +65,7 @@
from purchase_return_orders pro
left join supplier_manage sm on pro.supplier_id = sm.id
left join purchase_ledger pl on pro.purchase_ledger_id = pl.id
- where rm.status=1
+ where 1=1
<if test="req.returnNo != null and req.returnNo != ''">
and pro.no like concat('%',#{req.returnNo},'%')
</if>
@@ -74,7 +73,7 @@
and sm.supplier_name like concat('%',#{req.supplierName},'%')
</if>
<if test="req.startDate != null and req.endDate != null">
- AND DATE_FORMAT(pro.prepared_at, '%Y-%m-%d') BETWEEN #{startDate} AND #{endDate}
+ AND DATE_FORMAT(pro.prepared_at, '%Y-%m-%d') BETWEEN #{req.startDate} AND #{req.endDate}
</if>
order by pro.id DESC
</select>
diff --git a/src/main/resources/mapper/sales/ShippingInfoMapper.xml b/src/main/resources/mapper/sales/ShippingInfoMapper.xml
index ee384ed..b0bf4b7 100644
--- a/src/main/resources/mapper/sales/ShippingInfoMapper.xml
+++ b/src/main/resources/mapper/sales/ShippingInfoMapper.xml
@@ -22,12 +22,14 @@
pm.model as specification_model,
pm.unit,
p.product_name,
- sl.customer_name
+ sl.customer_name,
+ sor.outbound_batches
FROM shipping_info s
LEFT JOIN sales_ledger sl ON s.sales_ledger_id = sl.id
LEFT JOIN sales_ledger_product slp ON s.sales_ledger_product_id = slp.id and slp.type = 1
left join product_model pm on slp.product_model_id = pm.id
left join product p on pm.product_id = p.id
+ left join stock_out_record sor on sor.record_id= s.id and sor.record_type='13' and sor.approval_status=1
WHERE 1=1
<if test="req.salesContractNo != null and req.salesContractNo != ''">
AND sl.sales_contract_no LIKE CONCAT('%',#{req.salesContractNo},'%')
@@ -86,6 +88,6 @@
<select id="getShippingInfoByCustomerName" resultType="com.ruoyi.sales.pojo.ShippingInfo">
select * from shipping_info si
left join sales_ledger sl on si.sales_ledger_id = sl.id
- where si.status = '宸插彂璐�' and sl.customer_name = #{customerName}
+ where sl.customer_name = #{customerName}
</select>
</mapper>
diff --git a/src/main/resources/mapper/stock/StockInRecordMapper.xml b/src/main/resources/mapper/stock/StockInRecordMapper.xml
index 05f8c89..579a464 100644
--- a/src/main/resources/mapper/stock/StockInRecordMapper.xml
+++ b/src/main/resources/mapper/stock/StockInRecordMapper.xml
@@ -78,7 +78,7 @@
DATE(sir.create_time) AS inboundDate,
p.product_name,
pm.model as specification_model,
- sor.stock_in_num * slp.tax_inclusive_unit_price AS InboundAmount,
+ sir.stock_in_num * slp.tax_inclusive_unit_price AS InboundAmount,
pl.purchase_contract_number
FROM stock_in_record sir
-- 10 绫诲瀷鎵嶅叧鑱旇川妫�琛�
@@ -87,11 +87,11 @@
LEFT JOIN purchase_ledger pl
ON pl.id = IF(sir.record_type = 7, sir.record_id, qi.purchase_ledger_id)
-- 浜у搧鍏宠仈涓嶅姩
- LEFT JOIN sales_ledger_product slp ON slp.type = 2 AND pl.id = slp.product_id
- LEFT JOIN product_model pm ON slp.product_model_id = pm.id
+ LEFT JOIN sales_ledger_product slp ON pl.id = slp.product_id
+ LEFT JOIN product_model pm ON sir.product_model_id = pm.id
LEFT JOIN product p ON pm.product_id = p.id
-- 鏉′欢
- WHERE sir.approval_status = 1
+ WHERE sir.approval_status = 1 AND slp.type = 2
AND sir.record_type IN ('7','10')
<if test="req.inboundBatches != null and req.inboundBatches != ''">
AND sir.inbound_batches LIKE CONCAT('%',#{req.inboundBatches},'%')
@@ -100,7 +100,7 @@
AND pl.supplier_name LIKE CONCAT('%',#{req.supplierName},'%')
</if>
<if test="req.startDate != null and req.endDate != null">
- AND DATE(sir.create_time) BETWEEN #{startDate} AND #{endDate}
+ AND DATE(sir.create_time) BETWEEN #{req.startDate} AND #{req.endDate}
</if>
order by sir.id DESC
</select>
diff --git a/src/main/resources/mapper/stock/StockOutRecordMapper.xml b/src/main/resources/mapper/stock/StockOutRecordMapper.xml
index 9e32e21..35421c9 100644
--- a/src/main/resources/mapper/stock/StockOutRecordMapper.xml
+++ b/src/main/resources/mapper/stock/StockOutRecordMapper.xml
@@ -91,7 +91,7 @@
sor.id,
sor.outbound_batches,
sl.customer_name,
- s.shipping_date,
+ sor.create_time as shippingDate,
p.product_name,
pm.model as specification_model,
sor.stock_out_num * slp.tax_inclusive_unit_price as outboundAmount,
@@ -103,7 +103,7 @@
LEFT JOIN sales_ledger_product slp ON s.sales_ledger_product_id = slp.id and slp.type = 1
left join product_model pm on slp.product_model_id = pm.id
left join product p on pm.product_id = p.id
- WHERE s.status='宸插彂璐�' and sor.record_type='13'
+ WHERE sor.record_type='13' and sor.approval_status=1
<if test="req.outboundBatches != null and req.outboundBatches != ''">
AND sor.outbound_batches LIKE CONCAT('%',#{req.outboundBatches},'%')
</if>
@@ -111,7 +111,7 @@
AND sl.customer_name LIKE CONCAT('%',#{req.customerName},'%')
</if>
<if test="req.startDate != null and req.endDate != null">
- AND s.shipping_date BETWEEN #{startDate} AND #{endDate}
+ AND s.shipping_date BETWEEN #{req.startDate} AND #{req.endDate}
</if>
order by sor.id DESC
</select>
--
Gitblit v1.9.3