The Department of Labor's efforts to address labor shortages and cut costs failed to consider U.S. workers, the judge said.