/// <summary> /// 修改假期配置 /// </summary> /// <param name="args">配置信息实体</param> /// <returns>影响行数</returns> public CustomResult Update(OT_HDayConfig model) { using (DataSubmittedEntities db = new DataSubmittedEntities()) { using (TransactionScope transaction = new TransactionScope()) { CustomResult pReturnValue = new CustomResult(); var list = db.OT_HDayConfig.Where(a => a.Id == model.Id).ToList(); if (list != null && list.Count > 0) { if (model.CheckFloat != null && model.CheckFloat > 0) list[0].CheckFloat = model.CheckFloat; if (model.CompEnd != null) list[0].CompEnd = model.CompEnd; if (model.CompStart != null) list[0].CompStart = model.CompStart; if (!string.IsNullOrEmpty(model.ConfigName)) list[0].ConfigName = model.ConfigName; if (model.ForeDate != null) list[0].ForeDate = model.ForeDate; if (model.ForeFloat != null && model.ForeFloat > 0) list[0].ForeFloat = model.ForeFloat; if (model.HDayEnd != null) list[0].HDayEnd = model.HDayEnd; if (model.HDayId != null && model.HDayId > 0) list[0].HDayId = model.HDayId; if (model.HDayStart != null) list[0].HDayStart = model.HDayStart; if (!string.IsNullOrEmpty(model.RptRemark)) list[0].RptRemark = model.RptRemark; pReturnValue = Result.SaveUpdateResult(db, transaction); } else { pReturnValue.ResultKey = (byte)EResult.IsNull1; pReturnValue.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.Inexist; } return pReturnValue; } } }
/// <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; } } } }
public ActionResult UpdateNaturalHour(UpdateNaturalInfoViewModel args) { try { ReportFactory.Instance.log.WriteLog(OperationType.Update, Utility.GetReportNameByType(15), Utility.GetFormatDate(args.DataDate, null)); return Json(ReportFactory.Instance.report15.Update(args)); } catch (Exception ex) { CustomResult ret = new CustomResult(); ret.ResultKey = 0; ret.ResultValue = ex.Message; return Json(ret); } }
/// <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; }
/// <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); }
/// <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; }
public ActionResult UpdateTollRoadSum(UpdateDataDailyViewModel args) { args.StationType = 1; try { ReportFactory.Instance.log.WriteLog(OperationType.Update, Utility.GetReportNameByType(1), Utility.GetFormatDate(args.DataDate, null)); return Json(ReportFactory.Instance.report1.Update(args)); } catch (Exception ex) { CustomResult ret = new CustomResult(); ret.ResultKey = 0; ret.ResultValue = ex.Message; return Json(ret); } }
/// <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); }
/// <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); }
/// <summary> /// 批量修改 /// </summary> /// <param name="args"></param> /// <returns></returns> public CustomResult Update(UpdateDataDailyViewModel 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_Daily.Where(s => s.CalcuTime == args.DataDate && s.StaType == args.StationType).ToList(); using (TransactionScope transaction = new TransactionScope()) { try { foreach (var item in args.DataInfo) { //获取查询日期当天的数据 if (item.VehType == SystemConst.SmallCar) item.VehType = "0"; if (item.VehType == SystemConst.OtherCar) item.VehType = "1"; if (item.VehType == SystemConst.Truk) item.VehType = "2"; if (item.VehType == SystemConst.Green) item.VehType = "3"; int ptemp = int.Parse(item.VehType); RP_Daily pDataTemp = new RP_Daily(); if (pReportData.Where(i => i.VehType == ptemp).Count() == 1) { pDataTemp = pReportData.Where(i => i.VehType == ptemp).SingleOrDefault(); if (item.ExEn == SystemConst.In)//入口 { pDataTemp.InNum = item.VehNum;//出口 } else { pDataTemp.OutNum = item.VehNum; pDataTemp.ChagFee = item.CarChag * 10000;//转为元,存到数据库 } 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> /// 预测 /// </summary> /// <param name="para"></param> /// <returns></returns> public CustomResult ForecastData(QueryParameters para) { if (listExport != null) listExport.Clear(); CustomResult pReturnValue = new CustomResult(); //浮动范围 double pFloating = 1 + para.FloatingRange * 0.01; List<RoadRunSitViewModel> pForeList = new List<RoadRunSitViewModel>(); //预测数据集合 List<IReportViewModel> pInList = new List<IReportViewModel>(); 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.ForecastFaileNoConfig; return pReturnValue; } //判断报表预测浮动百分比配置是否正确 if (Math.Abs(para.FloatingRange) > (double)pds.ForeFloat.Value) { pReturnValue.ResultKey = (byte)EResult.Fail; pReturnValue.ResultValue = TipInfo.ErrorInfo + "范围应在负" + pds.ForeFloat.Value + "%-正" + pds.ForeFloat.Value + "%之间"; return pReturnValue; } //获取参考日期符合的数据 List<RP_AADTSta> pRefInfoList = db.RP_AADTSta.Where(s => s.CalculTime == para.StartTime).ToList(); //如果参考日期数据为0 则返回失败 if (pRefInfoList==null||pRefInfoList.Count == 0) { pReturnValue.ResultKey = (byte)EResult.Fail; pReturnValue.ResultValue = TipInfo.ForecastFaileFaileRefNoData; return pReturnValue; } //预测数据 RoadRunSitViewModel info = new RoadRunSitViewModel(); //预测数据集合 List<IReportViewModel> plist = new List<IReportViewModel>(); //参考数据 foreach (RP_AADTSta pRefInfo in pRefInfoList) { //出京总交通量(路线) info.LineExSum = Math.Round(pRefInfo.LineExSum == null ? 0 : pRefInfo.LineExSum.Value * pFloating, 2); //进京总交通量(路线) info.LineEnSum = Math.Round(pRefInfo.LineEnSum == null ? 0 : pRefInfo.LineEnSum.Value * pFloating, 2); //总交通量(路线) info.LineSum = info.LineExSum + info.LineEnSum; //小型客车免费通行交通量(合计) info.SmaCarFeeNum = Math.Round(pRefInfo.ExSmaCarFee == null ? 0 : pRefInfo.ExSmaCarFee.Value + pRefInfo.EnSmaCarFee == null ? 0 : pRefInfo.EnSmaCarFee.Value, 2); //小型客车免费金额 info.SmaCarFee = Math.Round(pRefInfo.SmaCarFee == null ? 0 : pRefInfo.SmaCarFee.Value * (decimal)pFloating, 2); //收费车辆(合计) info.ChagSumNum = Math.Round(pRefInfo.ChagSumNum == null ? 0 : pRefInfo.ChagSumNum.Value * pFloating, 2); //数据日期 info.CalculTime = (pRefInfo.CalculTime).Month + "月" + (pRefInfo.CalculTime).Day + "日"; //出进京比“出进京比”=出京交通量/进京交通量,保留两位小数。 if (info.LineEnSum != 0) { info.ExEnPer = Math.Round(info.LineExSum / info.LineEnSum, 2); } //“同比增幅”=(本年数据-去年数据)/去年数据*100%,保留两位小数。 //小型客车交通量同比增幅 info.SmaCarCompGrow = pRefInfo.SmaCarCompGrow == null ? "0.00" : Math.Round(pRefInfo.SmaCarCompGrow.Value, 2).ToString(); //总交通量同比增幅 info.SumGrow = pRefInfo.SumGrow == null ? "0.00" : Math.Round(pRefInfo.SumGrow.Value, 2).ToString(); plist.Add(info); } string path = Export(para, plist); pReturnValue.ResultKey = (byte)EResult.Succeed; pReturnValue.ResultValue = path; } } catch (Exception e) { pReturnValue.ResultKey = (byte)EResult.Fail; pReturnValue.ResultValue = TipInfo.ForecastFail + e.Message.ToString(); SystemLog.GetInstance().Error(TipInfo.ForecastFail, e); return pReturnValue; } return pReturnValue; }
/// <summary> /// 修改密码 /// </summary> /// <param name="userId">用户编号</param> /// <param name="pwd">新密码</param> /// <param name="oldpwd">旧密码</param> /// <returns>修改结果</returns> public CustomResult UpdatePassword(Guid userId, string pwd, string oldpwd) { using (DataSubmittedEntities db = new DataSubmittedEntities()) { using (TransactionScope transaction = new TransactionScope()) { MD5Encryptor md5 = new MD5Encryptor(); string password = md5.Encrypt(oldpwd); var list = db.OT_User.Where(a => a.Id == userId & a.Password == password & a.IsDelete == (byte)EUserStatus.Normal).ToList(); if (list != null && list.Count > 0) { password = md5.Encrypt(pwd); foreach (var info in list) { info.Password = password; } SessionManage.SetSession("UserInfo", null); return Result.SaveUpdateResult(db, transaction); } else { CustomResult pReturnValue = new CustomResult(); pReturnValue.ResultKey = (byte)EResult.Fail;//程序已经使用多处,所有不变动 pReturnValue.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.OldPasswordError; return pReturnValue; } } } }
public JsonResult UpdateJJTHighWay(AADTAndTransCalcuUViewModel args) { try { ReportFactory.Instance.log.WriteLog(OperationType.Update, Utility.GetReportNameByType(7), Utility.GetFormatDate(args.DataDate, null)); return Json(ReportFactory.Instance.report7.Update(args)); } catch (Exception ex) { CustomResult ret = new CustomResult(); ret.ResultKey = 0; ret.ResultValue = ex.Message; return Json(ret, JsonRequestBehavior.DenyGet); } }
public JsonResult UpdateHoliday(NodeViewModel model) { CustomResult result = new CustomResult(); if (string.IsNullOrEmpty(model.Name)) { result.ResultKey = (byte)ENodeAddResult.Exist; result.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.InputHolidayName; return Json(result, JsonRequestBehavior.DenyGet); } result = ReportFactory.Instance.DicUpdate(model); //精确假期名称存在提示信息 if (result.ResultKey == (byte)ENodeAddResult.Exist) { result.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.HolidayExist; } else if (result.ResultKey == (byte)EResult.Succeed) { ReportFactory.Instance.log.WriteLog(Common.OperationType.Update, string.Format("编辑了假期名称{0}", model.Name)); } return Json(result, JsonRequestBehavior.DenyGet); }
/// <summary> /// 返回带事物的提交结果-修改使用 /// </summary> /// <param name="db">提交数据库对象</param> /// <param name="transaction">事物</param> /// <returns>提交结果</returns> public static CustomResult SaveUpdateResult(DataSubmittedEntities db, TransactionScope transaction) { CustomResult pReturnValue = new CustomResult(); try { db.SaveChanges(); transaction.Complete(); 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; }
/// <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="args"></param> /// <returns></returns> public CustomResult Update(UpdateHourAADTViewModel 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; } using (DataSubmittedEntities db = new DataSubmittedEntities()) { var pReportData = db.RP_HourAADT.Where(s => s.CalcuTime == args.DataDate && s.HourPer != 24).ToList(); using (TransactionScope transaction = new TransactionScope()) { try { //获取对应的数据 foreach (UpdateHourAADTInfo item in args.UpdateData) { for (int i = 0; i < 24; i++) { RP_HourAADT pHourAADT = null; List<RP_HourAADT> pHourList = pReportData.Where(s => s.HourPer == i).ToList(); if (pHourList.Count > 0) { pHourAADT = pHourList.SingleOrDefault(); } else { //如果该时段的数据没有找到,则进行下次循环 continue; } Type myType = item.GetType(); PropertyInfo pinfo = myType.GetProperty("Count_" + i); if (item.StaName == "大羊坊站" && item.TraName == "出京入") { pHourAADT.Dyf_ExIn = (double)pinfo.GetValue(item); } if (item.StaName == "马驹桥东站" && item.TraName == "进京入") { pHourAADT.Mjqd_EnIn = (double)pinfo.GetValue(item); } if (item.StaName == "马驹桥西站" && item.TraName == "出京入") { pHourAADT.Mjqx_ExIn = (double)pinfo.GetValue(item); } if (item.StaName == "采育站" && item.TraName == "出京入") { pHourAADT.Cy_ExIn = (double)pinfo.GetValue(item); } if (item.StaName == "大羊坊站" && item.TraName == "进京出") { pHourAADT.Dyf_EnOut = (double)pinfo.GetValue(item); } if (item.StaName == "马驹桥东站" && item.TraName == "进京出") { pHourAADT.Mjqd_EnOut = (double)pinfo.GetValue(item); } if (item.StaName == "马驹桥西站" && item.TraName == "进京出") { pHourAADT.Mjqx_EnOut = (double)pinfo.GetValue(item); } if (item.StaName == "采育站" && item.TraName == "进京出") { pHourAADT.Cy_EnOut = (double)pinfo.GetValue(item); } pHourAADT.UpdDate = DateTime.Now; pHourAADT.State = "1"; if (SessionManage.GetLoginUser() != null) { pHourAADT.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> /// 修改 /// </summary> /// <param name="args"></param> /// <returns></returns> public Common.CustomResult Update(Common.ViewModels.AADTAndTransCalcuUViewModel args) { using (DataSubmittedEntities db = new DataSubmittedEntities()) { using (TransactionScope transaction = new TransactionScope()) { CustomResult pReturnValue = new CustomResult(); bool flag = false;//标记数据库中是否有数据修改 foreach (AADTAndTransCalcuViewModel model in args.DataInfo) { if (!string.IsNullOrEmpty(model.CalcuTimeUpdate)) { DateTime dt = new DateTime(); if (DateTime.TryParse(model.CalcuTimeUpdate, out dt)) { var list = db.RP_AADTAndTransCalcu.Where(a => a.CalcuTime == dt).ToList(); foreach (var item in list) { flag = true; item.EnTra = model.EnTra; item.EnCar = model.EnCar; //“旅客量”=“其中客车数”*5.84/10000 item.EnTrav = item.EnCar == null ? 0.00 : Math.Round(item.EnCar.Value * 5.84 / 10000, 2); item.ExCar = model.ExCar; item.ExTra = model.ExTra; //“旅客量”=“其中客车数”*5.84/10000 item.ExTrav = item.ExCar == null ? 0.00 : Math.Round(item.ExCar.Value * 5.84 / 10000, 2); item.State = "1"; item.UpdDate = DateTime.Now; if (SessionManage.GetLoginUser() != null) { item.UpdBy = SessionManage.GetLoginUser().UserName; } } } } } 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; } } } }
public JsonResult UpdateHDayEx(UpdateHdayExViewModel args) { try { ReportFactory.Instance.log.WriteLog(OperationType.Update, Utility.GetReportNameByType(12), Utility.GetFormatDate(args.StartTime, args.EndTime)); return Json(ReportFactory.Instance.report12.Update(args)); } catch (Exception ex) { CustomResult ret = new CustomResult(); ret.ResultKey = 0; ret.ResultValue = ex.Message; return Json(ret, JsonRequestBehavior.DenyGet); } }
/// <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="para"></param> /// <returns></returns> public CustomResult ForecastData(QueryParameters para) { CustomResult pReturnValue = new CustomResult(); //浮动范围 double pFloating = para.FloatingRange * 0.01; List<RP_Daily> pDailyList = new List<RP_Daily>(); //预测数据集合 List<IReportViewModel> pOutList = new List<IReportViewModel>(); List<IReportViewModel> pInList = new List<IReportViewModel>(); 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.ForecastFaileNoConfig; return pReturnValue; } //判断报表预测浮动百分比配置是否正确 if (Math.Abs(para.FloatingRange) > (double)pds.ForeFloat.Value) { pReturnValue.ResultKey = (byte)EResult.Fail; pReturnValue.ResultValue = TipInfo.ErrorInfo + "范围应在负" + pds.ForeFloat.Value + "%-正" + pds.ForeFloat.Value + "%之间"; return pReturnValue; } //获取参考日期符合的数据 List<RP_Daily> pRefDataDailyInfo = db.RP_Daily.Where(s => s.CalcuTime == para.StartTime && s.StaType == para.StationType).ToList(); //如果参考日期数据为0 则返回失败 if (pRefDataDailyInfo.Count == 0) { pReturnValue.ResultKey = (byte)EResult.Fail; pReturnValue.ResultValue = TipInfo.ForecastFaileFaileRefNoData; return pReturnValue; } foreach (RP_Daily info in pRefDataDailyInfo) { DataDailyInfoViewModel pOutInfo = new DataDailyInfoViewModel(); DataDailyInfoViewModel pInInfo = new DataDailyInfoViewModel(); pInInfo.VehNum = (float)Math.Round((double)(info.InNum + info.InNum * pFloating), 0); pOutInfo.VehNum = (float)Math.Round((double)(info.OutNum + info.OutNum * pFloating), 0); pInInfo.VehType = info.VehType.ToString(); pOutInfo.VehType = info.VehType.ToString(); pOutInfo.CarChag = Math.Round((decimal)(info.ChagFee + info.ChagFee * (decimal)pFloating) / 10000, 2); pOutList.Add(pOutInfo); pInList.Add(pInInfo); } string path = Export(para, pOutList, pInList); pReturnValue.ResultKey = (byte)EResult.Succeed; pReturnValue.ResultValue = path; } } catch (Exception e) { pReturnValue.ResultKey = (byte)EResult.Fail; pReturnValue.ResultValue = TipInfo.ForecastFail + e.Message.ToString(); SystemLog.GetInstance().Error(TipInfo.ForecastFail, e); return pReturnValue; } return pReturnValue; }
/// <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; } } } }
public JsonResult AddHoliday(string name) { CustomResult result = new CustomResult(); if (string.IsNullOrEmpty(name)) { result.ResultKey = (byte)ENodeAddResult.Exist; result.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.InputHolidayName; return Json(result, JsonRequestBehavior.DenyGet); } result = ReportFactory.Instance.DicAdd((int)EDicParentId.Holiday, name); if (result.ResultKey == (byte)ENodeAddResult.Succeed) { ReportFactory.Instance.log.WriteLog(Common.OperationType.Update, string.Format("新增了假期名称{0}", name)); } //精确假期名称存在提示信息 if (result.ResultKey == (byte)ENodeAddResult.Exist) { result.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.HolidayExist; } return Json(result, JsonRequestBehavior.DenyGet); }
/// <summary> /// 校正数据 /// </summary> /// <param name="args">校正日期,参考日期,浮动百分比</param> /// <returns></returns> public CustomResult CalibrationData(QueryParameters para) { CustomResult pReturnValue = new CustomResult(); // QueryNaturalInfoViewModel queryNatural = new QueryNaturalInfoViewModel(); //校正浮动范围 double pFloating = para.FloatingRange * 0.01; List<RP_Daily> pDailyList = new List<RP_Daily>(); 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<RP_Daily> pRefDataDailyInfo = db.RP_Daily.Where(s => s.CalcuTime == para.LastYearStart && s.StaType == para.StationType).ToList(); //如果参考日期数据为0 则返回失败 if (pRefDataDailyInfo.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 pCheckList = db.RP_Daily.Where(s => s.CalcuTime == para.StartTime && s.StaType == para.StationType).ToList(); //如果校正数据不存在则返回失败 if (pCheckList.Count == 0) { pReturnValue.ResultKey = (byte)EResult.Fail; pReturnValue.ResultValue = TipInfo.CalibrationFaileNoData; return pReturnValue; } using (TransactionScope tran = new TransactionScope()) { foreach (var item in pCheckList) { IEnumerable<RP_Daily> plist = pRefDataDailyInfo.Where(i => i.VehType == item.VehType); if (plist.Count() > 0) { RP_Daily pTemp = plist.First(); item.InNum = (int)(pTemp.InNum + pTemp.InNum * pFloating); item.OutNum = (int)(pTemp.OutNum + pTemp.OutNum * pFloating); item.ChagFee = pTemp.ChagFee.Value + pTemp.ChagFee.Value * decimal.Parse(pFloating.ToString()); item.CalcuTime = para.StartTime.Value; item.StaType = para.StationType; if (SessionManage.GetLoginUser() != null) { item.UpdBy = SessionManage.GetLoginUser().UserName; } item.UpdDate = DateTime.Now; item.State = 1; } } db.SaveChanges(); tran.Complete(); pReturnValue.ResultKey = (byte)EResult.Succeed; pReturnValue.ResultValue = TipInfo.CalibrationSuccess; } } else { pReturnValue.ResultKey = (byte)EResult.Fail; pReturnValue.ResultValue = TipInfo.CalibrationFaileDate; } } return pReturnValue; } catch (Exception e) { pReturnValue.ResultKey = (byte)EResult.Fail; pReturnValue.ResultValue = TipInfo.CalibrationFaile + e.Message.ToString(); SystemLog.GetInstance().Error(TipInfo.CalibrationFaile, e); return pReturnValue; } }
/// <summary> /// 修改所有不能设置假期名称的假期名称配置项 /// </summary> /// <param name="holidayId"></param> /// <returns></returns> public CustomResult Update(int holidayId) { using (DataSubmittedEntities db = new DataSubmittedEntities()) { using (TransactionScope transaction = new TransactionScope()) { CustomResult pReturnValue = new CustomResult(); var list = db.OT_HDayConfig.ToList(); if (list != null && list.Count > 0) { foreach (var item in list) { if (item.ConfigItem == null || !item.ConfigItem.Contains("HDayId")) item.HDayId = holidayId; } pReturnValue = Result.SaveUpdateResult(db, transaction); } else { pReturnValue.ResultKey = (byte)EResult.IsNull1; pReturnValue.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.InexistHoliday; } return pReturnValue; } } }
public JsonResult Update(string userId, List<string> roleList, string userName) { CustomResult result = new CustomResult(); #region 数据判定 Guid id = Guid.NewGuid(); if (!Guid.TryParse(userId, out id)) { result.ResultKey=(byte)EResult.IsNull1; result.ResultValue=Wttech.DataSubmitted.Common.Resources.TipInfo.SelectUser; return Json(result, JsonRequestBehavior.DenyGet); } bool flag = false; foreach (string roleId in roleList) { if (Guid.TryParse(roleId, out id)) flag = true; } if (!(roleList != null && roleList.Count > 0 && flag)) { result.ResultKey = (byte)EResult.IsNull2; result.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.SelectRole; return Json(result, JsonRequestBehavior.DenyGet); } if (string.IsNullOrEmpty(userName)) { result.ResultKey = (byte)EResult.IsNull3; result.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.InputUserName; return Json(result, JsonRequestBehavior.DenyGet); } #endregion //构造修改用户信息实体 UpdateUserInfoViewModel userInfoModel = new UpdateUserInfoViewModel(); userInfoModel.UserId = Guid.Parse(userId); userInfoModel.UserName = userName; List<Guid> list = new List<Guid>(); foreach (string roleId in roleList) { if (Guid.TryParse(roleId, out id)) { list.Add(id); } } userInfoModel.RoleIdList = list; //交给业务逻辑层处理 result = userManage.Update(userInfoModel); if (Session["UserInfo"] != null) ReportFactory.Instance.log.WriteLog(Common.OperationType.Update, string.Format("修改了{0}的信息", userName)); return Json(result, JsonRequestBehavior.DenyGet); }
/// <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_HDayAADTSta> pNaturalTraList = new List<RP_HDayAADTSta>(); 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_HDayAADTSta> pRefNaturalList = db.RP_HDayAADTSta.Where(s => s.CalcuTime == para.LastYearStart).ToList(); //如果参考日期数据为0 则返回失败 if (pRefNaturalList.Count == 0) { pReturnValue.ResultKey = (byte)EResult.Fail; pReturnValue.ResultValue = TipInfo.CalibrationFaileRefNoData; return pReturnValue; } //需要校正的数据 var pCheckNaturalList = db.RP_HDayAADTSta.Where(s => s.CalcuTime == para.StartTime).ToList(); //如果需要校正的数据为空则返回失败 if (pCheckNaturalList.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_HDayAADTSta pCheckInfo in pCheckNaturalList)//校正数据 { foreach (RP_HDayAADTSta pRefInfo in pRefNaturalList)//参考数据 { if (pRefInfo.LineType != 0 && pCheckInfo.LineType == pRefInfo.LineType) { //出京自然交通辆 if (pRefInfo.ExNat != null) pCheckInfo.ExNat = Math.Round(pRefInfo.ExNat.Value * pFloating); //进京自然交通辆 if (pRefInfo.EnNat != null) pCheckInfo.EnNat = Math.Round(pRefInfo.EnNat.Value * pFloating); //出京当量交通辆 if (pRefInfo.ExEqu != null) pCheckInfo.ExEqu = Math.Round(pRefInfo.ExEqu.Value * pFloating); //进京当量交通辆 if (pRefInfo.EnEqu != null) pCheckInfo.EnEqu = Math.Round(pRefInfo.EnEqu.Value * pFloating); //拥挤度-“拥挤度”=交通量(当量交通量)合计/设计交通量,保留四位小数; if (pCheckInfo.ExEqu != null && pCheckInfo.EnEqu != null) { HDayAADTViewModel model = new HDayAADTViewModel(); model.LineType = pRefInfo.LineType; pCheckInfo.CrowDeg = double.Parse(string.Format("{0:0.0000}", (pCheckInfo.ExEqu + pCheckInfo.EnEqu) / model.DeTra)); } //小型车出京 if (pRefInfo.SmaEx != null) pCheckInfo.SmaEx = Math.Round(pRefInfo.SmaEx.Value * pFloating); //小型车进京 if (pRefInfo.SmaEn != null) pCheckInfo.SmaEn = Math.Round(pRefInfo.SmaEn.Value * pFloating); //中型车出京 if (pRefInfo.MedEx != null) pCheckInfo.MedEx = Math.Round(pRefInfo.MedEx.Value * pFloating); //中型车进京 if (pRefInfo.MedEn != null) pCheckInfo.MedEn = Math.Round(pRefInfo.MedEn.Value * pFloating); //大型车出京 if (pRefInfo.LarEx != null) pCheckInfo.LarEx = Math.Round(pRefInfo.LarEx.Value * pFloating); //大型车进京 if (pRefInfo.LarEn != null) pCheckInfo.LarEn = Math.Round(pRefInfo.LarEn.Value * pFloating); //重型车出京 if (pRefInfo.HeaEx != null) pCheckInfo.HeaEx = Math.Round(pRefInfo.HeaEx.Value * pFloating); //重型车进京 if (pRefInfo.HeaEn != null) pCheckInfo.HeaEn = Math.Round(pRefInfo.HeaEn.Value * pFloating); //超大型车出京 if (pRefInfo.SupEx != null) pCheckInfo.SupEx = Math.Round(pRefInfo.SupEx.Value * pFloating); //超大型车进京 if (pRefInfo.SupEn != null) pCheckInfo.SupEn = Math.Round(pRefInfo.SupEn.Value * pFloating); //进出京大货车以上车型数量-进出京大货车以上车型数量”=大型车(合计)+重型车(合计)+超大型车(合计)。 if (pCheckInfo.LarEx != null && pCheckInfo.LarEn != null && pCheckInfo.HeaEx != null && pCheckInfo.HeaEn != null && pCheckInfo.SupEx != null && pCheckInfo.SupEn != null) pCheckInfo.SupTruNum = pCheckInfo.LarEx + pCheckInfo.LarEn + pCheckInfo.HeaEx + pCheckInfo.HeaEn + pCheckInfo.SupEx + pCheckInfo.SupEn; //进出京货车数量 if (pRefInfo.EnExTrukNum != null) pCheckInfo.EnExTrukNum = Math.Round(pRefInfo.EnExTrukNum.Value * pFloating); //客车货车比例-客车货车比例=(交通量(自然交通量)合计-进出京货车数量)/进出京货车数量*100%,保留四位小数; if (pCheckInfo.ExNat != null && pCheckInfo.EnNat != null && pCheckInfo.EnExTrukNum != null && pCheckInfo.EnExTrukNum != null && pCheckInfo.EnExTrukNum != 0) { pCheckInfo.CarTrukPer = double.Parse(string.Format("{0:0.0000}", (pCheckInfo.ExNat + pCheckInfo.EnNat - pCheckInfo.EnExTrukNum) / pCheckInfo.EnExTrukNum)); } //大货车以上占货车交通量比例-大货车以上占货车交通量比例(%)=进出京大货车以上车型的数量/进出京货车数量*100%,保留四位小数。 if (pCheckInfo.SupTruNum != null && pCheckInfo.EnExTrukNum != null && pCheckInfo.EnExTrukNum != 0) { pCheckInfo.SupTruPer = double.Parse(string.Format("{0:0.0000}", pCheckInfo.SupTruNum / pCheckInfo.EnExTrukNum)); } 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.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; } }
public JsonResult UpdateCityEnEx(UpdateEnExViewModel args) { args.StationType = 1; try { ReportFactory.Instance.log.WriteLog(OperationType.Update, Utility.GetReportNameByType(5), Utility.GetFormatDate(args.DataDate, null)); return Json(ReportFactory.Instance.report5.Update(args)); } catch (Exception ex) { CustomResult ret = new CustomResult(); ret.ResultKey = 0; ret.ResultValue = ex.Message; return Json(ret, JsonRequestBehavior.DenyGet); } }
/// <summary> /// 修改功能 /// </summary> /// <param name="args"></param> /// <returns></returns> public CustomResult Update(UHDayRoadStaViewModel args) { using (DataSubmittedEntities db = new DataSubmittedEntities()) { using (TransactionScope transaction = new TransactionScope()) { CustomResult pReturnValue = new CustomResult(); List<UpdateHDayRoadStaViewModel> list = args.DataInfo.Where(a => a.LineType != 0).ToList(); try { foreach (UpdateHDayRoadStaViewModel model in list) { var listHDayRoadSta = db.RP_HDayAADTSta.Where(a => a.CalcuTime == args.DataDate && a.LineType == model.LineType).ToList(); foreach (RP_HDayAADTSta hd in listHDayRoadSta) { // hd.LineType = model.LineType; hd.ExNat = model.ExNat; hd.EnNat = model.EnNat; hd.ExEqu = model.ExEqu; hd.EnEqu = model.EnEqu; //拥挤度-“拥挤度”=交通量(当量交通量)合计/设计交通量,保留四位小数; if (hd.ExEqu != null && hd.EnEqu != null) { HDayAADTViewModel model1 = new HDayAADTViewModel(); model1.LineType = model.LineType; Nullable<double> crowDeg = double.Parse(string.Format("{0:0.0000}", (hd.ExEqu + hd.EnEqu) / model1.DeTra)); hd.CrowDeg = crowDeg; } hd.SmaEx = model.SmaEx; hd.SmaEn = model.SmaEn; hd.MedEx = model.MedEx; hd.MedEn = model.MedEn; hd.LarEx = model.LarEx; hd.LarEn = model.LarEn; hd.HeaEx = model.HeaEx; hd.HeaEn = model.HeaEn; hd.SupEx = model.SupEx; hd.SupEn = model.SupEn; hd.EnExTrukNum = model.EnExTrukNum; //客车货车比例-客车货车比例=(交通量(自然交通量)合计-进出京货车数量)/进出京货车数量*100%,保留四位小数; if (hd.ExNat != null && hd.EnNat != null && hd.EnExTrukNum != null && hd.EnExTrukNum != null) { if (hd.EnExTrukNum != 0) { Nullable<double> carTrukPer = double.Parse(string.Format("{0:0.0000}", (hd.ExNat.Value + hd.EnNat.Value - hd.EnExTrukNum.Value) / hd.EnExTrukNum.Value)); hd.CarTrukPer = carTrukPer; } else { hd.CarTrukPer = 0; } } //进出京大货车以上车型数量-进出京大货车以上车型数量”=大型车(合计)+重型车(合计)+超大型车(合计)。 if (hd.LarEx != null && hd.LarEn != null && hd.HeaEx != null && hd.HeaEn != null && hd.SupEx != null && hd.SupEn != null) { Nullable<double> supTruNum = hd.LarEx.Value + hd.LarEn.Value + hd.HeaEx.Value + hd.HeaEn.Value + hd.SupEx.Value + hd.SupEn.Value; hd.SupTruNum = supTruNum; } //大货车以上占货车交通量比例-大货车以上占货车交通量比例(%)=进出京大货车以上车型的数量/进出京货车数量*100%,保留四位小数。 if (hd.SupTruNum != null && hd.EnExTrukNum != null) { if (hd.EnExTrukNum.Value != 0) { Nullable<double> supTruPer = double.Parse(string.Format("{0:0.0000}", hd.SupTruNum.Value / hd.EnExTrukNum.Value)); hd.SupTruPer = supTruPer; } else { hd.SupTruPer = 0; } } 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; } } } }
/// <summary> /// 校正数据 /// </summary> /// <param name="args"></param> /// <returns></returns> public CustomResult CalibrationData(QueryParameters para) { CustomResult pReturnValue = new CustomResult(); //判断选择校正时间段的有效性 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 = 1 + 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<RP_HourAADT> pRefHourAADTList = db.RP_HourAADT.Where(s => s.CalcuTime == para.LastYearStart && calibrationDataHour.Contains(s.HourPer.ToString())).ToList(); //如果参考日期数据为0 则返回失败 if (pRefHourAADTList.Count <= 0) { pReturnValue.ResultKey = (byte)EResult.Fail; pReturnValue.ResultValue = TipInfo.CalibrationFaileRefNoData; return pReturnValue; } //判断时间范围是否相同 if ((para.LastYearEnd - para.LastYearStart) == (para.EndTime - para.StartTime)) { //需要校正的数据 var pCheckHourAADTList = db.RP_HourAADT.Where(s => s.CalcuTime == para.StartTime && calibrationDataHour.Contains(s.HourPer.ToString())).ToList(); if (pCheckHourAADTList.Count <= 0) { pReturnValue.ResultKey = (byte)EResult.Fail; pReturnValue.ResultValue = TipInfo.CalibrationFaileNoData; return pReturnValue; } using (TransactionScope tran = new TransactionScope()) { foreach (var item in pCheckHourAADTList) { List<RP_HourAADT> plist = pRefHourAADTList.Where(i => i.HourPer == item.HourPer).ToList(); if (plist.Count() > 0) { RP_HourAADT pTemp = plist.First(); item.Dyf_EnOut = Math.Round(pTemp.Dyf_EnOut.Value * pFloating); item.Dyf_ExIn = Math.Round(pTemp.Dyf_ExIn.Value * pFloating); item.Mjqd_EnIn = Math.Round(pTemp.Mjqd_EnIn.Value * pFloating); item.Mjqd_EnOut = Math.Round(pTemp.Mjqd_EnOut.Value * pFloating); item.Mjqx_ExIn = Math.Round(pTemp.Mjqx_ExIn.Value * pFloating); item.Mjqx_EnOut = Math.Round(pTemp.Mjqx_EnOut.Value * pFloating); item.Cy_EnOut = Math.Round(pTemp.Cy_EnOut.Value * pFloating); item.Cy_ExIn = Math.Round(pTemp.Cy_ExIn.Value * pFloating); item.CalcuTime = para.StartTime.Value; 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.CalibrationRangeFaile; } } } catch (Exception e) { pReturnValue.ResultKey = (byte)EResult.Fail; pReturnValue.ResultValue = TipInfo.CalibrationFaile + e.Message.ToString(); SystemLog.GetInstance().Error(TipInfo.CalibrationFaile, e); return pReturnValue; } return pReturnValue; }
/// <summary> /// 修改用户信息 /// </summary> /// <param name="userInfo">修改用户信息实体</param> /// <returns>结果</returns> public CustomResult Update(UpdateUserInfoViewModel userInfo) { using (DataSubmittedEntities db = new DataSubmittedEntities()) { using (TransactionScope transaction = new TransactionScope()) { CustomResult pReturnValue = new CustomResult(); //查找用户表中是否已经存在该用户 var user = db.OT_User.Where(a => a.Name == userInfo.UserName&a.Id!=userInfo.UserId).Select(a => new { UserId = a.Id, IsDelete = a.IsDelete }).ToList(); //有记录,则返回用户已存在 if (user != null && user.Count > 0) { if (user[0].IsDelete == (byte)EUserStatus.Normal) { pReturnValue.ResultKey = (byte)EResult.IsRepeat; pReturnValue.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.AddFaileHasUser; } else { pReturnValue.ResultKey = (byte)EResult.IsRepeatDel; pReturnValue.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.AddFaileHasDelUser; } return pReturnValue; } //修改用户名 var listUserName = db.OT_User.Where(a => a.Id == userInfo.UserId).ToList(); //如果用户不存在,这返回,说明数据不是正常输入 if (!(listUserName != null && listUserName.Count > 0)) { pReturnValue.ResultKey = (byte)EResult.IsNull4; } listUserName[0].Name = userInfo.UserName; //获取用户角色关系 var list = db.OT_UserRole.Where(a => a.UserId == userInfo.UserId & a.IsDelete == (byte)EDataStatus.Normal).ToList(); //删除用户角色关系 foreach (var model in list) { model.IsDelete = (byte)EDataStatus.IsDelete; } //添加用户角色关系 foreach (Guid roleId in userInfo.RoleIdList) { OT_UserRole userRoleInfo = new OT_UserRole(); userRoleInfo.Id = Guid.NewGuid(); userRoleInfo.IsDelete = (byte)EDataStatus.Normal; userRoleInfo.RoleId = roleId; userRoleInfo.UserId = userInfo.UserId; db.OT_UserRole.Add(userRoleInfo); } pReturnValue = Result.SaveChangesResult(db, transaction); return pReturnValue; } } }
/// <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> /// 修改节点 /// </summary> /// <param name="model">数据字典实体</param> /// <returns>影响行数</returns> public CustomResult Update(DAL.OT_Dic model) { model.Name = model.Name.Trim();//去除空格 using (TransactionScope transaction = new TransactionScope()) { CustomResult pReturnValue = new CustomResult(); //检查同一级别的节点中是否已经存在了该节点的名称 var id = db.OT_Dic.Where(a => a.Belong == model.Belong & a.Name == model.Name & a.Id != model.Id).ToList(); if (id != null && id.Count > 0) { pReturnValue.ResultKey = (byte)ENodeAddResult.Exist; pReturnValue.ResultValue = Wttech.DataSubmitted.Common.Resources.TipInfo.Exist; return pReturnValue; } else { var list = db.OT_Dic.Where(a => a.Id == model.Id).ToList(); foreach (OT_Dic info in list) { if (!string.IsNullOrEmpty(model.Name)) info.Name = model.Name; if (model.Rank != null) info.Rank = model.Rank; if (!string.IsNullOrEmpty(model.Rek)) info.Rek = model.Rek; if (model.IsDelete != null) info.IsDelete = model.IsDelete; } return Result.SaveUpdateResult(db, transaction); } } }