Can query the list of illegal information according to City + license plate number + engine number.
Illegal entity class
Package org.wx.xhelper.model;/** * Illegal entity class * @author WANGXW * @version 1.0 * @date Jul, 3:25:34 PM */public class Vi Olregu {//violation time private string date;//violation location private string area;//violation of private string act;//violation of the private string fen;//violation of the fine P Rivate string money;//whether to handle the 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 class
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;/** * Illegal Query Service Interface class * @author WANGXW * @version 1.0 * @date Jul, 3:29:16 PM */public class Violreguservice {/** * Generate illegal information * @param cityname * @param carno * @param Engineno * @return Return violation information * @throws unsupportedencodingexception */public static string Getviolregudetail (String CityName , String carno,string Engineno) throws unsupportedencodingexception{//get the list of illegal messages list<violregu> violregulist = Getviolreguinfo (Cityname,carno,engineno);//Store 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 ("Violations:" +violregulist.get (i). Getact ()). Append ("\ n"); News.append ("Illegal deduction:" +violregulist.get (i). Getfen ( ). Append ("\ n"); News.append ("Penalty:" +violregulist.get (i). Getmoney ()). Append ("\ n"); News.append ("Processing Status:" + Violregulist.get (i). gethandled ()). Append ("\ n");}} if (news.length () = = 0) {news.append ("No relevant violation information, please enter again!");} return news.tostring ();} /** * Get a list of illegal information * @param cityname * @param carno * @param engineno * @return */public static list<violregu> Getviolre Guinfo (String cityname,string carno,string Engineno) {//Hold list of illegal information list<violregu> list = new Arraylist<violregu > (); try{//gets the city simple-fight String town = Citysutil.getsimpspell (cityname);//Gets the JSON string string json = Httprequestutil.httprequest ("http://apis.haoservice.com/weizhang/query?city=" +urlencoder.encode (city, "utf-8") + "&hphm=" + Urlencoder.encode (Carno, "utf-8") + "&hpzl=02&engineno=" +urlencoder.encode (Engineno, "Utf-8")+ "&key=keyvalue"); Jsonobject Jsonobject = Jsonobject.fromobject (JSON); Jsonobject Jsonresult = Jsonobject.fromobject (jsonobject.get ("result")); Jsonarray Listsarray = Jsonresult.getjsonarray ("lists");//Encapsulate data to 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")); Violation Time Violregu.setarea (Map.get ("area")); Illegal zone violregu.setact (map.get ("act")); Violation of the Violregu.setfen (Map.get ("Fen")); Illegal deduction points Violregu.setmoney (Map.get ("money")); Illegal fines violregu.sethandled (Map.get ("handled")); Whether to handle List.add (Violregu);}} catch (Exception e) {e.printstacktrace ();} return list;}}
Query Result:
Violation time: 2013-01-22 08:33:00
Illegal location: Yan ' An road and Ruijin Road intersection
To travel within a forbidden time, road, or Lane.
Illegal deduction: 0
Fines: 200
Processing status: Not processed
Violation time: 2013-03-12 08:33:00
Illegal location: Ruijin South Road and Cultural Road intersection
To travel within a forbidden time, road, or Lane.
Illegal deduction: 0
Fines: 200
Processing status: Not processed
Violation time: 2013-12-25 19:22:00
Place of violation: Arrow Road Street
Violations: The reverse of motor vehicles
Illegal deduction: 3
Fines: 200
Processing status: Not processed
Violation time: 2014-06-24 19:06:00
Illegal location: Jiefang Road (Jia Run Junction-South factory Junction)
To travel within a forbidden time, road, or Lane.
Illegal deduction: 0
Fines: 200
Processing status: Not processed
Illegal query free API interface code