/// <summary>
        /// 校正数据
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public CustomResult CalibrationData(QueryParameters para)
        {
            CustomResult pReturnValue = new CustomResult();
            QueryNaturalInfoViewModel queryNatural = new QueryNaturalInfoViewModel();
            //判断选择校正时间段的有效性
            string[] calibrationDataHour = new string[24];
            if (para.StartHour <= para.EndHour)
            {
                for (int i = para.StartHour; i <= para.EndHour; i++)
                {
                    calibrationDataHour[i] = i.ToString();
                }
            }
            else
            {
                pReturnValue.ResultKey = (byte)EResult.Fail;
                pReturnValue.ResultValue = TipInfo.CalibrationFaileHour;
                return pReturnValue;
            }
            double pFloating = para.FloatingRange * 0.01;
            List<RP_NatSta> pNaturalTraList = new List<RP_NatSta>();
            try
            {
                using (DataSubmittedEntities db = new DataSubmittedEntities())
                {
                    //判断报表浮动百分比配置是否正确
                    OT_HDayConfig pds = HolidayConfig.GetInstance().GetById(para.ReportType);
                    if (pds == null)
                    {
                        pReturnValue.ResultKey = (byte)EResult.Fail;
                        pReturnValue.ResultValue = TipInfo.CalibrationFaileNoConfig;
                        return pReturnValue;
                    }
                    if (Math.Abs(para.FloatingRange) > (double)pds.CheckFloat.Value)
                    {
                        pReturnValue.ResultKey = (byte)EResult.Fail;
                        pReturnValue.ResultValue = TipInfo.ErrorInfo + "范围应在负" + pds.CheckFloat.Value + "%-正" + pds.CheckFloat.Value + "%之间";
                        return pReturnValue;
                    }
                    //获取参考日期符合校正时间段的数据,因为只校正一天的数据,所以只查询开始数据的日期就可以
                    List<NaturalInfoViewModel> pRefNaturalList = db.RP_NatSta.Where(s => s.CalcuTime == para.LastYearStart && s.StaType == para.StationType && calibrationDataHour.Contains(s.HourPer.Value.ToString())).ToList().Select(s => new NaturalInfoViewModel
                    {
                        HourPer = (byte)s.HourPer,
                        DayTraffic = (double)s.Sum,
                        InDayTraffic = (double)s.EnNum,
                        OutDayTraffic = (double)s.ExNum,
                        RunningStatus = s.RunStae,
                        Remark = s.Rek
                    }).ToList();
                    //如果参考日期数据为0 则返回失败
                    if (pRefNaturalList.Count == 0)
                    {
                        pReturnValue.ResultKey = (byte)EResult.Fail;
                        pReturnValue.ResultValue = TipInfo.CalibrationFaileRefNoData;
                        return pReturnValue;
                    }
                    //判断校正数据日期是否合理
                    if (para.LastYearStart < para.StartTime && para.StartTime < DateTime.Now.AddDays(1))
                    {
                        //需要校正的数据
                        var pCheckNaturalList = db.RP_NatSta.Where(s => s.CalcuTime == para.StartTime && s.StaType == para.StationType && calibrationDataHour.Contains(s.HourPer.Value.ToString())).ToList();
                        if (pCheckNaturalList.Count == 0)
                        {
                            pReturnValue.ResultKey = (byte)EResult.Fail;
                            pReturnValue.ResultValue = TipInfo.CalibrationFaileNoData;
                            return pReturnValue;
                        }
                        using (TransactionScope tran = new TransactionScope())
                        {
                            foreach (var item in pCheckNaturalList)
                            {
                                IEnumerable<NaturalInfoViewModel> plist = pRefNaturalList.Where(i => i.HourPer == item.HourPer);
                                if (plist.Count() > 0)
                                {
                                    NaturalInfoViewModel pTemp = plist.First();
                                    item.EnNum = (int)(pTemp.InDayTraffic + pTemp.InDayTraffic * pFloating);
                                    item.ExNum = (int)(pTemp.OutDayTraffic + pTemp.OutDayTraffic * pFloating);
                                    item.Sum = item.EnNum + item.ExNum;
                                    item.RunStae = pTemp.RunningStatus;
                                    item.CalcuTime = para.StartTime.Value;
                                    item.StaType = para.StationType;
                                    if (SessionManage.GetLoginUser() != null)
                                    {
                                        item.UpdBy = SessionManage.GetLoginUser().UserName;
                                    }
                                    item.UpdDate = DateTime.Now;
                                    item.State = "1";
                                }
                            }
                            db.SaveChanges();
                            tran.Complete();
                            pReturnValue.ResultKey = (byte)EResult.Succeed;
                            pReturnValue.ResultValue = TipInfo.CalibrationSuccess;
                        }
                    }
                    else
                    {
                        pReturnValue.ResultKey = (byte)EResult.Fail;
                        pReturnValue.ResultValue = TipInfo.CalibrationFaileDate;
                    }

                }
                return pReturnValue;
            }
            catch (Exception e)
            {
                pReturnValue.ResultKey = (byte)EResult.Fail;
                pReturnValue.ResultValue = TipInfo.CalibrationFaile + e.Message.ToString();
                SystemLog.GetInstance().Error(TipInfo.CalibrationFaile, e);
                return pReturnValue;
            }
        }
        /// <summary>
        /// 15,16,17根据查询条件获取数据
        /// </summary>
        /// <param name="para">查询条件类</param>
        /// <returns></returns>
        public IReportViewModel GetListByPra(QueryParameters para)
        {
            QueryNaturalInfoViewModel pReturn = new QueryNaturalInfoViewModel();
            try
            {
                using (DataSubmittedEntities db = new DataSubmittedEntities())
                {
                    //添加合计
                    new TrafficStatisticalSum().CreateOrUpdateSum(para, (int)para.StationType);
                    //某类报表所涉及的收费站名称
                    string[] pStationNames = null;

                    if (para.ReportType == 17)
                    {
                        //报表17所包含的站名称
                        pStationNames = db.OT_Station.Where(s => s.Num == para.StationType.Value.ToString()).Select(s => s.Name).ToArray();

                        pReturn.ReportData = db.RP_NatSta.Where(s => s.CalcuTime == para.StartTime && s.StaType == para.StationType && s.HourPer == 24).ToList().Select(s => new NaturalInfoViewModel
                        {
                            HourPer = 0,
                            DayTraffic = double.Parse(string.Format("{0:0.0000}", s.Sum * 0.0001)),
                            InDayTraffic = double.Parse(string.Format("{0:0.0000}", s.EnNum * 0.0001)),
                            OutDayTraffic = double.Parse(string.Format("{0:0.0000}", s.ExNum * 0.0001)),
                            RunningStatus = s.RunStae,
                            Remark = s.Rek
                        }).ToList();
                        if (pReturn.ReportData.Count == 0)
                        {
                            pReturn.ReportData.Add(new NaturalInfoViewModel
                            {
                                HourPer = 0,
                                RoadName = SystemConst.RoadName,
                                DayTraffic = null,
                                InDayTraffic = null,
                                OutDayTraffic = null,
                                RunningStatus = SystemConst.RunningStatus,
                                Remark = ""
                            });
                            pReturn.ReportData.Add(new NaturalInfoViewModel
                            {
                                HourPer = 24,
                                RoadName = SystemConst.RoadName,
                                DayTraffic = null,
                                InDayTraffic = null,
                                OutDayTraffic = null,
                                RunningStatus = "",
                                Remark = ""
                            });
                        }
                        else
                        {
                            pReturn.ReportData.Add(new NaturalInfoViewModel
                            {
                                HourPer = 24,
                                RoadName = SystemConst.RoadName,
                                DayTraffic = double.Parse(string.Format("{0:0.0000}", pReturn.ReportData[0].DayTraffic)),
                                InDayTraffic = double.Parse(string.Format("{0:0.0000}", pReturn.ReportData[0].InDayTraffic)),
                                OutDayTraffic = double.Parse(string.Format("{0:0.0000}", pReturn.ReportData[0].OutDayTraffic)),
                                RunningStatus = pReturn.ReportData[0].RunningStatus,
                                Remark = pReturn.ReportData[0].Remark
                            });
                        }
                    }
                    else
                    {
                        //报表15,16所包含的站名称
                        pStationNames = db.OT_Station.Where(s => s.District == para.StationType.Value).Select(s => s.Name).ToArray();
                        //获取查询日期当天所有已上传的数据,包括合计
                        pReturn.ReportData = db.RP_NatSta.Where(s => s.CalcuTime == para.StartTime && s.StaType == para.StationType).Select(s => new NaturalInfoViewModel
                        {
                            HourPer = (byte)s.HourPer,
                            DayTraffic = (double)s.Sum,
                            InDayTraffic = (double)s.EnNum,
                            OutDayTraffic = (double)s.ExNum,
                            RunningStatus = s.RunStae,
                            Remark = s.Rek
                        }).ToList();

                        //补充数据
                        IEnumerable<NaturalInfoViewModel> pNa = pReturn.ReportData.Where(s => s.HourPer != 24);
                        int pMaxTimeHour = -1;//补充在此之后的数据
                        int pMinTimeHour = -1;//补充在此之前的数据
                        if (pNa.Count() > 0)
                        {
                            pMinTimeHour = (int)pNa.Min(s => s.HourPer);
                            pMaxTimeHour = (int)pNa.Max(s => s.HourPer);
                        }
                        else
                        {
                            pReturn.ReportData.Add(new NaturalInfoViewModel
                            {
                                HourPer = 24,
                                DayTraffic = null,
                                InDayTraffic = null,
                                OutDayTraffic = null,
                                RunningStatus = SystemConst.RunningStatus,
                                Remark = ""
                            });
                        }
                        if (pMinTimeHour != -1 && pMinTimeHour != 0)
                        {
                            for (int i = 0; i < pMinTimeHour; i++)
                            {
                                InsertNull(para.StartTime.Value, (byte)i, para.StationType.Value);
                                pReturn.ReportData.Add(new NaturalInfoViewModel
                                {

                                    HourPer = (byte)i,
                                    DayTraffic = 0,
                                    InDayTraffic = 0,
                                    OutDayTraffic = 0,
                                    RunningStatus = SystemConst.RunningStatus,
                                    Remark = ""
                                });
                            }
                        }
                        //查看统计的最小时间和最大时间直接,数据是否统计上来
                        for (int i = pMinTimeHour + 1; i < pMaxTimeHour; i++)
                        {
                            if (db.RP_NatSta.Where(s => s.CalcuTime == para.StartTime && s.StaType == para.StationType && s.HourPer == (byte)i).Count() <= 0)
                            {
                                InsertNull(para.StartTime.Value, (byte)i, para.StationType.Value);
                                pReturn.ReportData.Add(new NaturalInfoViewModel
                                {

                                    HourPer = (byte)i,
                                    DayTraffic = 0,
                                    InDayTraffic = 0,
                                    OutDayTraffic = 0,
                                    RunningStatus = SystemConst.RunningStatus,
                                    Remark = ""
                                });
                            }
                        }
                        if (pMaxTimeHour < 23)
                        {
                            int pTemp = DateTime.Now.Hour;
                            for (int i = (int)pMaxTimeHour + 1; i < 24; i++)
                            {
                                //如果查询日期小于服务器时间,并且无数据上来,则认为是系统异常没有统计到数据,则将数据补充到数据库。
                                if (para.StartTime < DateTime.Now.Date)
                                {
                                    InsertNull(para.StartTime.Value, (byte)i, para.StationType.Value);
                                    pReturn.ReportData.Add(new NaturalInfoViewModel
                                    {
                                        HourPer = (byte)i,
                                        DayTraffic = 0,
                                        InDayTraffic = 0,
                                        OutDayTraffic = 0,
                                        RunningStatus = SystemConst.RunningStatus,
                                        Remark = ""
                                    });
                                }
                            }
                            if (para.StartTime == DateTime.Now.Date)
                            {
                                for (int n = 0; n < pTemp; n++)
                                {
                                    if (db.RP_NatSta.Where(s => s.CalcuTime == para.StartTime && s.StaType == para.StationType && s.HourPer == (byte)n).Count() <= 0)
                                    {
                                        InsertNull(para.StartTime.Value, (byte)n, para.StationType.Value);
                                        pReturn.ReportData.Add(new NaturalInfoViewModel
                                        {
                                            HourPer = (byte)n,
                                            DayTraffic = 0,
                                            InDayTraffic = 0,
                                            OutDayTraffic = 0,
                                            RunningStatus = SystemConst.RunningStatus,
                                            Remark = ""
                                        });
                                    }
                                }
                                for (int m = pTemp; m < 24; m++)
                                {
                                    pReturn.ReportData.Add(new NaturalInfoViewModel
                                    {
                                        HourPer = (byte)m,
                                        DayTraffic = null,
                                        InDayTraffic = null,
                                        OutDayTraffic = null,
                                        RunningStatus = SystemConst.RunningStatus,
                                        Remark = ""
                                    });
                                }
                            }
                        }

                        //按序号排序
                        pReturn.ReportData = pReturn.ReportData.OrderBy(s => s.HourPer).ToList();

                        //获取当前统计类型不包含的收费站列表
                        IEnumerable<OT_ErrorStation> pNoaccept = db.OT_ErrorStation.Where(i =>
                            pStationNames.Contains(i.StaName)).ToList().Where(s => s.CalcuTime == para.StartTime);

                        if (pNoaccept.Count() > 0)
                            pReturn.IsFull = 0;//不完整
                        else
                            pReturn.IsFull = 1;//完整                      
                    }
                    //获取报表备注
                    OT_HDayConfig holiday = HolidayConfig.GetInstance().GetById(para.ReportType);
                    if (holiday != null)
                    {
                        if (holiday.RptRemark != null)
                            pReturn.ReportRemark = holiday.RptRemark;
                        else
                            pReturn.ReportRemark = "";
                    }
                    else
                    {
                        pReturn.ReportRemark = "";
                    }
                }
            }
            catch (Exception e)
            {
                SystemLog.GetInstance().Info(e);
            }
            return pReturn;
        }