It is recorded in Vol. 21 "Maritime Channels·Coastal Defense" of Qiong Tai Zhi, the book of the Ming Dynasty (AD 1368-1644) that, "In the twentieth year of Hongwu, the pirates landed in Haikou, and Hua Mao the commander submitted a petition to the emperor about establishing a castle, to be manned by soldiers from the Thousand-household Bureau.
In the twenty-third year, pirates disembarked in Qiziwan in Changhua, and Sang Zhao the commander alerted the military commander of Changhua about the upcoming invasion.
In the twenty-fourth year, Sang Zhao submitted a memorial to the emperor, suggesting establishment of a 1,000-troop garrison at Qinglan Port, on the ground that Japanese pirates had been known to harass the region.
In the twenty-fifth year, Japanese pirates looted Wanzhou and Sang Zhao the commander requested a reinforcement of 1,000 troops, which were placed under the leadership of Yu Kai, the military commander, for building a stronghold for defensive purposes.
In the twenty-seventh year, Hua Mao the commander suggested establishing a commander post in Nanshan Mountain, for its location on the coast and for disembarkation of Japanese pirates there. He also suggested that 1,000 troops be stationed there for defensive purposes.
In the twenty-seventh year, Hua Mao the commander relocated the patrol bureau to Nanjiong Village, Taiping, to guard against pirating."
In the Ming Dynasty, patrol divisions were distributed, and one commander was appointed, to be exclusively charged with maritime patrol. A system integrating commanding, defense and coastal management had been established.