To address the matching difficulties in person Re-IDentification (Re-ID) under complex scenes such as occlusion, viewpoint changes, and pose variations, an Re-ID algorithm based on spatio-temporal modeling and hierarchical feature enhancement was proposed. In the algorithm, a collaborative improvement of global consistency and local discriminability was achieved through a three-stage progressive feature optimization framework. First, after extracting appearance features by the backbone network, a dual-pooling temporal attention mechanism was introduced. In the mechanism, complementary information of sequence features was captured by combining global average pooling and temporal average pooling, and spatio-temporal dependency modeling was performed through channel and spatial interaction, so that the motion-related features were highlighted and the local information loss caused by occlusion was alleviated. Second, to address the problem of uneven distribution of human body part features, a flexible feature fusion module was constructed, so that the multi-part features were aggregated through learnable weights adaptively, occlusion noise was suppressed, and discriminative local features were enhanced, thereby obtaining the global and local hierarchical representations. Finally, a confidence correction network was designed before the classification layer, so that the identity prediction confidence distribution was optimized through residual learning, and the cross-camera retrieval accuracy was improved. The results of systematic evaluation on the Market-1501 public dataset show that the proposed algorithm achieves an mAP of 93.2% and a Rank-1 of 97.4%, which are increased by 3.8 and 1.7 percentage points compared with the baseline algorithm Body Part-Based ReID model (BPBReIDHR). It can be seen that the proposed algorithm improves the Re-ID performance in complex scenes significantly by the combination of spatio-temporal modeling and hierarchical feature enhancement.