Beispiel #1
0
 /// <summary>
 /// 补充数据
 /// </summary>
 /// <param name="dt"></param>
 /// <param name="hour"></param>
 /// <param name="stationtype"></param>
 private void InsertNull(DateTime dt, byte hour, int stationtype)
 {
     using (DataSubmittedEntities db = new DataSubmittedEntities())
     {
         if (db.RP_NatSta.Where(s => s.CalcuTime == dt && s.StaType == stationtype && s.HourPer == hour).Count() <= 0)
         {
             using (TransactionScope trans = new TransactionScope())
             {
                 db.RP_NatSta.Add(new RP_NatSta()
                 {
                     Id        = Guid.NewGuid(),
                     HourPer   = hour,
                     Sum       = 0,
                     EnNum     = 0,
                     ExNum     = 0,
                     RunStae   = SystemConst.RunningStatus,
                     CalcuTime = dt,
                     StaType   = stationtype,
                     State     = "0"
                 });
                 db.SaveChanges();
                 trans.Complete();
             }
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// 添加节点,知道父节点的名称
        /// </summary>
        /// <param name="model">节点实体</param>
        /// <param name="name">父节点名称</param>
        /// <returns>添加结果</returns>
        public CustomResult Add(DAL.OT_Dic model, string name)
        {
            model.Name = model.Name.Trim();//去除空格
            using (TransactionScope transaction = new TransactionScope())
            {
                List <DictionaryViewModel> info = GetList(name);//获取根节点信息
                CustomResult pReturnValue       = new CustomResult();
                if (info != null && info.Count > 0)
                {
                    //检查同一级别的节点中是否已经存在了该节点的名称
                    var id = db.OT_Dic.Where(a => a.Belong == info[0].DictId & a.Name == model.Name).ToList().Select(a => new
                    {
                        a.Id
                    }).ToList();

                    if (id != null && id.Count > 0)
                    {
                        pReturnValue.ResultKey   = (byte)ENodeAddResult.Exist;
                        pReturnValue.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.Exist;
                    }
                    else
                    {
                        //添加节点
                        db.OT_Dic.Add(model);
                        if (db.SaveChanges() > 0)
                        {
                            transaction.Complete();
                            pReturnValue.ResultKey   = (byte)ENodeAddResult.Succeed;
                            pReturnValue.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.Success;
                        }
                        else
                        {
                            pReturnValue.ResultKey   = (byte)ENodeAddResult.Fail;
                            pReturnValue.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.Failed;
                        }
                    }
                }
                else
                {
                    pReturnValue.ResultKey   = (byte)ENodeAddResult.Inexist;
                    pReturnValue.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.Inexist;
                }
                return(pReturnValue);
            }
        }
Beispiel #3
0
        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>
        /// 补数据
        /// </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.CalculTime).ToList().Contains(dtime);
                            if (!flag)//补数据
                            {
                                RP_AADTSta hday = new RP_AADTSta();
                                hday.CalculTime = dtime;
                                if (SessionManage.GetLoginUser() != null)
                                {
                                    hday.CrtBy = SessionManage.GetLoginUser().UserName;
                                }
                                hday.CrtDate   = DateTime.Now;
                                hday.Id        = Guid.NewGuid();
                                hday.LineEnSum = 0;
                                hday.LineExSum = 0;
                                db.RP_AADTSta.Add(hday);
                            }
                            else//将数据中有空值的改成0
                            {
                                var hday = db.RP_AADTSta.Where(a => a.CalculTime == dtime).ToList()[0];
                                if (hday.LineEnSum == null)
                                {
                                    hday.LineEnSum = 0;
                                }
                                if (hday.LineExSum == null)
                                {
                                    hday.LineExSum = 0;
                                }
                            }
                        }
                    }
                    try
                    {
                        db.SaveChanges();
                        transaction.Complete();
                    }
                    catch (Exception ex)
                    {
                        SystemLog.GetInstance().Error(TipInfo.AddFaile, ex);
                    }
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// 创建或修改15,16合计
        /// </summary>
        /// <param name="para"></param>
        /// <param name="stationtype">收费站类型</param>
        public void CreateOrUpdateSum(QueryParameters para, int stationtype)
        {
            using (DataSubmittedEntities db = new DataSubmittedEntities())
            {
                #region 合计
                //查询日期当天除合计外的全部数据
                IEnumerable <RP_NatSta> naturalall = db.RP_NatSta.Where(s => s.CalcuTime == para.StartTime && s.StaType == stationtype && s.HourPer != 24);

                IEnumerable <RP_NatSta> naturallistsum = db.RP_NatSta.Where(s => s.CalcuTime == para.StartTime && s.HourPer == 24 && s.StaType == stationtype);
                RP_NatSta natural = new RP_NatSta();
                //如果有数据则进行合计
                if (naturalall.Count() > 0)
                {
                    if (naturallistsum.Count() > 0)
                    {
                        natural = naturallistsum.First();
                    }

                    natural.Sum     = naturalall.Sum(s => s.Sum);
                    natural.ExNum   = naturalall.Sum(s => s.ExNum);
                    natural.EnNum   = naturalall.Sum(s => s.EnNum);
                    natural.State   = "1";
                    natural.UpdDate = DateTime.Now;
                    using (TransactionScope transaction = new TransactionScope())
                    {
                        if (naturallistsum.Count() <= 0)
                        {
                            natural.RunStae   = "正常";
                            natural.HourPer   = 24;//24代表合计
                            natural.Id        = Guid.NewGuid();
                            natural.StaType   = stationtype;
                            natural.CalcuTime = (DateTime)para.StartTime;
                            natural.CrtDate   = DateTime.Now;
                            db.RP_NatSta.Add(natural);
                        }
                        db.SaveChanges();
                        //提交事务
                        transaction.Complete();
                    }
                    #endregion
                }
            }
            #endregion

            #region 10 Static Methods
            #endregion

            #region 11 Private Methods
            #endregion

            #region 12 Protected Methods
            #endregion
        }
Beispiel #6
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public Common.CustomResult Update(Common.ViewModels.UpdateEnExViewModel args)
        {
            using (DataSubmittedEntities db = new DataSubmittedEntities())
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    CustomResult pReturnValue = new CustomResult();

                    DateTime dt = new DateTime();
                    if (DateTime.TryParse(args.DataInfo[0].CalcuTime, out dt))
                    {
                        var list = db.RP_EnEx.Where(a => a.CalcuTime == dt & a.StaType == args.StationType).ToList();
                        if (list != null && list.Count > 0 && args.DataInfo != null && args.DataInfo.Count > 0)
                        {
                            // list[0].CalcuTime = args.DataInfo[0].CalcuTime;
                            //  list[0].EnGre = args.DataInfo[0].EnGre;

                            list[0].EnOthCar = args.DataInfo[0].EnOthCar;
                            list[0].EnSmaCar = args.DataInfo[0].EnSmaCar;
                            list[0].EnTruk   = args.DataInfo[0].EnTruk;
                            list[0].State    = "1";
                            list[0].UpdDate  = DateTime.Now;
                            if (SessionManage.GetLoginUser() != null)
                            {
                                list[0].UpdBy = SessionManage.GetLoginUser().UserName;
                            }
                        }
                        try
                        {
                            db.SaveChanges();
                            transaction.Complete();
                            pReturnValue.ResultKey   = (byte)EResult.Succeed;
                            pReturnValue.ResultValue = TipInfo.UpdateSuccess;
                            return(pReturnValue);
                        }
                        catch (Exception ex)
                        {
                            Common.SystemLog.GetInstance().Log.Info(TipInfo.UpdateDataRepeat, ex);
                            pReturnValue.ResultKey   = (byte)EResult.Fail;
                            pReturnValue.ResultValue = TipInfo.UpdateDataRepeat;
                            return(pReturnValue);
                        }
                    }
                    else
                    {
                        pReturnValue.ResultKey   = (byte)EResult.Fail;
                        pReturnValue.ResultValue = TipInfo.DateTimeIsNull;
                        return(pReturnValue);
                    }
                }
            }
        }
        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}:开始获取7报表数据", startTime));
                using (DataSubmittedEntities db = new DataSubmittedEntities())
                {
                    DateTime pDt = DateTime.Parse(dt.ToShortDateString());

                    //获取数据//p.VehType == 0 表示合计数据,
                    IEnumerable <DS_DataSource> pCollection = db.DS_DataSource.Where(p =>
                                                                                     DbFunctions.TruncateTime(p.CalcuTime) == DbFunctions.TruncateTime(dt) &&
                                                                                     p.VehType == 0 && p.StaID == (int)StationConfiguration.StationID.DYF);
                    //大羊坊单日数据
                    List <RP_AADTAndTransCalcu> pList     = db.RP_AADTAndTransCalcu.Where(p => p.CalcuTime == pDt).ToList();
                    RP_AADTAndTransCalcu        pAADTInfo = null;
                    bool pIsHas = false;
                    if (pList.Count > 0)
                    {
                        pAADTInfo = pList.FirstOrDefault();
                        pIsHas    = true;
                    }
                    else
                    {
                        pAADTInfo = new RP_AADTAndTransCalcu();
                    }
                    //更新实体
                    UpdateInfo(pCollection, pAADTInfo, pDt, pIsHas);
                    using (TransactionScope transaction = new TransactionScope())
                    {
                        //如果不存在,则添加,否则则更新
                        if (pList.Count <= 0)
                        {
                            db.RP_AADTAndTransCalcu.Add(pAADTInfo);
                        }
                        db.SaveChanges();
                        transaction.Complete();
                    }
                }
                string endTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                SystemLog.GetInstance().Log.Info(string.Format("{0}:结束获取7报表数据", endTime));
                SystemLog.GetInstance().Log.Info(string.Format("统计7报表数据耗时{0}秒", (DateTime.Parse(endTime) - DateTime.Parse(startTime)).TotalSeconds));
                //显示执行该方法的线程ID
                //SystemLog.GetInstance().Log.Info(string.Format("调用7Update的线程ID为:{0}", Thread.CurrentThread.ManagedThreadId));
                Thread.Sleep(1000);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 /// <summary>
 /// 修改数据信息
 /// </summary>
 /// <typeparam name="T">数据表类型集合</typeparam>
 /// <param name="args">参数</param>
 /// <returns>影响行数</returns>
 public CustomResult Update(UpdateHdayExViewModel args)
 {
     using (DataSubmittedEntities db = new DataSubmittedEntities())
     {
         using (TransactionScope transaction = new TransactionScope())
         {
             CustomResult    pReturnValue = new CustomResult();
             int             count        = (args.EndTime.Value - args.StartTime.Value).Days + 1;
             HDayExViewModel model        = null;
             if (args.DataInfo.Count > 0)
             {
                 if (args.DataInfo[0].Num == 15)
                 {
                     model = args.DataInfo[0];
                 }
             }
             try
             {
                 for (int i = 0; i < count; i++)
                 {
                     DateTime pDateTime = args.StartTime.Value.AddDays(i);
                     var      listHDa   = db.RP_HDayAADT.Where(a => a.CalcuTime == pDateTime).ToList();
                     foreach (RP_HDayAADT hd in listHDa)
                     {
                         Type         myType = model.GetType();
                         PropertyInfo pinfo  = myType.GetProperty("Tra" + (i + 1));
                         hd.Out     = (double)pinfo.GetValue(model);
                         hd.UpdDate = DateTime.Now;
                         hd.State   = "1";
                         if (SessionManage.GetLoginUser() != null)
                         {
                             hd.UpdBy = SessionManage.GetLoginUser().UserName;
                         }
                     }
                 }
                 db.SaveChanges();
                 transaction.Complete();
                 pReturnValue.ResultKey   = (byte)EResult.Succeed;
                 pReturnValue.ResultValue = TipInfo.UpdateSuccess;
                 return(pReturnValue);
             }
             catch (Exception ex)
             {
                 Common.SystemLog.GetInstance().Log.Info(TipInfo.UpdateDataRepeat, ex);
                 pReturnValue.ResultKey   = (byte)EResult.Fail;
                 pReturnValue.ResultValue = TipInfo.UpdateDataRepeat;
                 return(pReturnValue);
             }
         }
     }
 }
