Example #1
0
        /// <summary>
        /// 数据转换
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="OldDate">扩展报警状态位新老数据分割时间 </param>
        /// <returns></returns>
        private WebGIS.RealtimeDataServer.CarRealData[] CarDataConvent(DataTable dt, DateTime OldDate)
        {
            List <WebGIS.RealtimeDataServer.CarRealData> res = new List <WebGIS.RealtimeDataServer.CarRealData>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dtr = dt.Rows[i];
                WebGIS.RealtimeDataServer.CarRealData cdm = new WebGIS.RealtimeDataServer.CarRealData();
                cdm.TDateTime   = DateTime.Parse(dtr["T_DateTime"].ToString());
                cdm.Carid       = int.Parse(dtr["CID"].ToString());
                cdm.CarNum      = dtr["CarNo"].ToString();
                cdm.Alarm       = long.Parse(dtr["T_ALARM"].ToString());
                cdm.Alarm808    = long.Parse(dtr["T_Alarm808"].ToString());
                cdm.AlarmExt808 = long.Parse(dtr["T_AlarmExt808"].ToString());


                cdm.AltitudeMeters = int.Parse(dtr["T_AltitudeMeters"] == DBNull.Value ? "0" : dtr["T_AltitudeMeters"].ToString());

                cdm.Heading    = int.Parse(dtr["T_Heading"].ToString());
                cdm.HeadingStr = CarDataConvert.ConvertDir(cdm.Heading);
                double[] s = CarDataConvert.ConvertCoordToGCJ02(double.Parse(dtr["T_Long"].ToString()), double.Parse(dtr["T_Lati"].ToString()));
                cdm.Lati         = s[1];
                cdm.Long         = s[0];
                cdm.Speed        = float.Parse(dtr["T_Speed"].ToString());
                cdm.Status       = int.Parse(dtr["T_Status"].ToString());
                cdm.Status808    = int.Parse(dtr["T_Status808"].ToString());
                cdm.StatusExt808 = int.Parse(dtr["T_StatusExt808"].ToString());
                if (cdm.TDateTime > OldDate)
                {
                    cdm.AlarmStr  = AlarmStatusAnalysis.ConvertMain.AlarmConvertMain(cdm.Alarm, cdm.Alarm808, cdm.AlarmExt808);
                    cdm.StatusStr = AlarmStatusAnalysis.ConvertMain.StatusConvertMain(cdm.Status, cdm.Status808, cdm.StatusExt808);
                }
                else
                {
                    cdm.AlarmStr  = AlarmStatusAnalysis.ConvertMain.AlarmConvertMain(cdm.Alarm, cdm.Alarm808, cdm.AlarmExt808, false);
                    cdm.StatusStr = AlarmStatusAnalysis.ConvertMain.StatusConvertMain(cdm.Status, cdm.Status808, cdm.StatusExt808, false);
                }

                cdm.SumMiles = int.Parse(dtr["T_SumMiles"].ToString());
                if (dtr["TNO"] == DBNull.Value)
                {
                    continue;
                }
                cdm.TNO = long.Parse(dtr["TNO"].ToString());;
                //cdm.sPositionAdditionalInfo = timeResponse.Tir[i].sPositionAdditionalInfo;

                cdm.OnlineStatus = (DateTime.Now - cdm.TDateTime).TotalMinutes < 5 ? 1 : 2;

                if (cdm.OnlineStatus == 2)
                {
                    cdm.OnlineStatusStr = "停止";
                }
                else
                {
                    cdm.OnlineStatusStr = "上线";
                }

                res.Add(cdm);
            }
            return(res.ToArray());
        }
