select
a.id,
a.goods_name,
a.goods_no,
a.packing_size,
a.support_unit_id,
a.support_unit,
a.support_unit_quantity,
a.material_unit_ea,
a.material_unit_ea_quantity,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.top_organization_id,
a.organization_id,
a.organization_name,
a.del_flag,
a.order_id,
a.unit_price,
a.tax_unit_price,
a.tax_rate,
a.taxes,
a.amount,
a.tax_amount,
sum(case task.task_status when 2 then task.plan_num else 0 end) completeNum, -- 物料完成数量
1234567890 stockUsableNum,
a.remark
FROM
oms_goods a
left join oms_task_order task on a.id = task.goods_id and task.del_flag = 1 -- 作业任务(未删除)
left join oms_scm_order scm on a.order_id = scm.order_id and scm.del_flag = 1 -- 供应链订单(未删除)
a.del_flag = 1
and a.top_organization_id = #{topOrganizationId}
and a.organization_id = #{organizationId}
and a.organization_name like concat('%', #{organizationName}, '%')
and a.order_id = #{orderId}
and a.goods_no = #{goodsNo}
and a.goods_name like concat('%', #{goodsName}, '%')
and a.packing_size = #{packingSize}
and a.support_unit_id = #{supportUnitId}
and a.support_unit = #{supportUnit}
and a.material_unit_ea = #{materialUnitEa}
and a.unit_price = #{unitPrice}
and a.tax_unit_price = #{taxUnitPrice}
and a.tax_rate = #{taxRate}
and a.taxes = #{taxes}
and a.amount = #{amount}
and a.tax_amount = #{taxAmount}
and scm.id = #{scmId}
and a.id in
#{id}