Analytical solution and entanglement swapping of a double Jaynes–Cummings model in non-Markovian environments