Refineries owned by oil companies that also produce crude (supermajors, NOCs and state oil companies), run as part of an integrated chain from wellhead to fuel and petrochemicals, often with captive crude supply and their own marketing networks.
State refiners are one player in the oil & gas industry, and an industry of their own, with their own suppliers, customers, software, regulators, and money flows. This full map is on the roadmap.
Meanwhile: how state refiners fit into oil & gas