Zac Brown claims he worked on a song with Ryan Tedder for months, only for the OneRepublic frontman to suddenly give the beat to Diplo ... and now Zac is suing for ownership. According to a new lawsuit, obtained by TMZ ... Zac claims he started…