Beispiel #9
0
        /// <summary>
        /// 添加文件导出记录
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public byte Create(OT_ExportHis args)
        {
            byte num;

            using (DataSubmittedEntities db = new DataSubmittedEntities())
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    db.OT_ExportHis.Add(args);
                    num = (byte)db.SaveChanges();
                    transaction.Complete();
                }
            }
            return(num);
        }
Beispiel #10
0
        /// <summary>
        /// 数据提交结果-删除
        /// </summary>
        /// <param name="db">提交数据库对象</param>
        /// <returns>提交结果</returns>
        public static CustomResult DelChangesResult(DataSubmittedEntities db)
        {
            CustomResult pReturnValue = new CustomResult();

            if (db.SaveChanges() > 0)
            {
                pReturnValue.ResultKey   = (byte)EResult.Succeed;
                pReturnValue.ResultValue = Resources.TipInfo.DeleteSuccess;
            }
            else
            {
                pReturnValue.ResultKey   = (byte)EResult.Fail;
                pReturnValue.ResultValue = Resources.TipInfo.DeleteFaile;
            }
            return(pReturnValue);
        }
Beispiel #11
0
        /// <summary>
        /// 创建或修改13,14合计
        /// </summary>
        /// <param name="para"></param>
        /// <param name="stationtype">收费站类型</param>
        private void CreateOrUpdateSum(QueryParameters para)
        {
            using (DataSubmittedEntities db = new DataSubmittedEntities())
            {
                //查询日期当天除合计外的全部数据
                IEnumerable <RP_HourAADT> all = db.RP_HourAADT.Where(s => s.CalcuTime == para.StartTime && s.HourPer != 24);

                IEnumerable <RP_HourAADT> listsum = db.RP_HourAADT.Where(s => s.CalcuTime == para.StartTime && s.HourPer == 24);
                RP_HourAADT pHourAADT             = new RP_HourAADT();
                //如果有数据则进行合计
                if (all.Count() > 0)
                {
                    if (listsum.Count() > 0)
                    {
                        pHourAADT = listsum.First();
                    }
                    pHourAADT.Dyf_ExIn   = all.Sum(s => s.Dyf_ExIn);
                    pHourAADT.Dyf_EnOut  = all.Sum(s => s.Dyf_EnOut);
                    pHourAADT.Mjqd_EnIn  = all.Sum(s => s.Mjqd_EnIn);
                    pHourAADT.Mjqd_EnOut = all.Sum(s => s.Mjqd_EnOut);
                    pHourAADT.Mjqx_EnOut = all.Sum(s => s.Mjqx_EnOut);
                    pHourAADT.Mjqx_ExIn  = all.Sum(s => s.Mjqx_ExIn);
                    pHourAADT.Cy_EnOut   = all.Sum(s => s.Cy_EnOut);
                    pHourAADT.Cy_ExIn    = all.Sum(s => s.Cy_ExIn);
                    pHourAADT.State      = "1";
                    using (TransactionScope transaction = new TransactionScope())
                    {
                        if (listsum.Count() <= 0)
                        {
                            pHourAADT.HourPer   = 24;//24代表合计
                            pHourAADT.Id        = Guid.NewGuid();
                            pHourAADT.CalcuTime = (DateTime)para.StartTime;
                            pHourAADT.CrtDate   = DateTime.Now;
                            pHourAADT.State     = "0";
                            db.RP_HourAADT.Add(pHourAADT);
                        }
                        else
                        {
                            pHourAADT.UpdDate = DateTime.Now;
                        }
                        db.SaveChanges();
                        //提交事务
                        transaction.Complete();
                    }
                }
            }
        }
        /// <summary>
        /// 初始化单条密码
        /// </summary>
        /// <param name="listUserRoleId">用户角色关系编号集合</param>
        /// <returns>修改结构</returns>
        public CustomResult StartPassword(List <Guid> listUserId)
        {
            using (DataSubmittedEntities db = new DataSubmittedEntities())
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    int    flag     = 0;
                    string password = ConfigurationManager.AppSettings["StartPassword"];
                    foreach (Guid userId in listUserId)
                    {
                        var list = db.OT_User.Where(a => a.Id == userId & a.IsDelete == (byte)EUserStatus.Normal).ToList();

                        if (list != null && list.Count > 0)
                        {
                            foreach (var i in list)
                            {
                                i.Password = password;
                            }
                            flag++;
                        }
                    }
                    if (flag > 0)
                    {
                        CustomResult pReturnValue = new CustomResult();
                        if (db.SaveChanges() > 0)
                        {
                            transaction.Complete();
                            pReturnValue.ResultKey   = (byte)EResult.Succeed;
                            pReturnValue.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.StartPassword;
                        }
                        else
                        {
                            pReturnValue.ResultKey   = (byte)EResult.Fail;//程序已经使用多处,所有不变动
                            pReturnValue.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.StartPassword;
                        }
                        return(pReturnValue);
                    }
                    else
                    {
                        CustomResult pReturnValue = new CustomResult();
                        pReturnValue.ResultKey   = (byte)EResult.Fail;//程序已经使用多处,所有不变动
                        pReturnValue.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.Inexist;
                        return(pReturnValue);
                    }
                }
            }
        }
