/// <summary>
        /// 补数据
        /// </summary>
        /// <param name="para"></param>
        private void RepairData(QueryParameters para)
        {
            using (DataSubmittedEntities db = new DataSubmittedEntities())
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    int day = (para.EndTime.Value - para.StartTime.Value).Days + 1;
                    for (int i = 0; i < day; i++)
                    {
                        DateTime dtime = para.StartTime.Value.AddDays(i);

                        //时间小于当前时间
                        if (DateTime.Now > dtime)
                        {
                            bool flag = StrWhere(db, para).Select(a => a.CalcuTime).ToList().Contains(dtime);
                            if (!flag)//补数据
                            {
                                RP_HDayAADT hday = new RP_HDayAADT();
                                hday.CalcuTime = dtime;
                                hday.CompGrow = 0;
                                if (SessionManage.GetLoginUser() != null)
                                {
                                    hday.CrtBy = SessionManage.GetLoginUser().UserName;
                                }
                                hday.CrtDate = DateTime.Now;
                                hday.Id = Guid.NewGuid();
                                hday.JC = 0;
                                hday.JZL = 0;
                                hday.KG = 0;
                                hday.Out = 0;
                                hday.SameSum = 0;
                                hday.State = "0";
                                hday.Sum = 0;
                                hday.TGB = 0;
                                hday.TGX = 0;
                                hday.TGXF = 0;
                                hday.YC = 0;
                                hday.YXBD = 0;
                                hday.YXBX = 0;
                                db.RP_HDayAADT.Add(hday);
                            }
                            else//将数据中有空值的改成0
                            {
                                var hday = db.RP_HDayAADT.Where(a => a.CalcuTime == dtime).ToList()[0];
                                if (hday.JC == null)
                                    hday.JC = 0;
                                if (hday.JZL == null)
                                    hday.JZL = 0;
                                if (hday.KG == null)
                                    hday.KG = 0;
                                if (hday.Out == null)
                                    hday.Out = 0;
                                if (hday.SameSum == null)
                                    hday.SameSum = 0;
                                if (hday.Sum == null)
                                    hday.Sum = 0;
                                if (hday.TGB == null)
                                    hday.TGB = 0;
                                if (hday.TGX == null)
                                    hday.TGX = 0;
                                if (hday.TGXF == null)
                                    hday.TGXF = 0;
                                if (hday.YC == null)
                                    hday.YC = 0;
                                if (hday.YXBD == null)
                                    hday.YXBD = 0;
                                if (hday.YXBX == null)
                                    hday.YXBX = 0;
                            }
                        }
                    }
                    try
                    {
                        db.SaveChanges();
                        transaction.Complete();
                    }
                    catch (Exception ex)
                    {
                        SystemLog.GetInstance().Error(TipInfo.AddFaile, ex);
                    }
                }
            }
        }
        /// <summary>
        /// 获取或更新报表11,12源数据
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="HourPer"></param>
        public void Update(DateTime dt, int HourPer)
        {
            try
            {
                string startTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                SystemLog.GetInstance().Log.Info(string.Format("{0}:开始获取11,12报表数据", startTime));
                using (DataSubmittedEntities db = new DataSubmittedEntities())
                {
                    //获取报表12配置的假期信息
                    List<OT_HDayConfig> pdayconfigs = db.OT_HDayConfig.Where(s => s.Id == 12).ToList();
                    OT_HDayConfig pdayconfig = new OT_HDayConfig();
                    if (pdayconfigs.Count > 0)
                    {
                        pdayconfig = pdayconfigs.First();
                    }
                    DateTime pDt = DateTime.Parse(dt.ToShortDateString());
                    //报表11,12收费站
                    List<int> TJStation = StationConfiguration.GetStaionList();
                    //获取今年当日数据//p.VehType == 0 表示合计数据,
                    IEnumerable<DS_DataSource> pCollection = db.DS_DataSource.Where(p =>
                        DbFunctions.TruncateTime(p.CalcuTime) == DbFunctions.TruncateTime(dt)
                        && p.VehType == 0 && TJStation.Contains(p.StaID.Value));

                    //今年数据
                    IEnumerable<DS_DataSource> pHdayCollection = db.DS_DataSource.Where(p =>
                        (DbFunctions.TruncateTime(p.CalcuTime) <= pdayconfig.HDayEnd.Value
                        && DbFunctions.TruncateTime(p.CalcuTime) >= pdayconfig.HDayStart.Value)
                        && p.VehType == 0 && TJStation.Contains(p.StaID.Value));

                    //每日数据
                    List<RP_HDayAADT> pList = db.RP_HDayAADT.Where(p => p.CalcuTime == pDt).ToList();
                    RP_HDayAADT pAADTInfo = null;
                    bool pIsHas = false;
                    if (pList.Count > 0)
                    {
                        pAADTInfo = pList.FirstOrDefault();
                        pIsHas = true;
                    }
                    else
                    {
                        pAADTInfo = new RP_HDayAADT();
                    }
                    //更新实体
                    UpdateInfo(pCollection, pAADTInfo, pDt, pIsHas, pHdayCollection);
                    using (TransactionScope transaction = new TransactionScope())
                    {
                        //如果不存在,则添加,否则则更新
                        if (!pIsHas)
                            db.RP_HDayAADT.Add(pAADTInfo);
                        db.SaveChanges();
                        transaction.Complete();
                    }
                }
                string endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                SystemLog.GetInstance().Log.Info(string.Format("{0}:结束获取11,12报表数据", endTime));
                SystemLog.GetInstance().Log.Info(string.Format("统计11,12报表数据耗时{0}秒", (DateTime.Parse(endTime) - DateTime.Parse(startTime)).TotalSeconds));
                //显示执行该方法的线程ID
                //SystemLog.GetInstance().Log.Info(string.Format("调用11,12Update的线程ID为:{0}", Thread.CurrentThread.ManagedThreadId));
                Thread.Sleep(1000);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 补充数据
        /// </summary>
        /// <param name="dt">统计日期</param>
        private void InsertNull(DateTime dt)
        {
            HDayStatisticalReport pHday = new HDayStatisticalReport("");
            using (DataSubmittedEntities db = new DataSubmittedEntities())
            {
                RP_HDayAADT info = new RP_HDayAADT();

                info.Id = Guid.NewGuid();
                info.CrtDate = DateTime.Now;
                info.State = "0";
                info.CalcuTime = dt;
                //杨村站流量
                info.YC = 0;
                //宜兴埠东站流量
                info.YXBD = 0;
                //宜兴埠西站流量
                info.YXBX = 0;
                //金钟路站流量
                info.JZL = 0;
                //机场站流量
                info.JC = 0;
                //空港经济区站流量
                info.KG = 0;
                //塘沽西站流量
                info.TGX = 0;
                //塘沽西分站流量
                info.TGXF = 0;
                //塘沽北站流量
                info.TGB = 0;
                //表12出口流量
                info.Out = 0;
                //去年同期
                info.SameSum = pHday.GetSameSum(dt);
                using (TransactionScope transac = new TransactionScope())
                {
                    db.RP_HDayAADT.Add(info);
                    db.SaveChanges();
                    transac.Complete();
                }
            }
        }
        /// <summary>
        /// 更新实体信息
        /// </summary>
        /// <param name="sourcelist">数据源列表</param>
        /// <param name="info">实体信息</param>
        /// <param name="oldinfo">去年同期</param>
        /// <param name="dt">数据日期</param>
        /// <param name="ishas">记录是否已存在</param>
        /// <param name="hdaylist">今年数据</param>
        private void UpdateInfo(IEnumerable<DS_DataSource> sourcelist, RP_HDayAADT info, DateTime dt, bool ishas, IEnumerable<DS_DataSource> hdaylist)
        {
            if (ishas)//已存在
            {
                info.UpdDate = DateTime.Now;
                info.State = "1";
            }
            else//不存在
            {
                info.Id = Guid.NewGuid();
                info.CrtDate = DateTime.Now;
                info.State = "0";
            }
            info.CalcuTime = dt;
            //杨村站流量
            info.YC = sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.YC).Sum(s => s.OutNum.Value)
                + sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.YC).Sum(s => s.InNum.Value);
            //宜兴埠东站流量
            info.YXBD = sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.YXBD).Sum(s => s.OutNum.Value)
                + sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.YXBD).Sum(s => s.InNum.Value);
            //宜兴埠西站流量
            info.YXBX = sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.YXBX).Sum(s => s.OutNum.Value)
                + sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.YXBX).Sum(s => s.InNum.Value);
            //金钟路站流量
            info.JZL = sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.JZL).Sum(s => s.OutNum.Value)
                + sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.JZL).Sum(s => s.InNum.Value);
            //机场站流量
            info.JC = sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.JC).Sum(s => s.OutNum.Value)
                + sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.JC).Sum(s => s.InNum.Value);
            //空港经济区站流量
            info.KG = sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.KG).Sum(s => s.OutNum.Value)
                + sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.KG).Sum(s => s.InNum.Value);
            //塘沽西站流量
            info.TGX = sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.TGX).Sum(s => s.OutNum.Value)
                + sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.TGX).Sum(s => s.InNum.Value);
            //塘沽西分站流量
            info.TGXF = sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.TGXF).Sum(s => s.OutNum.Value)
                + sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.TGXF).Sum(s => s.InNum.Value);
            //塘沽北站流量
            info.TGB = sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.TG).Sum(s => s.OutNum.Value)
                + sourcelist.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.TG).Sum(s => s.InNum.Value);

            //本年数据
            double pTodayTemp = hdaylist.Sum(s => s.OutNum.Value);
            //表12出口流量
            info.Out = sourcelist.Sum(s => s.OutNum.Value);
            //去年同期
            info.SameSum = GetSameSum(dt);
            //    //合计
            //    info.Sum = pTodayTemp;
            //    //同比增幅    
            //    if (info.SameSum.HasValue && info.SameSum.Value != 0 && info.SameSum != 0.0)
            //        info.CompGrow = Math.Round((pTodayTemp - info.SameSum.Value) / info.SameSum.Value, 2);
        }