Ejemplo n.º 1
0
 public bool Add(EmployeePlate model)
 {
     using (DbOperator dbOperator = ConnectionManager.CreateConnection())
     {
         return(Add(model, dbOperator));
     }
 }
Ejemplo n.º 2
0
        public static bool Update(EmployeePlate model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            IEmployeePlate factory = EmployeePlateFactory.GetFactory();

            return(factory.Update(model));
        }
Ejemplo n.º 3
0
        public static bool Add(BaseEmployee employee, EmployeePlate plate, BaseCard card, ParkGrant parkGrant, DbOperator dbOperator)
        {
            if (employee == null)
            {
                throw new ArgumentNullException("employee");
            }
            if (plate == null)
            {
                throw new ArgumentNullException("plate");
            }
            if (card == null)
            {
                throw new ArgumentNullException("card");
            }
            if (parkGrant == null)
            {
                throw new ArgumentNullException("parkGrant");
            }

            bool result = BaseEmployeeServices.AddOrUpdateBaseEmployee(employee, dbOperator);

            if (!result)
            {
                throw new MyException("保存人员信息失败");
            }

            result = BaseCardServices.AddOrUpdateCard(card, dbOperator);
            if (!result)
            {
                throw new MyException("保存卡信息失败");
            }

            result = EmployeePlateServices.AddOrUpdateEmployeePlate(plate, dbOperator);
            if (!result)
            {
                throw new MyException("保存车牌信息失败");
            }

            parkGrant.PlateID = plate.PlateID;
            parkGrant.CardID  = card.CardID;
            result            = AddOrderUpdateParkGrant(parkGrant, dbOperator);
            if (!result)
            {
                throw new MyException("保存授权失败");
            }
            if (result)
            {
                OperateLogServices.AddOperateLog <BaseEmployee>(employee, OperateType.Add);
                OperateLogServices.AddOperateLog <EmployeePlate>(plate, OperateType.Add);
                OperateLogServices.AddOperateLog <BaseCard>(card, OperateType.Add);
                OperateLogServices.AddOperateLog <ParkGrant>(parkGrant, OperateType.Add);
            }
            return(result);
        }
Ejemplo n.º 4
0
        public static bool Add(EmployeePlate model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            model.PlateID = GuidGenerator.GetGuidString();
            IEmployeePlate factory = EmployeePlateFactory.GetFactory();

            return(factory.Add(model));
        }
Ejemplo n.º 5
0
        public static bool AddOrUpdateEmployeePlate(EmployeePlate plate, DbOperator dbOperator)
        {
            IEmployeePlate plateFactory = EmployeePlateFactory.GetFactory();
            EmployeePlate  oldPlate     = plateFactory.Query(plate.PlateID);

            if (oldPlate == null)
            {
                return(plateFactory.Add(plate, dbOperator));
            }
            else
            {
                oldPlate.Color      = plate.Color;
                oldPlate.PlateNo    = plate.PlateNo;
                oldPlate.EmployeeID = plate.EmployeeID;
                plate = oldPlate;
                return(plateFactory.Update(plate, dbOperator));
            }
        }
Ejemplo n.º 6
0
        public bool Update(EmployeePlate model, DbOperator dbOperator)
        {
            model.LastUpdateTime = DateTime.Now;
            model.HaveUpdate     = SystemDefaultConfig.DataUpdateFlag;

            StringBuilder strSql = new StringBuilder();

            strSql.Append("update EmployeePlate set EmployeeID=@EmployeeID,PlateNo=@PlateNo,Color=@Color,CarBrand=@CarBrand,LastUpdateTime=@LastUpdateTime,HaveUpdate=@HaveUpdate");
            strSql.Append(" where PlateID=@PlateID");
            dbOperator.ClearParameters();
            dbOperator.AddParameter("PlateID", model.PlateID);
            dbOperator.AddParameter("EmployeeID", model.EmployeeID);
            dbOperator.AddParameter("PlateNo", model.PlateNo);
            dbOperator.AddParameter("Color", (int)model.Color);
            dbOperator.AddParameter("CarBrand", model.CarBrand);
            dbOperator.AddParameter("LastUpdateTime", model.LastUpdateTime);
            dbOperator.AddParameter("HaveUpdate", model.HaveUpdate);
            return(dbOperator.ExecuteNonQuery(strSql.ToString()) > 0);
        }
