Exemple #1
0
        /// <summary>
        /// 采用ado 查询一段时间内的里程
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public List<ReportMileageViewModel> GetNewMileage(ReportMileageWCFPara para)
        {
            List<ReportMileageViewModel> ReportMileageViewModelList = new List<ReportMileageViewModel>();
            try
            {
                if (para.VehicleCode == null || para.VehicleCode.Count() == 0)
                    return ReportMileageViewModelList;

                VehicleDAL vdal = new VehicleDAL();
                List<EHistoryDataStoreConfig> tableList = vdal.GetVechileInfo(para.VehicleCode.ToList());

                //获得VehicleCode和LicenceNuber之间的关系
                Dictionary<Guid, string> dicCodeAndLicence = new Dictionary<Guid, string>();
                for (int i = 0, i_Count = para.VehicleCode.Count(); i < i_Count; i++)
                {
                    dicCodeAndLicence.Add(para.VehicleCode[i], para.LicenceNumber[i]);
                }
                
                foreach (EHistoryDataStoreConfig config in tableList)
                {
                    if (config.StoreTable == null)
                        continue;

                    List<Guid> vehicleList = tableList.Where(b=>b.StoreTable==config.StoreTable).Select(c => c.VehicleCode).ToList();
                    List<EMileage> EMileageList = GetReportTimeSpanMileage(config, vehicleList, para.BeginTime, para.EndTime, false);

                    foreach (EMileage objEMileage in EMileageList)
                    {
                        ReportMileageViewModel objModel = new ReportMileageViewModel();
                        objModel.VehicleCode = objEMileage.VehicleCode;
                        objModel.LicenceNumber = dicCodeAndLicence[objModel.VehicleCode];
                        objModel.Mileage = objEMileage.TotalMileage;
                        ReportMileageViewModelList.Add(objModel);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("GetMileage" + ex.Message, ex);
            }
            return ReportMileageViewModelList;
        }
Exemple #2
0
        /// <summary>
        /// 查询一段时间内的里程
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public List<ReportMileageViewModel> GetMileage(ReportMileageWCFPara para)
        {
            List<ReportMileageViewModel> ReportMileageViewModelList = new List<ReportMileageViewModel>();
            try
            {
                if (para.VehicleCode == null || para.VehicleCode.Count() == 0)
                    return ReportMileageViewModelList;

                //取出车辆列表所用到的历史数据配置信息列表
                List<EHistoryDataStoreConfig> configList = tableConfigSev.GetVehicleStoreTableConfig(para.VehicleCode.ToList());

                //对历史数据配置信息中的StoreTable字段进行GroupBy操作,去除重复
                var q = from f in configList group f by f.StoreTable into g select new EHistoryDataStoreConfig { StoreTable = g.Key };

                List<EHistoryDataStoreConfig> tableList = q.ToList();

                //获得VehicleCode和LicenceNuber之间的关系
                Dictionary<Guid, string> dicCodeAndLicence = new Dictionary<Guid, string>();
                for (int i = 0, i_Count = para.VehicleCode.Count(); i < i_Count; i++)
                {
                    dicCodeAndLicence.Add(para.VehicleCode[i], para.LicenceNumber[i]);
                }

                foreach (EHistoryDataStoreConfig config in tableList)
                {
                    if (config.StoreTable == null)
                        continue;
                    //将同一个历史表的车辆里程数据一次性查询出来
                    var query = from f in configList
                                where f.StoreTable == config.StoreTable
                                select f.VehicleCode;
                    List<Guid> vehicleList = query.ToList<Guid>();
                    List<EMileage> EMileageList = GetReportTimeSpanMileage(config, vehicleList, para.BeginTime, para.EndTime, false);

                    foreach (EMileage objEMileage in EMileageList)
                    {
                        ReportMileageViewModel objModel = new ReportMileageViewModel();
                        objModel.VehicleCode = objEMileage.VehicleCode;
                        objModel.LicenceNumber = dicCodeAndLicence[objModel.VehicleCode];
                        objModel.Mileage = objEMileage.TotalMileage;
                        ReportMileageViewModelList.Add(objModel);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("GetMileage" + ex.Message, ex);
            }
            return ReportMileageViewModelList;
        }
Exemple #3
0
        /// <summary>
        /// 报表汇总
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public List<ReportSummaryVM> CountReport(ReportSummaryParam param)
        {
            try
            {
                ReportMileageWCFPara mileageParam = new ReportMileageWCFPara()
                {
                    BeginTime = param.BeginTime,
                    EndTime = param.EndTime,
                    tenantCode = param.TenantCode,
                    VehicleCode = param.Vehicles.Select(s => s.VehicleCode).ToArray(),
                    LicenceNumber = param.Vehicles.Select(s => s.LicenceNumber).ToArray()
                };
                //List<ReportMileageViewModel> listMileage = this.GetMileage(mileageParam);执行使用8.22s
                //查询车辆里程的代码优化
                List<ReportMileageViewModel> listMileage = this.GetNewMileage(mileageParam);//执行使用5.74s
                IAlertReportBase reportBase = new AlertReportBase();
                var ltVehicleCode = param.Vehicles.Select(s => s.VehicleCode).ToList();
                Dictionary<Guid, VCountStopCar> dicStop = new StopCarReportService().Count(ltVehicleCode, param.BeginTime,
                    param.EndTime, StopCar_Time, param.TenantCode);


                Dictionary<Guid, int> dicRob = reportBase.Count<ERobAlertReport>(ltVehicleCode, param.BeginTime, param.EndTime);
                Dictionary<Guid, int> dicPowerdown = reportBase.Count<EPowerDownAlertReport>(ltVehicleCode, param.BeginTime, param.EndTime);

                Dictionary<Guid, int> dicOverSpeed = CountOverSpeed(param);
                var dicParam = new Dictionary<string, object>();
                dicParam.Add("IsInArea", true);    //入区域条件
                dicParam.Add("IsDelayStay", false);   //非延迟出区域
                Dictionary<Guid, int> dicArea = reportBase.Count<EAreaAlertReport>(ltVehicleCode, param.BeginTime, param.EndTime, dicParam);

                return CrateReportSummaryVM(param.Vehicles, listMileage, dicStop, dicPowerdown, dicRob, dicOverSpeed, dicArea);

            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                return null;
            }
        }