Beispiel #13
0
        /// <summary>
        /// 返回带事物的提交结果-新增
        /// </summary>
        /// <param name="db">提交数据库对象</param>
        /// <param name="transaction">事物</param>
        /// <returns>提交结果</returns>
        public static CustomResult SaveChangesResult(DataSubmittedEntities db, TransactionScope transaction)
        {
            CustomResult pReturnValue = new CustomResult();

            if (db.SaveChanges() > 0)
            {
                transaction.Complete();
                pReturnValue.ResultKey   = (byte)EResult.Succeed;
                pReturnValue.ResultValue = Resources.TipInfo.AddSuccess;
            }
            else
            {
                pReturnValue.ResultKey   = (byte)EResult.Fail;
                pReturnValue.ResultValue = Resources.TipInfo.AddFaile;
            }
            return(pReturnValue);
        }
Beispiel #14
0
        /// <summary>
        /// 数据提交结果-修改使用
        /// </summary>
        /// <param name="db">提交数据库对象</param>
        /// <returns>提交结果</returns>
        public static CustomResult SaveUpdateResult(DataSubmittedEntities db)
        {
            CustomResult pReturnValue = new CustomResult();

            try
            {
                db.SaveChanges();
                pReturnValue.ResultKey   = (byte)EResult.Succeed;
                pReturnValue.ResultValue = Resources.TipInfo.UpdateSuccess;
            }
            catch (Exception ex)
            {
                SystemLog.GetInstance().Error(TipInfo.UpdateFaile, ex);
                pReturnValue.ResultKey   = (byte)EResult.Fail;//程序已经使用多处,所有不变动
                pReturnValue.ResultValue = Resources.TipInfo.UpdateFaile;
            }
            return(pReturnValue);
        }
Beispiel #15
0
 /// <summary>
 /// 补充数据
 /// </summary>
 /// <param name="dt">统计日期</param>
 private void InsertNull(DateTime dt)
 {
     using (DataSubmittedEntities db = new DataSubmittedEntities())
     {
         int ptemp = 24;
         if (DateTime.Now.Date == dt)
         {
             ptemp = DateTime.Now.Hour;
         }
         List <RP_HourAADT> pList = new List <RP_HourAADT>();
         for (int i = 0; i < ptemp; i++)
         {
             List <RP_HourAADT> pTemp = db.RP_HourAADT.Where(s => s.CalcuTime == dt && s.HourPer == (byte)i).ToList();
             //如果数据不存在,才补充
             if (pTemp.Count <= 0)
             {
                 RP_HourAADT pHour = new RP_HourAADT();
                 pHour.Id         = Guid.NewGuid();
                 pHour.Mjqd_EnIn  = 0;
                 pHour.Mjqd_EnOut = 0;
                 pHour.Dyf_EnOut  = 0;
                 pHour.Dyf_ExIn   = 0;
                 pHour.Mjqx_EnOut = 0;
                 pHour.Mjqx_ExIn  = 0;
                 pHour.Cy_EnOut   = 0;
                 pHour.Cy_ExIn    = 0;
                 pHour.State      = "0";
                 pHour.CalcuTime  = dt;
                 pHour.CrtDate    = DateTime.Now;
                 pHour.HourPer    = (byte)i;
                 pList.Add(pHour);
             }
         }
         using (TransactionScope transac = new TransactionScope())
         {
             db.RP_HourAADT.AddRange(pList);
             if (pList.Count > 0)
             {
                 db.SaveChanges();
                 transac.Complete();
             }
         }
     }
 }
        /// <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();
                }
            }
        }
