Time series anomaly detection is crucial for energy consumption monitoring and management. In order to solve the problem that the period decomposition algorithm is easily affected by the inconsistency of patterns in time series, this dissertation proposes an anomaly detection method combining pattern clustering and periodic decomposition, which uses a density peak clustering algorithm to find the cluster centers and uses the cyclic distance measurement to solve the subsequence phase shift. To shield the influence between different patterns, the seasonal decomposition algorithm S-H-ESD (Seasonal Hybrid Extreme Studentized Deviate) is used to find anomalies in clusters with the same periodic pattern, and the anomaly degree of the detection results is evaluated and filtered. The experimental results show that the proposed method is effective and suitable for anomaly detection of complex periodic time series.