The invention belongs to the technical field of medicine, particularly relates to a heterocyclic nitrogen compound which acts as a tyrosine kinase inhibitor and is represented by a general formula (I) as well as a deuterated material, pharmaceutically acceptable salt or stereisomer thereof. In the general formula (I), X, W, R1, R2, R3, L1, L2, a, b, c, d, e, p, q, a ring A and a ring B are defined in specification. The invention further relates to a preparation method of the compounds, a pharmaceutic preparation containing the compounds, and important actions of the compounds in treatment of leukemia (such as B cell chronic lymphocytic carcinoma and non-hodgkin lymphoma) related to B cell, and autoimmune diseases (such as rheumatoid arthritis and systemic lupus erythematosus).