Duke Energy must act immediately to eliminate sources of groundwater contamination at its coal ash dumps, a judge said Thursday in a ruling that came from a complaint filed in 2012, before a massive spill from one of the utility’s plants coated 70 miles of the Dan River in toxic sludge this year.