Ejemplo n.º 7
0
        public bool Add(EmployeePlate model, DbOperator dbOperator)
        {
            model.DataStatus     = DataStatus.Normal;
            model.LastUpdateTime = DateTime.Now;
            model.HaveUpdate     = SystemDefaultConfig.DataUpdateFlag;

            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into EmployeePlate(PlateID,EmployeeID,PlateNo,Color,CarBrand,LastUpdateTime,HaveUpdate,DataStatus)");
            strSql.Append(" values(@PlateID,@EmployeeID,@PlateNo,@Color,@CarBrand,@LastUpdateTime,@HaveUpdate,@DataStatus)");
            dbOperator.ClearParameters();
            dbOperator.AddParameter("PlateID", model.PlateID);
            dbOperator.AddParameter("EmployeeID", model.EmployeeID);
            dbOperator.AddParameter("PlateNo", model.PlateNo);
            dbOperator.AddParameter("Color", (int)model.Color);
            dbOperator.AddParameter("CarBrand", model.CarBrand);
            dbOperator.AddParameter("LastUpdateTime", model.LastUpdateTime);
            dbOperator.AddParameter("HaveUpdate", model.HaveUpdate);
            dbOperator.AddParameter("DataStatus", (int)model.DataStatus);
            return(dbOperator.ExecuteNonQuery(strSql.ToString()) > 0);
        }
Ejemplo n.º 8
0
        public static ParkGrant GenerateParkGrantModel(string PKID, EmployeePlate plate, BaseCard card, string pkLot, string carModelId, string carTypeId, string AreaIDS, string GateID)
        {
            ParkGrant model = new ParkGrant();

            model.PKID     = PKID;
            model.CardID   = card.CardID;
            model.PlateID  = plate.PlateID;
            model.PlateNo  = plate.PlateNo;
            model.PKLot    = pkLot;
            model.PKLotNum = 0;

            ParkCarModel carModel = ParkCarModelServices.QueryByRecordId(carModelId);

            if (carModel == null)
            {
                throw new MyException("选择的车型不存在");
            }
            model.CarModelID = carModel.CarModelID;

            ParkCarType carType = ParkCarTypeServices.QueryParkCarTypeByRecordId(carTypeId);

            if (carType == null)
            {
                throw new MyException("选择的车类不存在");
            }
            model.CarTypeID = carType.CarTypeID;

            if (string.IsNullOrWhiteSpace(AreaIDS))
            {
                throw new MyException("获取选择的车场区域失败");
            }
            model.AreaIDS = AreaIDS == "-1" ? string.Empty : AreaIDS;

            if (string.IsNullOrWhiteSpace(GateID))
            {
                throw new MyException("获取选择的车场通道失败");
            }
            model.GateID = GateID == "-1" ? string.Empty : GateID;
            return(model);
        }
Ejemplo n.º 9
0
 public static bool Add(BaseEmployee employee, EmployeePlate plate, BaseCard card, ParkGrant parkGrant)
 {
     using (DbOperator dbOperator = ConnectionManager.CreateConnection())
     {
         try
         {
             dbOperator.BeginTransaction();
             bool result = Add(employee, plate, card, parkGrant, dbOperator);
             if (!result)
             {
                 throw new MyException("保存车辆信息失败");
             }
             dbOperator.CommitTransaction();
             return(result);
         }
         catch
         {
             dbOperator.RollbackTransaction();
             throw;
         }
     }
 }
