Hyundai has reached agreement with its labour unions on wages and working conditions, bringing to an end the costliest dispute in the carmaker's history.