In Industry 4.0, efficient fault diagnosis is crucial for predictive maintenance but is often hindered by significant domain shifts between training and testing domains and lack of training datasets, limiting the effectiveness of machine learning in practice. Transfer learning has been used to address these challenges by utilizing knowledge from similar source domains. However, the scarcity of faulty data from real machines and the difficulty of obtaining labeled datasets from lab machines as source domain pose significant obstacles. This paper presents a novel diagnostic framework that integrates digital twins and transfer learning to overcome these limitations. Digital twins generate training datasets, while a model update strategy based on parameter sensitivity analysis improves adaptability. The framework also incorporates a partial transfer diagnostic model with a double attention mechanism to handle data distribution discrepancies and label inconsistencies between digital twins and real machines. Validated on an industrial rotating machine case study using real data, the proposed approach improves diagnostic accuracy by over 10% compared to state-of-the-art methods.