Ejemplo n.º 10
0
        public static EmployeePlate GenerateEmployeePlateModel(BaseEmployee employee, string villageId, string plateNo)
        {
            EmployeePlate model = new EmployeePlate();

            model.PlateNo = plateNo;

            string        errorMsg = string.Empty;
            EmployeePlate dbPlate  = EmployeePlateServices.GetEmployeePlateNumberByPlateNumber(villageId, model.PlateNo, out errorMsg);

            if (!string.IsNullOrWhiteSpace(errorMsg))
            {
                throw new MyException("获取车牌失败");
            }
            if (dbPlate != null)
            {
                dbPlate.EmployeeID = employee.EmployeeID;
                return(dbPlate);
            }
            model.Color      = PlateColor.Blue;
            model.PlateID    = GuidGenerator.GetGuidString();
            model.EmployeeID = employee.EmployeeID;
            return(model);
        }
Ejemplo n.º 11
0
        public static decimal CalculateMonthlyRentExpiredWaitPayAmount(DateTime start, string grantId)
        {
            ParkGrant grant = ParkGrantServices.QueryByGrantId(grantId);

            if (grant == null)
            {
                throw new MyException("获取授权失败");
            }
            if (grant.BeginDate == DateTime.MinValue || grant.EndDate == DateTime.MinValue || (grant.EndDate != DateTime.MinValue && grant.EndDate.Date >= DateTime.Now.Date))
            {
                return(0);
            }
            ParkCarType carType = ParkCarTypeServices.QueryParkCarTypeByRecordId(grant.CarTypeID);

            if (carType == null)
            {
                throw new MyException("获取车类失败");
            }

            if (carType.BaseTypeID != BaseCarType.MonthlyRent)
            {
                return(0);
            }

            DateTime startDate = grant.EndDate.AddDays(1).Date;
            DateTime endDate   = start.Date;

            List <string> plateNos = new List <string>();
            EmployeePlate plate    = EmployeePlateServices.Query(grant.PlateID);

            if (plate == null)
            {
                throw new MyException("获取车牌号失败");
            }

            plateNos.Add(plate.PlateNo);

            if (!string.IsNullOrWhiteSpace(grant.PKLot))
            {
                List <ParkGrant> sameGrants = ParkGrantServices.QueryByParkingAndLotAndCarType(grant.PKID, grant.PKLot, BaseCarType.MonthlyRent, grant.GID);
                foreach (var item in sameGrants)
                {
                    int lot1 = grant.PKLot.Split(',').Length;
                    int lot2 = item.PKLot.Split(',').Length;
                    if (lot1 != lot2)
                    {
                        continue;
                    }

                    EmployeePlate plate1 = EmployeePlateServices.Query(item.PlateID);
                    if (plate1 == null)
                    {
                        throw new MyException("获取车牌号失败");
                    }
                    plateNos.Add(plate1.PlateNo);
                }
            }
            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.QueryMonthExpiredNotPayAmount(startDate, endDate, grant.PKID, plateNos));
        }
