Ejemplo n.º 1
0
        public List<OverSpeedReportViewModel> GetOverSpeedDetailViewModel(OverSpeedReportWCFPara para)
        {
            List<OverSpeedReportViewModel> list = new List<OverSpeedReportViewModel>();

            Guid[] VehicleCodeList = para.VehicleCodeList;//车辆序列
            string[] LicenceNumberList = para.LicenceNumberList;//车牌号码序列

            ReportService ser = new ReportService();
            //获取超速行驶报警报表记录
            List<EOverSpeedDetailAlertReport> reportList = ser.GetOverSpeedDetailReportRecord(VehicleCodeList, para.BeginTime, para.EndTime);

            if (!reportList.IsNullOrEmpty())
            {
                for (int i = 0; i < reportList.Count; i++)
                {
                    if (reportList[i].AlertState == 1)
                    {
                        if (i > 0 && reportList[i - 1].AlertState == 0)
                        {
                            list.Add(new OverSpeedReportViewModel()
                            {
                                VehicleCode = reportList[i].VehicleCode,
                                LicenceNumber = reportList[i].LicenceNumber,
                                GPSReporttime = reportList[i-1].GPSReportTime.ToString("yyyy-MM-dd HH:mm"),
                                VehicleSpeed = reportList[i-1].VehicleSpeed,
                                VehiclePosition = reportList[i-1].VehiclePosition
                            });
                        }
                    }
                }
            }
            list = list.OrderBy(f => f.LicenceNumber).ToList();
            return list;
        }
Ejemplo n.º 2
0
        public List<OverSpeedReportViewModel> GetOverSpeedReportViewModel(OverSpeedReportWCFPara para)
        {
            List<OverSpeedReportViewModel> list = new List<OverSpeedReportViewModel>();

            Guid[] VehicleCodeList = para.VehicleCodeList;//车辆序列
            string[] LicenceNumberList = para.LicenceNumberList;//车牌号码序列

            IReportService ser = new ReportService();
            //获取超速行驶报警报表记录
            List<EOverSpeedAlertReport> reportList = ser.GetOverSpeedAlertReportRecord(VehicleCodeList, para.BeginTime, para.EndTime);
            //循环车辆序列,统计每辆车的超速次数笥超速时长
            for (int i = 0, i_count = VehicleCodeList.Length; i < i_count; i++)
            {
                //从报表记录中筛选当前车辆的报警记录
                List<EOverSpeedAlertReport> tempList = reportList.Where(f => f.VehicleCode == VehicleCodeList[i]).ToList();
                if (tempList.Count > 0)
                {
                    //如果AlertState值为0,代表当前正在超速行驶,那么记录中AlertState值为0的记录数即是当前车辆的超速总次数
                    //int OverSpeedCount = tempList.Where(f => f.AlertState == 0).Count();
                    int OverSpeedCount = 0;
                    TimeSpan OverSpeedDuration = new TimeSpan();
                    for (int j = 0, j_count = tempList.Count; j < j_count; j++)
                    {
                        //如果AlertState值为1,代表当前已经由超速行驶转为正常行驶,那么该记录减去前一条记录的时间就是该次超速的行驶时间
                        if (tempList[j].AlertState == 1)
                        {
                            //当前记录至少为第2条记录,前且前一条记录的必须为超速行驶记录
                            if (j > 0 && tempList[j - 1].AlertState == 0)
                            {
                                //累计超速时间
                                OverSpeedDuration += tempList[j].GPSReportTime - tempList[j - 1].GPSReportTime;
                                OverSpeedCount++;
                            }
                        }
                    }
                    list.Add(new OverSpeedReportViewModel() { VehicleCode = VehicleCodeList[i], LicenceNumber = LicenceNumberList[i], OverSpeedDuration = OverSpeedDuration, OverSpeedCount = OverSpeedCount });
                }
                else//报表中找不到当前车辆的记录时,次数与时长都为0
                    list.Add(new OverSpeedReportViewModel() { VehicleCode = VehicleCodeList[i], LicenceNumber = LicenceNumberList[i], OverSpeedDuration = new TimeSpan(), OverSpeedCount = 0 });
            }

            list = list.OrderBy(f => f.LicenceNumber).ToList();
            return list;
        }