Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
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;
        }