Exemplo n.º 1
0
        /// <summary>
        /// 增加通道信息
        /// </summary>
        /// <param name="BoxID"></param>
        /// <param name="inout"></param>
        public static ParkGate GetParkGate(string BoxID, int inout)
        {
            ParkGate model = new ParkGate();

            model.BoxID  = BoxID;
            model.GateNo = inout.ToString();
            if (inout == 1)
            {
                model.GateName = "进通道";
                model.IoState  = IoState.GoIn;
            }
            else
            {
                model.GateName = "出通道";
                model.IoState  = IoState.GoOut;
            }
            model.DataStatus           = DataStatus.Normal;
            model.GateID               = GuidGenerator.GetGuidString();
            model.HaveUpdate           = 3;
            model.IsEnterConfirm       = YesOrNo.Yes;
            model.IsTempInOut          = YesOrNo.Yes;
            model.LastUpdateTime       = DateTime.Now;
            model.OpenPlateBlurryMatch = YesOrNo.No;
            model.IsNeedCapturePaper   = false;
            return(model);
        }
Exemplo n.º 2
0
 public JsonResult SaveEdit(ParkGate model)
 {
     try
     {
         bool result = false;
         if (string.IsNullOrWhiteSpace(model.GateID))
         {
             result = ParkGateServices.Add(model);
             if (!result)
             {
                 throw new MyException("添加失败");
             }
             return(Json(MyResult.Success()));
         }
         else
         {
             result = ParkGateServices.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("保存通道信息失败")));
     }
 }
Exemplo n.º 3
0
 private string GetCompanyId(string pid, string bid, string gid)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(gid))
         {
             ParkGate gate = ParkGateServices.QueryByRecordId(gid);
             if (gate != null)
             {
                 bid = gate.BoxID;
             }
         }
         if (!string.IsNullOrWhiteSpace(pid))
         {
             BaseCompany company = CompanyServices.QueryByParkingId(pid);
             if (company != null)
             {
                 return(company.CPID);
             }
         }
         if (!string.IsNullOrWhiteSpace(bid))
         {
             BaseCompany company = CompanyServices.QueryByBoxID(bid);
             if (company != null)
             {
                 return(company.CPID);
             }
         }
     }
     catch (Exception ex)
     {
         ExceptionsServices.AddExceptionToDbAndTxt("QRCodeParkPayment", "GetCompanyId方法处理异常", ex, LogFrom.WeiXin);
     }
     return(string.Empty);
 }
Exemplo n.º 4
0
        public bool Update(ParkGate model)
        {
            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                model.DataStatus     = DataStatus.Normal;
                model.LastUpdateTime = DateTime.Now;
                model.HaveUpdate     = SystemDefaultConfig.DataUpdateFlag;

                StringBuilder strSql = new StringBuilder();
                strSql.Append("update ParkGate set GateNo=@GateNo,GateName=@GateName,BoxID=@BoxID,IoState=@IoState,IsTempInOut=@IsTempInOut,IsEnterConfirm=@IsEnterConfirm,OpenPlateBlurryMatch=@OpenPlateBlurryMatch");
                strSql.Append(",Remark=@Remark,LastUpdateTime=@LastUpdateTime,HaveUpdate=@HaveUpdate,IsNeedCapturePaper=@IsNeedCapturePaper,PlateNumberAndCard=@PlateNumberAndCard,IsWeight=@IsWeight where GateID=@GateID");
                dbOperator.ClearParameters();
                dbOperator.AddParameter("GateID", model.GateID);
                dbOperator.AddParameter("GateNo", model.GateNo);
                dbOperator.AddParameter("GateName", model.GateName);
                dbOperator.AddParameter("BoxID", model.BoxID);
                dbOperator.AddParameter("IoState", (int)model.IoState);
                dbOperator.AddParameter("IsTempInOut", (int)model.IsTempInOut);
                dbOperator.AddParameter("IsEnterConfirm", (int)model.IsEnterConfirm);
                dbOperator.AddParameter("OpenPlateBlurryMatch", (int)model.OpenPlateBlurryMatch);
                dbOperator.AddParameter("Remark", model.Remark);
                dbOperator.AddParameter("LastUpdateTime", model.LastUpdateTime);
                dbOperator.AddParameter("HaveUpdate", model.HaveUpdate);
                dbOperator.AddParameter("DataStatus", (int)model.DataStatus);
                dbOperator.AddParameter("IsNeedCapturePaper", model.IsNeedCapturePaper);
                dbOperator.AddParameter("PlateNumberAndCard", model.PlateNumberAndCard);
                dbOperator.AddParameter("IsWeight", model.IsWeight);
                return(dbOperator.ExecuteNonQuery(strSql.ToString()) > 0);
            }
        }
Exemplo n.º 5
0
        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("下载二维码失败")));
            }
        }
Exemplo n.º 6
0
        public static bool Update(ParkGate model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            IParkGate factory = ParkGateFactory.GetFactory();
            bool      result  = factory.Update(model);

            if (result)
            {
                OperateLogServices.AddOperateLog <ParkGate>(model, OperateType.Update);
            }
            return(result);
        }
