@ -59,7 +59,7 @@
bmi.material_categories,
bmi.material_categories,
bmi.material_subclass,
bmi.material_subclass,
bmi.material_type_id,
bmi.material_type_id,
bmt.type_name material_type_name,
bmt.type_name material_type_name,
bmi.batch_flag,
bmi.batch_flag,
bmi.batch_amount,
bmi.batch_amount,
bmi.material_unit_id,
bmi.material_unit_id,
@ -91,12 +91,12 @@
bmi.erp_modify_date,
bmi.erp_modify_date,
bmi.safe_stock_amount,
bmi.safe_stock_amount,
mbui.unit_name,
mbui.unit_name,
wst.availableAmount,
IF( wst.availableAmount IS NULL, 0, wst.availableAmount) availableAmount,
IF(wst.availableAmount >= bmi.safe_stock_amount , '1', '0') isExceeded
IF(bmi.safe_stock_amount > IF(wst.availableAmount IS NULL, 0, wst.availableAmount) , '1', '0') isExceeded
from mes_base_material_info bmi
from mes_base_material_info bmi
left join mes_base_material_type bmt on bmt.matrial_type_id = bmi.material_type_id
left join mes_base_material_type bmt on bmt.matrial_type_id = bmi.material_type_id
left join mes_base_unit_info mbui on bmi.material_unit_id = mbui.erp_id
left join mes_base_unit_info mbui on bmi.material_unit_id = mbui.erp_id
left join (select material_id, SUM(total_amount - occupy_amount ) availableAmount
left join (select material_id, SUM(total_amount) availableAmount
from wms_stock_total
from wms_stock_total
GROUP BY material_id) wst on bmi.material_id = wst.material_id
GROUP BY material_id) wst on bmi.material_id = wst.material_id
</sql>
</sql>
@ -142,7 +142,7 @@
<if test= "accessoriesFlag != null and accessoriesFlag != ''" > and bmi.accessories_flag = #{accessoriesFlag}</if>
<if test= "accessoriesFlag != null and accessoriesFlag != ''" > and bmi.accessories_flag = #{accessoriesFlag}</if>
<if test= "lowValueConsumableFlag != null and lowValueConsumableFlag != ''" > and bmi.low_value_consumable_flag = #{lowValueConsumableFlag}</if>
<if test= "lowValueConsumableFlag != null and lowValueConsumableFlag != ''" > and bmi.low_value_consumable_flag = #{lowValueConsumableFlag}</if>
<if test= "alwaysFlag != null and alwaysFlag != ''" > and bmi.always_flag = #{alwaysFlag}</if>
<if test= "alwaysFlag != null and alwaysFlag != ''" > and bmi.always_flag = #{alwaysFlag}</if>
<if test= "isExceeded != null and isExceeded != ''" > and IF(wst.availableAmount >= bmi.safe_stock_amount , '1', '0') = #{isExceeded}</if>
<if test= "isExceeded != null and isExceeded != ''" > and IF(bmi.safe_stock_amount > IF(wst.availableAmount IS NULL, 0, wst.availableAmount) , '1', '0') = #{isExceeded}</if>
<if test= "selectType != null and selectType !=''" > and exists (select 1 from wms_warehouse_material wwm where wwm.storage_type='1' and wwm.warehouse_id=511 and wwm.storage_id=bmi.material_id)</if>
<if test= "selectType != null and selectType !=''" > and exists (select 1 from wms_warehouse_material wwm where wwm.storage_type='1' and wwm.warehouse_id=511 and wwm.storage_id=bmi.material_id)</if>
<if test= "filterMaterialId != null " > and exists (select 1
<if test= "filterMaterialId != null " > and exists (select 1
from (select m1.material_id, m1.material_name, m2.material_id prod_id, m2.material_name prod_name
from (select m1.material_id, m1.material_name, m2.material_id prod_id, m2.material_name prod_name