Electricity consumption prediction is important for the management and security of smart grid. Aiming at the complexity of the fluctuation of social electricity consumption, this paper proposes a Granger-Transformer model, through the Granger causality test, to dig out the variables and lag period that have a significant impact on the prediction of electricity consumption, and then build a Transformer model to complete the prediction of electricity consumption. In order to select the electricity consumption and important economic data of major industries in China from January 2013 to April 2023 for the case study. Combining the comparison of various error indicators, the model proposed in this article has better performance compared to other classical prediction models such as CNNLSTM and Random Forest. The results indicate that the combination of Granger and Transformer can effectively screen influencing factors and improve the accuracy of predictions.