示例#1
0
        public List<AreaReportDetailViewModel> GetAreaReportDetailViewModel(AreaReportWCFPara para)
        {
            List<AreaReportDetailViewModel> list = new List<AreaReportDetailViewModel>();

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

            IReportService ser = new ReportService();
            //获取区域进入报警报表记录
            List<EAreaAlertDetailReport> reportList = ser.GetAreaAlertReportDetail(VehicleCodeList, para.BeginTime, para.EndTime);
            Guid InAreaid = Guid.NewGuid();
            Guid BackRecordId = Guid.NewGuid();
            AreaReportDetailViewModel entity = new AreaReportDetailViewModel();

            for (int i = 0; i < reportList.Count; i++)
            {
                if (reportList[i].IsInArea)
                {
                    entity = new AreaReportDetailViewModel();
                    entity.VehicleCode = reportList[i].VehicleCode;
                    entity.LicenceNumber = reportList[i].LicenceNumber;
                    entity.AreaName = reportList[i].AreaName;
                    entity.InAreaDate = reportList[i].GPSReportTime;
                }

                if (reportList[i].InAreaID.HasValue)
                {
                    InAreaid = reportList[i].InAreaID.Value;
                }

                // 出区域时所对应的进区域记录
                if (InAreaid.Equals(BackRecordId) && !reportList[i].IsInArea)
                {
                    entity.OutAreaDate = reportList[i].GPSReportTime;
                    entity.AreaDuration = new TimeSpan(reportList[i].StayTime);
                    list.Add(entity);
                }

                BackRecordId = reportList[i].RecordID;
            }

            list = list.OrderBy(f => f.LicenceNumber).ToList();
            return list;
        }
示例#2
0
        public List<AreaReportViewModel> GetAreaReportViewModel(AreaReportWCFPara para)
        {
            List<AreaReportViewModel> list = new List<AreaReportViewModel>();

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

            IReportService ser = new ReportService();
            //获取区域进入报警报表记录
            List<EAreaAlertReport> reportList = ser.GetAreaAlertReportRecord(VehicleCodeList, para.BeginTime, para.EndTime);
            //循环车辆序列,统计每辆车的区域进入次数与停留时长
            for (int i = 0, i_count = VehicleCodeList.Length; i < i_count; i++)
            {
                //从报表记录中筛选当前车辆的报警记录
                List<EAreaAlertReport> tempList = reportList.Where(f => f.VehicleCode == VehicleCodeList[i]).ToList();
                if (tempList.Count > 0)
                {
                    //如果IsInArea值为1,代表当前进入区域,那么记录中IsInArea值为1的记录数即是当前车辆的区域进入总次数
                    int AreaCount = tempList.Where(f => f.IsInArea).Count();
                    TimeSpan AreaDuration = new TimeSpan(tempList.Where(f => !f.IsInArea).Sum(f => f.StayTime));

                    int tmpHour = 0, tmpMinutes = 0;
                    for (int j = 0, j_count = tempList.Count; j < j_count; j++)
                    {
                        // 汇总的时长和明细的时长一样,2012-2-9与徐斌确认
                        if (!tempList[j].IsInArea)
                        {
                            TimeSpan tmpTS = new TimeSpan(tempList[j].StayTime);
                            if (tmpTS.Hours > 0) {
                                tmpHour += tmpTS.Hours;
                            }
                            if (tmpTS.Minutes > 0) {
                                tmpMinutes += tmpTS.Minutes;
                            }
                        }
                    }
                    // 明细的秒会被四舍五入掉的,所以在这里记为0
                    AreaDuration = new TimeSpan(tmpHour, tmpMinutes, 0);
                    list.Add(new AreaReportViewModel() { VehicleCode = VehicleCodeList[i], LicenceNumber = LicenceNumberList[i], AreaDuration = AreaDuration, AreaCount = AreaCount });
                }
                else//报表中找不到当前车辆的记录时,次数与时长都为0
                    list.Add(new AreaReportViewModel() { VehicleCode = VehicleCodeList[i], LicenceNumber = LicenceNumberList[i], AreaDuration = new TimeSpan(), AreaCount = 0 });
            }

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