/// <summary> /// 写入日志,非报表类操作 /// </summary> /// <param name="type">操作类型</param> /// <param name="describe">操作描述</param> /// <returns></returns> public byte WriteLog(String type, string describe) { OT_Log pTemp = new OT_Log(); try { var pUser = SessionManage.GetLoginUser(); if (pUser != null) { pTemp.Id = Guid.NewGuid(); pTemp.LogDate = DateTime.Now; pTemp.Type = type; pTemp.UserName = pUser.UserName; pTemp.RptName = string.Empty; pTemp.Describe = describe; if (pUser.RoleList.Count > 0 && pUser.RoleList[0] != null) { pTemp.RoleName = pUser.RoleList[0].RoleName; } return(Create(pTemp)); } } catch (Exception ex) { SystemLog.GetInstance().Error("插入操作日志失败!", ex); } return((byte)EResult.Fail); }
/// <summary> /// 写入日志,报表类操作 /// </summary> /// <param name="type">操作类型</param> /// <param name="report">报表名称</param> /// <param name="dt">时间(yyyy-MM-dd)或时间范围(yyyy-MM-dd - yyyy-MM-dd)</param> /// <returns></returns> public byte WriteLog(String type, String report, String dt) { OT_Log pTemp = new OT_Log(); try { var pUser = SessionManage.GetLoginUser(); if (pUser != null) { pTemp.Id = Guid.NewGuid(); pTemp.LogDate = DateTime.Now; pTemp.Type = type; pTemp.UserName = pUser.UserName; if (type != OperationType.Login && type != OperationType.LoginOut) { pTemp.RptName = report; pTemp.Describe = String.Format("{0}{1}{2}", type, dt, report); } if (pUser.RoleList.Count > 0 && pUser.RoleList[0] != null) { pTemp.RoleName = pUser.RoleList[0].RoleName; } return(Create(pTemp)); } } catch (Exception ex) { SystemLog.GetInstance().Error("插入操作日志失败!", ex); } return((byte)EResult.Fail); }
/// <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="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 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="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); } }