In the dual-carbon context of "peak carbon" and "carbon neutrality", the regulation of flexible resources in the electric power energy system has become an important means of reducing carbon emissions and improving energy utilization. The energy system of urban buildings contains a huge number of resources with flexible and adjustable characteristics. Energy saving and emission reduction in buildings is important to achieve the goal. We take the massive heterogeneous distributed flexible loads in the energy system of urban building clusters as the research object, firstly, we introduce each component of Residential Integrated Energy System (RIES), categorize the building loads according to different characteristics of electricity consumption, and model and analyze each part of the building system; the lowest operating costs as the objective function for optimization. The traditional scheduling method is difficult to meet the demand for real-time optimization of the building energy system scheduling decision-making speed, so this paper proposes an improved whale algorithm with high intelligence and fast decision-making ability to solve the model, the optimization strategy of building energy scheduling simulation and analysis, the results of the example have verified the validity of the built model.