Can I apply for a patent for invention after applying for a patent for utility model?

As long as the utility model patent is not authorized to be disclosed.

You can take the initiative to withdraw the patent application, or if you don't go through the formalities at the time of official notification, it will be regarded as withdrawal, and then you can resubmit the application for a patent for invention and claim the priority of utility model.

It should be noted that if you want to claim priority, you need to file an application for a patent for invention within 12 months after the application for utility model, otherwise the time limit will be exceeded.