The present invention relates to a 1,2-dihydropyrrol[3,4-c]pyridin/pyrimidin-3-one derivative substituted by N-(3-aminophenyl)acrylamide and a preparation method and pharmaceutical use thereof. In particular, the present invention relates to a compound of formula (II) or a pharmaceutically acceptable salt, stereoisomer, solvate, or prodrug thereof and a preparation method and application of the same. The definition of each substituent in the formula is described in detail in the specification and claims.