物流运输管理系统TMS 司机车辆GPS+手机定位设计(C#源码)
物流运输管理系统(TMS)
适用于物流运输公司、各企业下面的运输车队等,它主要包括订单管理、配载作业、调度分配、行车管理、GPS车辆定位系统、车辆管理、人员管理、数据报表、基本信息维护、系统管理等模块。该系统对车辆、驾驶员、线路等进行全面详细的统计考核,能大大提高运作效率,降低运输成本,使您在激烈的市场竞争中处于领先优势。
TMS系统定位方式
传统TMS系统采用GPS硬件模块进行车辆定位,缺点是成本高。
我们的TMS系统采用双终端定位方式,既车辆定位和APP定位。车辆定位采用中交兴路第三方定位服务平台,TMS系统对接中交兴路提供的定位服务接口,界面嵌入百度地图即可实现定位。
TMS系统登录界面
中交兴路车辆定位,根据车牌号码获取车辆当前位置,如下图:
C# Code:
/// <summary>
/// 根据车牌号查询定位
/// </summary>
/// <param name="carNo"></param>
public void ShowLocation(string carNo)
{
txtCarNo.Text = carNo;
try
{
btnLocate.Enabled = false;
CCursor.ShowWaitCursor();
//调用WebApi接口获取定位
Firs95155Api.ModelLocation location = Get95155_Location(carNo);
if (location == null) return;
//智运开放平台除以600000得到84系坐标
decimal lon = decimal.Parse(location.lon) / 600000;//经度115.83242333333333333333333333M
decimal lat = decimal.Parse(location.lat) / 600000;//纬度28.036483333333333333333333333M
string add = location.adr;
DateTime locatTime = UtcToDateTime.ToDatetime(double.Parse(location.utc));
locatTime = locatTime.AddHours(-8);
lon = Math.Round(lon, 5);
lat = Math.Round(lat, 5);
//百度地图显示定位信息
object[] args0 = { "1", lon, lat, locatTime.ToString("yyyy/MM/dd HH:mm:ss"), add };
//webBrowser1.Refresh(WebBrowserRefreshOption.Normal);
webBrowser1.Document.InvokeScript("clearOldPoints", null);
webBrowser1.Document.InvokeScript("addMarker", args0);
webBrowser1.Document.InvokeScript("setMapCenterPoint", args0);
webBrowser1.Document.InvokeScript("addLine", null);
Application.DoEvents();
//自动生成跟踪信息
AddYDTraceLog(location.adr);
}
finally
{
btnLocate.Enabled = true;
CCursor.ShowDefaultCursor();
}
}
//来源:C/S框架网(www.csframework.com) QQ:23404761
/// 根据车牌号查询定位
/// </summary>
/// <param name="carNo"></param>
public void ShowLocation(string carNo)
{
txtCarNo.Text = carNo;
try
{
btnLocate.Enabled = false;
CCursor.ShowWaitCursor();
//调用WebApi接口获取定位
Firs95155Api.ModelLocation location = Get95155_Location(carNo);
if (location == null) return;
//智运开放平台除以600000得到84系坐标
decimal lon = decimal.Parse(location.lon) / 600000;//经度115.83242333333333333333333333M
decimal lat = decimal.Parse(location.lat) / 600000;//纬度28.036483333333333333333333333M
string add = location.adr;
DateTime locatTime = UtcToDateTime.ToDatetime(double.Parse(location.utc));
locatTime = locatTime.AddHours(-8);
lon = Math.Round(lon, 5);
lat = Math.Round(lat, 5);
//百度地图显示定位信息
object[] args0 = { "1", lon, lat, locatTime.ToString("yyyy/MM/dd HH:mm:ss"), add };
//webBrowser1.Refresh(WebBrowserRefreshOption.Normal);
webBrowser1.Document.InvokeScript("clearOldPoints", null);
webBrowser1.Document.InvokeScript("addMarker", args0);
webBrowser1.Document.InvokeScript("setMapCenterPoint", args0);
webBrowser1.Document.InvokeScript("addLine", null);
Application.DoEvents();
//自动生成跟踪信息
AddYDTraceLog(location.adr);
}
finally
{
btnLocate.Enabled = true;
CCursor.ShowDefaultCursor();
}
}
//来源:C/S框架网(www.csframework.com) QQ:23404761
C# Code:
//定位节点模型
public class ModelTraceNode
{
public ModelTraceNode();
public string agl { get; set; }
public string gtm { get; set; }
public string hgt { get; set; }
public string lat { get; set; }
public string lon { get; set; }
public string mlg { get; set; }
public string spd { get; set; }
}
//来源:C/S框架网(www.csframework.com) QQ:23404761
public class ModelTraceNode
{
public ModelTraceNode();
public string agl { get; set; }
public string gtm { get; set; }
public string hgt { get; set; }
public string lat { get; set; }
public string lon { get; set; }
public string mlg { get; set; }
public string spd { get; set; }
}
//来源:C/S框架网(www.csframework.com) QQ:23404761
中交兴路车辆行驶轨迹定位,显示车辆指定时间区间的行驶轨迹,如下图:
C# Code:
/// <summary>
/// 显示车辆行驶定位轨迹
/// </summary>
/// <param name="carNo">车牌号</param>
/// <param name="begin">开始时间</param>
/// <param name="end">结束时间</param>
public void ShowTrace(string carNo, DateTime begin, DateTime end)
{
txtCarNo.Text = carNo;
txtBegin.DateTime = begin;
txtEnd.DateTime = end;
//兼容,只差24小时内
TimeSpan ts = end - begin;
if (ts.TotalHours > 24) begin = end.AddHours(-23);
try
{
btnTrace.Enabled = false;
CCursor.ShowWaitCursor();
List<ModelTraceNode> list = Get95155_Trace(carNo, begin, end);
if (list == null || list.Count == 0) return;
int count = (int)txtCount.Value;
//最多显示轨迹数量
if (list.Count > count) list = GetList(list, count);
decimal lon; decimal lat;
object[] node;
string addr;
webBrowser1.Document.InvokeScript("clearOldPoints", null);
//循环添加节点
for (int i = 0; i <= count && i <= list.Count - 1; i++)
{
lon = decimal.Parse(list[i].lon) / 600000;
lat = decimal.Parse(list[i].lat) / 600000;
lon = Math.Round(lon, 5);
lat = Math.Round(lat, 5);
addr = "lon:" + (lon.ToString().Length > 11 ? lon.ToString().Substring(0, 11) : lon.ToString())
+ ",lat:" + (lat.ToString().Length > 11 ? lat.ToString().Substring(0, 11) : lat.ToString());
node = new object[] { i, lon, lat, list[i].gtm, addr };
//node = new object[] { i, lon, lat, "", "" };
webBrowser1.Document.InvokeScript("addMarker", node);
}
webBrowser1.Document.InvokeScript("addLine", null);//绘制连接线
if (list.Count > 2)
{
lon = decimal.Parse(list[list.Count / 2].lon) / 600000;
lat = decimal.Parse(list[list.Count / 2].lat) / 600000;
lon = Math.Round(lon, 5);
lat = Math.Round(lat, 5);
object[] args0 = { lon, lat, "11" };//地图居中显示,取最中间的定位
webBrowser1.Document.InvokeScript("setMapCenterPoint", args0);
}
}
finally
{
btnTrace.Enabled = true;
CCursor.ShowDefaultCursor();
}
}
//来源:C/S框架网(www.csframework.com) QQ:23404761
/// 显示车辆行驶定位轨迹
/// </summary>
/// <param name="carNo">车牌号</param>
/// <param name="begin">开始时间</param>
/// <param name="end">结束时间</param>
public void ShowTrace(string carNo, DateTime begin, DateTime end)
{
txtCarNo.Text = carNo;
txtBegin.DateTime = begin;
txtEnd.DateTime = end;
//兼容,只差24小时内
TimeSpan ts = end - begin;
if (ts.TotalHours > 24) begin = end.AddHours(-23);
try
{
btnTrace.Enabled = false;
CCursor.ShowWaitCursor();
List<ModelTraceNode> list = Get95155_Trace(carNo, begin, end);
if (list == null || list.Count == 0) return;
int count = (int)txtCount.Value;
//最多显示轨迹数量
if (list.Count > count) list = GetList(list, count);
decimal lon; decimal lat;
object[] node;
string addr;
webBrowser1.Document.InvokeScript("clearOldPoints", null);
//循环添加节点
for (int i = 0; i <= count && i <= list.Count - 1; i++)
{
lon = decimal.Parse(list[i].lon) / 600000;
lat = decimal.Parse(list[i].lat) / 600000;
lon = Math.Round(lon, 5);
lat = Math.Round(lat, 5);
addr = "lon:" + (lon.ToString().Length > 11 ? lon.ToString().Substring(0, 11) : lon.ToString())
+ ",lat:" + (lat.ToString().Length > 11 ? lat.ToString().Substring(0, 11) : lat.ToString());
node = new object[] { i, lon, lat, list[i].gtm, addr };
//node = new object[] { i, lon, lat, "", "" };
webBrowser1.Document.InvokeScript("addMarker", node);
}
webBrowser1.Document.InvokeScript("addLine", null);//绘制连接线
if (list.Count > 2)
{
lon = decimal.Parse(list[list.Count / 2].lon) / 600000;
lat = decimal.Parse(list[list.Count / 2].lat) / 600000;
lon = Math.Round(lon, 5);
lat = Math.Round(lat, 5);
object[] args0 = { lon, lat, "11" };//地图居中显示,取最中间的定位
webBrowser1.Document.InvokeScript("setMapCenterPoint", args0);
}
}
finally
{
btnTrace.Enabled = true;
CCursor.ShowDefaultCursor();
}
}
//来源:C/S框架网(www.csframework.com) QQ:23404761
APP终端定位,APP实时上报手机定位信息,若用户关闭手机的定位服务,则不会上传。
<本文完>
参考文章:
C/S系统开发框架成功案例-物流运输管理系统(TMS)
WebApi开发框架成功案例-物流行业TMS系统+APP+微信小程序
WebApi开发框架成功案例-智运天下TMS系统APP项目截图