Beispiel #17
0
        /// <summary>
        /// 补充数据
        /// </summary>
        /// <param name="dt">统计日期</param>
        /// <param name="stationtype">统计类型</param>
        private void InsertNull(DateTime dt, int stationtype)
        {
            using (DataSubmittedEntities db = new DataSubmittedEntities())
            {
                List <RP_Daily> pDailyList = new List <RP_Daily>();
                for (int i = 0; i < 4; i++)
                {
                    //0小型客车,1其他客车,2货车(不包含绿通),3绿通
                    //每个站只有四条合计数据,每天数据表里一共只有16条
                    List <RP_Daily> pTemp = db.RP_Daily.Where(s => s.CalcuTime == dt && s.VehType == i && s.StaType == stationtype).ToList();
                    //如果数据不存在,才补充
                    if (pTemp.Count <= 0)
                    {
                        RP_Daily pDaily = new RP_Daily();

                        pDaily.Id        = Guid.NewGuid();
                        pDaily.CrtDate   = DateTime.Now;
                        pDaily.VehType   = i;//车辆类型
                        pDaily.StaType   = stationtype;
                        pDaily.State     = 0;
                        pDaily.OutNum    = 0;
                        pDaily.InNum     = 0;
                        pDaily.ChagFee   = 0;
                        pDaily.CalcuTime = DateTime.Parse(dt.ToShortDateString());
                        pDailyList.Add(pDaily);
                    }
                }
                using (TransactionScope transac = new TransactionScope())
                {
                    db.RP_Daily.AddRange(pDailyList);
                    if (pDailyList.Count > 0)
                    {
                        db.SaveChanges();
                        transac.Complete();
                    }
                }
            }
        }
Beispiel #18
0
        /// <summary>
        /// 补充数据
        /// </summary>
        /// <param name="dt">统计日期</param>
        private void InsertNull(DateTime dt)
        {
            using (DataSubmittedEntities db = new DataSubmittedEntities())
            {
                RP_AADTSta info = new RP_AADTSta();
                info.Id             = Guid.NewGuid();
                info.CrtDate        = DateTime.Now;
                info.State          = "0";
                info.CalculTime     = dt;
                info.LineSum        = 0;
                info.SumGrow        = -1;
                info.LineExSum      = 0;
                info.LineEnSum      = 0;
                info.ExEnPer        = 0;
                info.FeeSum         = 0;
                info.SmaCarFeeNum   = 0;
                info.ExSmaCarFee    = 0;
                info.EnSmaCarFee    = 0;
                info.SmaCarFee      = 0;
                info.SmaCarCompGrow = 0;
                info.ChagSumNum     = 0;
                info.ExChagNum      = 0;
                info.EnChagNum      = 0;
                info.ChagAmount     = 0;
                info.GreNum         = 0;
                info.GreFee         = 0;
                info.StaExSum       = 0;
                info.StaEnSum       = 0;

                using (TransactionScope transac = new TransactionScope())
                {
                    db.RP_AADTSta.Add(info);
                    db.SaveChanges();
                    transac.Complete();
                }
            }
        }
Beispiel #19
0
        /// <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);
            }
        }
Beispiel #20
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public Common.CustomResult Update(Common.ViewModels.UpdateHDayStaExEnViewModel args)
        {
            using (DataSubmittedEntities db = new DataSubmittedEntities())
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    CustomResult pReturnValue = new CustomResult();

                    bool flag  = false;//标记数据库中是否有数据修改
                    int  count = (args.EndTime - args.StartTime).Days + 1;

                    for (int j = 1; j < args.DataInfo.Count; j++)
                    {
                        HDayStaExEnViewModel model = args.DataInfo[j];

                        Type myType0 = qModel.TitleList[0].GetType();

                        for (int i = 1; i < count + 1; i++)
                        {
                            Type         myType = model.GetType();
                            PropertyInfo pinfo  = myType.GetProperty("Date" + i);
                            PropertyInfo pinfo0 = myType0.GetProperty("Date" + i);
                            if (args.StartTime.AddDays(i - 1).ToString("M月d日").ToString() == pinfo0.GetValue(qModel.TitleList[0]).ToString())
                            {
                                DateTime dt   = args.StartTime.AddDays(i - 1);
                                var      list = db.RP_HDayAADT.Where(a => a.CalcuTime == dt).ToList();

                                double info = double.Parse(pinfo.GetValue(model).ToString());

                                foreach (var item in list)
                                {
                                    flag = true;
                                    if (model.Num == "43")//杨村站
                                    {
                                        item.YC = info;
                                    }
                                    else if (model.Num == "44")//宜兴埠东站
                                    {
                                        item.YXBD = info;
                                    }
                                    else if (model.Num == "45")//宜兴埠西站
                                    {
                                        item.YXBX = info;
                                    }
                                    else if (model.Num == "46")//金钟路站
                                    {
                                        item.JZL = info;
                                    }
                                    else if (model.Num == "47")//机场站
                                    {
                                        item.JC = info;
                                    }
                                    else if (model.Num == "48")//空港经济区站
                                    {
                                        item.KG = info;
                                    }
                                    else if (model.Num == "49")//塘沽西站
                                    {
                                        item.TGX = info;
                                    }
                                    else if (model.Num == "50")//塘沽西分站
                                    {
                                        item.TGXF = info;
                                    }
                                    else if (model.Num == "51")//塘沽北站
                                    {
                                        item.TGB = info;
                                    }

                                    item.UpdDate = DateTime.Now;
                                    if (SessionManage.GetLoginUser() != null)
                                    {
                                        item.UpdBy = SessionManage.GetLoginUser().UserName;
                                    }
                                    item.State = "1";
                                }
                            }
                        }
                    }
                    if (flag)//有修改成功的数据
                    {
                        try
                        {
                            db.SaveChanges();
                            transaction.Complete();
                            pReturnValue.ResultKey   = (byte)EResult.Succeed;
                            pReturnValue.ResultValue = TipInfo.UpdateSuccess;
                            return(pReturnValue);
                        }
                        catch (Exception ex)
                        {
                            Common.SystemLog.GetInstance().Log.Info(TipInfo.UpdateDataRepeat, ex);
                            pReturnValue.ResultKey   = (byte)EResult.Fail;
                            pReturnValue.ResultValue = TipInfo.UpdateDataRepeat;
                            return(pReturnValue);
                        }
                    }
                    else//存在数据尚未生成
                    {
                        pReturnValue.ResultKey   = (byte)EResult.Fail;
                        pReturnValue.ResultValue = TipInfo.UpdateDataRepeat;
                        return(pReturnValue);
                    }
                }
            }
        }
        /// <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);
            }
        }
