OTO Catering App Real-time order logistics Tracking System Architecture Design (i)

Source: Internet
Author: User
Tags uuid stringbuffer

1. Introduction . 1 1.1 Purpose

Whether it is Amoy point or hungry, as long as it is intended to do the takeaway app, I think there is no real-time map to show the location of the takeaway order information is not justified, because I think that the delivery of real-time logistics is very harsh. 11:00 the sale at 12:00 has not been sent to the user, are not forgiven.

Based on this I would like to design a map real-time display of the delivery Agent location information System.

2.1 Functional Requirements

The main functions of the system include:

1). After receiving the order, the Distributor app logs in and sends its location information to the server management.

2). The user client can view the real-time location information on the map after the order has been transferred to the distribution clerk.

3) The server receives the distribution Clerk location information and forwards it to the corresponding user client according to the delivery order information.

4) Other functions. After the user app submits the bill of lading to the Web server, the Web server pushes the message to the Order tracking server

3.1 Business Process Design

   

4.1 Interface Design

1) Store version

     


2) Distribution Clerk

  






5) Detailed design and implementation of each module

5.1 User app request geographic location

public class Myudpclient extends Udpclientbase {public myudpclient (byte[] uuid, int appid, String serveraddr, int serv

		Erport) throws Exception {super (UUID, AppID, serveraddr, ServerPort);
		} @Override public Boolean hasnetworkconnection () {return util.hasnetwork (onlineservice.this);
		} @Override public void Trysystemsleep () {tryreleasewakelock ();
			@Override public void onpushmessage (Message message) {if (message = = null) {return;
			} else if (message.getdata () = = NULL | | message.getdata (). Length = = 0) {return;
			} else if (message.getcmd () = =) {//0x10 general push Information} else if (message.getcmd () = =) {//0x11 group Push Information}
				else if (message.getcmd () = = +) {//0x20 custom push information String str = NULL;
				try{str = new String (Message.getdata (), 5,message.getcontentlength (), "UTF-8");
				}catch (Exception e) {str = Util.convert (Message.getdata (), 5,message.getcontentlength ());
}//converted to JSON string lbs real-time logistics chase,				Gson Gson = new Gson (); 
				Msgtype Msgtype = Gson.fromjson (str,new typetoken<msgtype> () {}.gettype ());
				if (Msgtype.equals ("Wuliu")) {//Distribution Agent address location} else if (Msgtype.equals ("Order")) {//Order confirmation}
				else {Notifyuser (32, "Custom push Information", "" "+str," receive custom push Information ");
		}} setpkgsinfo ();
 }

	}



Baidu Map API version v_3_1, Baidu positioning API version v_4.2

 

Package com.cmyy.ui;
Import org.json.JSONException;

Import Org.json.JSONObject;
Import Android.content.BroadcastReceiver;
Import Android.content.Context;
Import android.content.Intent;
Import Android.content.IntentFilter;
Import android.content.SharedPreferences;
Import Android.os.Bundle;

Import Android.util.Log;
Import com.baidu.location.BDLocation;
Import Com.baidu.location.BDLocationListener;
Import com.baidu.location.LocationClient;
Import com.baidu.location.LocationClientOption;
Import Com.baidu.mapapi.SDKInitializer;
Import Com.baidu.mapapi.map.BaiduMap;
Import Com.baidu.mapapi.map.MapStatusUpdate;
Import Com.baidu.mapapi.map.MapStatusUpdateFactory;
Import Com.baidu.mapapi.map.MapView;
Import Com.baidu.mapapi.map.MyLocationData;
Import Com.baidu.mapapi.model.LatLng;
Import COM.CMYY.R;
Import Com.cmyy.push.OnlineService;
Import Com.cmyy.push.Params;
Import Com.google.gson.Gson;


Import Com.google.gson.reflect.TypeToken; Real-time Logistics page public class Logisticstrackingactivity extends Baseactivity{private static final String Ltag = LogisticsTrackingActivity.class.getSimpleName ();
	Private Mapview Mmapview;
	Private Baidumap Mbaidumap;
	Private Sdkreceiver Mreceiver;
	Locating relevant private locationclient mlocclient; Public Mylocationlistenner MyListener = new Mylocationlistenner ();
	Locate Boolean isfirstloc = true;//if the private Pushlocationreceiver Mpushlocationreceice is first positioned;
		@Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);
		Register SDK Broadcast Listener Intentfilter iFilter = new Intentfilter ();
		Ifilter.addaction (Sdkinitializer.sdk_broadtcast_action_string_permission_check_error);
		Ifilter.addaction (Sdkinitializer.sdk_broadcast_action_string_network_error);
		Mreceiver = new Sdkreceiver ();
		
		Registerreceiver (Mreceiver, IFilter);
					
		Setcontentview (r.layout.activity_tracking);
		Notify the server of the need for logistic geolocation//register to receive location information broadcast Intentfilter Ipushfilter = new Intentfilter (); Ipushfilter.addaction ("Com.cmyy.ui.LogisticsTrackingAcTivity.
		Pushlocationreceiver ");
		Mpushlocationreceice = new Pushlocationreceiver ();
		
		Registerreceiver (Mpushlocationreceice, Ipushfilter);
		Start the service to receive Location Saveaccountinfo ();
		Intent startsrv = new Intent (this, onlineservice.class);
		Startsrv.putextra ("CMD", "RESET");
		StartService (STARTSRV);
		Show Map Mmapview = (mapview) Findviewbyid (R.id.bmapview);
		Mbaidumap = Mmapview.getmap ();
		Turn on the positioning layer mbaidumap.setmylocationenabled (true);
		Positioning initialization/*mlocclient = new Locationclient (this);
		Mlocclient.registerlocationlistener (MyListener);
		locationclientoption option = new Locationclientoption (); Option.setopengps (TRUE);//Open GPS Option.setcoortype ("Bd09ll");
		Set the coordinate type Option.setscanspan (1000);
		mlocclient.setlocoption (option);  Mlocclient.start (); */} public class Pushlocationreceiver extends Broadcastreceiver {public pushlocationreceiver () {} @Override public void OnReceive (context context, Intent Intent) {//received the location information sent by the distribution officer String me SsaGE = Intent.getstringextra ("Data");
			LOG.I ("Receive", message);
			Gson Gson = new Gson ();
	        Mylocationdata locdata = Gson.fromjson (message,new typetoken<mylocationdata> () {}.getType ());
	        Jsonobject Jsonobj;
	        Double latitude = 39.915;
			Double longitude = 116.404;
				try {jsonobj = new jsonobject (message);
				Latitude = jsonobj.getdouble ("latitude");
			Longitude= jsonobj.getdouble ("longitude");
			} catch (Jsonexception e) {//TODO auto-generated catch block E.printstacktrace ();
			} log.i ("Receive", String.valueof (latitude));
			LOG.I ("Receive", String.valueof (longitude));
			Mbaidumap.setmylocationdata (Locdata);
				if (isfirstloc) {isfirstloc = false;
				LATLNG ll = new Latlng (latitude, longitude);
				Mapstatusupdate U = mapstatusupdatefactory.newlatlng (ll);
			Mbaidumap.animatemapstatus (U); }}}/** * Locate SDK Listener function */public class Mylocationlistenner implements Bdlocationlistener {@Override Publi c void ONreceivelocation (bdlocation location) {//Map view is not processed after the newly received position is not handled if (site = = NULL | | mmapview = = NULL) retu
			Rn Mylocationdata locdata = new Mylocationdata.builder (). Accuracy (Location.getradius ())//Here Set the direction information the developer gets, clockwise 0-36
			0. Direction (+). Latitude (Location.getlatitude ()). Longitude (Location.getlongitude ()). build ();
			Mbaidumap.setmylocationdata (Locdata);
				if (isfirstloc) {isfirstloc = false;
				LATLNG ll = new Latlng (Location.getlatitude (), Location.getlongitude ());
				Mapstatusupdate U = mapstatusupdatefactory.newlatlng (ll);
			Mbaidumap.animatemapstatus (U); }} public void Onreceivepoi (Bdlocation poilocation) {}}/** * Constructs broadcast listener class, monitors SDK key authentication and network exception broadcast */public C Lass Sdkreceiver extends Broadcastreceiver {public void OnReceive (context context, Intent Intent) {String s = inten
			T.getaction ();
			LOG.D (Ltag, "action:" + s); if (S.equals (Sdkinitializer.sdk_broadtcast_action_string_permission_check_error){LOG.E ("logisticstrackingactivity", "Key validation error!), check the key settings in the Androidmanifest.xml file"); } else if (S.equals (Sdkinitializer.sdk_broadcast_action_string_network_error)) {LOG.E ("logisticstrackingactivity",
			"Network error"); }}} protected void Saveaccountinfo () {sharedpreferences account = this.getsharedpreferences (params.default_pre_n
		Ame,context.mode_private);
		Sharedpreferences.editor Editor = Account.edit ();
		Editor.putstring (Params.server_ip, "192.168.88.130");
		Editor.putstring (Params.server_port, "9966");
		Editor.putstring (Params.push_port, "9998");
		Editor.putstring (Params.user_name, "333");
		Editor.putstring (params.sent_pkgs, "0");
		Editor.putstring (params.receive_pkgs, "0");	
	Editor.commit ();
		} @Override protected void OnPause () {super.onpause ();
	Pause the Map Control Mmapview.onpause () while the activity is paused;
		} @Override protected void Onresume () {super.onresume ();
	Restore the map control at the same time when activity resumes Mmapview.onresume ();
} @Override protected void OnDestroy () {		Mlocclient.stop ();
		Turn off positioning layer mbaidumap.setmylocationenabled (false);
		Super.ondestroy ();
		Cancel the Listener SDK broadcast unregisterreceiver (mreceiver);
	Destroy the map control at the same time when the activity is destroyed Mmapview.ondestroy (); }}<strong> </strong>

 

5.2 Distribution Agent app sends geo-location information to Tracking server

  Accept Server Push information saveaccountinfo ();
		Set the server IP port Intent startsrv = new Intent (this, onlineservice.class);
		
	    StartService (STARTSRV);
	    push = new push (this);
	    Start geo-location monitoring Mbaidumapcontrol = new Baidumapcontrol (); Mbaidumapcontrol.location (Getapplicationcontext (), new Bdlocationlistener () {@Override public void Onreceiveloc ation (bdlocation location) {Mylocationdata Locdata = new Mylocationdata.builder (). Accuracy (Location.getradius ())///Here Set the direction information the developer obtains, clockwise 0-360. Direction (+). Latitude (Location.getlatitude ()). Longitude (location.getlongit
			   	 Ude ()). build ();
			   	 Gson Gson = new Gson ();
			     geolocation information String strlocation = Gson.tojson (locdata). toString ();
				LOG.I ("Baidulocationapidem", strlocation);
				Receive location/*stringbuffer sb = new StringBuffer (256);
				Sb.append ("Time:");             Sb.append (Location.gettime ());
				Positioning time Sb.append ("\nerror Code:"); Sb.append (Location.getloctypE ());
				Sb.append ("\nlatitude:");       Sb.append (Location.getlatitude ());
				The developer obtains the direction information, clockwise 0-360 sb.append ("\nlontitude:");
				Sb.append (Location.getlongitude ());
				Sb.append ("\nradius:");            
				Sb.append (Location.getradius ());
					if (location.getloctype () = = bdlocation.typegpslocation) {sb.append ("\nspeed:");
					Sb.append (Location.getspeed ());
					Sb.append ("\nsatellite:");
					Sb.append (Location.getsatellitenumber ());
					Sb.append ("\ndirection:");
					Sb.append ("\naddr:");
					Sb.append (Location.getaddrstr ());
				Sb.append (Location.getdirection ());
					} else if (location.getloctype () = = bdlocation.typenetworklocation) {sb.append ("\naddr:");
					Sb.append (Location.getaddrstr ());
					Carrier information Sb.append ("\noperationers:");
				Sb.append (Location.getoperators ());	} log.i ("Baidulocationapidem", sb.tostring ());  
							
			*///location successfully sent to server push.send0x20 ("333", strlocation); }
 	
	    });   

not finished ....






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.