Socialists win second term as Spain's ruling party