I was using StockStateInterface to get stock qty, it was working fine in development and staging server but was not working in production server.
Then I used StockRegistryInterface to get the result and it worked on the production server.
Why it happened so?
I used this:
\Magento\CatalogInventory\Api\StockStateInterface $stockState,
\Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry,