From 16c783c70a0fc4904c35b035c6e9a243ae8e0053 Mon Sep 17 00:00:00 2001 From: yinq Date: Wed, 1 Apr 2026 14:09:11 +0800 Subject: [PATCH] =?UTF-8?q?1.1.6=20=E9=87=87=E8=B4=AD=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=9B=9E=E6=98=BE=E6=95=B0=E6=8D=AE=E6=9C=AA?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E6=95=B0=E9=87=8F=E8=BF=9B=E8=A1=8C=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erp/ErpProjectPurchaseMaterialMapper.xml | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/ruoyi-modules/ruoyi-oa/src/main/resources/mapper/oa/erp/ErpProjectPurchaseMaterialMapper.xml b/ruoyi-modules/ruoyi-oa/src/main/resources/mapper/oa/erp/ErpProjectPurchaseMaterialMapper.xml index 04374f5a..ac8c115f 100644 --- a/ruoyi-modules/ruoyi-oa/src/main/resources/mapper/oa/erp/ErpProjectPurchaseMaterialMapper.xml +++ b/ruoyi-modules/ruoyi-oa/src/main/resources/mapper/oa/erp/ErpProjectPurchaseMaterialMapper.xml @@ -59,15 +59,31 @@ t.unit_id, u.unit_name, t.amount as need_purchase_amount, - t.amount as purchase_amount, + case + when coalesce(pm.purchased_amount, 0) >= t.amount then 0 + else t.amount - coalesce(pm.purchased_amount, 0) + end as purchase_amount, m.material_code as relation_material_code, COALESCE(m.material_name, t.product_name) as relation_material_name from erp_contract_material t left join erp_project_contracts pc on pc.contract_id = t.contract_id and pc.del_flag = '0' left join base_material_info m on m.material_id = t.material_id left join base_unit_info u on u.unit_id = t.unit_id + left join (select ppm.relation_details_id, + pp.relation_id, + sum(coalesce(ppm.purchase_amount, 0)) as purchased_amount + from erp_project_purchase_material ppm + inner join erp_project_purchase pp on pp.project_purchase_id = ppm.project_purchase_id + and pp.del_flag = '0' + and pp.spare_flag = '1' + where ppm.del_flag = '0' + and ppm.spare_flag = '1' + group by ppm.relation_details_id, pp.relation_id) pm + on pm.relation_details_id = t.contract_material_id + and pm.relation_id = t.contract_id where t.del_flag = '0' and pc.project_id = #{projectId} + order by t.contract_material_id asc