Paraphrase the text:
The Spanish troops gunned down about twenty people before taking control of the factory and rounding up others.
By the time the Spanish soldiers took possession of the plant, rounded up all the people present, they had shot about twenty people.