This is going to be a case of “if you give a man a fish, you feed him for a day, if you teach a man to fish they eat for life.”
Neither I nor anyone else on this forum is going to do this for you. The fact that you just pasted in this code as is strongly implies that you have no idea how this code works. So start with that. Once you understand the code you can come back and say “I have an ESP device that publishes to the following MQTT topics and subscribes to the following MQTT topics.”
No one here wants to try to figure that out on their own by reading some random code. In truth, I suspect there is only a minority of users on this forum who even know how to read this code.
Then review How to get started (there is no step-by-step tutorial) and all the links posted there. This will help you understand OH. Then read the MQTT binding docs which tell you how to set it up.
Neither I nor anyone else on this forum is going to code this for you. But we will help answer specific questions if you show a willingness to learn.