diff --git a/src/main/java/cn/lihongjie/coal/warehouseReceipt/service/WarehouseReceiptService.java b/src/main/java/cn/lihongjie/coal/warehouseReceipt/service/WarehouseReceiptService.java index ae9eeb24..c1f45ce3 100644 --- a/src/main/java/cn/lihongjie/coal/warehouseReceipt/service/WarehouseReceiptService.java +++ b/src/main/java/cn/lihongjie/coal/warehouseReceipt/service/WarehouseReceiptService.java @@ -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 barCode??> and gs.bar_code like '%' || :barCode || '%' <#if code??> and gs.code like '%' || :code || '%' - - + + <#if goodsName??> - + and gs.name like '%' || :goodsName || '%' - + <#if categoryIds?has_content> and gs.category_id in :categoryIds - + <#if brandIds?has_content> and gs.brand_id in :brandIds - + <#if unitIds?has_content> and gs.unit_id in :unitIds - + ) 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 @@ -1026,33 +1026,33 @@ from ( <#if goodsIds?has_content> and gs.id in :goodsIds - + <#if barCode??> and gs.bar_code like '%' || :barCode || '%' <#if code??> and gs.code like '%' || :code || '%' - - + + <#if goodsName??> - + and gs.name like '%' || :goodsName || '%' - + <#if categoryIds?has_content> and gs.category_id in :categoryIds - + <#if brandIds?has_content> and gs.brand_id in :brandIds - + <#if unitIds?has_content> and gs.unit_id in :unitIds ) 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 barCode??> and gs.bar_code like '%' || :barCode || '%' <#if code??> and gs.code like '%' || :code || '%' - - + + <#if goodsName??> - + and gs.name like '%' || :goodsName || '%' - + <#if categoryIds?has_content> and gs.category_id in :categoryIds - + <#if brandIds?has_content> and gs.brand_id in :brandIds - + <#if unitIds?has_content> and gs.unit_id in :unitIds - + ) 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 barCode??> and gs.bar_code like '%' || :barCode || '%' <#if code??> and gs.code like '%' || :code || '%' - - + + <#if goodsName??> - + and gs.name like '%' || :goodsName || '%' - + <#if categoryIds?has_content> and gs.category_id in :categoryIds - + <#if brandIds?has_content> and gs.brand_id in :brandIds - + <#if unitIds?has_content> and gs.unit_id in :unitIds ) 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 @@ -1169,50 +1169,54 @@ from ( <#if goodsIds?has_content> and gs.id in :goodsIds - + <#if barCode??> and gs.bar_code like '%' || :barCode || '%' <#if code??> and gs.code like '%' || :code || '%' - - + + <#if goodsName??> - + and gs.name like '%' || :goodsName || '%' - + <#if categoryIds?has_content> and gs.category_id in :categoryIds - + <#if brandIds?has_content> and gs.brand_id in :brandIds - + <#if unitIds?has_content> and gs.unit_id in :unitIds - + ) as "入库商品总价" - - + + from t_warehouse_supplier s where s.organization_id = :organizationId + + <#if supplierIds?has_content> + and s.id in :supplierIds + ) - - + + select * from tmp1 - - + + <#if excludeEmpty> - + where "入库单数量" > 0 - - - + + + """, request);