Classification of certain compact Riemannian manifolds with harmonic curvature and non-parallel Ricci tensor