In order to improve the accuracy of predicting RUL of lithium-ion batteries, a lithium-ion battery RUL prediction method based on the DBOCNN-DSformer model is proposed. Firstly, the health characteristics of the battery are extracted and the local information of health features is mined using CNN. DSformer is utilized for global information, local information, and variable correlation learning of battery aging characteristics. The DBO is used to optimize the super-parameters of the CNN-DSformer model and build the DBOCNN-DSformer model. Finally, the battery aging data set was used for verification. The results show that DBOCNN-DSformer, which sets different prediction starting points, can extract sequence information from input data and establish long-term dependencies between sequences. The maximum average MRE error in the NASA data set was 0.05, the maximum average MAE was 0.018, and the maximum average AE error was within 5. The maximum average MRE error of the CALCE data set was 0.37, the maximum average MAE was 0.014, and the maximum average AE prediction error was within 10. Compared with LSTM, RNN, and Transformer models, it was found that DBOCNN-DSformer showed high prediction accuracy and good robustness.