Is there any way to convert uint64 to uint32 without losing any data?
Yes, but only if you know certain characteristics of your possible uint64 values and those characteristics allow a lossless conversion.
What is most likely relevant here is knowing your values will never exceed the maximum value of a uint32. In this case, what you actually have is a 32-bit value stored in 64 bits and the conversion simply changes how it is stored rather than changing the value. To do the conversion in this case, simply cast it, such as with static_cast.
If you want to handle any arbitrary uint64 value, then this is simply impossible. If it were possible, you could compress any file, including a 40 terabyte database, down to a single 32-bit value by repeated application of the conversion.