Apparatus for the treatment of wet solids, especially pulpy materials, by heating or cooling