Example #2
0
        public ResponseResult getCarLastTrack(Dictionary <string, string> inparams)
        {
            ResponseResult Result = null;

            if (!inparams.Keys.Contains("CIDs"))
            {
                Result = new ResponseResult(ResState.ParamsImperfect, "缺少参数", null);
                return(Result);
            }
            string  sysflag  = inparams["sysflag"];
            ResList list_res = new ResList();

            try
            {
                //调用存储过程或WebGIS实时数据服务接口查询车辆轨迹数据
                DataTable dt = new DataTable();

                //初始化DataTable的列
                dt.Columns.Add(new DataColumn("Alarm", typeof(long)));
                dt.Columns.Add(new DataColumn("Alarm808", typeof(long)));
                dt.Columns.Add(new DataColumn("AlarmExt808", typeof(long)));
                dt.Columns.Add(new DataColumn("AlarmStr", typeof(string)));
                dt.Columns.Add(new DataColumn("AltitudeMeters", typeof(int)));
                dt.Columns.Add(new DataColumn("CarNum", typeof(string)));
                dt.Columns.Add(new DataColumn("Carid", typeof(long)));
                dt.Columns.Add(new DataColumn("Heading", typeof(int)));
                dt.Columns.Add(new DataColumn("HeadingStr", typeof(string)));
                dt.Columns.Add(new DataColumn("Lati", typeof(float)));
                dt.Columns.Add(new DataColumn("Long", typeof(float)));
                dt.Columns.Add(new DataColumn("Speed", typeof(float)));
                dt.Columns.Add(new DataColumn("Status", typeof(long)));
                dt.Columns.Add(new DataColumn("Status808", typeof(long)));
                dt.Columns.Add(new DataColumn("StatusExt808", typeof(long)));
                dt.Columns.Add(new DataColumn("StatusStr", typeof(string)));
                dt.Columns.Add(new DataColumn("SumMiles", typeof(int)));
                dt.Columns.Add(new DataColumn("TDateTime", typeof(DateTime)));
                dt.Columns.Add(new DataColumn("TNO", typeof(long)));
                dt.Columns.Add(new DataColumn("OnlineStatus", typeof(int)));
                dt.Columns.Add(new DataColumn("OnlineStatusStr", typeof(string)));
                //sPositionAdditionalInfo
                WebGIS.RealtimeDataServer.CarRealData[] res = new WebGIS.RealtimeDataServer.CarRealData[] { };

                res = CarRealDataByCids(sysflag, ToIntArray(inparams["CIDs"].Split(',')));


                //利用查询结果填充DataTable
                foreach (WebGIS.RealtimeDataServer.CarRealData carRealData in res)
                {
                    DataRow dr = dt.NewRow();
                    dr["Alarm"]           = carRealData.Alarm;
                    dr["Alarm808"]        = carRealData.Alarm808;
                    dr["AlarmExt808"]     = carRealData.AlarmExt808;
                    dr["AlarmStr"]        = carRealData.AlarmStr;
                    dr["AltitudeMeters"]  = carRealData.AltitudeMeters;
                    dr["CarNum"]          = carRealData.CarNum;
                    dr["Carid"]           = carRealData.Carid;
                    dr["Heading"]         = carRealData.Heading;
                    dr["HeadingStr"]      = carRealData.HeadingStr;
                    dr["Lati"]            = carRealData.Lati;
                    dr["Long"]            = carRealData.Long;
                    dr["Speed"]           = carRealData.Speed;
                    dr["Status"]          = carRealData.Status;
                    dr["Status808"]       = carRealData.Status808;
                    dr["StatusExt808"]    = carRealData.StatusExt808;
                    dr["StatusStr"]       = carRealData.StatusStr;
                    dr["SumMiles"]        = carRealData.SumMiles;
                    dr["TDateTime"]       = carRealData.TDateTime;
                    dr["TNO"]             = carRealData.TNO;
                    dr["OnlineStatus"]    = carRealData.OnlineStatus;
                    dr["OnlineStatusStr"] = carRealData.OnlineStatusStr;
                    //carRealData.sPositionAdditionalInfo
                    dt.Rows.Add(dr);
                }

                //
                list_res.total   = dt.Rows.Count;
                list_res.page    = 0;
                list_res.size    = 0;
                list_res.records = dt;

                Result = new ResponseResult(ResState.Success, "操作成功", list_res);
            }
            catch (Exception ex)
            {
                Result = new ResponseResult(ResState.OperationFailed, ex.Message, "");
                LogHelper.WriteError("getCarLastTrack", ex);
            }


            return(Result);
        }
