Free api interface code for violation query and api for violation Query

Source: Internet
Author: User

Free api interface code for violation query and api for violation Query

You can query the list of violation information based on the city, license plate number, and engine number;

Illegal entity

Package org. wx. xhelper. model;/*** violation entity class * @ author wangxw * @ version 1.0 * @ date Jul 11,201 4 3:25:34 */public class ViolRegu {// violation time private String date; // violation location private String area; // violation behavior private String act; // violation deduction point private String fen; // violation penalty private String money; // whether to handle private String handled; public String getDate () {return date;} public void setDate (String date) {this. date = date;} public String getArea () {return area;} public void setArea (String area) {this. area = area;} public String getAct () {return act;} public void setAct (String act) {this. act = act;} public String getFen () {return fen;} public void setFen (String fen) {this. fen = fen;} public String getMoney () {return money;} public void setMoney (String money) {this. money = money;} public String getHandled () {return handled;} public void setHandled (String handled) {this. handled = handled ;}}


Illegal query service interface

Package org. wx. xhelper. service; import java. io. unsupportedEncodingException; import java.net. URLEncoder; import java. util. arrayList; import java. util. hashMap; import java. util. iterator; import java. util. list; import net. sf. json. JSONArray; import net. sf. json. JSONObject; import org. wx. xhelper. model. violRegu; import org. wx. xhelper. util. citysUtil; import org. wx. xhelper. util. httpRequestUtil;/*** violation query service interface class * @ auth Or wangxw * @ version 1.0 * @ date Jul 11,201 4 3:29:16 */public class ViolReguService {/*** generate violation information * @ param cityName * @ param carNo * @ param engineNo * @ return returns violation information * @ throws UnsupportedEncodingException */public static String getViolReguDetail (String cityName, string carNo, String engineNo) throws UnsupportedEncodingException {// List of obtained violation information <ViolRegu> violregulist = getViolReguInfo (cityName, ca RNo, engineNo); // stores the text information StringBuffer news = new StringBuffer (); if (violregulist! = Null & violregulist. size ()> 0) {for (int I = 0; I <violregulist. size (); I ++) {news. append ("violation time:" + violregulist. get (I ). getDate ()). append ("\ n"); news. append ("illegal location:" + violregulist. get (I ). getArea ()). append ("\ n"); news. append ("Violation Behavior:" + violregulist. get (I ). getAct ()). append ("\ n"); news. append ("violation points:" + violregulist. get (I ). getFen ()). append ("\ n"); news. append ("penalty:" + violregulist. get (I ). getMoney ()). append ("\ n"); news. ap Pend ("processing status:" + violregulist. get (I ). getHandled ()). append ("\ n") ;}} if (news. length () = 0) {news. append ("no related violation information. Please enter it again! ");} Return news. toString ();} /*** get violation information List * @ param cityName * @ param carNo * @ param engineNo * @ return */public static List <ViolRegu> getViolReguInfo (String cityName, String carNo, string engineNo) {// List of information about illegal storage <ViolRegu> list = new ArrayList <ViolRegu> (); try {// obtain the String city = CitysUtil. getSimpSpell (cityName); // obtain the json String json = HttpRequestUtil. httpRequest ("http://apis.haoservice.com/weizh Ang/query? City = "+ URLEncoder. encode (city, "UTF-8") + "& hphm =" + URLEncoder. encode (carNo, "UTF-8") + "& hpzl = 02 & engineno =" + URLEncoder. encode (engineNo, "UTF-8") + "& key = 8ff45540c1364ad6b1b0d7479bf3d1f8"); JSONObject jsonObject = JSONObject. fromObject (json); JSONObject jsonResult = JSONObject. fromObject (jsonObject. get ("result"); JSONArray listsArray = jsonResult. getJSONArray ("lists"); // encapsulate data to the list for (int I = 0; I <listsArray. size (); I ++) {HashMap <String, String> map = new HashMap <String, String> (); ViolRegu violRegu = new ViolRegu (); JSONObject futurnObject = JSONObject. fromObject (listsArray. getJSONObject (I); Iterator iterator = futurnObject. keys (); while (iterator. hasNext () {String key = String. valueOf (iterator. next (); String value = (String) futurnObject. get (key); map. put (key, value);} violRegu. setDate (map. get ("date"); // time of violation violRegu. setArea (map. get ("area"); // illegal region violRegu. setAct (map. get ("act"); // violRegu. setFen (map. get ("fen"); // violation score deducted from violRegu. setMoney (map. get ("money"); // violRegu is fined in violation of regulations. setHandled (map. get ("handled"); // whether to process list. add (violRegu) ;}} catch (Exception e) {e. printStackTrace ();} return list ;}}


Query results:

Violation time: 08:33:00
Illegal location: intersection of yan'an Road and Ruijin Road
Illegal Behavior: driving in the prohibited time, road section, or lane
Violation deduction: 0
Fine for violation: 200
Processing status: not processed

Violation time: 08:33:00
Illegal location: intersection of Ruijin South Road and Wenwen Road
Illegal Behavior: driving in the prohibited time, road section, or lane
Violation deduction: 0
Fine for violation: 200
Processing status: not processed

Violation time: 19:22:00
Illegal location: Arrow Street
Violation: The vehicle is driving in reverse order.
Violation deduction: 3
Fine for violation: 200
Processing status: not processed

Violation time: 19:06:00
Illegal location: Jiefang Road (jialun road junction-South Factory intersection)
Illegal Behavior: driving in the prohibited time, road section, or lane
Violation deduction: 0
Fine for violation: 200
Processing status: not processed


Illegal query api

Hello, you can log on to the local vehicle management office or the Traffic Management Bureau website to query the traffic violations. You need to enter the license plate number and the engine number (the last six digits of the vehicle identification number in some cities). This is very simple. I hope it will be helpful to you. If you have any questions, please ask. If you are satisfied, please select my answers as soon as possible.
 
How to find the api code of your website

Cannot be found.
The website's api interfaces are self-built. What APIs do you need to provide to others.
Of course, some CMS programs have built-in API interfaces related to members and articles. If you are referring to this API, you can simply find it in the file directory. Generally, CMS members, such as PHPCMS, and other modules have APIs in the directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.