mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
fix(warehouse): 供应商统计查询报错问题
- 在 SQL 查询中添加了对 supplierIds 的判断和使用 - 优化了 SQL 查询的格式和可读性- 通过 FreeMarker 模板生成 SQL,修复了可能导致查询报错的问题
This commit is contained in:
@@ -950,13 +950,13 @@ from (
|
||||
String sql =
|
||||
FreeMakerUtils.render(
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
with tmp1 as (
|
||||
|
||||
|
||||
|
||||
|
||||
select s.*,
|
||||
|
||||
|
||||
(select count(distinct re.id)
|
||||
from t_warehouse_receipt re
|
||||
inner join t_warehouse_receipt_detail d
|
||||
@@ -977,34 +977,34 @@ from (
|
||||
<#if goodsIds?has_content>
|
||||
and gs.id in :goodsIds
|
||||
</#if>
|
||||
|
||||
|
||||
<#if barCode??>
|
||||
and gs.bar_code like '%' || :barCode || '%'
|
||||
</#if>
|
||||
<#if code??>
|
||||
and gs.code like '%' || :code || '%'
|
||||
</#if>
|
||||
|
||||
|
||||
|
||||
|
||||
<#if goodsName??>
|
||||
|
||||
|
||||
and gs.name like '%' || :goodsName || '%'
|
||||
|
||||
|
||||
</#if>
|
||||
<#if categoryIds?has_content>
|
||||
and gs.category_id in :categoryIds
|
||||
</#if>
|
||||
|
||||
|
||||
<#if brandIds?has_content>
|
||||
and gs.brand_id in :brandIds
|
||||
</#if>
|
||||
|
||||
|
||||
<#if unitIds?has_content>
|
||||
and gs.unit_id in :unitIds
|
||||
</#if>
|
||||
|
||||
|
||||
) as "入库单数量",
|
||||
|
||||
|
||||
(select count(d.id)
|
||||
from t_warehouse_receipt re
|
||||
inner join t_warehouse_receipt_detail d
|
||||
@@ -1013,7 +1013,7 @@ from (
|
||||
where re.organization_id = s.organization_id
|
||||
and re.receipt_type = '0'
|
||||
and d.supplier_id = s.id
|
||||
|
||||
|
||||
<#if startTime??>
|
||||
and re.receipt_date >= :startTime
|
||||
</#if>
|
||||
@@ -1026,33 +1026,33 @@ from (
|
||||
<#if goodsIds?has_content>
|
||||
and gs.id in :goodsIds
|
||||
</#if>
|
||||
|
||||
|
||||
<#if barCode??>
|
||||
and gs.bar_code like '%' || :barCode || '%'
|
||||
</#if>
|
||||
<#if code??>
|
||||
and gs.code like '%' || :code || '%'
|
||||
</#if>
|
||||
|
||||
|
||||
|
||||
|
||||
<#if goodsName??>
|
||||
|
||||
|
||||
and gs.name like '%' || :goodsName || '%'
|
||||
|
||||
|
||||
</#if>
|
||||
<#if categoryIds?has_content>
|
||||
and gs.category_id in :categoryIds
|
||||
</#if>
|
||||
|
||||
|
||||
<#if brandIds?has_content>
|
||||
and gs.brand_id in :brandIds
|
||||
</#if>
|
||||
|
||||
|
||||
<#if unitIds?has_content>
|
||||
and gs.unit_id in :unitIds
|
||||
</#if>
|
||||
) as "入库单明细数量",
|
||||
|
||||
|
||||
(select count(distinct d.goods_id)
|
||||
from t_warehouse_receipt re
|
||||
inner join t_warehouse_receipt_detail d
|
||||
@@ -1073,34 +1073,34 @@ from (
|
||||
<#if goodsIds?has_content>
|
||||
and gs.id in :goodsIds
|
||||
</#if>
|
||||
|
||||
|
||||
<#if barCode??>
|
||||
and gs.bar_code like '%' || :barCode || '%'
|
||||
</#if>
|
||||
<#if code??>
|
||||
and gs.code like '%' || :code || '%'
|
||||
</#if>
|
||||
|
||||
|
||||
|
||||
|
||||
<#if goodsName??>
|
||||
|
||||
|
||||
and gs.name like '%' || :goodsName || '%'
|
||||
|
||||
|
||||
</#if>
|
||||
<#if categoryIds?has_content>
|
||||
and gs.category_id in :categoryIds
|
||||
</#if>
|
||||
|
||||
|
||||
<#if brandIds?has_content>
|
||||
and gs.brand_id in :brandIds
|
||||
</#if>
|
||||
|
||||
|
||||
<#if unitIds?has_content>
|
||||
and gs.unit_id in :unitIds
|
||||
</#if>
|
||||
|
||||
|
||||
) as "入库商品种数",
|
||||
|
||||
|
||||
(select round(sum(d.number)::::numeric, 2)
|
||||
from t_warehouse_receipt re
|
||||
inner join t_warehouse_receipt_detail d
|
||||
@@ -1121,33 +1121,33 @@ from (
|
||||
<#if goodsIds?has_content>
|
||||
and gs.id in :goodsIds
|
||||
</#if>
|
||||
|
||||
|
||||
<#if barCode??>
|
||||
and gs.bar_code like '%' || :barCode || '%'
|
||||
</#if>
|
||||
<#if code??>
|
||||
and gs.code like '%' || :code || '%'
|
||||
</#if>
|
||||
|
||||
|
||||
|
||||
|
||||
<#if goodsName??>
|
||||
|
||||
|
||||
and gs.name like '%' || :goodsName || '%'
|
||||
|
||||
|
||||
</#if>
|
||||
<#if categoryIds?has_content>
|
||||
and gs.category_id in :categoryIds
|
||||
</#if>
|
||||
|
||||
|
||||
<#if brandIds?has_content>
|
||||
and gs.brand_id in :brandIds
|
||||
</#if>
|
||||
|
||||
|
||||
<#if unitIds?has_content>
|
||||
and gs.unit_id in :unitIds
|
||||
</#if>
|
||||
) as "入库商品数量",
|
||||
|
||||
|
||||
(select round(sum(d.amount)::::numeric, 2)
|
||||
from t_warehouse_receipt re
|
||||
inner join t_warehouse_receipt_detail d
|
||||
@@ -1156,7 +1156,7 @@ from (
|
||||
where re.organization_id = s.organization_id
|
||||
and re.receipt_type = '0'
|
||||
and d.supplier_id = s.id
|
||||
|
||||
|
||||
<#if startTime??>
|
||||
and re.receipt_date >= :startTime
|
||||
</#if>
|
||||
@@ -1169,50 +1169,54 @@ from (
|
||||
<#if goodsIds?has_content>
|
||||
and gs.id in :goodsIds
|
||||
</#if>
|
||||
|
||||
|
||||
<#if barCode??>
|
||||
and gs.bar_code like '%' || :barCode || '%'
|
||||
</#if>
|
||||
<#if code??>
|
||||
and gs.code like '%' || :code || '%'
|
||||
</#if>
|
||||
|
||||
|
||||
|
||||
|
||||
<#if goodsName??>
|
||||
|
||||
|
||||
and gs.name like '%' || :goodsName || '%'
|
||||
|
||||
|
||||
</#if>
|
||||
<#if categoryIds?has_content>
|
||||
and gs.category_id in :categoryIds
|
||||
</#if>
|
||||
|
||||
|
||||
<#if brandIds?has_content>
|
||||
and gs.brand_id in :brandIds
|
||||
</#if>
|
||||
|
||||
|
||||
<#if unitIds?has_content>
|
||||
and gs.unit_id in :unitIds
|
||||
</#if>
|
||||
|
||||
|
||||
) as "入库商品总价"
|
||||
|
||||
|
||||
|
||||
|
||||
from t_warehouse_supplier s
|
||||
where s.organization_id = :organizationId
|
||||
|
||||
<#if supplierIds?has_content>
|
||||
and s.id in :supplierIds
|
||||
</#if>
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
select * from tmp1
|
||||
|
||||
|
||||
|
||||
|
||||
<#if excludeEmpty>
|
||||
|
||||
|
||||
where "入库单数量" > 0
|
||||
</#if>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
""",
|
||||
request);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user