Example #3
0
        /// <summary>
        /// 获取车辆实时数据导出
        /// </summary>
        /// <param name="inparams"></param>
        /// <returns></returns>
        public ResponseResult getCarLastTrackOut(Dictionary <string, string> inparams)
        {
            ResponseResult Result = null;

            if (!inparams.Keys.Contains("CIDs"))
            {
                Result = new ResponseResult(ResState.ParamsImperfect, "缺少参数", null);
                return(Result);
            }
            string  sysflag  = inparams["sysflag"];
            ResList list_res = new ResList();

            try
            {
                //调用存储过程或WebGIS实时数据服务接口查询车辆轨迹数据
                DataTable dt = new DataTable();

                //初始化DataTable的列

                dt.Columns.Add(new DataColumn("CarNum", typeof(string)));
                dt.Columns.Add(new DataColumn("TDateTime", typeof(DateTime)));
                dt.Columns.Add(new DataColumn("Speed", typeof(float)));
                dt.Columns.Add(new DataColumn("StatusStr", typeof(string)));
                dt.Columns.Add(new DataColumn("AlarmStr", typeof(string)));
                dt.Columns.Add(new DataColumn("OnlineStatusStr", typeof(string)));
                dt.Columns.Add(new DataColumn("HeadingStr", typeof(string)));
                dt.Columns.Add(new DataColumn("SumMiles", typeof(int)));
                dt.Columns.Add(new DataColumn("Lati", typeof(float)));
                dt.Columns.Add(new DataColumn("Long", typeof(float)));
                dt.Columns.Add(new DataColumn("Address", typeof(string)));
                //dt.Columns.Add(new DataColumn("Alarm", typeof(long)));
                //dt.Columns.Add(new DataColumn("Alarm808", typeof(long)));
                //dt.Columns.Add(new DataColumn("AlarmExt808", typeof(long)));
                //dt.Columns.Add(new DataColumn("Carid", typeof(long)));
                //dt.Columns.Add(new DataColumn("Heading", typeof(int)));
                //dt.Columns.Add(new DataColumn("Status", typeof(long)));
                //dt.Columns.Add(new DataColumn("Status808", typeof(long)));
                //dt.Columns.Add(new DataColumn("StatusExt808", typeof(long)));
                // dt.Columns.Add(new DataColumn("AltitudeMeters", typeof(int)));
                //dt.Columns.Add(new DataColumn("TNO", typeof(long)));
                //dt.Columns.Add(new DataColumn("OnlineStatus", typeof(int)));

                //sPositionAdditionalInfo
                WebGIS.RealtimeDataServer.CarRealData[] res = new WebGIS.RealtimeDataServer.CarRealData[] { };

                res = CarRealDataByCids(sysflag, ToIntArray(inparams["CIDs"].Split(',')));

                List <AddressConvert.DLngLat> convertAddrList = new List <AddressConvert.DLngLat>(); //存放需要解析地址的轨迹点的坐标


                //利用查询结果填充DataTable
                foreach (WebGIS.RealtimeDataServer.CarRealData carRealData in res)
                {
                    DataRow dr = dt.NewRow();

                    dr["AlarmStr"]        = carRealData.AlarmStr;
                    dr["CarNum"]          = carRealData.CarNum;
                    dr["HeadingStr"]      = carRealData.HeadingStr;
                    dr["Lati"]            = carRealData.Lati;
                    dr["Long"]            = carRealData.Long;
                    dr["Speed"]           = carRealData.Speed;
                    dr["StatusStr"]       = carRealData.StatusStr;
                    dr["SumMiles"]        = carRealData.SumMiles;
                    dr["TDateTime"]       = carRealData.TDateTime;
                    dr["OnlineStatusStr"] = carRealData.OnlineStatusStr;
                    dt.Rows.Add(dr);
                    AddressConvert.DLngLat dlnglat = new AddressConvert.DLngLat();
                    dlnglat.Lng = carRealData.Long;
                    dlnglat.Lat = carRealData.Lati;
                    convertAddrList.Add(dlnglat);
                }
                string[] conArr = CommLibrary.AddressConvert.AddConvertBatch(convertAddrList);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dt.Rows[i]["Address"] = conArr[i];
                }

                NPOIHelper npoiHelper       = new NPOIHelper();
                string[]   headerDataArray  = { "车牌号", "GPS时间", "车速", "车辆状态", "报警状态", "在线状态", "方向", "里程", "经度", "纬度", "地址" };
                string[][] contentDataArray = npoiHelper.convertDataTableToStringArray(dt);
                npoiHelper.WorkbookName = "车辆实时监控数据" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
                // 设置导入内容
                npoiHelper.HeaderData  = headerDataArray;
                npoiHelper.ContentData = contentDataArray;
                string basepath = HttpRuntime.AppDomainAppPath.ToString();
                string filePath = @"UI\Excel\Query\";
                string sd       = basepath + filePath;
                npoiHelper.saveExcel(sd);

                Result = new ResponseResult(ResState.Success, "", filePath + npoiHelper.WorkbookName);
                return(Result);
            }
            catch (Exception ex)
            {
                Result = new ResponseResult(ResState.OtherError, "", ex.Message + ex.StackTrace);
                return(Result);
            }
        }