public static bool Update(ParkFeeRule model) { if (model == null) { throw new ArgumentNullException("model"); } ParkArea parkArea = ParkAreaServices.QueryByRecordId(model.AreaID); if (parkArea == null) { throw new MyException("获取区域信息失败"); } IParkFeeRule factory = ParkFeeRuleFactory.GetFactory(); if (model.IsOffline) { List <ParkFeeRule> models = factory.QueryParkFeeRuleByParkingId(parkArea.PKID); if (models.Exists(p => p.IsOffline == true && p.FeeRuleID != model.FeeRuleID)) { throw new MyException("该车场已存在脱机收费规则了"); } } model.ParkFeeRuleDetails.ForEach(p => { p.RuleDetailID = GuidGenerator.GetGuid().ToString(); p.RuleID = model.FeeRuleID; }); bool result = factory.Update(model); if (result) { OperateLogServices.AddOperateLog <ParkFeeRule>(model, OperateType.Update); } return(result); }
public JsonResult Edit(ParkArea model) { try { bool result = false; if (string.IsNullOrWhiteSpace(model.AreaID)) { result = ParkAreaServices.Add(model); } else { result = ParkAreaServices.Update(model); } if (!result) { throw new MyException("保存区域失败"); } return(Json(MyResult.Success())); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "保存区域信息失败"); return(Json(MyResult.Error("保存失败"))); } }
public JsonResult DownloadQRCode(string gateId, int size) { try { List <int> dics = new List <int>(); dics.Add(258); dics.Add(344); dics.Add(430); dics.Add(860); dics.Add(1280); List <string> imgs = new List <string>(); ParkGate gate = ParkGateServices.QueryByRecordId(gateId); if (gate == null) { throw new MyException("获取通道信息失败"); } BaseCompany company = CompanyServices.QueryByBoxID(gate.BoxID); if (company == null) { throw new MyException("获取单位信息失败"); } ParkBox box = ParkBoxServices.QueryByRecordId(gate.BoxID); if (box == null) { throw new MyException("获取岗亭信息失败"); } ParkArea area = ParkAreaServices.QueryByRecordId(box.AreaID); if (area == null) { throw new MyException("获取区域信息失败"); } BaseParkinfo parking = ParkingServices.QueryParkingByParkingID(area.PKID); if (parking == null) { throw new MyException("获取车场信息失败"); } string content = string.Format("{0}/qrl/scio_ix_pid={1}^io={2}", SystemDefaultConfig.SystemDomain, parking.PKID, gate.GateID); foreach (var item in dics) { string parkingName = string.Format("{0}_{1}_{2}_{3}_{4}", parking.PKName, area.AreaName, box.BoxName, gate.GateName, item); string result = QRCodeServices.GenerateQRCode(company.CPID, content, item, parkingName); imgs.Add(item.ToString() + "|" + result); } return(Json(MyResult.Success("", imgs))); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "下载二维码失败"); return(Json(MyResult.Error("下载二维码失败"))); } }
public JsonResult GetParkFeeRuleData() { JsonResult json = new JsonResult(); try { if (string.IsNullOrEmpty(Request.Params["parkingId"])) { return(json); } string parkingId = Request.Params["parkingId"].ToString(); List <ParkCarType> carTypes = ParkCarTypeServices.QueryParkCarTypeByParkingId(parkingId); List <ParkCarModel> carModels = ParkCarModelServices.QueryByParkingId(parkingId); List <ParkFeeRule> rules = ParkFeeRuleServices.QueryParkFeeRuleByParkingId(parkingId); List <ParkArea> areas = ParkAreaServices.GetParkAreaByParkingId(parkingId); List <ParkFeeRuleView> models = new List <ParkFeeRuleView>(); foreach (var item in rules) { ParkFeeRuleView view = new ParkFeeRuleView().ToParkFeeRuleView(item, areas, carTypes, carModels); view.ParkingID = parkingId; models.Add(view); } json.Data = models; } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "获取收费规则集合失败"); } return(json); }
/// <summary> /// 根据车场信息获取区域信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public string GetParkAreaData(string parkingId) { try { if (string.IsNullOrWhiteSpace(parkingId)) { return("{\"rows\":[]}"); } List <ParkArea> parkAreas = ParkAreaServices.GetParkAreaByParkingId(parkingId); string json = "{\"rows\":["; var topAreas = parkAreas.Where(p => string.IsNullOrWhiteSpace(p.MasterID)); foreach (var dr in topAreas) { json += "{\"id\":" + dr.ID + ","; json += "\"AreaID\":\"" + dr.AreaID + "\""; json += ",\"AreaName\":\"" + dr.AreaName + "\""; json += ",\"PKID\":\"" + dr.PKID + "\""; json += ",\"CarbitNum\":" + dr.CarbitNum + ""; json += ",\"MasterID\":\"" + dr.MasterID + "\""; json += ",\"Remark\":\"" + dr.Remark + "\""; json += ",\"NeedToll\":\"" + (int)dr.NeedToll + "\""; json += ",\"TwoCameraWait\":\"" + (int)dr.TwoCameraWait + "\""; json += ",\"CameraWaitTime\":\"" + dr.CameraWaitTime + "\""; json += ",\"iconCls\":\"my-pkarea-icon\"},"; var childs = parkAreas.Where(p => p.MasterID == dr.AreaID); foreach (var obj in childs) { json += "{\"id\":" + obj.ID + ","; json += "\"AreaID\":\"" + obj.AreaID + "\""; json += ",\"AreaName\":\"" + obj.AreaName + "\""; json += ",\"PKID\":\"" + obj.PKID + "\""; json += ",\"ParkingID\":\"" + obj.PKID + "\""; json += ",\"CarbitNum\":" + obj.CarbitNum + ""; json += ",\"MasterID\":\"" + obj.MasterID + "\""; json += ",\"Remark\":\"" + obj.Remark + "\""; json += ",\"NeedToll\":\"" + (int)obj.NeedToll + "\""; json += ",\"TwoCameraWait\":\"" + (int)obj.TwoCameraWait + "\""; json += ",\"CameraWaitTime\":\"" + obj.CameraWaitTime + "\""; json += ",\"_parentId\":\"" + dr.AreaID + "\""; json += ",\"iconCls\":\"my-pkarea-icon\"},"; } } if (topAreas.Count() > 0) { json = json.Substring(0, json.Length - 1); } json += "]}"; return(json); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "根据车场编号获取车场区域信息失败"); return("{\"rows\":[]}"); } }
/// <summary> /// 获取区域 /// </summary> /// <returns></returns> public JsonResult GetAreas() { string parkingid = Request.Params["parkingid"]; JsonResult json = new JsonResult(); try { json.Data = ParkAreaServices.GetParkAreaByParkingId(parkingid); } catch { } return(json); }
public JsonResult GetParkArea() { JsonResult json = new JsonResult(); if (string.IsNullOrEmpty(Request.Params["parkingId"])) { return(json); } string parkingId = Request.Params["parkingId"].ToString(); json.Data = ParkAreaServices.GetParkAreaByParkingId(parkingId); return(json); }
/// <summary> /// 根据车场ID获取区域树 /// </summary> /// <returns></returns> public string GetAreaTreeData() { string parkingId = Request.Params["parkingId"].ToString(); string excludeAreaID = string.Empty; if (!string.IsNullOrWhiteSpace(Request.Params["excludeAreaID"])) { excludeAreaID = Request.Params["excludeAreaID"].ToString(); } List <ParkArea> models = ParkAreaServices.GetParkAreaByParkingId(parkingId); List <ParkArea> parkAreas = new List <ParkArea>(); if (!string.IsNullOrWhiteSpace(excludeAreaID)) { //是修改,并且存在下属区域 List <ParkArea> childParkAreas = models.Where(p => p.MasterID == excludeAreaID).ToList(); if (childParkAreas.Count == 0) { parkAreas = models.Where(p => string.IsNullOrWhiteSpace(p.MasterID) && p.AreaID != excludeAreaID).ToList(); } } else { parkAreas = models.Where(p => string.IsNullOrWhiteSpace(p.MasterID)).ToList(); } parkAreas.Insert(0, new ParkArea { AreaID = string.Empty, AreaName = "顶级" }); string json = "["; foreach (var dr in parkAreas) { json += "{\"id\":\"" + dr.AreaID + "\","; json += "\"attributes\":{\"type\":0},"; json += "\"text\":\"" + dr.AreaName + "\""; json += "},"; } if (parkAreas.Count() > 0) { json = json.Substring(0, json.Length - 1); } json += "]"; return(json); }
public ActionResult SaveBooking(string plateNo, string parkingId, string areaId, DateTime startTime, DateTime endTime) { try { WXReserveBitResult result = PkBitBookingServices.WXReservePKBit(WeiXinUser.AccountID, string.Empty, parkingId, areaId, plateNo, startTime, endTime); if (result.code == 0) { if (parkingId != result.Order.PKID) { throw new MyException("车场编号不一致"); } BaseParkinfo parking = ParkingServices.QueryParkingByParkingID(parkingId); if (parking == null) { throw new MyException("获取车场信息失败"); } ViewBag.ParkingName = parking.PKName; ParkArea area = ParkAreaServices.QueryByRecordId(areaId); if (area == null) { throw new MyException("获取区域信息失败"); } ViewBag.AreaName = area.AreaName; ViewBag.PlateNo = plateNo; ViewBag.StartTime = startTime.ToString("yyyy-MM-dd HH:mm:ss"); ViewBag.EndTime = endTime.ToString("yyyy-MM-dd HH:mm:ss"); ViewBag.AreaId = areaId; return(View(result)); } if (result.code == 1) { throw new MyException("您已经预约过了,请勿重复预约"); } throw new MyException("预约失败[" + result.message + "]"); } catch (MyException ex) { return(PageAlert("Index", "ParkBitBooking", new { RemindUserContent = ex.Message })); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("WeiXinWeb", "预约失败", ex, LogFrom.WeiXin); return(PageAlert("Index", "ParkBitBooking", new { RemindUserContent = "预约失败!" })); } }
public string GetPrakAreaTreeData() { try { StringBuilder strAreaTree = new StringBuilder(); List <BaseParkinfo> parkings = ParkingServices.QueryParkingByVillageIds(GetLoginUserVillages.Select(p => p.VID).ToList()); if (parkings.Count == 0) { return(string.Empty); } List <ParkArea> parkAreas = ParkAreaServices.GetParkAreaByParkingIds(parkings.Select(p => p.PKID).ToList()); strAreaTree.Append("["); int index = 1; foreach (var item in GetLoginUserVillages) { BaseCompany company = GetLoginUserRoleCompany.FirstOrDefault(p => p.CPID == item.CPID); if (company == null) { continue; } string text = string.Format("{0}【{1}】", item.VName, company.CPName); strAreaTree.Append("{\"id\":\"" + item.VID + "\","); strAreaTree.Append("\"iconCls\":\"my-village-icon\","); strAreaTree.Append("\"attributes\":{\"type\":0},"); strAreaTree.Append("\"text\":\"" + text + "\""); GetParkingTreeData(parkings, parkAreas, item.VID, strAreaTree); strAreaTree.Append("}"); if (index != GetLoginUserVillages.Count) { strAreaTree.Append(","); } index++; } strAreaTree.Append("]"); return(strAreaTree.ToString()); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "构建车场区域树失败"); return(string.Empty); } }
private string GetParkingId(string pid, string bid, string gid) { try { if (!string.IsNullOrWhiteSpace(pid)) { return(pid); } if (!string.IsNullOrWhiteSpace(bid)) { ParkBox box = ParkBoxServices.QueryByRecordId(bid); if (box != null) { ParkArea area = ParkAreaServices.QueryByRecordId(box.AreaID); if (area != null) { return(area.PKID); } } } if (!string.IsNullOrWhiteSpace(gid)) { ParkGate gate = ParkGateServices.QueryByRecordId(gid); if (gate != null) { ParkBox box = ParkBoxServices.QueryByRecordId(gate.BoxID); if (box != null) { ParkArea area = ParkAreaServices.QueryByRecordId(box.AreaID); if (area != null) { return(area.PKID); } } } } } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("QRCodeParkPayment", "GetParkingId方法处理异常", ex, LogFrom.WeiXin); } return(string.Empty); }
public JsonResult Delete(string areaId) { try { bool result = ParkAreaServices.Delete(areaId); if (!result) { throw new MyException("删除区域失败"); } return(Json(MyResult.Success())); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "删除区域信息失败"); return(Json(MyResult.Error("删除失败"))); } }
public string GetAreaDataByParkingId(string parkingId) { StringBuilder strTree = new StringBuilder(); strTree.Append("["); strTree.Append("{\"id\":\"-1\","); strTree.Append("\"text\":\"所有\",\"selected\":true"); strTree.Append("}"); if (!string.IsNullOrWhiteSpace(parkingId)) { List <ParkArea> areas = ParkAreaServices.GetParkAreaByParkingId(parkingId); foreach (var item in areas) { strTree.Append(",{\"id\":\"" + item.AreaID + "\","); strTree.Append("\"text\":\"" + item.AreaName + "\""); strTree.Append("}"); } } strTree.Append("]"); return(strTree.ToString()); }
public ActionResult Passed(string recordId) { try { List <BaseVillage> villages = VillageServices.QueryVillageByEmployeeMobilePhone(WeiXinUser.MobilePhone); List <EnumContext> parkContexts = new List <EnumContext>(); if (villages.Count > 0) { List <BaseParkinfo> parkings = ParkingServices.QueryParkingByVillageIds(villages.Select(p => p.VID).ToList()); foreach (var item in parkings) { EnumContext model = new EnumContext(); model.Description = item.PKName; model.EnumString = item.PKID; parkContexts.Add(model); } } ViewBag.ParkContexts = parkContexts; ParkMonthlyCarApply monthlyCarApply = ParkMonthlyCarApplyServices.QueryByRecordID(recordId); if (monthlyCarApply == null) { throw new MyException("申请信息不存在"); } List <ParkArea> areas = ParkAreaServices.GetParkAreaByParkingId(monthlyCarApply.PKID); List <EnumContext> areaContexts = new List <EnumContext>(); foreach (var item in areas) { EnumContext model = new EnumContext(); model.Description = item.AreaName; model.EnumString = item.AreaID; areaContexts.Add(model); } ViewBag.AreaContexts = areaContexts; List <EnumContext> gateContexts = new List <EnumContext>(); foreach (var item in areaContexts) { List <ParkGate> gates = ParkGateServices.QueryByParkAreaRecordIds(new List <string>() { item.EnumString }); foreach (var gate in gates) { EnumContext model = new EnumContext(); model.Description = gate.GateName; model.EnumString = string.Format("{0}|{1}", gate.GateID, item.EnumString); gateContexts.Add(model); } } ViewBag.GateContexts = gateContexts; return(View(monthlyCarApply)); } catch (Exception ex) { ExceptionsServices.AddExceptionToDbAndTxt("AdminAduitCarApply", "查看月租车申请详情失败", ex, LogFrom.WeiXin); return(RedirectToAction("Index", "AdminAduitCarApply", new { RemindUserContent = "审核失败" })); } }
/// <summary> /// 模拟参数算费 /// </summary> /// <param name="platenumber"></param> /// <param name="areaid"></param> /// <param name="intime"></param> /// <param name="exitTime"></param> /// <param name="cartypeID"></param> /// <param name="carModeid"></param> /// <returns></returns> public static ResultAgs GetRateResult(string platenumber, string areaid, DateTime intime, DateTime exitTime, string cartypeID, string carModeid = "") { if (areaid.IsEmpty()) { return(null); } string errorMsg = ""; InputAgs args = new InputAgs(); args.AreadInfo = ParkAreaServices.QueryByRecordId(areaid); args.IORecord = new ParkIORecord(); args.IORecord.EntranceTime = intime; args.IORecord.ExitTime = exitTime; args.IORecord.PlateNumber = platenumber; args.IORecord.CarTypeID = cartypeID; args.IORecord.RecordID = ""; if (args.AreadInfo.IsNestArea && args.AreadInfo.Parent == null)//内部车场时 且上级区域为空时 { args.AreadInfo.Parent = ParkAreaServices.QueryByRecordId(args.AreadInfo.MasterID); if (args.AreadInfo.Parent == null)//还是找不到上级区域时 { LogerHelper.Loger.Error(string.Format("找不到车场[{0}]的上级车场,上级车场ID为[{1}].", args.AreadInfo.AreaName, args.AreadInfo.MasterID)); args.AreadInfo.MasterID = "";//找不到就至为空 } } args.AreadInfo.Parkinfo = ParkingServices.QueryParkingByParkingID(args.AreadInfo.PKID); if (args.AreadInfo.Parkinfo == null)//还是找不到上级区域时 { LogerHelper.Loger.Error(string.Format("找不到区域[{0}]对应的车场.", args.AreadInfo.AreaName)); return(null); } args.Plateinfo = new PlateInfo(); args.Plateinfo.LicenseNum = platenumber; args.Plateinfo.TriggerTime = exitTime; args.CarTypeInfo = ParkCarTypeServices.QueryParkCarTypeByRecordId(cartypeID); if (args.CarTypeInfo == null) { return(null); } if (carModeid.IsEmpty()) { args.CarModel = ParkCarModelServices.GetDefaultCarModel(args.AreadInfo.PKID, out errorMsg); } else { args.CarModel = ParkCarModelServices.QueryByRecordId(carModeid); } if (args.CarModel == null) { return(null); } //获取默认车类型 args.GateInfo = new ParkGate(); args.GateInfo.IoState = IoState.GoOut; ResultAgs rst = new ResultAgs(); rst.InOutBaseCardType = BaseCarType.TempCar; rst.ResCode = ResultCode.OutOK; var rateContext = new RateTemplate(); rateContext.Process(args, rst); return(rst); }
/// <summary> /// 白天黑夜最大收费参数设置 /// </summary> //public static DayAndNightMaxMoneyPara DayAndNightMaxMoneyPara { get; set; } //private static XDocument document; //public static XDocument _XDocument //{ // get // { // return document; // } // private set // { // document = value; // } //} //static RateProcesser() //{ // try // { // string xmlName = "TimeShareFeeRule.xml"; // var dirName = Path.Combine(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase, xmlName); // XDocument xdoc = XDocument.Load(dirName); // foreach (var item in xdoc.Root.Elements()) // { // if (item.Attribute("IsEnable").Value.ToBoolean()) // { // _XDocument = xdoc; // } // break; // } // } // catch(Exception ex) // { // LogerHelper.Loger.Error(ex); // } //} //public static void LoadCustomFeerule(string ruletext) //{ // try // { // using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(ruletext))) // { // XDocument xdoc = XDocument.Load(stream); // foreach (var item in xdoc.Root.Elements()) // { // if (item.Attribute("IsEnable").Value.ToBoolean()) // { // _XDocument = xdoc; // } // break; // } // } // } // catch (Exception ex) // { // LogerHelper.Loger.Error(ex); // } //} /// <summary> /// 根据入场记录算费 /// </summary> /// <param name="ioRecord"></param> /// <returns></returns> public static ResultAgs GetRateResult(ParkIORecord ioRecord, ParkGate outGate, DateTime exitTime, string carModeid = "") { if (outGate == null) { return(null); } string errorMsg = ""; InputAgs args = new InputAgs(); args.AreadInfo = ParkAreaServices.QueryByRecordId(ioRecord.AreaID); if (args.AreadInfo.IsNestArea && args.AreadInfo.Parent == null)//内部车场时 且上级区域为空时 { args.AreadInfo.Parent = ParkAreaServices.QueryByRecordId(args.AreadInfo.MasterID); if (args.AreadInfo.Parent == null)//还是找不到上级区域时 { LogerHelper.Loger.Error(string.Format("找不到车场[{0}]的上级车场,上级车场ID为[{1}].", args.AreadInfo.AreaName, args.AreadInfo.MasterID)); args.AreadInfo.MasterID = "";//找不到就至为空 } } args.AreadInfo.Parkinfo = ParkingServices.QueryParkingByParkingID(args.AreadInfo.PKID); if (args.AreadInfo.Parkinfo == null)//还是找不到上级区域时 { LogerHelper.Loger.Error(string.Format("找不到区域[{0}]对应的车场.", args.AreadInfo.AreaName)); return(null); } args.Plateinfo = new PlateInfo(); args.Plateinfo.LicenseNum = ioRecord.PlateNumber; args.Plateinfo.TriggerTime = exitTime; args.CarTypeInfo = ParkCarTypeServices.QueryParkCarTypeByRecordId(ioRecord.CarTypeID); string str = errorMsg; EmployeePlate platenumber = EmployeePlateServices.GetEmployeePlateNumberByPlateNumber(args.AreadInfo.Parkinfo.VID, args.Plateinfo.LicenseNum, out errorMsg); if (platenumber != null) { //根据车牌获取车辆用户信息 var pkcard = ParkGrantServices.GetParkGrantByPlateNumberID(args.AreadInfo.PKID, platenumber.PlateID, out errorMsg); if (pkcard.Count() > 0) { //判断是否有区域 通道限制 var cardinfo = pkcard.First(); args.CardInfo = cardinfo; args.CardInfo.OwnerPlateNumber = platenumber; var usercard = BaseCardServices.GetBaseCard(args.CardInfo.CardID, out errorMsg); if (usercard != null) { args.CardInfo.Usercard = usercard; } else { args.CardInfo = null; } if (!args.CardInfo.CarModelID.IsEmpty()) { carModeid = args.CardInfo.CarModelID; } } } if (args.CarTypeInfo == null) { return(null); } if (carModeid.IsEmpty()) { args.CarModel = ParkCarModelServices.GetDefaultCarModel(args.AreadInfo.PKID, out errorMsg); } else { args.CarModel = ParkCarModelServices.QueryByRecordId(carModeid); if (args.CarModel == null) { args.CarModel = ParkCarModelServices.GetDefaultCarModel(args.AreadInfo.PKID, out errorMsg); } } if (args.CarModel == null) { return(null); } //获取默认车类型 args.GateInfo = outGate; args.IORecord = ioRecord; ResultAgs rst = new ResultAgs(); rst.InOutBaseCardType = BaseCarType.TempCar; rst.ResCode = ResultCode.OutOK; var rateContext = new RateTemplate(); rateContext.Process(args, rst); return(rst); }
/// <summary> /// Context工厂 /// </summary> /// <param name="args"></param> /// <returns></returns> private RuleHandler CreateRuleHandler(InputAgs args, ResultAgs rst) { string errorMsg = ""; if (args.AreadInfo.IsNestArea && args.AreadInfo.Parent == null)//内部车场时 且上级区域为空时 { args.AreadInfo.Parent = ParkAreaServices.QueryByRecordId(args.AreadInfo.MasterID); if (args.AreadInfo.Parent == null)//还是找不到上级区域时 { LogerHelper.Loger.Error(string.Format("找不到车场[{0}]的上级车场,上级车场ID为[{1}].", args.AreadInfo.AreaName, args.AreadInfo.MasterID)); args.AreadInfo.MasterID = "";//找不到就至为空 } } //判断系统停车或非系统停车 var cartype = BaseCarType.TempCar; if (!args.Plateinfo.LicenseNum.Contains("无") && args.Plateinfo.LicenseNum.Length > 3)//不是“无车牌” { EmployeePlate platenumber = null; if (args.GateInfo.OpenPlateBlurryMatch == YesOrNo.Yes) { string likeplate = args.Plateinfo.LicenseNum; platenumber = EmployeePlateServices.GetEmployeePlateNumberByPlateNumber(args.AreadInfo.Parkinfo.VID, likeplate, out errorMsg); if (platenumber == null && args.Plateinfo.LicenseNum.Length >= 3)//模糊识别 前一位后一位模糊识别 { likeplate = args.Plateinfo.LicenseNum.Substring(2, args.Plateinfo.LicenseNum.Length - 2); platenumber = EmployeePlateServices.GetGrantPlateNumberByLike(args.AreadInfo.Parkinfo.VID, likeplate, out errorMsg); if (platenumber == null) { likeplate = args.Plateinfo.LicenseNum.Substring(0, args.Plateinfo.LicenseNum.Length - 2); platenumber = EmployeePlateServices.GetGrantPlateNumberByLike(args.AreadInfo.Parkinfo.VID, likeplate, out errorMsg); } if (platenumber != null) { args.Plateinfo.LicenseNum = platenumber.PlateNo; } } } else { platenumber = EmployeePlateServices.GetEmployeePlateNumberByPlateNumber(args.AreadInfo.Parkinfo.VID, args.Plateinfo.LicenseNum, out errorMsg); } if (platenumber != null) { //根据车牌获取车辆用户信息 var pkcard = ParkGrantServices.GetParkGrantByPlateNumberID(args.AreadInfo.PKID, platenumber.PlateID, out errorMsg); if (pkcard.Count() > 0) { //判断是否有区域 通道限制 var cardinfo = pkcard.First(); args.LastCardInfo = cardinfo; if (cardinfo.AreaIDS.IsEmpty())//没有限制 { if ((cardinfo.GateID.IsEmpty()) || cardinfo.GateID.Contains(args.GateInfo.GateID)) //区域包含 且通道未控制授权 或 通道已经授权 { args.CardInfo = cardinfo; args.CardInfo.OwnerPlateNumber = platenumber; var usercard = BaseCardServices.GetBaseCard(args.CardInfo.CardID, out errorMsg); if (usercard != null) { args.CardInfo.Usercard = usercard; } else { args.CardInfo = null; } } } else { if (cardinfo.AreaIDS.Contains(args.AreadInfo.AreaID) && (cardinfo.GateID.IsEmpty()) || cardinfo.GateID.Contains(args.GateInfo.GateID)) //区域包含 且通道未控制授权 或 通道已经授权 { args.CardInfo = cardinfo; args.CardInfo.OwnerPlateNumber = platenumber; var usercard = BaseCardServices.GetBaseCard(args.CardInfo.CardID, out errorMsg); if (usercard != null) { args.CardInfo.Usercard = usercard; } else { args.CardInfo = null; } } } if (args.CardInfo == null) { rst.ValidMsg = "非本区域月卡"; } } } if (args.CardInfo != null) { var pkcardtype = ParkCarTypeServices.QueryParkCarTypeByRecordId(args.CardInfo.CarTypeID); if (pkcardtype != null) { args.CarTypeInfo = pkcardtype; } else { //获取对应的卡类型 var pkcardtypes = ParkCarTypeServices.QueryCardTypesByBaseCardType(args.AreadInfo.PKID, BaseCarType.TempCar); if (pkcardtypes != null && pkcardtypes.Count() > 0) { args.CarTypeInfo = pkcardtypes.First(); } } if (!args.CardInfo.CarModelID.IsEmpty()) { var model = ParkCarModelServices.QueryByRecordId(args.CardInfo.CarModelID); args.CarModel = model; } if (args.CarModel == null) { //获取卡对应的车类型 var listcarmodel = ParkCarModelServices.GetDefaultCarModel(args.AreadInfo.PKID, out errorMsg); if (listcarmodel != null) { args.CarModel = listcarmodel; } } } else { //默认为临时车 var pkcardtypes = ParkCarTypeServices.QueryCardTypesByBaseCardType(args.AreadInfo.PKID, BaseCarType.TempCar); if (pkcardtypes != null && pkcardtypes.Count() > 0) { args.CarTypeInfo = pkcardtypes.First(); } ////获取默认车类型 //var listcarmodel = ParkCarModelServices.GetDefaultCarModel(args.AreadInfo.PKID, out errorMsg); //if (listcarmodel != null) //{ // args.CarModel = listcarmodel; //} if (args.Plateinfo.PlateColor != null && args.Plateinfo.PlateColor.Contains("黄")) { var list = ParkCarModelServices.QueryByParkingId(args.AreadInfo.PKID); foreach (var item in list) { if (item.PlateColor != null && item.PlateColor.Contains("黄")) { args.CarModel = item; break; } } } if (args.CarModel == null) { //获取卡对应的车类型 var carmode = ParkCarModelServices.GetDefaultCarModel(args.AreadInfo.PKID, out errorMsg); if (carmode != null) { args.CarModel = carmode; } } } } else { //默认为临时车 var pkcardtypes = ParkCarTypeServices.QueryCardTypesByBaseCardType(args.AreadInfo.PKID, BaseCarType.TempCar); if (pkcardtypes != null && pkcardtypes.Count() > 0) { args.CarTypeInfo = pkcardtypes.First(); } if (args.Plateinfo.PlateColor != null && args.Plateinfo.PlateColor.Contains("黄")) { var list = ParkCarModelServices.QueryByParkingId(args.AreadInfo.PKID); foreach (var item in list) { if (item.PlateColor != null && item.PlateColor.Contains("黄")) { args.CarModel = item; break; } } } if (args.CarModel == null) { //获取卡对应的车类型 var carmode = ParkCarModelServices.GetDefaultCarModel(args.AreadInfo.PKID, out errorMsg); if (carmode != null) { args.CarModel = carmode; } } } if (args.AreadInfo.IsNestArea)//小车场 先查询对应的通行记录 { ParkIORecord ioRecord = ParkIORecordServices.GetNoExitIORecordByPlateNumber(args.AreadInfo.PKID, args.Plateinfo.LicenseNum, out errorMsg); args.NestAreaIORecord = ioRecord; } if (args.CarTypeInfo == null) { rst.ResCode = ResultCode.LocalError; throw new Exception("参数错误:默认卡片类型为空"); } if (args.CarTypeInfo == null) { rst.ResCode = ResultCode.LocalError; throw new Exception("参数错误:默认车辆类型为空"); } cartype = args.CarTypeInfo.BaseTypeID; #region 生产对应的验证规则 //此处可根据配置文件利用反射生成配置的验证规则 RuleHandler ruleHandler = null; switch (cartype) { case BaseCarType.MonthlyRent: #region 月卡 if (args.GateInfo.IoState == IoState.GoIn) //进 { ruleHandler = RuleHandlerFactory.Instance.CreateMonthMainInRuleHandler(); } else //出 { ruleHandler = RuleHandlerFactory.Instance.CreateMonthMainOutRuleHandler(); } #endregion break; case BaseCarType.TempCar: #region 临时卡 if (args.GateInfo.IoState == IoState.GoIn) //进 { ruleHandler = RuleHandlerFactory.Instance.CreateTempMainInRuleHandler(); } else //出 { ruleHandler = RuleHandlerFactory.Instance.CreateTempMainOutRuleHandler(); } #endregion break; case BaseCarType.StoredValueCar: #region 储值卡 if (args.GateInfo.IoState == IoState.GoIn) //进 { ruleHandler = RuleHandlerFactory.Instance.CreateValueMainInRuleHandler(); } else //出 { ruleHandler = RuleHandlerFactory.Instance.CreateValueMainOutRuleHandler(); } #endregion break; case BaseCarType.VIPCar: #region VIP卡 if (args.GateInfo.IoState == IoState.GoIn) //进 { ruleHandler = RuleHandlerFactory.Instance.CreateVIPMainInRuleHandler(); } else //出 { ruleHandler = RuleHandlerFactory.Instance.CreateVIPMainOutRuleHandler(); } #endregion break; } #endregion return(ruleHandler); }