/// <summary> /// 根据查询条件获取数据 /// </summary> /// <param name="para">查询条件类,站类型也需要</param> /// <returns></returns> public IReportViewModel GetListByPra(QueryParameters para) { //查询返回实体 QueryHourAADTViewModel pReturn = new QueryHourAADTViewModel(); try { using (DataSubmittedEntities db = new DataSubmittedEntities()) { //补充空数据 InsertNull(para.StartTime.Value); List <int> pStationNames = StationConfiguration.GetBJStaion(); List <RP_HourAADT> pHourAADTList = db.RP_HourAADT.Where(s => s.CalcuTime == para.StartTime).ToList(); RP_HourAADT pHourAADTInfo = new RP_HourAADT(); //创建或更新合计 CreateOrUpdateSum(para); //报表数据 pReturn.ReportData = GetViewModelInfo(para); //判断当前统计站类型,数据是否完整 if (GetNoDataList(para).Count() > 0) { pReturn.IsFull = 0;//不完整 } else { pReturn.IsFull = 1;//完整 } } } catch (Exception ex) { SystemLog.GetInstance().Info(ex.Message); } return(pReturn); }
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}:开始获取13,14报表数据", startTime)); using (DataSubmittedEntities db = new DataSubmittedEntities()) { DateTime pDt = DateTime.Parse(dt.ToShortDateString()); //报表13,14收费站 List <int> BJStation = StationConfiguration.GetBJStaion(); //获取今年当日数据//p.VehType == 0 表示合计数据, List <DS_DataSource> pCollection = db.DS_DataSource.Where(p => p.CalcuTime == dt && p.VehType == 0 && p.HourPer == HourPer && BJStation.Contains(p.StaID.Value)).ToList(); bool pIsHas = false; //北京段数据 RP_HourAADT pHoursTraffic = null; List <RP_HourAADT> pBJList = db.RP_HourAADT.Where(p => p.CalcuTime == pDt && p.HourPer == (byte)HourPer).ToList(); if (pBJList.Count > 0) { pHoursTraffic = pBJList.FirstOrDefault(); //每种状态需要重新赋值,防止公用同一个变量,值不明确 pIsHas = true; } else { pHoursTraffic = new RP_HourAADT(); pIsHas = false; } //更新实体 UpdateInfo(pCollection, pHoursTraffic, HourPer, pDt, pIsHas); using (TransactionScope transaction = new TransactionScope()) { //更新或添加 if (!pIsHas) { db.RP_HourAADT.Add(pHoursTraffic); } db.SaveChanges(); //提交事务 transaction.Complete(); } } string endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); SystemLog.GetInstance().Log.Info(string.Format("{0}:结束获取,13,14报表数据", endTime)); SystemLog.GetInstance().Log.Info(string.Format("统计13,14报表数据耗时{0}秒", (DateTime.Parse(endTime) - DateTime.Parse(startTime)).TotalSeconds)); //显示执行该方法的线程ID //SystemLog.GetInstance().Log.Info(string.Format("调用13,14Update的线程ID为:{0}", Thread.CurrentThread.ManagedThreadId)); Thread.Sleep(1000); } catch (Exception ex) { throw ex; } }
/// <summary> ///更新每日报送数据15.16.17 /// </summary> public void Update(DateTime dt, int HourPer) { string startTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); SystemLog.GetInstance().Log.Info(string.Format("{0}:开始获取15,16,17报表数据", startTime)); using (DataSubmittedEntities db = new DataSubmittedEntities()) { DateTime pdt = DateTime.Parse(dt.ToShortDateString()); //北京段相同数据是否存在 List <RP_NatSta> pBJlist = db.RP_NatSta.Where(p => p.CalcuTime == pdt && p.HourPer == (byte?)HourPer && p.StaType == (int)StationConfiguration.StationType.BeiJingDuan).ToList(); bool BJHasTime = pBJlist.Count > 0; //大羊坊相同数据是否存在 List <RP_NatSta> pDYFlist = db.RP_NatSta.Where(p => p.CalcuTime == pdt && p.HourPer == (byte?)HourPer && p.StaType == (int)StationConfiguration.StationID.DYF).ToList(); bool DYFHasTime = pDYFlist.Count > 0; IList <RP_NatSta> pNaturalEntities = new List <RP_NatSta>(); List <int> BJStation = StationConfiguration.GetBJStaion(); List <int> outBJStation = StationConfiguration.GetOutBJStaion(); //p.VehType != 0 表示不包括合计数据, IEnumerable <DS_DataSource> pStagingCollection = db.DS_DataSource.Where(p => p.CalcuTime == dt && p.VehType != 0 && p.HourPer == HourPer && BJStation.Contains(p.StaID.Value)); RP_NatSta pNaturalTrafficBJ = null; //北京段 RP_NatSta pNaturalTraffic = null; //大羊坊 //北京段 //如果相同日期,相同时间段,相同统计站类型数据已存在则进行更新 if (!BJHasTime) { pNaturalTrafficBJ = new RP_NatSta();//北京段 pNaturalTrafficBJ.Id = Guid.NewGuid(); } else { pNaturalTrafficBJ = pBJlist[0]; } pNaturalTrafficBJ.EnNum = pStagingCollection.Sum(s => s.OutNum); pNaturalTrafficBJ.ExNum = pStagingCollection.Where(s => outBJStation.Contains(s.StaID.Value)).Sum(s => s.InNum); pNaturalTrafficBJ.Sum = pNaturalTrafficBJ.EnNum + pNaturalTrafficBJ.ExNum; pNaturalTrafficBJ.StaType = (int)StationConfiguration.StationType.BeiJingDuan; pNaturalTrafficBJ.CalcuTime = DateTime.Parse(dt.ToShortDateString()); pNaturalTrafficBJ.HourPer = (byte)HourPer; pNaturalTrafficBJ.CrtDate = DateTime.Now; pNaturalTrafficBJ.RunStae = SystemConst.RunningStatus; pNaturalTrafficBJ.State = "0"; //大羊坊 //如果相同日期,相同时间段,相同统计站类型数据已存在则进行更新 if (!DYFHasTime) { pNaturalTraffic = new RP_NatSta();//大羊坊 pNaturalTraffic.Id = Guid.NewGuid(); } else { pNaturalTraffic = pDYFlist[0]; } pNaturalTraffic.EnNum = pStagingCollection.Where(s => s.StaID == (int)StationConfiguration.StationID.DYF).Sum(s => s.OutNum); pNaturalTraffic.ExNum = pStagingCollection.Where(s => s.StaID == (int)StationConfiguration.StationID.DYF).Sum(s => s.InNum); pNaturalTraffic.Sum = pNaturalTraffic.EnNum + pNaturalTraffic.ExNum; pNaturalTraffic.StaType = (int)StationConfiguration.StationID.DYF; pNaturalTraffic.CrtDate = DateTime.Now; pNaturalTraffic.HourPer = (byte)HourPer; pNaturalTraffic.CalcuTime = DateTime.Parse(dt.ToShortDateString()); pNaturalTraffic.RunStae = SystemConst.RunningStatus; pNaturalTraffic.State = "0"; pNaturalEntities.Add(pNaturalTrafficBJ); pNaturalEntities.Add(pNaturalTraffic); using (TransactionScope transaction = new TransactionScope()) { //如果都不存在,则添加 if (!DYFHasTime && !BJHasTime) { db.RP_NatSta.AddRange(pNaturalEntities); } else if (!DYFHasTime && BJHasTime) { db.RP_NatSta.Add(pNaturalTraffic); } else if (DYFHasTime && !BJHasTime) { db.RP_NatSta.Add(pNaturalTrafficBJ); } db.SaveChanges(); //提交事务 transaction.Complete(); } string endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); SystemLog.GetInstance().Log.Info(string.Format("{0}:结束获取15.16.17报表数据", endTime)); SystemLog.GetInstance().Log.Info(string.Format("统计15,16,17报表数据耗时{0}秒", (DateTime.Parse(endTime) - DateTime.Parse(startTime)).TotalSeconds)); //显示执行该方法的线程ID //SystemLog.GetInstance().Log.Info(string.Format("调用15,16,17Update的线程ID为:{0}", Thread.CurrentThread.ManagedThreadId)); Thread.Sleep(1000); } }
/// <summary> /// 1.2.3.4获取更新方法 /// </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}:开始获取1,2,3,4报表数据", startTime)); using (DataSubmittedEntities db = new DataSubmittedEntities()) { DateTime pdt = DateTime.Parse(dt.ToShortDateString()); //获取北京段收费站列表 List <int> BJStation = StationConfiguration.GetBJStaion(); //获取天津段收费站列表 List <int> TJStation = StationConfiguration.GetStaionList2(); //获取北京段各车型合计数据VehType == 0表示合计//数据库中只存放每种车型的合计,有则更新,无则添加 IEnumerable <DS_DataSource> pBJDataSource = db.DS_DataSource.Where(p => DbFunctions.TruncateTime(p.CalcuTime) == DbFunctions.TruncateTime(dt) && BJStation.Contains(p.StaID.Value) && p.VehType == 0); //获取天津段各车型合计数据 IEnumerable <DS_DataSource> pTJDataSource = db.DS_DataSource.Where(p => DbFunctions.TruncateTime(p.CalcuTime) == DbFunctions.TruncateTime(dt) && TJStation.Contains(p.StaID.Value) && p.VehType == 0); //定义实体列表 List <RP_Daily> plist = new List <RP_Daily>(); //统计北京段 plist.AddRange(this.CalcuRP(1, pBJDataSource, pdt, BJStation)); //统计天津段 plist.AddRange(this.CalcuRP(3, pTJDataSource, pdt, TJStation)); //统计大羊坊 IEnumerable <DS_DataSource> pDYF = pBJDataSource.Where(s => s.StaID == (int)StationConfiguration.StationID.DYF); plist.AddRange(this.CalcuRP(15, pDYF, pdt, BJStation.Where(s => s.Equals(15)).ToList())); //统计泗村店 IEnumerable <DS_DataSource> pSCD = pTJDataSource.Where(s => s.StaID == (int)StationConfiguration.StationID.SCD); plist.AddRange(this.CalcuRP(33, pSCD, pdt, TJStation.Where(s => s.Equals(33)).ToList())); //添加 if (plist.Count > 0) { using (TransactionScope transac = new TransactionScope()) { db.RP_Daily.AddRange(plist); db.SaveChanges(); transac.Complete(); } } } string endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); SystemLog.GetInstance().Log.Info(string.Format("{0}:结束获取1,2,3,4报表数据", endTime)); SystemLog.GetInstance().Log.Info(string.Format("统计1,2,3,4报表数据耗时{0}秒", (DateTime.Parse(endTime) - DateTime.Parse(startTime)).TotalSeconds)); //显示执行该方法的线程ID //SystemLog.GetInstance().Log.Info(string.Format("调用1,2,3,4Update的线程ID为:{0}", Thread.CurrentThread.ManagedThreadId)); Thread.Sleep(1000); } catch (Exception ex) { throw ex; } }
/// <summary> /// 报表18获取数据源方法 /// </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}:开始获取18报表数据", startTime)); using (DataSubmittedEntities db = new DataSubmittedEntities()) { //北京段包含出入口收费站 List <int> BJStation = StationConfiguration.GetBJStaion(); DateTime pdt = DateTime.Parse(dt.ToShortDateString()); //获取当日北京段数据源,不包括合计数据 List <DS_DataSource> pBJCollection = db.DS_DataSource.Where(s => DbFunctions.TruncateTime(s.CalcuTime) == pdt && s.VehType != 0 && BJStation.Contains(s.StaID.Value)).ToList(); //判断数据是否已存在 RP_HDayAADTSta pHDayStaInfo = null; //5种路线类型 for (int i = 1; i < 7; i++) { List <RP_HDayAADTSta> pList = db.RP_HDayAADTSta.Where(p => p.CalcuTime == pdt && p.LineType == i).ToList(); if (pList.Count > 0)//已存在,则更新 { pHDayStaInfo = pList.FirstOrDefault(); pHDayStaInfo.UpdDate = DateTime.Now; pHDayStaInfo.State = "1"; } else//不存在,添加 { pHDayStaInfo = new RP_HDayAADTSta(); pHDayStaInfo.Id = Guid.NewGuid(); pHDayStaInfo.CrtDate = DateTime.Now; pHDayStaInfo.State = "0"; } pHDayStaInfo.CalcuTime = pdt; switch (i) { //观测点1 case 1: { this.SetInfo(pBJCollection, pHDayStaInfo, StationConfiguration.GetEnObs1(), StationConfiguration.GetExObs1(), 50000, i); break; } //观测点2 case 2: { this.SetInfo(pBJCollection, pHDayStaInfo, StationConfiguration.GetEnObs2(), StationConfiguration.GetExObs2(), 50000, i); break; } //观测点3 case 3: { this.SetInfo(pBJCollection, pHDayStaInfo, StationConfiguration.GetEnObs3(), StationConfiguration.GetExObs3(), 50000, i); break; } //收费站马驹桥 case 4: { this.SetInfo(pBJCollection, pHDayStaInfo, new List <int> { (int)StationConfiguration.StationID.MJQ, (int)StationConfiguration.StationID.MJQD }, new List <int> { (int)StationConfiguration.StationID.MJQ }, 35000, i); break; } //收费站大羊坊 case 5: { this.SetInfo(pBJCollection, pHDayStaInfo, new List <int> { (int)StationConfiguration.StationID.DYF }, new List <int> { (int)StationConfiguration.StationID.DYF }, 60000, i); break; } case 6: //空数据 { pHDayStaInfo.LineType = i; break; } } if (pList.Count <= 0) { db.RP_HDayAADTSta.Add(pHDayStaInfo); } } using (TransactionScope tran = new TransactionScope()) { db.SaveChanges(); tran.Complete(); } } string endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); SystemLog.GetInstance().Log.Info(string.Format("{0}:结束获取18报表数据", endTime)); SystemLog.GetInstance().Log.Info(string.Format("统计18报表数据耗时{0}秒", (DateTime.Parse(endTime) - DateTime.Parse(startTime)).TotalSeconds)); //显示执行该方法的线程ID //SystemLog.GetInstance().Log.Info(string.Format("调用18Update的线程ID为:{0}", Thread.CurrentThread.ManagedThreadId)); Thread.Sleep(1000); } catch (Exception ex) { throw ex; } }
/// <summary> /// 更新或获取报表5,6数据 /// </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}:开始获取5,6报表数据", startTime)); using (DataSubmittedEntities db = new DataSubmittedEntities()) { DateTime pDt = DateTime.Parse(dt.ToShortDateString()); //北京段包含出入口收费站 List <int> BJStation = StationConfiguration.GetBJStaion(); //获取数据//p.VehType == 0 表示合计数据, IEnumerable <DS_DataSource> pCollection = db.DS_DataSource.Where(p => DbFunctions.TruncateTime(p.CalcuTime) == DbFunctions.TruncateTime(dt) && p.VehType == 0); //判断北京段数据是否已存在,StaType:1表示北京段,33表示泗村店 RP_EnEx pBJEnExInfo = null; RP_EnEx pSCDEnExInfo = null; bool pIsHas = false; //北京段数据 List <RP_EnEx> pBJList = db.RP_EnEx.Where(p => p.CalcuTime == pDt && p.StaType == (int)StationConfiguration.StationType.BeiJingDuan).ToList(); if (pBJList.Count > 0) { pBJEnExInfo = pBJList.FirstOrDefault(); //每种状态需要重新赋值,防止公用同一个变量,值不明确 pIsHas = true; } else { pBJEnExInfo = new RP_EnEx(); pIsHas = false; } //更新北京段实体信息 UpdateInfo(pCollection.Where(s => BJStation.Contains(s.StaID.Value)), pBJEnExInfo, (int)StationConfiguration.StationType.BeiJingDuan, pDt, pIsHas); //泗村店数据 List <RP_EnEx> pSCDList = db.RP_EnEx.Where(p => p.CalcuTime == pDt && p.StaType == (int)StationConfiguration.StationID.SCD).ToList(); if (pSCDList.Count > 0) { pSCDEnExInfo = pSCDList.FirstOrDefault(); pIsHas = true; } else { pSCDEnExInfo = new RP_EnEx(); pIsHas = false; } //更新泗村店实体信息 UpdateInfo(pCollection.Where(s => s.StaID.Value == (int)StationConfiguration.StationID.SCD), pSCDEnExInfo, (int)StationConfiguration.StationID.SCD, pDt, pIsHas); //更新或添加到数据库 using (TransactionScope trans = new TransactionScope()) { //如果不存在,则添加,否则则更新 if (pBJList.Count <= 0) { db.RP_EnEx.Add(pBJEnExInfo); } if (pSCDList.Count <= 0) { db.RP_EnEx.Add(pSCDEnExInfo); } db.SaveChanges(); trans.Complete(); } } string endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); SystemLog.GetInstance().Log.Info(string.Format("{0}:结束获取5,6报表数据", endTime)); SystemLog.GetInstance().Log.Info(string.Format("统计5,6报表数据耗时{0}秒", (DateTime.Parse(endTime) - DateTime.Parse(startTime)).TotalSeconds)); //显示执行该方法的线程ID //SystemLog.GetInstance().Log.Info(string.Format("调用5,6Update的线程ID为:{0}", Thread.CurrentThread.ManagedThreadId)); Thread.Sleep(1000); } catch (Exception ex) { throw ex; } }
/// <summary> /// 8.9.10数据源更新方法 /// </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}:开始获取8,9,10报表数据", startTime)); using (DataSubmittedEntities db = new DataSubmittedEntities()) { DateTime plasttime = new DateTime(); List <OT_HDayConfig> pdayconfigs = db.OT_HDayConfig.Where(s => s.Id == 9).ToList(); OT_HDayConfig pdayconfig = new OT_HDayConfig(); if (pdayconfigs.Count > 0) { pdayconfig = pdayconfigs.First(); if (pdayconfig.HDayStart.HasValue && pdayconfig.HDayEnd.HasValue) { int ptemp = 0; //判断当天是否在假期配置时间范围内 DateTime ptempdt = DateTime.Parse(dt.ToShortDateString()); if (ptempdt >= pdayconfig.HDayStart.Value && ptempdt <= pdayconfig.HDayEnd) { //间隔的天数 ptemp = (ptempdt - pdayconfig.HDayStart.Value).Days; } if (pdayconfig.CompStart.HasValue) { plasttime = pdayconfig.CompStart.Value.AddDays(ptemp); } } } List <RP_AADTSta> pOlds = db.RP_AADTSta.Where(s => s.CalculTime == plasttime).ToList(); //判断去年同期是否存在 RP_AADTSta oldinfo = new RP_AADTSta(); if (pOlds.Count > 0) { oldinfo = pOlds.First(); } DateTime pdt = DateTime.Parse(dt.ToShortDateString()); //北京段包含出入口收费站 List <int> BJStation = StationConfiguration.GetBJStaion(); //北京段只包含出口收费站 List <int> outBJStation = StationConfiguration.GetOutBJStaion(); //获取北京段数据//p.VehType == 0 表示合计数据, IEnumerable <DS_DataSource> pBJCollection = db.DS_DataSource.Where(p => DbFunctions.TruncateTime(p.CalcuTime) == DbFunctions.TruncateTime(dt) && p.VehType == 0 && BJStation.Contains(p.StaID.Value)); //判断数据是否已存在 RP_AADTSta pAADTStaInfo = null; List <RP_AADTSta> pList = db.RP_AADTSta.Where(p => p.CalculTime == pdt).ToList(); if (pList.Count > 0)//已存在,则更新 { pAADTStaInfo = pList.FirstOrDefault(); pAADTStaInfo.UpdDate = DateTime.Now; pAADTStaInfo.State = "1"; } else//不存在,添加 { pAADTStaInfo = new RP_AADTSta(); pAADTStaInfo.Id = Guid.NewGuid(); pAADTStaInfo.CrtDate = DateTime.Now; pAADTStaInfo.State = "0"; } //涉及到金额的单位全部转为万元,保留两位小数 //出京路线总交通量,不包括绿通 pAADTStaInfo.LineExSum = pBJCollection.Where(s => outBJStation.Contains(s.StaID.Value) && s.CalcuType != 3).Sum(s => s.InNum); //入京路线总交通量,不包括绿通 pAADTStaInfo.LineEnSum = pBJCollection.Where(s => BJStation.Contains(s.StaID.Value) && s.CalcuType != 3).Sum(s => s.OutNum); pAADTStaInfo.LineSum = pAADTStaInfo.LineEnSum + pAADTStaInfo.LineExSum; //总交通量同比增幅 if (oldinfo.LineSum.HasValue) { pAADTStaInfo.SumGrow = double.Parse(string.Format("{0:0.00}", (pAADTStaInfo.LineSum - oldinfo.LineSum) / oldinfo.LineSum)); } //出进京比 pAADTStaInfo.ExEnPer = double.Parse(string.Format("{0:0.00}", (pAADTStaInfo.LineExSum / pAADTStaInfo.LineEnSum))); //收费/免征总金额 pAADTStaInfo.FeeSum = Math.Round(pBJCollection.Sum(s => s.RecMoney.Value) / 10000, 2); //出京小型客车免费通行交通量 pAADTStaInfo.ExSmaCarFee = pBJCollection.Where(s => s.CalcuType == 0 && outBJStation.Contains(s.StaID.Value)).Sum(s => s.InNum); //进京小型客车免费通行交通量 pAADTStaInfo.EnSmaCarFee = pBJCollection.Where(s => s.CalcuType == 0).Sum(s => s.OutNum); //小型客车免费通行交通量(合计) pAADTStaInfo.SmaCarFeeNum = pAADTStaInfo.ExSmaCarFee + pAADTStaInfo.EnSmaCarFee; //小型客车交通量同比增幅 if (oldinfo.SmaCarFeeNum.HasValue) { pAADTStaInfo.SmaCarCompGrow = double.Parse(string.Format("{0:0.00}", (pAADTStaInfo.SmaCarFeeNum - oldinfo.SmaCarFeeNum) / oldinfo.SmaCarFeeNum)); }//小型客车免费金额 pAADTStaInfo.SmaCarFee = Math.Round(pBJCollection.Where(s => s.CalcuType.Value == 0).Sum(s => s.RecMoney.Value) / 10000, 2); //出京收费车辆 pAADTStaInfo.ExChagNum = pBJCollection.Where(s => outBJStation.Contains(s.StaID.Value) && (s.CalcuType == 1 || s.CalcuType == 2)).Sum(s => s.InNum); //进京收费车辆 pAADTStaInfo.EnChagNum = pBJCollection.Where(s => s.CalcuType == 1 || s.CalcuType == 2).Sum(s => s.OutNum); //收费车辆合计 pAADTStaInfo.ChagSumNum = pAADTStaInfo.ExChagNum + pAADTStaInfo.EnChagNum; //收费额度 pAADTStaInfo.ChagAmount = Math.Round(pBJCollection.Where(s => s.CalcuType == 1 || s.CalcuType == 2).Sum(s => s.RecMoney.Value) / 10000, 2); //绿色通道车辆数 pAADTStaInfo.GreNum = pBJCollection.Where(s => s.CalcuType == 3).Sum(s => s.OutNum); //绿色通道免收费金额 pAADTStaInfo.GreFee = Math.Round(pBJCollection.Where(s => s.CalcuType == 3).Sum(s => s.RecMoney.Value) / 10000, 2); //出京总交通量(站) pAADTStaInfo.StaExSum = pBJCollection.Where(s => s.StaID == (int)StationConfiguration.StationID.DYF).Sum(s => s.InNum); //进京总交通量(站) pAADTStaInfo.StaEnSum = pBJCollection.Where(s => s.StaID == (int)StationConfiguration.StationID.DYF).Sum(s => s.OutNum); pAADTStaInfo.CalculTime = pdt; using (TransactionScope trans = new TransactionScope()) { if (pList.Count <= 0) { db.RP_AADTSta.Add(pAADTStaInfo); } db.SaveChanges(); trans.Complete(); } } string endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); SystemLog.GetInstance().Log.Info(string.Format("{0}:结束获取8,9,10报表数据", endTime)); SystemLog.GetInstance().Log.Info(string.Format("统计8,9,10报表数据耗时{0}秒", (DateTime.Parse(endTime) - DateTime.Parse(startTime)).TotalSeconds)); //显示执行该方法的线程ID //SystemLog.GetInstance().Log.Info(string.Format("调用8,9,10Update的线程ID为:{0}", Thread.CurrentThread.ManagedThreadId)); Thread.Sleep(1000); } catch (Exception ex) { throw ex; } }