From 6a2d5ddbb3ca06b48b94f6850ef0d7da8450ad99 Mon Sep 17 00:00:00 2001 From: lizhenhua <1075222162@qq.com> Date: Tue, 10 Feb 2026 17:02:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BE=9B=E5=BA=94=E9=93=BE?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DrpInventoryIntoDetailServiceImpl.java | 4 +- .../DrpInventoryIntoDetailMapper.xml | 455 ++----- .../mapper/reportforms/DrpInventorMapper.xml | 424 ++++++ .../DrpInventoryIntoDetailMapper.xml | 544 ++++++++ .../mapper/reportforms/OrgConsumerMapper.xml | 1176 +++++++++++++++++ .../mapper/reportforms/placeMapper.xml | 136 ++ 6 files changed, 2390 insertions(+), 349 deletions(-) create mode 100644 bonus-modules/bonus-supply-chain/src/main/resources/mapper/reportforms/DrpInventorMapper.xml create mode 100644 bonus-modules/bonus-supply-chain/src/main/resources/mapper/reportforms/DrpInventoryIntoDetailMapper.xml create mode 100644 bonus-modules/bonus-supply-chain/src/main/resources/mapper/reportforms/OrgConsumerMapper.xml create mode 100644 bonus-modules/bonus-supply-chain/src/main/resources/mapper/reportforms/placeMapper.xml diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/reportforms/service/impl/DrpInventoryIntoDetailServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/reportforms/service/impl/DrpInventoryIntoDetailServiceImpl.java index 739d9576..9ed54155 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/reportforms/service/impl/DrpInventoryIntoDetailServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/reportforms/service/impl/DrpInventoryIntoDetailServiceImpl.java @@ -87,12 +87,12 @@ public class DrpInventoryIntoDetailServiceImpl implements IDrpInventoryIntoDetai public Map pageInventoryOutDetail(DrpInventoryIntoDetailQueryDTO queryDTO) { SysUser currentUser = SecurityUtils.getLoginUser().getSysUser(); List warehouseAuthority = drpInventoryIntoDetailMapper.getTenantWarehouseIds(currentUser.getUserId()); - List areaAuth = drpInventoryIntoDetailMapper.getTenantAreaIds(currentUser.getUserId()); + // List areaAuth = drpInventoryIntoDetailMapper.getTenantAreaIds(currentUser.getUserId()); PageHelper.startPage(queryDTO); DrpInventoryIntoDetailWrapper wrapper = new DrpInventoryIntoDetailWrapper(); wrapper.setParam(queryDTO); wrapper.setWarehouseAuthority(warehouseAuthority); - wrapper.setAreaAuth(areaAuth); + wrapper.setAreaAuth(null); List drpInventoryoutDetailVOS = drpInventoryIntoDetailMapper.queryInventoryOutDetail(wrapper); /* for ( DrpInventoryoutDetailVO c : drpInventoryoutDetailVOS) { try { diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/reportforms/DrpInventoryIntoDetailMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/reportforms/DrpInventoryIntoDetailMapper.xml index fd573777..65373f64 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/reportforms/DrpInventoryIntoDetailMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/reportforms/DrpInventoryIntoDetailMapper.xml @@ -219,214 +219,143 @@ + SELECT - SUM(intoNum) as totalInQty, - SUM(intoAmount) as totalInAmount, - -- 库存总计(直接从主表查询,不包含退款记录) - (SELECT SUM(de2.inventory_num) - FROM report_drp_inventory_base de2 - LEFT JOIN menu_material mm2 ON de2.material_id = mm2.material_id - LEFT JOIN drp_warehouse dw2 ON de2.warehouse_id = dw2.warehouse_id - LEFT JOIN alloc_area aa2 ON aa2.area_id = dw2.area_id - WHERE de2.record_type = 2 - AND de2.out_into_type IN (1,3,5,6) - - AND de2.record_date >= #{param.startDate} - - - AND de2.record_date <= #{param.endDate} - - - AND (mm2.material_name like concat('%', #{param.materialName}, '%') - OR mm2.material_code like concat('%', #{param.materialName}, '%')) - - - AND dw2.area_id in - - #{id} - - - - AND dw2.warehouse_id in - - #{id} - - - - AND dw2.warehouse_id in - - #{id} - - - - AND dw2.area_id in - - #{id} - - - ) as totalStockQty, - (SELECT SUM(de2.total_amount) - FROM report_drp_inventory_base de2 - LEFT JOIN menu_material mm2 ON de2.material_id = mm2.material_id - LEFT JOIN drp_warehouse dw2 ON de2.warehouse_id = dw2.warehouse_id - LEFT JOIN alloc_area aa2 ON aa2.area_id = dw2.area_id - WHERE de2.record_type = 2 - AND de2.out_into_type IN (1,3,5,6) - - AND de2.record_date >= #{param.startDate} - - - AND de2.record_date <= #{param.endDate} - - - AND (mm2.material_name like concat('%', #{param.materialName}, '%') - OR mm2.material_code like concat('%', #{param.materialName}, '%')) - - - AND dw2.area_id in - - #{id} - - - - AND dw2.warehouse_id in - - #{id} - - - - AND dw2.warehouse_id in - - #{id} - - - - AND dw2.area_id in - - #{id} - - - ) as totalStockAmount + SUM(combined.intoNum) AS totalInQty, + SUM(combined.intoAmount) AS totalInAmount, + SUM(combined.balance_num) AS totalStockQty, + SUM(combined.balance_amount) AS totalStockAmount FROM ( - -- 正常入库记录 + -- 正常入库 + 退单负数 SELECT - de.out_into_num as intoNum, - de.out_into_amount as intoAmount + -- 数量:退单为负 + CASE + WHEN de.record_type = 1 AND de.out_into_type = 6 + THEN -de.out_into_num + ELSE de.out_into_num + END AS intoNum, + + -- 金额:退单为负 + CASE + WHEN de.record_type = 1 AND de.out_into_type = 6 + THEN -de.out_into_amount + ELSE de.out_into_amount + END AS intoAmount, + + de.inventory_num AS balance_num, + de.total_amount AS balance_amount + FROM report_drp_inventory_base de LEFT JOIN menu_material mm ON de.material_id = mm.material_id LEFT JOIN drp_unit du ON de.unit_id = du.unit_id LEFT JOIN menu_material_category mmc ON mmc.category_id = mm.category_id LEFT JOIN drp_warehouse dw ON dw.warehouse_id = de.warehouse_id LEFT JOIN alloc_area aa ON aa.area_id = dw.area_id - LEFT JOIN mgr_user mu ON de.fetch_user_id = mu.user_id - WHERE de.record_type = 2 - AND de.out_into_type IN (1,3,5,6) + + WHERE + ( + -- 正常入库 + (de.record_type = 2 AND de.out_into_type IN (1,3,5,6)) + OR + -- 退单 + (de.record_type = 1 AND de.out_into_type = 6) + ) AND de.record_date >= #{param.startDate} @@ -636,148 +503,42 @@ AND de.record_date <= #{param.endDate} - - AND de.fetch_user_id in - - #{id} - - - - AND (mm.material_name like concat('%', #{param.materialName}, '%') - OR mm.material_code like concat('%', #{param.materialName}, '%')) - - - - AND mmc.category_id in - - #{id} - - - - - AND de.out_into_type in - - #{id} - - - - - AND de.record_id like concat('%', #{param.recordId}, '%') + AND (mm.material_name LIKE CONCAT('%', #{param.materialName}, '%') + OR mm.material_code LIKE CONCAT('%', #{param.materialName}, '%')) - AND dw.area_id in + AND dw.area_id IN #{id} - AND dw.warehouse_id in + AND dw.warehouse_id IN #{id} - AND dw.warehouse_id in + AND dw.warehouse_id IN #{id} - AND dw.area_id in + AND dw.area_id IN #{id} - UNION ALL + ) AS combined - -- 退款记录(负数) - SELECT - de.out_into_num as intoNum, -- 注意:这里需要改成负数,或者保持正数在外部处理 - -de.out_into_amount as intoAmount -- 金额为负数 - FROM report_drp_inventory_base de - LEFT JOIN menu_material mm ON de.material_id = mm.material_id - LEFT JOIN drp_unit du ON de.unit_id = du.unit_id - LEFT JOIN menu_material_category mmc ON mmc.category_id = mm.category_id - LEFT JOIN drp_warehouse dw ON dw.warehouse_id = de.warehouse_id - LEFT JOIN alloc_area aa ON aa.area_id = dw.area_id - LEFT JOIN mgr_user mu ON de.fetch_user_id = mu.user_id - INNER JOIN order_info oi ON oi.inventory_out_id = de.record_id - INNER JOIN order_refund rr ON rr.order_id = oi.order_id AND rr.check_state = 2 - WHERE de.record_type = 2 - AND de.out_into_type IN (1,3,5,6) - - - AND rr.apply_time >= #{param.startDate} - - - AND rr.apply_time <= #{param.endDate} - - - - AND de.fetch_user_id in - - #{id} - - - - - AND (mm.material_name like concat('%', #{param.materialName}, '%') - OR mm.material_code like concat('%', #{param.materialName}, '%')) - - - - AND mmc.category_id in - - #{id} - - - - - AND de.out_into_type in - - #{id} - - - - - AND de.record_id like concat('%', #{param.recordId}, '%') - - - - AND dw.area_id in - - #{id} - - - - - AND dw.warehouse_id in - - #{id} - - - - - AND dw.warehouse_id in - - #{id} - - - - - AND dw.area_id in - - #{id} - - - ) AS combined_data - + diff --git a/bonus-modules/bonus-supply-chain/src/main/resources/mapper/reportforms/DrpInventorMapper.xml b/bonus-modules/bonus-supply-chain/src/main/resources/mapper/reportforms/DrpInventorMapper.xml new file mode 100644 index 00000000..bf2952fb --- /dev/null +++ b/bonus-modules/bonus-supply-chain/src/main/resources/mapper/reportforms/DrpInventorMapper.xml @@ -0,0 +1,424 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bonus-modules/bonus-supply-chain/src/main/resources/mapper/reportforms/DrpInventoryIntoDetailMapper.xml b/bonus-modules/bonus-supply-chain/src/main/resources/mapper/reportforms/DrpInventoryIntoDetailMapper.xml new file mode 100644 index 00000000..65373f64 --- /dev/null +++ b/bonus-modules/bonus-supply-chain/src/main/resources/mapper/reportforms/DrpInventoryIntoDetailMapper.xml @@ -0,0 +1,544 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bonus-modules/bonus-supply-chain/src/main/resources/mapper/reportforms/OrgConsumerMapper.xml b/bonus-modules/bonus-supply-chain/src/main/resources/mapper/reportforms/OrgConsumerMapper.xml new file mode 100644 index 00000000..02857fcb --- /dev/null +++ b/bonus-modules/bonus-supply-chain/src/main/resources/mapper/reportforms/OrgConsumerMapper.xml @@ -0,0 +1,1176 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bonus-modules/bonus-supply-chain/src/main/resources/mapper/reportforms/placeMapper.xml b/bonus-modules/bonus-supply-chain/src/main/resources/mapper/reportforms/placeMapper.xml new file mode 100644 index 00000000..1c3e823c --- /dev/null +++ b/bonus-modules/bonus-supply-chain/src/main/resources/mapper/reportforms/placeMapper.xml @@ -0,0 +1,136 @@ + + + + + +