Ejemplo n.º 12
0
        public static BaseCard GenerateCardModel(string VID, string PKID, BaseEmployee employee, EmployeePlate plate, string loginUserRecordId)
        {
            BaseCard model = new BaseCard();

            model.CardID   = GuidGenerator.GetGuidString();
            model.CardNo   = plate.PlateNo;
            model.CardNumb = model.CardNo;
            model.VID      = VID;

            BaseCard oldCard = BaseCardServices.QueryBaseCardByParkingId(PKID, model.CardNo);

            if (oldCard != null)
            {
                model.CardID = oldCard.CardID;
                if (oldCard != null && oldCard.CardID != model.CardID)
                {
                    throw new MyException("车牌号已存在,不能重复添加");
                }

                string errorMsg = string.Empty;
                model = BaseCardServices.GetBaseCard(model.CardID, out errorMsg);
                if (model == null || !string.IsNullOrWhiteSpace(errorMsg))
                {
                    throw new MyException("获取卡信息失败");
                }

                model.CardNo   = plate.PlateNo;
                model.CardNumb = model.CardNo;
                model.VID      = VID;
            }
            else
            {
                if (oldCard != null)
                {
                    throw new MyException("车牌号已存在,不能重复添加");
                }
                model.RegisterTime = DateTime.Now;
            }

            model.OperatorID = loginUserRecordId;
            model.CardSystem = CardSystem.Park;
            model.EmployeeID = employee.EmployeeID;
            model.CardType   = CardType.Plate;
            return(model);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 审核通过
        /// </summary>
        /// <param name="recordId"></param>
        /// <returns></returns>
        public static bool Passed(string RecordID, string AuditRemark, string CarTypeID, string CarModelID, string AreaIDS, string GateID, string OperatorId)
        {
            if (string.IsNullOrWhiteSpace(CarTypeID))
            {
                throw new MyException("获取车类失败");
            }
            if (string.IsNullOrWhiteSpace(CarModelID))
            {
                throw new MyException("获取车型失败");
            }

            ParkMonthlyCarApply monthlyCarApply = ParkMonthlyCarApplyServices.QueryByRecordID(RecordID);

            if (monthlyCarApply == null)
            {
                throw new MyException("该申请不存在");
            }
            if (monthlyCarApply.ApplyStatus != MonthlyCarApplyStatus.Applying)
            {
                throw new MyException("该申请是申请中状态");
            }
            monthlyCarApply.CarModelID  = CarModelID;
            monthlyCarApply.CarTypeID   = CarTypeID;
            monthlyCarApply.AuditRemark = AuditRemark;

            BaseParkinfo parking = ParkingServices.QueryParkingByParkingID(monthlyCarApply.PKID);

            if (parking == null)
            {
                throw new MyException("车场信息不存在");
            }

            BaseEmployee  employee  = GenerateBaseEmployeeModel(parking.VID, monthlyCarApply.ApplyName, monthlyCarApply.ApplyMoblie, monthlyCarApply.FamilyAddress);
            EmployeePlate plate     = GenerateEmployeePlateModel(employee, parking.VID, monthlyCarApply.PlateNo);
            BaseCard      card      = GenerateCardModel(parking, employee, plate, OperatorId);
            ParkGrant     parkGrant = GenerateParkGrantModel(parking, plate, card, monthlyCarApply.PKLot, monthlyCarApply.CarModelID, monthlyCarApply.CarTypeID, AreaIDS, GateID);

            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                try
                {
                    dbOperator.BeginTransaction();
                    bool result = ParkGrantServices.Add(employee, plate, card, parkGrant, dbOperator);
                    if (!result)
                    {
                        throw new MyException("保存车辆信息失败");
                    }

                    IParkMonthlyCarApply factory = ParkMonthlyCarApplyFactory.GetFactory();
                    result = factory.Passed(monthlyCarApply, dbOperator);
                    if (!result)
                    {
                        throw new MyException("修改申请状态失败");
                    }

                    dbOperator.CommitTransaction();
                    monthlyCarApply = ParkMonthlyCarApplyServices.QueryByRecordID(monthlyCarApply.RecordID);
                    OperateLogServices.AddOperateLog <ParkMonthlyCarApply>(monthlyCarApply, OperateType.Update);
                    return(result);
                }
                catch
                {
                    dbOperator.RollbackTransaction();
                    throw;
                }
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 续期或续费
        /// </summary>
        /// <param name="grantId"></param>
        /// <param name="renewalMonth"></param>
        /// <param name="payTotalMoney"></param>
        /// <param name="operatorId"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        public static bool RenewalsOrRecharge(string grantId, int renewalMonth, decimal payTotalMoney, string operatorId, DateTime startDate, DateTime endDate)
        {
            lock (parkGrant_lock)
            {
                ParkGrant grant = ParkGrantServices.QueryByGrantId(grantId);
                if (grant == null)
                {
                    throw new MyException("获取授权信息失败");
                }

                if (endDate != null && endDate != DateTime.MinValue)
                {
                    endDate = endDate.Date.AddDays(1).AddSeconds(-1);
                }
                string   errorMsg = string.Empty;
                BaseCard card     = BaseCardServices.GetBaseCard(grant.CardID, out errorMsg);
                if (card == null || !string.IsNullOrWhiteSpace(errorMsg))
                {
                    throw new MyException("获取卡失败");
                }

                ParkCarType carType = ParkCarTypeServices.QueryParkCarTypeByRecordId(grant.CarTypeID);
                if (carType == null)
                {
                    throw new MyException("获取卡类失败");
                }

                List <ParkGrant> operateTargets = new List <ParkGrant>();
                List <string>    ioRecords      = new List <string>();

                using (DbOperator dbOperator = ConnectionManager.CreateConnection())
                {
                    try
                    {
                        bool renewalsResult = false;
                        dbOperator.BeginTransaction();
                        switch (carType.BaseTypeID)
                        {
                        case BaseCarType.StoredValueCar:
                        {
                            IBaseCard factory = BaseCardFactory.GetFactory();
                            if (payTotalMoney > 0)
                            {
                                ParkOrder order = ParkOrderServices.AddStoredValueCarOrder(grant.PKID, payTotalMoney, card, operatorId, dbOperator);
                                if (order == null)
                                {
                                    throw new MyException("创建充值订单失败");
                                }

                                decimal cardtotalmoney = card.Balance + payTotalMoney;
                                if (order.NewMoney != cardtotalmoney)
                                {
                                    throw new MyException("充值金额计算错误");
                                }
                                renewalsResult = factory.Recharge(card.CardID, payTotalMoney, dbOperator);
                                if (!renewalsResult)
                                {
                                    throw new MyException("卡充值失败【更改卡余额失败】");
                                }
                            }
                            renewalsResult = factory.SetEndDate(card.CardID, endDate, dbOperator);
                            if (!renewalsResult)
                            {
                                throw new MyException("卡充值失败【更改有效期失败】");
                            }
                            break;
                        }

                        case BaseCarType.VIPCar:
                        {
                            ParkOrder order = ParkOrderServices.AddVipCardOrder(grant.PKID, grantId, grant.BeginDate, grant.EndDate, startDate, endDate, renewalMonth, operatorId, dbOperator);
                            if (order == null)
                            {
                                throw new MyException("充值失败【创建充值订单失败】");
                            }

                            IParkGrant factory = ParkGrantFactory.GetFactory();
                            renewalsResult = factory.Renewals(grant.GID, startDate, endDate, dbOperator);
                            if (!renewalsResult)
                            {
                                throw new MyException("修改车辆有效期失败");
                            }
                            break;
                        }

                        case BaseCarType.MonthlyRent:
                        {
                            int pkLotQuantity = 1;
                            if (!string.IsNullOrWhiteSpace(grant.PKLot))
                            {
                                pkLotQuantity = grant.PKLot.TrimEnd(',').Split(',').Length;
                            }
                            decimal amount = ParkOrderServices.CalculateMonthlyRentExpiredWaitPayAmount(startDate, grantId);

                            //if (payTotalMoney != ((carType.Amount * renewalMonth * pkLotQuantity) + amount))
                            //    throw new MyException("凭证续期金额计算有误");



                            List <ParkGrant> shareCardGrants = new List <ParkGrant>();
                            if (!string.IsNullOrWhiteSpace(grant.PKLot))
                            {
                                shareCardGrants = ParkGrantServices.QueryByParkingAndLotAndCarType(grant.PKID, grant.PKLot, BaseCarType.MonthlyRent, grant.GID);
                            }
                            IParkGrant factory = ParkGrantFactory.GetFactory();
                            renewalsResult = factory.Renewals(grant.GID, startDate, endDate, dbOperator);
                            if (!renewalsResult)
                            {
                                throw new MyException("修改车辆有效期失败");
                            }


                            //修改多车多位的有效期
                            foreach (var item in shareCardGrants)
                            {
                                if (string.IsNullOrWhiteSpace(item.PKLot))
                                {
                                    continue;
                                }

                                int len1 = item.PKLot.TrimEnd(',').Split(',').Length;
                                int len2 = grant.PKLot.TrimEnd(',').Split(',').Length;
                                if (len1 != len2)
                                {
                                    continue;
                                }

                                item.BeginDate = startDate;
                                item.EndDate   = endDate;
                                factory.Update(item, dbOperator);
                                operateTargets.Add(item);
                            }
                            //过期转临停订单处理
                            if (grant.EndDate.Date < DateTime.Now.Date)
                            {
                                List <string> plateNos = new List <string>();
                                EmployeePlate plate    = EmployeePlateServices.Query(grant.PlateID);
                                if (plate == null)
                                {
                                    throw new MyException("授权车牌信息不存在");
                                }

                                plateNos.Add(plate.PlateNo);

                                foreach (var item in shareCardGrants)
                                {
                                    if (string.IsNullOrWhiteSpace(item.PKLot))
                                    {
                                        continue;
                                    }

                                    int len1 = item.PKLot.TrimEnd(',').Split(',').Length;
                                    int len2 = grant.PKLot.TrimEnd(',').Split(',').Length;
                                    if (len1 != len2)
                                    {
                                        continue;
                                    }

                                    EmployeePlate otherplate = EmployeePlateServices.Query(item.PlateID);
                                    if (otherplate == null)
                                    {
                                        throw new MyException("多车多位存在无效的车牌");
                                    }
                                    plateNos.Add(otherplate.PlateNo);
                                }

                                if (plateNos.Count > 0 && grant.EndDate != DateTime.MinValue)
                                {
                                    IParkIORecord ioRecord = ParkIORecordFactory.GetFactory();
                                    ioRecords = ioRecord.QueryMonthExpiredNotPayAmountIORecordIds(grant.EndDate.AddDays(1).Date, startDate, grant.PKID, plateNos);
                                    if (ioRecords.Count > 0)
                                    {
                                        bool result = ioRecord.UpdateIORecordEnterType(ioRecords, 0, dbOperator);
                                        if (!result)
                                        {
                                            throw new MyException("修改进出记录类型失败");
                                        }
                                        result = ParkOrderServices.AddExpiredToProStopOrder(ioRecords, operatorId, dbOperator);
                                        if (!result)
                                        {
                                            throw new MyException("创建月卡转临停订单失败");
                                        }
                                    }
                                }
                            }
                            ParkOrder order = ParkOrderServices.AddMonthlyRentOrderCS(grant.PKID, carType.CarTypeID, grant.GID, grant.BeginDate, grant.EndDate, startDate, endDate, renewalMonth, pkLotQuantity, operatorId, payTotalMoney, dbOperator);
                            if (order == null)
                            {
                                throw new MyException("续期失败【创建续期订单失败】");
                            }
                            break;
                        }

                        //case BaseCarType.WorkCar:
                        //    {
                        //        IParkGrant factory = ParkGrantFactory.GetFactory();
                        //        renewalsResult = factory.Renewals(grant.GID, startDate, endDate, dbOperator);
                        //        if (!renewalsResult) throw new MyException("修改卡结束时间错误");
                        //        break;
                        //    }
                        default: throw new MyException("选择的车辆不能续期和充值");
                        }
                        dbOperator.CommitTransaction();

                        string remark = string.Format("grantId:{0};renewalMonth:{1};payTotalMoney:{2};operatorId:{3};startDate:{4};endDate:{5}", grantId, renewalMonth, payTotalMoney, operatorId, startDate.ToString("yyyy-MM-dd"), endDate.ToString("yyyy-MM-dd"));
                        OperateLogServices.AddOperateLog(OperateType.Update, remark);
                        if (ioRecords.Count > 0)
                        {
                            string updateIORecord = string.Format("修改IORecord表,RecordIDs:{0},EnterType:0", string.Join(",", ioRecords));
                            OperateLogServices.AddOperateLog(OperateType.Update, updateIORecord);
                        }
                        return(renewalsResult);
                    }
                    catch (Exception ex)
                    {
                        dbOperator.RollbackTransaction();
                        throw ex;
                    }
                }
            }
        }
Ejemplo n.º 15
0
        /// <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);
        }
Ejemplo n.º 16
0
        /// <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);
        }