Beispiel #22
0
        /// <summary>
        /// 补数据
        /// </summary>
        /// <param name="para"></param>
        private void RepairData(QueryParameters para)
        {
            using (DataSubmittedEntities db = new DataSubmittedEntities())
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    DateTime dtQuery = new DateTime();
                    //判断传入的时间段是否正确
                    if (para.StartTime != null && DateTime.TryParse(para.StartTime.Value.ToString(), out dtQuery))
                    {
                        DateTime dtime = para.StartTime.Value;

                        //时间小于当前时间
                        if (DateTime.Now > dtime)
                        {
                            bool flag = db.RP_EnEx.Where(a => a.CalcuTime == dtime & a.StaType == para.StationType).Select(a => a.CalcuTime).ToList().Contains(dtime);
                            if (!flag)//补数据
                            {
                                RP_EnEx hday = new RP_EnEx();
                                hday.CalcuTime = dtime;

                                if (SessionManage.GetLoginUser() != null)
                                {
                                    hday.CrtBy = SessionManage.GetLoginUser().UserName;
                                }
                                hday.CrtDate  = DateTime.Now;
                                hday.Id       = Guid.NewGuid();
                                hday.EnGre    = 0;
                                hday.EnOthCar = 0;
                                hday.EnSmaCar = 0;
                                hday.EnTruk   = 0;
                                hday.State    = "0";
                                hday.StaType  = para.StationType;
                                db.RP_EnEx.Add(hday);
                            }
                            else//将数据中有空值的改成0
                            {
                                var hday = db.RP_EnEx.Where(a => a.CalcuTime == dtime & a.StaType == para.StationType).ToList()[0];
                                if (hday.EnGre == null)
                                {
                                    hday.EnGre = 0;
                                }
                                if (hday.EnOthCar == null)
                                {
                                    hday.EnOthCar = 0;
                                }
                                if (hday.EnSmaCar == null)
                                {
                                    hday.EnSmaCar = 0;
                                }
                                if (hday.EnTruk == null)
                                {
                                    hday.EnTruk = 0;
                                }
                            }
                        }
                        try
                        {
                            db.SaveChanges();
                            transaction.Complete();
                        }
                        catch (Exception ex)
                        {
                            SystemLog.GetInstance().Error(TipInfo.AddFaile, ex);
                        }
                    }
                }
            }
        }
Beispiel #23
0
        /// <summary>
        /// 校正
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public Common.CustomResult CalibrationData(Common.QueryParameters para)
        {
            CustomResult pReturnValue = new CustomResult();
            double       pFloating    = 1 + para.FloatingRange * 0.01;

            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);
                }
                //判断时间范围是否相同
                if ((para.LastYearEnd - para.LastYearStart) == (para.EndTime - para.StartTime))
                {
                    //获取参考日期符合校正时间段的数据
                    List <RP_HDayAADT> pRefNaturalList = db.RP_HDayAADT.Where(a => a.CalcuTime >= para.LastYearStart & a.CalcuTime <= para.LastYearEnd).OrderBy(a => a.CalcuTime).ToList();
                    //如果参考日期数据为0 则返回失败
                    if (pRefNaturalList == null || pRefNaturalList.Count == 0)
                    {
                        pReturnValue.ResultKey   = (byte)EResult.Fail;
                        pReturnValue.ResultValue = TipInfo.CalibrationFaileRefNoData;
                        return(pReturnValue);
                    }
                    //需要校正的数据
                    var pCheckNaturalList = db.RP_HDayAADT.Where(a => a.CalcuTime >= para.StartTime & a.CalcuTime <= para.EndTime).OrderBy(a => a.CalcuTime).ToList();
                    //如果需要校正的数据为空则返回失败
                    if (pCheckNaturalList == null || pCheckNaturalList.Count == 0)
                    {
                        pReturnValue.ResultKey   = (byte)EResult.Fail;
                        pReturnValue.ResultValue = TipInfo.CalibrationFaileNoData;
                        return(pReturnValue);
                    }
                    using (TransactionScope tran = new TransactionScope())
                    {
                        for (int i = 0; i < pCheckNaturalList.Count; i++)
                        {
                            if (pRefNaturalList[i].JC != null)
                            {
                                pCheckNaturalList[i].JC = Math.Round(pRefNaturalList[i].JC.Value * pFloating);
                            }
                            if (pRefNaturalList[i].JZL != null)
                            {
                                pCheckNaturalList[i].JZL = Math.Round(pRefNaturalList[i].JZL.Value * pFloating);
                            }
                            if (pRefNaturalList[i].KG != null)
                            {
                                pCheckNaturalList[i].KG = Math.Round(pRefNaturalList[i].KG.Value * pFloating);
                            }
                            if (pRefNaturalList[i].TGB != null)
                            {
                                pCheckNaturalList[i].TGB = Math.Round(pRefNaturalList[i].TGB.Value * pFloating);
                            }
                            if (pRefNaturalList[i].TGX != null)
                            {
                                pCheckNaturalList[i].TGX = Math.Round(pRefNaturalList[i].TGX.Value * pFloating);
                            }
                            if (pRefNaturalList[i].TGXF != null)
                            {
                                pCheckNaturalList[i].TGXF = Math.Round(pRefNaturalList[i].TGXF.Value * pFloating);
                            }
                            if (pRefNaturalList[i].YC != null)
                            {
                                pCheckNaturalList[i].YC = Math.Round(pRefNaturalList[i].YC.Value * pFloating);
                            }
                            if (pRefNaturalList[i].YXBD != null)
                            {
                                pCheckNaturalList[i].YXBD = Math.Round(pRefNaturalList[i].YXBD.Value * pFloating);
                            }
                            if (pRefNaturalList[i].YXBX != null)
                            {
                                pCheckNaturalList[i].YXBX = Math.Round(pRefNaturalList[i].YXBX.Value * pFloating);
                            }
                            if (SessionManage.GetLoginUser() != null)
                            {
                                pCheckNaturalList[i].UpdBy = SessionManage.GetLoginUser().UserName;
                            }
                            pCheckNaturalList[i].UpdDate = DateTime.Now;
                            pCheckNaturalList[i].State   = "1";
                        }
                        try
                        {
                            db.SaveChanges();
                            tran.Complete();
                            pReturnValue.ResultKey   = (byte)EResult.Succeed;
                            pReturnValue.ResultValue = TipInfo.CalibrationSuccess;
                        }
                        catch (Exception e)
                        {
                            pReturnValue.ResultKey   = (byte)EResult.Fail;
                            pReturnValue.ResultValue = TipInfo.CalibrationFaile + e.Message.ToString();
                            SystemLog.GetInstance().Error(TipInfo.CalibrationFaile, e);
                            return(pReturnValue);
                        }
                    }
                }
                else
                {
                    pReturnValue.ResultKey   = (byte)EResult.Fail;
                    pReturnValue.ResultValue = TipInfo.CalibrationRangeFaile;
                }
            }
            return(pReturnValue);
        }
        /// <summary>
        /// 补数据
        /// </summary>
        /// <param name="para"></param>
        private void RepairData(QueryParameters para)
        {
            using (DataSubmittedEntities db = new DataSubmittedEntities())
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    DateTime dtime = para.StartTime.Value;

                    //时间小于当前时间
                    if (DateTime.Now > dtime)
                    {
                        bool flag = StrWhere(db, para).Select(a => a.CalculTime).ToList().Contains(dtime);
                        if (!flag)//补数据
                        {
                            RP_AADTSta model = new RP_AADTSta();
                            model.CalculTime = dtime;
                            if (SessionManage.GetLoginUser() != null)
                            {
                                model.CrtBy = SessionManage.GetLoginUser().UserName;
                            }
                            model.CrtDate        = DateTime.Now;
                            model.Id             = Guid.NewGuid();
                            model.ChagSumNum     = 0.00;
                            model.ExEnPer        = 0.00;
                            model.LineEnSum      = 0.00;
                            model.LineExSum      = 0.00;
                            model.LineSum        = 0.00;
                            model.SmaCarCompGrow = 0.00;
                            model.SmaCarFee      = (decimal)0.00;
                            model.SmaCarFeeNum   = 0.00;
                            model.SumGrow        = 0.00;
                            model.State          = "0";
                            db.RP_AADTSta.Add(model);
                        }
                        else//将数据中有空值的改成0
                        {
                            var model = db.RP_AADTSta.Where(a => a.CalculTime == dtime).ToList()[0];
                            if (model.ChagSumNum == null)
                            {
                                model.ChagSumNum = 0.00;
                            }
                            if (model.ExEnPer == null)
                            {
                                model.ExEnPer = 0.00;
                            }
                            if (model.LineEnSum == null)
                            {
                                model.LineEnSum = 0.00;
                            }
                            if (model.LineExSum == null)
                            {
                                model.LineExSum = 0.00;
                            }
                            if (model.LineSum == null)
                            {
                                model.LineSum = 0.00;
                            }
                            if (model.SmaCarCompGrow == null)
                            {
                                model.SmaCarCompGrow = 0.00;
                            }
                            if (model.SmaCarFee == null)
                            {
                                model.SmaCarFee = (decimal)0.00;
                            }
                            if (model.SmaCarFeeNum == null)
                            {
                                model.SmaCarFeeNum = 0.00;
                            }
                            if (model.SumGrow == null)
                            {
                                model.SumGrow = 0.00;
                            }
                        }
                    }
                    try
                    {
                        db.SaveChanges();
                        transaction.Complete();
                    }
                    catch (Exception ex)
                    {
                        SystemLog.GetInstance().Error(TipInfo.AddFaile, ex);
                    }
                }
            }
        }
