In engineering practice, equipment experiences expected degradation while also being affected by random shocks. A method for predicting the remaining useful life (RUL) of equipment considering both degradation and random shocks has been proposed for equipment degraded by random shocks during operation. Firstly, a comprehensive degradation model is constructed to characterize the equipment degradation process. This model employs a nonlinear Wiener process to identify the continuous degradation process, a normal distribution to describe the impact of random shocks on the amount of equipment degradation, and a compound Poisson process with a time-varying shock frequency is used to characterize the effects of random shocks on degradation levels. This general formulation reduces to the traditional case with a constant shock frequency, while the time-varying form better reflects real-world operating behavior where shocks occur less frequently in the early stage and more frequently in the later stage of degradation. Secondly, the RUL prediction accounts for device heterogeneity and uncertainty, yielding an approximate analytical RUL distribution, with model parameters estimated via maximum likelihood estimation. Finally, the influence of different parameters in the model on the RUL prediction results is verified through numerical simulation, validating the effectiveness of the proposed method, and the engineering application value of the proposed method is demonstrated through bearing examples. Compared with existing methods, this method has higher estimation accuracy and can quantify prediction uncertainty. It has certain theoretical significance for solving the problem of RUL prediction for equipment affected by random shocks.