fix(filter): append 23:59:59 to end_date to resolve midnight truncation bug in date range queries

This commit is contained in:
DXC
2026-04-07 17:39:14 +08:00
parent 5ea2be58ae
commit f612c47143
2 changed files with 18 additions and 0 deletions

View File

@ -114,6 +114,12 @@ class InboundSummaryService:
)
query = query.filter(rule)
# 日期补全:解决零点截断问题
if end_date and len(str(end_date).strip()) == 10:
end_date = f"{str(end_date).strip()} 23:59:59"
if start_date and len(str(start_date).strip()) == 10:
start_date = f"{str(start_date).strip()} 00:00:00"
if start_date and end_date:
query = query.filter(cte.c.inbound_date.between(start_date, end_date))
@ -286,6 +292,12 @@ class InboundSummaryService:
)
query = query.filter(rule)
# 日期补全:解决零点截断问题
if end_date and len(str(end_date).strip()) == 10:
end_date = f"{str(end_date).strip()} 23:59:59"
if start_date and len(str(start_date).strip()) == 10:
start_date = f"{str(start_date).strip()} 00:00:00"
if start_date and end_date:
query = query.filter(cte.c.inbound_date.between(start_date, end_date))

View File

@ -198,6 +198,12 @@ class OutboundService:
支持跨表搜索单号、领用人、SKU、物料名称、规格型号
search_type: all, no, name, sku, material_name, spec_model
"""
# 日期补全:解决零点截断问题
if end_date and len(str(end_date).strip()) == 10:
end_date = f"{str(end_date).strip()} 23:59:59"
if start_date and len(str(start_date).strip()) == 10:
start_date = f"{str(start_date).strip()} 00:00:00"
# 1. 构建基础查询
# 如果有关键词,需要联表搜索物料名称和规格型号
if keyword: