Disclaimer: Much of this is theoretical, as I've never had to actually deal with a massive flooding event. Some of my knowledge is also out of date; I've never run into an underground river before. I'm assuming that they function like an overground river or an aquifer, i.e. they produce an infinite amount of unpressurized water.
The first step is to seal off the water as much as you can. Forbid any doors that are in its path - doors are waterproof until they're opened. Forbidden doors are locked and can't be opened, so they'll act as a seal. Just make sure you don't lock anyone in.
You should be able to place constructions up to a depth of 3 units. It looks like the water is slowly expanding, so you should be able to still add doors to 1-2 depth areas. If you have narrow corridors, place doors in them to block the water and forbid them. Make two layers, just in case something goes wrong. If not, then just use walls. Doors are suggested simply because they're lighter than raw stone and usually plentiful.
There are two ways to remove water:
- Pump it back into a source of water (I can't guarantee this works
for an underground river; it will not work for a light aquifer
or for any finite source of water)
- Let it evaporate. Water at 1/7 depth will eventually disappear on its own. If you seal off the breach, eventually all the water will settle and evaporate from the top. This won't remove any water that has pooled into lower areas, but you can use pumps to pull this water out into a wider area where it can evaporate.
To pump the water out:
- Excavate the area directly above the breach: You need a channel over the breached area you want to reclaim, and another channel over the underground river.
- For maximum safety, place floor grates over both channeled areas, and add doors to ensure water cannot escape. Water can travel through grates, even through a pump, but dwarves cannot. Just in case I'm wrong about how pressurized water works here.
- Build a pump over the breached area. Have it set up so the pumped water follows a narrow corridor into the other channeled area - in other words, pump the water back into the river.
- An infinite source of water also acts as an infinite reservoir, so this should result in the pumped water being removed. Pumps pump faster than unpressurized water travels, so this will prevent any further water coming out, and will pick up the water that had already escaped.
- Once the water drains and goes under 3/7 past the pump, you should be able to install doors, actual flood gates, or walls just past the pumped area, and thus permanently seal it off, at the source.
This will not recover any flooded lower areas, but you can just install a pump on top of another channeled area and pump it into a larger area. This water will then settle to 1/7 and evaporate. Slowly, but it's going to be easier than trying to work it back into the underground river.