Using classical Cepheids to study the far side of the Milky Way disk. I. Spectroscopic classification and the metallicity gradient