Beispiel #25
0
        /// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public CustomResult Update(UpdateNaturalInfoViewModel args)
        {
            CustomResult pReturnValue = new CustomResult();

            pReturnValue.ResultKey   = (byte)EResult.Fail;
            pReturnValue.ResultValue = TipInfo.UpdateFaile;
            if (args.UpdateData == null)
            {
                pReturnValue.ResultKey   = (byte)EResult.Succeed;
                pReturnValue.ResultValue = TipInfo.DataNull;
                return(pReturnValue);
            }
            if (args.StationType != 15)
            {
                args.StationType = 1;
            }
            using (DataSubmittedEntities db = new DataSubmittedEntities())
            {
                var pReportData = db.RP_NatSta.Where(s => s.CalcuTime == args.DataDate && s.StaType == args.StationType).ToList();
                using (TransactionScope transaction = new TransactionScope())
                {
                    try
                    {
                        foreach (var item in args.UpdateData)
                        {
                            //获取查询日期当天所有已上传的数据,包括合计

                            var pDataTemp = pReportData.Where(i => i.HourPer == item.Num - 1).SingleOrDefault();
                            pDataTemp.EnNum = item.InDayTraffic;
                            pDataTemp.ExNum = item.OutDayTraffic;
                            pDataTemp.Sum   = item.InDayTraffic + item.OutDayTraffic;
                            pDataTemp.Rek   = item.Remark;
                            if (!string.IsNullOrEmpty(item.RunningStatus))
                            {
                                pDataTemp.RunStae = item.RunningStatus;
                            }
                            else
                            {
                                pDataTemp.RunStae = SystemConst.RunningStatus;
                            }
                            pDataTemp.UpdDate = DateTime.Now;
                            pDataTemp.State   = "1";
                            if (SessionManage.GetLoginUser() != null)
                            {
                                pDataTemp.UpdBy = SessionManage.GetLoginUser().UserName;
                            }
                        }
                        db.SaveChanges();
                        transaction.Complete();
                        pReturnValue.ResultKey   = (byte)EResult.Succeed;
                        pReturnValue.ResultValue = TipInfo.UpdateSuccess;
                    }
                    catch (Exception ex)
                    {
                        Common.SystemLog.GetInstance().Log.Info(TipInfo.UpdateDataRepeat, ex);
                        pReturnValue.ResultKey   = (byte)EResult.Fail;
                        pReturnValue.ResultValue = TipInfo.UpdateDataRepeat;
                    }
                    return(pReturnValue);
                }
            }
        }
        /// <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;
            }
        }
Beispiel #27
0
        /// <summary>
        /// 批量修改
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public CustomResult Update(UpdateHDayTraInfoViewModel args)
        {
            CustomResult pReturnValue = new CustomResult();

            pReturnValue.ResultKey   = (byte)EResult.Fail;
            pReturnValue.ResultValue = TipInfo.UpdateFaile;
            if (args.DataInfo == null)
            {
                pReturnValue.ResultKey   = (byte)EResult.Succeed;
                pReturnValue.ResultValue = TipInfo.DataNull;
                return(pReturnValue);
            }
            List <UpdateDataDailyInfo> pNewUpdateData = new List <UpdateDataDailyInfo>();

            using (DataSubmittedEntities db = new DataSubmittedEntities())
            {
                //获取修改日期的数据
                var pReportData = db.RP_AADTSta.Where(s => s.CalculTime == args.DataDate).ToList();
                if (pReportData.Count > 0)
                {
                    using (TransactionScope transaction = new TransactionScope())
                    {
                        try
                        {
                            foreach (var item in args.DataInfo)
                            {
                                var pDataTemp = pReportData.SingleOrDefault();
                                pDataTemp.FeeSum      = item.FeeSum;
                                pDataTemp.ExSmaCarFee = item.ExSmaCarFee;
                                pDataTemp.EnSmaCarFee = item.EnSmaCarFee;
                                pDataTemp.SmaCarFee   = item.SmaCarFee;
                                pDataTemp.ExChagNum   = item.ExChagNum;
                                pDataTemp.EnChagNum   = item.EnChagNum;
                                pDataTemp.ChagAmount  = item.ChagAmount;
                                pDataTemp.GreNum      = item.GreNum;
                                pDataTemp.GreFee      = item.GreFee;
                                pDataTemp.StaExSum    = item.StaExSum;
                                pDataTemp.StaEnSum    = item.StaEnSum;
                                pDataTemp.WorkPeoNum  = item.WorkPeoNum;
                                pDataTemp.InfoNum     = item.InfoNum;
                                pDataTemp.SitState    = item.SitState;
                                pDataTemp.LineExSum   = item.ExSmaCarFee + item.ExChagNum;
                                pDataTemp.LineEnSum   = item.EnSmaCarFee + item.EnChagNum;
                                pDataTemp.LineSum     = pDataTemp.LineExSum + pDataTemp.LineEnSum;
                                pDataTemp.UpdDate     = DateTime.Now;
                                pDataTemp.State       = "1";
                                if (SessionManage.GetLoginUser() != null)
                                {
                                    pDataTemp.UpdBy = SessionManage.GetLoginUser().UserName;
                                }
                            }
                            db.SaveChanges();
                            transaction.Complete();
                            pReturnValue.ResultKey   = (byte)EResult.Succeed;
                            pReturnValue.ResultValue = TipInfo.UpdateSuccess;
                        }
                        catch (Exception ex)
                        {
                            Common.SystemLog.GetInstance().Log.Info(TipInfo.UpdateDataRepeat, ex);
                            pReturnValue.ResultKey   = (byte)EResult.Fail;
                            pReturnValue.ResultValue = TipInfo.UpdateDataRepeat;
                        }
                    }
                }
                else
                {
                    pReturnValue.ResultKey   = (byte)EResult.Fail;
                    pReturnValue.ResultValue = TipInfo.DataNull;
                }
                return(pReturnValue);
            }
        }
