To address the poor optimization and high life loss of battery energy storage systems (BESS) in microgrid gridconnected scenarios, this paper proposes a two-stage rolling optimization operation strategy for microgrids, considering the state of battery energy storage unit (BESU). Firstly, a microgrid grid-connected instruction set optimization model is established with the objectives of minimizing the number of unqualified periods of gridconnected power scheduling, minimizing the number of unqualified periods of grid-connected power fluctuations, and minimizing the cumulative charging and discharging throughput of BESS. The multi-objective exponential distribution optimizer (MOEDO) is utilized to solve this model. Secondly, considering the number of charge and discharge state conversions, state of charge (SOC) consistency, and charge and discharge efficiency indicators, a BESS power allocation strategy comprising a unit grouping module, a unit screening module, and a power allocation module is designed. The energy valley optimizer (EVO) is employed to optimize the allocation scheme. Finally, in order to solve the optimal compromise decision-making problem, a multi-dimensional evaluation system for the microgrid operation results was constructed, the analytic hierarchy process (AHP) was used to weight the evaluation system, and simulation experiments were carried out using the actual parameters of the microgrid in a specific area. The comparison results show that the proposed strategy can reduce the number of BESS charge and discharge state transitions, improve the SOC consistency level and charge and discharge efficiency while improving the microgrid's grid-connected performance.