Characteristic Classes and Integrable Systems. General Construction