If your visa allows ONE transit through another Schengen country then you will have used that one transit on the way to Spain and you can't use it again on the way home.
In practice it is quite possible that you won't have a problem boarding your flight to Germany on the way back as the only people who will check your ID will be airport/airline staff. However, when you get to Germany you will go through a passport check with the German border agency before you are allowed onto your flight home, and if they notice that your paperwork is not in order then you could have some problems.
So... this means that you will need another visa for your flight home. As you will be a (temporary) resident in Spain you should be able to obtain this after your arrival, but you may want to play safe and get it before you leave China.
Visas which only allow ONE transit seem like a pretty dumb idea to me, but I presume that whoever thought of the idea probably isn't a traveller!