Water, as a finite and vital resource, necessitates water quality monitoring to ensure its sustainable use. A key aspect of this process is the accurate measurement of critical parameters such as chemical oxygen demand (COD). However, current spectroscopic methods struggle with accurately and consistently measuring COD in large-scale, complex water environments due to an insufficient understanding of water spectra and limited generalizability. To address these limitations, we introduce the physicochemical-informed spectral Transformer (PIST) model, combined with ultraviolet-visible-shortwave-near-infrared (UV-vis-SWNIR) spectroscopy for water quality sensing. To the best of our knowledge, this is the first approach to combine Transformer with spectroscopy for water quality sensing. PIST integrates a physicochemical-informed block to incorporate existing physical and chemical information into the spectral encoding for domain adaptation, along with a feature embedding block for comprehensive spectral features extraction. We validated PIST using an actual surface water spectral data set with extensive geographic coverage including the Yangtze River and Poyang Lake. PIST demonstrated notable performance in COD sensing within complex water environments, achieving an impressive R2 value of 0.9008 and reducing root mean squared error (RMSE) by 45.20% and 29.38% compared to benchmark models such as support vector regression (SVR) and convolutional neural network (CNN). These results emphasize PIST's accuracy and generalizability, marking a significant advancement in multidisciplinary approaches that combine spectroscopy with deep learning for rapid water quality sensing.