It is an off-grid and on-grid hybrid photovoltaic power generation control system. The control system consists of a photovoltaic array, a grid-connected inverter, a battery bank, a bi-directional inverter, a load, a power meter, a utility grid, a demand-response control system and a switching group. The photovoltaic array is connected to the AC side through a grid-connected inverter, and the battery bank is connected to the AC side through a bidirectional inverter; the grid-connected inverter is connected to the bidirectional inverter, and the public grid is connected to the load through the switchgear (S1-S4); the entire off-grid and grid-connected hybrid power generation system is unified through the demand-response control system. The system supports 8 different operation modes through the combination of switchgear opening and closing to optimize the economic benefits and peak and valley shaving of the grid, and to extend the service life of the battery by limiting its discharge depth and charging and discharging power.