The Internet of Things (IoT) is a network of smart gadgets that are connected through the Internet, including computers, cameras, smart sensors, and mobile phones. Recent developments in the industrial IoT (IIoT) have enabled a wide range of applications, from small businesses to smart cities, which have become indispensable to many facets of human existence. In a system with a few devices, the short lifespan of conventional batteries, which raises maintenance costs, necessitates more replacements and has a negative environmental impact, does not present a problem. However, in networks with millions or even billions of devices, it poses a serious problem. The rapid expansion of the IoT paradigm is threatened by these battery restrictions, thus academics and businesses are now interested in prolonging the lifespan of IoT devices while retaining optimal performance. Resource management is an important aspect of IIoT because it's scarce and limited. Therefore, this paper proposed an efficient algorithm based on federated learning. Firstly, the optimization problem is decomposed into various sub-problems. Then, the particle swarm optimization algorithm is deployed to solve the energy budget. Finally, a communication resource is optimized by an iterative matching algorithm. Simulation results show that the proposed algorithm has better performance as compared with existing algorithms.