Provided are a class of compounds, as represented by formula (I), having a bifunctional active quaternary ammonium salt structure of a β2 adrenoreceptor agonist and an M receptor antagonist, a pharmaceutically acceptable salt, solvate, and an optical isomer thereof, and a pharmaceutical composition containing such a compound with the quaternary ammonium salt structure, a method for preparing such a compound with the quaternary ammonium salt structure and an intermediate thereof, and the use thereof in treating pulmonary diseases. The compound of the present invention has high selectivity for M receptor subtypes, and has the characteristics of fewer adverse effects and less toxic side effects in the treatment of pulmonary diseases such as COPD and asthma.