Exemplo n.º 7
0
        public static bool Add(ParkGate model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            model.GateID = GuidGenerator.GetGuid().ToString();
            IParkGate factory = ParkGateFactory.GetFactory();
            bool      result  = factory.Add(model);

            if (result)
            {
                OperateLogServices.AddOperateLog <ParkGate>(model, OperateType.Add);
            }
            return(result);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        private static bool AddDefaultParkDeviceParam(string gateId, string deviceId, string deviceNo, DbOperator dbOperator)
        {
            ParkGate        gate        = ParkGateServices.QueryByRecordId(gateId);
            ParkBox         box         = ParkBoxServices.QueryByRecordId(gate.BoxID);
            ParkArea        area        = ParkAreaServices.QueryByRecordId(box.AreaID);
            ParkDeviceParam param       = CreateDefualtParam(deviceId, int.Parse(deviceNo), area.CarbitNum, (int)gate.IoState);
            IParkDevice     factory     = ParkDeviceFactory.GetFactory();
            ParkDeviceParam deviceParam = factory.QueryParkDeviceParamByDevID(param.DevID);

            if (deviceParam != null)
            {
                throw new MyException("设备编号不能重复");
            }

            bool result = factory.AddParam(param, dbOperator);

            if (!result)
            {
                throw new MyException("添加设备默认参数失败");
            }
            return(result);
        }
Exemplo n.º 10
0
        public ActionResult TollRelease(decimal waitPay, string recordId, string carModelId)
        {
            try
            {
                string       errorMsg = string.Empty;
                ParkIORecord model    = ParkIORecordServices.GetIORecord(recordId, out errorMsg);
                if (!string.IsNullOrWhiteSpace(errorMsg))
                {
                    throw new MyException("获取该入场记录失败");
                }
                if (model == null)
                {
                    throw new MyException("找不到该入场记录");
                }
                if (model.IsExit)
                {
                    throw new MyException("该车辆已经出场");
                }

                DateTime        outTime   = DateTime.Now;
                List <ParkGate> parkGates = ParkGateServices.QueryByParkAreaRecordIds(new List <string>()
                {
                    model.AreaID
                });
                ParkGate outGate = parkGates.FirstOrDefault(p => p.IoState == IoState.GoOut);
                if (outGate == null)
                {
                    throw new MyException("获取出口通道失败");
                }
                ResultAgs billResult = RateProcesser.GetRateResult(model, outGate, outTime, carModelId);
                if (!string.IsNullOrWhiteSpace(billResult.ValidFailMsg))
                {
                    throw new MyException(billResult.ValidFailMsg);
                }
                if (billResult.Rate == null)
                {
                    throw new MyException("计算停车费失败");
                }
                if (waitPay != billResult.Rate.UnPayAmount)
                {
                    throw new MyException("缴费金额与实际金额不匹配,请重新选择入场记录");
                }

                bool result = CentralFeeServices.Payment(recordId, model.ParkingID, billResult, GetLoginUser.RecordID);
                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("缴费失败")));
            }
        }
Exemplo n.º 11
0
        public ActionResult QueryWaitPayDetail(string recordId, string carModelId)
        {
            try
            {
                string       errorMsg = string.Empty;
                ParkIORecord model    = ParkIORecordServices.GetIORecord(recordId, out errorMsg);
                if (!string.IsNullOrWhiteSpace(errorMsg))
                {
                    throw new MyException("获取该入场记录失败");
                }
                if (model == null)
                {
                    throw new MyException("找不到该入场记录");
                }
                if (model.IsExit)
                {
                    throw new MyException("该车辆已经出场");
                }

                DateTime        outTime   = DateTime.Now;
                List <ParkGate> parkGates = ParkGateServices.QueryByParkAreaRecordIds(new List <string>()
                {
                    model.AreaID
                });
                ParkGate outGate = parkGates.FirstOrDefault(p => p.IoState == IoState.GoOut);
                if (outGate == null)
                {
                    throw new MyException("获取出口通道失败");
                }
                ResultAgs billResult = RateProcesser.GetRateResult(model, outGate, outTime, carModelId);
                if (!string.IsNullOrWhiteSpace(billResult.ValidFailMsg))
                {
                    throw new MyException(billResult.ValidFailMsg);
                }
                if (billResult.Rate == null)
                {
                    throw new MyException("计算停车费失败");
                }

                List <ParkIORecord> records = new List <ParkIORecord>()
                {
                    model
                };
                var result = from p in records
                             select new
                {
                    RecordID              = p.RecordID,
                    EntranceImageUrl      = GetImagePath(p.EntranceImage, true, false),
                    EntrancePlateImageUrl = GetImagePath(p.EntranceImage, false, false),
                    PlateNumber           = p.PlateNumber,
                    EntranceTime          = p.EntranceTime.ToString("yyyy-MM-dd HH:mm:ss"),
                    OutTime        = outTime.ToString("yyyy-MM-dd HH:mm:ss"),
                    TotalDuration  = p.EntranceTime.GetParkingDuration(outTime),
                    TotalFee       = billResult.Rate.Amount.ToString("0.0"),
                    PaySuccess     = billResult.Rate.OnlinePayAmount.ToString("0.0"),
                    WaitPay        = billResult.Rate.UnPayAmount.ToString("0.0"),
                    DiscountAmount = billResult.Rate.DiscountAmount.ToString("0.0")
                };

                return(Json(MyResult.Success(string.Empty, result)));
            }
            catch (MyException ex)
            {
                return(Json(MyResult.Error(ex.Message)));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "中央缴费获取待支付记录失败");
                return(Json(MyResult.Error("取待支付记录失败")));
            }
        }
Exemplo n.º 12
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);
        }