Rooftop photovoltaics (RPV) offer a promising solution for supplying clean energy in high-density urban areas. Given its localized electricity generation, effective RPV deployment requires consideration of region-specific conditions influencing both power generation potential and energy demand, as well as potential mismatches between them. Here, we present a nationwide analysis of this supply-demand mismatch across 316 Chinese cities, integrating solar resources, rooftop availability, and electricity demands. Our results reveal a total annual RPV potential of 5871.68 TWh, accounting for 78.36% of the national electricity consumption. However, a pronounced supply-demand disconnect exists, with annual power yields ranging from 214.98 to 472.64 kWh/m2, and correlations between the power supply and demand factors being negligible or even negative in many cities. To resolve this mismatch, we develop a multi-objective optimization framework that maximizes RPV energy generation, demand fulfillment, and environmental benefits under rooftop and system constraints. Our study provides spatial deployment pathways and serves as a generalizable decision-support tool for urban planners and policymakers aiming to align distributed solar expansion with local energy needs.