How to compensate for being injured by a worker in a factory, whether to compensate the worker who beat him or the boss, is it a work-related injury?

This is not a work-related injury. Whether the factory is responsible depends on the location of your accident and whether the workers who hit people are instructed by the factory. If it is directed by the factory, it is a criminal case and handed over to the public security organ for handling. If it's just a general friction, then if the factory is only responsible for the site management in the factory, the main responsibility is the migrant workers. Medical compensation should also be paid by workers who hit people, and it is best to handle it as a public security incident through public security organs.