## 3 Methods
### Overview
OmniAnomaly achieved F1-scores of 95.57% in Case 1 and 97.32% in Case 2, while InterFusion scored 96.00% in Case 1 and 97.99% in Case 2. Although the performances of these two methods are close to that of STformer, they exhibit significant disadvantages in computational complexity, particularly in handling large datasets, where STformer's efficient architecture maintains high detection accuracy while significantly reducing computational complexity, showcasing its strong practical application advantages. Transformer-based models have gradually become mainstream in time-series analysis, with models like OmniAnomaly and InterFusion exciting in detecting anomalies in multidimensional time series. OmniAnomaly employs Stochastic Recursive Neural Networks (SRNNs) and generative models to effectively detect anomalies in time series. However, it overly relies on temporal dimensions and overlooks potential dependencies between different variables. In contrast, STformer not only utilizes time blocks to capture long- and short-term temporal dependencies but also models interactions among different variables through variable blocks, addressing the shortcomings of existing Transformer models. Additionally, STformer reduces model complexity through UMAP dimensionality reduction techniques, improving computational efficiency while maintaining high detection accuracy. ## 6 Conclusions and Future Work

In response to the increasing vulnerability of distributed photovoltaic (PV) microgrid interconnected systems during the information process, we propose an advanced network attack detection method, STformer, based on the Transformer model. First, we employed the innovative dimensionality reduction technique UMAP to compress the complex raw data, preserving essential features while minimizing losses, thus laying the foundation for real-time and accurate anomaly detection. Second, we integrated temporal and variable attention mechanisms to deeply explore sequence dynamics and the complexity between variables, uncovering potential anomalies or threats. The synergistic use of these two mechanisms constructed a robust and comprehensive analytical framework that effectively analyzes and highlights anomalies in distributed PV communication monitoring, demonstrating strong detection capabilities, particularly in addressing DoS and FDIA attacks. The results of this study are of great significance to the cybersecurity of PV microgrids. As distributed PV technology becomes more widely applied, the system's digitizationand interconnectedness heighten its vulnerability. The method proposed in this paper not only effectively detects network attacks but also provides an extensible solution for future smart grid systems, contributing to improved robustness in energy management systems. Moreover, this research reveals the potential of deep learning models in detecting complex network anomalies through spatiotemporal feature collaborative modeling, providing a technical foundation for the automated security defense of future grid systems. Future research can proceed in several directions. First, the model's adaptability should be further validated in complex scenarios, particularly in the robustness of multi-energy integrated systems, and the model's capability to handle uncertainties should be optimized. Second, while the model performs well in detection accuracy, improving real-time performance remains a key focus for future efforts. Optimizing computational efficiency and reducing detection latency will help ensure the method's rapid response in practical applications. Future studies can also explore integrating information from different data sources, such as image data and sensor data, to enhance the model's detection capabilities in multimodal data environments. Additionally, exploring proactive defense and automatic recovery mechanisms is a promising direction. Through deep learning-based strategies, these mechanisms can strengthen the system's resilience following an attack and enhance the security of distributed energy systems.