Internet of Things systems are developed rapidly, there is a need for anomaly detection to identify malicious data to guarantee that the systems perform under healthy condition. However, the dynamic system state is not only influenced by sequential patterns in the time dimension but also affected by other sensor channels in the spatial dimension. Although many successful models have been established in past research to handle multivariate time series data, most of these models exhibit shortcomings in capturing spatiotemporal dependencies. The Internet of Things offers a promising platform for advanced data analysis, but its unique characteristics present challenges for anomaly detection. This paper introduces a novel spatiotemporal polynomial graph neural network (STPGNN) is proposed for anomaly detection of complex systems within the Internet of Things (IoT) framework. Specifically, we propose an adaptive spatiotemporal feature modeling module that includes two developed adaptive modules: the Adaptive Temporal Module and the Spatial Module. These modules are designed to capture dynamic spatial dependencies across multiple time steps and temporal dependencies over time, respectively. The results are then output through a decoder. Importantly, the multi-head attention mechanism employed in both sub-modules can effectively explore potential spatiotemporal dependency patterns within different subspaces. The proposed model, utilizing the innovative approach of STPGNN, demonstrates superior performance compared to existing techniques, as evidenced by experimental results on the real-world test run dataset. This marks a significant advancement in the field of anomaly detection, particularly for complex systems.