Complex sentence: Thereafter it was assigned to the Middle Department, in which it served until the end of the war.
Split into simpler sentences: Thereafter it was assigned to the Middle Department. It served in the Middle Department until the end of the war.