In order to overcome the energy hole problem in some wireless sensor networks (WSNs), lifetime optimization algorithm with mobile sink nodes for wireless sensor networks (LOA MSN) is proposed. In LOA MSN, hybrid positioning algorithm of satellite positioning and RSSI positioning is proposed to save energy. Based on location information, movement path constraints, flow constraint, energy consumption constraint, link transmission constraint, and other constraints are analyzed. Network optimization model is established and decomposed into movement path selection model and lifetime optimization model with known grid movement paths. Finally, the two models are solved by distributed method. Sink nodes gather data of sensor nodes along the calculated paths. Sensor nodes select father nodes and transmit data to corresponding sink node according to local information. Simulation results show that LOA MSN makes full use of node energy to prolong network lifetime. LOA MSN with multiple sink nodes also reduces node energy consumption and data gathering latency. Under certain conditions, it outperforms MCP, subgradient algorithm, EASR, and GRAND.