Beispiel #28
0
        /// <summary>
        /// 校正
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        public CustomResult CalibrationData(QueryParameters para)
        {
            CustomResult      pReturnValue    = new CustomResult();
            double            pFloating       = 1 + para.FloatingRange * 0.01;
            List <RP_AADTSta> pNaturalTraList = new List <RP_AADTSta>();

            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);
                    }
                    //判断校正数据日期是否合理
                    if (para.LastYearStart < para.StartTime && para.StartTime < DateTime.Now.AddDays(1))
                    {
                        //获取参考日期符合校正时间段的数据,因为只校正一天的数据,所以只查询开始数据的日期就可以
                        List <RP_AADTSta> pRefNaturalList = db.RP_AADTSta.Where(s => s.CalculTime == para.LastYearStart).ToList();
                        //如果参考日期数据为0 则返回失败
                        if (pRefNaturalList.Count == 0)
                        {
                            pReturnValue.ResultKey   = (byte)EResult.Fail;
                            pReturnValue.ResultValue = TipInfo.CalibrationFaileRefNoData;
                            return(pReturnValue);
                        }
                        //需要校正的数据
                        var pCheckNaturalList = db.RP_AADTSta.Where(s => s.CalculTime == para.StartTime).ToList();
                        //如果需要校正的数据为空则返回失败
                        if (pCheckNaturalList.Count == 0)
                        {
                            pReturnValue.ResultKey   = (byte)EResult.Fail;
                            pReturnValue.ResultValue = TipInfo.CalibrationFaileNoData;
                            return(pReturnValue);
                        }
                        using (TransactionScope tran = new TransactionScope())
                        {
                            //校正数据
                            RP_AADTSta pCheckInfo = pCheckNaturalList.First();
                            //参考数据
                            RP_AADTSta pRefInfo = pRefNaturalList.First();

                            //出京总交通量(路线)
                            if (pRefInfo.LineExSum.HasValue)
                            {
                                pCheckInfo.LineExSum = Math.Round(pRefInfo.LineExSum.Value * pFloating);
                            }
                            //进京总交通量(路线)
                            if (pRefInfo.LineEnSum.HasValue)
                            {
                                pCheckInfo.LineEnSum = Math.Round(pRefInfo.LineEnSum.Value * pFloating);
                            }
                            //总交通量(路线)
                            pCheckInfo.LineSum = pCheckInfo.LineExSum + pCheckInfo.LineEnSum;
                            //总交通量同比增幅
                            pCheckInfo.SumGrow = double.Parse(string.Format("{0:0.00}", (pCheckInfo.LineSum - pRefInfo.LineSum) / pRefInfo.LineSum));
                            //出进京比
                            pCheckInfo.ExEnPer = double.Parse(string.Format("{0:0.00}", pCheckInfo.LineExSum / pCheckInfo.LineEnSum));
                            //免、收费总金额
                            if (pRefInfo.FeeSum.HasValue)
                            {
                                pCheckInfo.FeeSum = Math.Round(pRefInfo.FeeSum.Value * (decimal)pFloating, 2);
                            }
                            //出京小型客车免费通行交通量
                            if (pRefInfo.FeeSum.HasValue)
                            {
                                pCheckInfo.ExSmaCarFee = Math.Round(pRefInfo.ExSmaCarFee.Value * pFloating);
                            }
                            //进京小型客车免费通行交通量
                            if (pRefInfo.FeeSum.HasValue)
                            {
                                pCheckInfo.EnSmaCarFee = Math.Round(pRefInfo.EnSmaCarFee.Value * pFloating);
                            }
                            //小型客车免费通行交通量(合计)
                            if (pRefInfo.ExSmaCarFee.HasValue)
                            {
                                pCheckInfo.SmaCarFeeNum = pRefInfo.ExSmaCarFee.Value + pRefInfo.EnSmaCarFee.Value;
                            }
                            //小型客车交通量同比增幅
                            pCheckInfo.SmaCarCompGrow = double.Parse(string.Format("{0:0.00}", (pCheckInfo.SmaCarFeeNum - pRefInfo.SmaCarFeeNum) / pRefInfo.SmaCarFeeNum));
                            //小型客车免费金额
                            if (pRefInfo.SmaCarFee.HasValue)
                            {
                                pCheckInfo.SmaCarFee = Math.Round(pRefInfo.SmaCarFee.Value * (decimal)pFloating, 2);
                            }
                            //收费车辆(合计)
                            if (pRefInfo.ChagSumNum.HasValue)
                            {
                                pCheckInfo.ChagSumNum = Math.Round(pRefInfo.ChagSumNum.Value * pFloating);
                            }
                            //出京收费车辆
                            if (pRefInfo.ExChagNum.HasValue)
                            {
                                pCheckInfo.ExChagNum = Math.Round(pRefInfo.ExChagNum.Value * pFloating);
                            }
                            //进京收费车辆
                            if (pRefInfo.EnChagNum.HasValue)
                            {
                                pCheckInfo.EnChagNum = Math.Round(pRefInfo.EnChagNum.Value * pFloating);
                            }
                            //收费额度
                            if (pRefInfo.ChagAmount.HasValue)
                            {
                                pCheckInfo.ChagAmount = Math.Round(pRefInfo.ChagAmount.Value * (decimal)pFloating, 2);
                            }
                            //绿色通道车辆数
                            if (pRefInfo.GreNum.HasValue)
                            {
                                pCheckInfo.GreNum = Math.Round(pRefInfo.GreNum.Value * pFloating);
                            }
                            //绿色通道免收费金额
                            if (pRefInfo.GreFee.HasValue)
                            {
                                pCheckInfo.GreFee = Math.Round(pRefInfo.GreFee.Value * (decimal)pFloating, 2);
                            }
                            //出京总交通量(站)
                            if (pRefInfo.StaExSum.HasValue)
                            {
                                pCheckInfo.StaExSum = Math.Round(pRefInfo.StaExSum.Value * pFloating);
                            }
                            //进京总交通量(站)
                            if (pRefInfo.StaEnSum.HasValue)
                            {
                                pCheckInfo.StaEnSum = Math.Round(pRefInfo.StaEnSum.Value * pFloating);
                            }
                            if (SessionManage.GetLoginUser() != null)
                            {
                                pCheckInfo.UpdBy = SessionManage.GetLoginUser().UserName;
                            }
                            pCheckInfo.UpdDate = DateTime.Now;
                            pCheckInfo.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>
        /// 校正数据
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public CustomResult CalibrationData(QueryParameters para)
        {
            CustomResult pReturnValue = new CustomResult();
            double       pFloating    = 1 + para.FloatingRange * 0.01;

            List <RP_HDayAADT> pHDayAADT = new List <RP_HDayAADT>();

            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);
                    }
                    //判断时间范围是否相同
                    if ((para.LastYearEnd - para.LastYearStart) == (para.EndTime - para.StartTime))
                    {
                        //获取参考日期符合校正时间段的数据
                        List <RP_HDayAADT> pRefList = db.RP_HDayAADT.Where(s => s.CalcuTime >= para.LastYearStart && s.CalcuTime <= para.LastYearEnd).ToList();
                        //如果参考日期数据为0 则返回失败
                        if (pRefList.Count == 0)
                        {
                            pReturnValue.ResultKey   = (byte)EResult.Fail;
                            pReturnValue.ResultValue = TipInfo.CalibrationFaileRefNoData;
                            return(pReturnValue);
                        }
                        //需要校正的数据
                        var pCheckList = db.RP_HDayAADT.Where(s => s.CalcuTime >= para.StartTime && s.CalcuTime <= para.EndTime).ToList();
                        //如果需要校正的数据为空则返回失败
                        if (pCheckList.Count == 0)
                        {
                            pReturnValue.ResultKey   = (byte)EResult.Fail;
                            pReturnValue.ResultValue = TipInfo.CalibrationFaileNoData;
                            return(pReturnValue);
                        }
                        using (TransactionScope tran = new TransactionScope())
                        {
                            ////校正数据
                            //RP_HDayAADTSta pCheckInfo = pCheckNaturalList.First();
                            ////参考数据
                            //RP_HDayAADTSta pRefInfo = pRefNaturalList.First();

                            foreach (RP_HDayAADT pCheckInfo in pCheckList) //校正数据
                            {
                                foreach (RP_HDayAADT pRefInfo in pRefList) //参考数据
                                {
                                    if (pRefInfo.CalcuTime == pRefInfo.CalcuTime)
                                    {
                                        pCheckInfo.Out = Math.Round(pRefInfo.Out.Value * pFloating);
                                        if (SessionManage.GetLoginUser() != null)
                                        {
                                            pCheckInfo.UpdBy = SessionManage.GetLoginUser().UserName;
                                        }
                                        pCheckInfo.UpdDate = DateTime.Now;
                                        pCheckInfo.State   = "1";
                                        break;
                                    }
                                }
                            }
                            db.SaveChanges();
                            tran.Complete();
                            pReturnValue.ResultKey   = (byte)EResult.Succeed;
                            pReturnValue.ResultValue = TipInfo.CalibrationSuccess;
                        }
                    }
                    else
                    {
                        pReturnValue.ResultKey   = (byte)EResult.Fail;
                        pReturnValue.ResultValue = TipInfo.CalibrationRangeFaile;
                    }
                }
                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>
        /// 统计类型
        /// </summary>
        /// <param name="stationtype">统计段类型</param>
        /// <param name="datasource">统计段数据源</param>
        /// <param name="dt">时间</param>
        /// <returns></returns>
        private List <RP_Daily> CalcuRP(int stationtype, IEnumerable <DS_DataSource> datasource, DateTime dt, List <int> stationlist)
        {
            List <RP_Daily> plist = new List <RP_Daily>();

            using (DataSubmittedEntities db = new DataSubmittedEntities())
            {
                for (int i = 0; i < 4; i++)
                {
                    //0小型客车,1其他客车,2货车(不包含绿通),3绿通
                    //每个站只有四条合计数据,每天数据表里一共只有16条
                    //判断各站各车型数据是有已存在,存在进行更新,不存在进行添加
                    List <RP_Daily> pDailyList = db.RP_Daily.Where(s => s.CalcuTime == dt && s.VehType == i && s.StaType == stationtype).ToList();
                    RP_Daily        pDaily     = new RP_Daily();
                    if (pDailyList.Count > 0)
                    {
                        pDaily         = pDailyList.First();
                        pDaily.State   = 1;
                        pDaily.UpdDate = DateTime.Now;
                    }
                    else
                    {
                        pDaily.Id      = Guid.NewGuid();
                        pDaily.CrtDate = DateTime.Now;
                        pDaily.VehType = i;//车辆类型
                        pDaily.StaType = stationtype;
                        pDaily.State   = 0;
                    }
                    byte ptemp = (byte)i;
                    pDaily.OutNum = datasource.Where(p => p.CalcuType == ptemp).Sum(p => p.OutNum);
                    pDaily.InNum  = datasource.Where(p => p.CalcuType == ptemp).Sum(p => p.InNum);
                    if (i == 0)
                    {
                        pDaily.ChagFee = this.GetCharge(stationlist, datasource);
                    }
                    if (i == 1)
                    {
                        pDaily.ChagFee = datasource.Where(s => s.CalcuType == 1).Sum(s => s.RecMoney);
                    }
                    if (i == 2)
                    {
                        pDaily.ChagFee = datasource.Where(s => s.CalcuType == 2).Sum(s => s.RecMoney);
                    }
                    if (i == 3)
                    {
                        pDaily.InNum   = 0;//入口绿通为0
                        pDaily.ChagFee = datasource.Where(s => s.CalcuType == 3).Sum(s => s.RecMoney);
                    }
                    pDaily.CalcuTime = DateTime.Parse(dt.ToShortDateString());

                    if (pDailyList.Count > 0)//进行更新
                    {
                        using (TransactionScope transac = new TransactionScope())
                        {
                            db.SaveChanges();
                            transac.Complete();
                        }
                    }
                    else
                    {
                        //将实体加入集合
                        plist.Add(pDaily);
                    }
                }
            }
            return(plist);
        }