Perhaps the most important lesson Manhattan District Attorney Cy Vance has learned from the Harvey Weinstein scandal is not to mess with the NYPD.

He defended his office’s decision not to charge Weinstein in 2015 after Italian actress Ambra Battilana Gutierrez alleged that the movie producer groped her because his office did not think the case, brought by the NYPD, was provable.

That criticism of its actions in the Weinstein case led NYPD Deputy Commissioner for Public Information Stephen Davis to issue a forceful rebuttal: “The case was carried out by experienced detectives and supervisors from NYPD’s Special Victims Unit. The detectives used well-established investigative techniques. The recorded conversation with the subject corroborates the acts that were the basis for the victim’s complaint to the police a day earlier,” the NYPD said.

Stick that in your coffee, Vance, the NYPD seemed to be saying.

Public relations is a big deal at the NYPD. You don’t become the greatest police department in the world without a top public relations man — or woman. The NYPD has had both, as well as some dogs.

DCPI is staffed around the clock by more than twice the number of PR people as are employed by the city’s five DA offices combined. They’ve seen it all and can be kind or cruel, following the tone set by the NYPD commissioner and his person at DCPI.

When then-Commissioner Ray Kelly, who frightened many at Police Plaza, banned me as a “security threat” in 2006, one DCPI officer became especially obnoxious. He’s still around.

In 2009, a city newspaper flinched under Kelly. A DCPI sergeant cursed and threatened a Daily News reporter for questions about a subway stabbing. A half-dozen people witnessed his tirade. No one intervened, no apology was offered and no public reprimand was given to the sergeant. The News did not write a story.

Back in 1995, Mayor Rudy Giuliani became incensed that Bill Bratton, then his police commissioner, was receiving more favorable headlines than he was. Giuliani then fired DCPI’s deputy commissioner and ordered the transfers of all 35 cops who worked there.

That deputy commissioner returned under Bratton in 2014, this time as deputy commissioner of intelligence and counterterrorism. His name: John Miller.