Ejemplo n.º 1
0
        public ActionResult LocationOut()
        {
            Response resp = new Response();
            Log      log  = LogFactory.GetLogger("locationout");

            try
            {
                string wh = Request.Form["txtOutWh"];
                if (string.IsNullOrEmpty(wh))
                {
                    return(Content("库区为空,传输数据丢失!"));
                }
                int    warehouse = Convert.ToInt32(wh);
                string Addrs     = Request.Form["txtOutLoc"];
                if (string.IsNullOrEmpty(Addrs))
                {
                    return(Content("车位为空,传输数据丢失!"));
                }
                resp = new CWLocation().LocationOut(warehouse, Addrs);
                return(Content(resp.Message));
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                return(Content("系统异常"));
            }
        }
Ejemplo n.º 2
0
        public ActionResult TransferLoc()
        {
            string wh = Request.Form["txtTransWh"];

            if (string.IsNullOrEmpty(wh))
            {
                return(Content("库区为空,传输数据丢失!"));
            }
            int        warehouse = Convert.ToInt32(wh);
            string     fromAddrs = Request.Form["txtFrom"];
            string     toAddrs   = Request.Form["txtTo"];
            CWLocation cwlctn    = new CWLocation();
            Location   fromLoc   = cwlctn.FindLocation(lc => lc.Warehouse == warehouse && lc.Address == fromAddrs);

            if (fromLoc == null)
            {
                return(Content("找不到源车位-" + fromAddrs));
            }
            Location toLoc = cwlctn.FindLocation(lc => lc.Warehouse == warehouse && lc.Address == toAddrs);

            if (toLoc == null)
            {
                return(Content("找不到目的车位-" + toLoc));
            }
            int ret = new CWLocation().TransportLoc(fromLoc, toLoc);

            if (ret == 1)
            {
                return(Content("操作成功!"));
            }
            else
            {
                return(Content("操作引发异常!"));
            }
        }
Ejemplo n.º 3
0
        public ActionResult TempGet(string iccode, int hallID, bool isplate)
        {
            Response resp = new Response();
            //先查找车位,后获取库区号
            Location lct = null;

            if (isplate)
            {
                lct = new CWLocation().FindLocation(l => l.PlateNum == iccode);
            }
            else
            {
                lct = new CWLocation().FindLocation(l => l.ICCode == iccode);
            }
            if (lct != null)
            {
                int warehouse = lct.Warehouse;
                resp = new CWTaskTransfer(hallID, warehouse).TempGetCar(lct.ICCode);
            }
            else
            {
                resp.Code    = 0;
                resp.Message = "找不到取车车位";
            }
            return(Json(new ReturnModel()
            {
                code = resp.Code, message = resp.Message
            }));
        }
Ejemplo n.º 4
0
        public ActionResult QueryParkingFee()
        {
            ParkingFeeInfo resp = new ParkingFeeInfo();

            #region
            Log log = LogFactory.GetLogger("QueryParkingFee");
            try
            {
                byte[] bytes = new byte[Request.InputStream.Length];
                Request.InputStream.Read(bytes, 0, bytes.Length);
                string req = System.Text.Encoding.UTF8.GetString(bytes);
                //显示,记录
                log.Info(req);
                JObject jo     = (JObject)JsonConvert.DeserializeObject(req);
                string  iccode = jo["iccode"].ToString();
                string  plate  = jo["plateNum"].ToString();

                CWLocation cwlctn = new CWLocation();
                Location   loc    = null;
                if (!string.IsNullOrEmpty(plate))
                {
                    loc = cwlctn.FindLocation(lc => lc.PlateNum == plate);
                }
                if (loc == null)
                {
                    if (!string.IsNullOrEmpty(iccode))
                    {
                        loc = cwlctn.FindLocation(lc => lc.ICCode == iccode);
                    }
                }
                if (loc == null)
                {
                    log.Error("APP查询费用时, 找不到取车位, plate - " + plate + " ,iccode-" + iccode);
                    resp.Message = "没有存车";
                    return(Json(resp));
                }
                float    fee = 0;
                Response res = new CWTariff().CalculateTempFee(loc.InDate, DateTime.Now, out fee);
                if (res.Code == 1)
                {
                    resp.Code     = 1;
                    resp.Message  = "查询费用成功";
                    resp.Fee      = fee;
                    resp.InDtime  = loc.InDate.ToString();
                    resp.OutDtime = DateTime.Now.ToString();
                }
                else
                {
                    log.Error("APP查询费用,系统异常- " + resp.Message);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                resp.Message = "系统异常";
            }
            #endregion
            return(Json(resp));
        }
Ejemplo n.º 5
0
        public ActionResult LocationIn()
        {
            string wh = Request.Form["txtInWh"];

            if (string.IsNullOrEmpty(wh))
            {
                return(Content("库区为空,传输数据丢失!"));
            }
            int    warehouse = Convert.ToInt32(wh);
            string Addrs     = Request.Form["txtInLoc"];

            if (string.IsNullOrEmpty(Addrs))
            {
                return(Content("入库车位为空,传输数据丢失!"));
            }
            string indate = Request.Form["txtInDtime"];

            if (string.IsNullOrEmpty(indate))
            {
                return(Content("入库时间为空,操作失败!"));
            }
            DateTime dt   = DateTime.Parse(indate);
            string   iccd = Request.Form["txtInIccd"];

            if (string.IsNullOrEmpty(iccd))
            {
                return(Content("入库卡号为空,操作失败!"));
            }
            #region 验证下
            Regex rex = new Regex(@"^\d+$");
            if (!rex.IsMatch(iccd))
            {
                return(Content("请输入有效的数字"));
            }
            #endregion
            string distance = Request.Form["txtInDist"];
            if (string.IsNullOrEmpty(distance))
            {
                return(Content("入库轴距为空,操作失败!"));
            }
            string   carsize = Request.Form["txtInSize"];
            string   plate   = Request.Form["txtInPlate"];
            Location orig    = new Location()
            {
                Warehouse = warehouse,
                Address   = Addrs,
                ICCode    = iccd,
                InDate    = dt,
                WheelBase = Convert.ToInt32(distance),
                CarSize   = carsize,
                PlateNum  = plate
            };
            Response resp = new CWLocation().LocationIn(orig);
            return(Content(resp.Message));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 查询存车车位
        /// </summary>
        /// <returns></returns>
        public ActionResult FindLocByICCard()
        {
            Response resp = new Response();
            Log      log  = LogFactory.GetLogger("FindLocByICCard");

            try
            {
                string iccd    = Request.QueryString["txtIccd"];
                string isPlate = Request.QueryString["isplate"];
                bool   frplate = false;
                if (!string.IsNullOrEmpty(isPlate))
                {
                    frplate = Convert.ToBoolean(isPlate);
                }
                if (!frplate)
                {
                    Location loc = new CWLocation().FindLocation(lc => lc.ICCode == iccd);
                    if (loc != null && loc.Status != EnmLocationStatus.Space)
                    {
                        resp.Code = 1;
                        resp.Data = loc;
                    }
                }
                else
                {
                    //依车牌号查询存车位
                    Location loc = new CWLocation().FindLocation(lc => lc.PlateNum == iccd);
                    if (loc != null && loc.Status != EnmLocationStatus.Space)
                    {
                        resp.Code = 1;
                        resp.Data = loc;
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            return(Json(resp, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 7
0
        public async Task <JsonResult> TempUserOutCar()
        {
            Response resp = new Response();
            Log      log  = LogFactory.GetLogger("TempUserOutCar");

            #region
            try
            {
                string iccd      = Request.Form["iccode"];
                string isplate   = Request.Form["isplate"];
                string warehouse = Request.Form["wh"];
                string hallID    = Request.Form["hallID"];
                string indate    = Request.Form["indate"];
                string spantime  = Request.Form["spantime"];
                string needfee   = Request.Form["needfee"];
                string actualfee = Request.Form["actualfee"];
                string coinfee   = Request.Form["coinfee"];

                CWLocation cwlctn = new CWLocation();
                Location   loc    = null;
                #region
                if (Convert.ToBoolean(isplate))
                {
                    //是车牌号
                    loc = await cwlctn.FindLocationAsync(l => l.PlateNum == iccd);
                }
                else
                {
                    #region
                    //ICCard icard = new CWICCard().Find(ic=>ic.UserCode==iccd);
                    //if (icard == null)
                    //{
                    //    resp.Message = "不是本系统用卡,ICCode - " + iccd;
                    //    return Json(resp);
                    //}
                    //if(icard.Status==EnmICCardStatus.Lost||
                    //    icard.Status == EnmICCardStatus.Disposed)
                    //{
                    //    resp.Message = "卡已挂失或注销,ICCode - " + iccd;
                    //    return Json(resp);
                    //}
                    #endregion
                    //是卡号
                    loc = await cwlctn.FindLocationAsync(l => l.ICCode == iccd);
                }
                if (loc == null)
                {
                    resp.Message = "找不到取车位,proof - " + iccd;
                    return(Json(resp));
                }
                #endregion
                int    wh    = Convert.ToInt16(warehouse);
                int    hcode = Convert.ToInt32(hallID);
                Device hall  = await new CWDevice().FindAsync(d => d.Warehouse == wh && d.DeviceCode == hcode);
                if (hall == null)
                {
                    resp.Message = "找不到出库车厅,wh - " + warehouse + " , code - " + hallID;
                    return(Json(resp));
                }
                resp = new CWTaskTransfer(hcode, wh).OCreateTempUserOfOutCar(loc);
                if (resp.Code == 1)
                {
                    string oprt = User.Identity.Name;
                    //保存收费记录
                    TempUserChargeLog templog = new TempUserChargeLog
                    {
                        Proof       = loc.ICCode,
                        Plate       = loc.PlateNum,
                        Warehouse   = wh,
                        Address     = loc.Address,
                        InDate      = loc.InDate.ToString(),
                        OutDate     = DateTime.Now.ToString(),
                        SpanTime    = spantime,
                        NeedFee     = needfee,
                        ActualFee   = actualfee,
                        CoinChange  = coinfee,
                        OprtCode    = oprt,
                        RecordDTime = DateTime.Now
                    };
                    await new CWTariffLog().AddTempLogAsync(templog);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                resp.Message = "系统异常";
            }
            #endregion
            return(Json(resp));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 固定用户收费界面出车
        /// </summary>
        /// <returns></returns>
        public ActionResult FixGUIOutCar(int type, string uiccd, int warehouse, int hallID)
        {
            Response resp = new Response();

            #region
            Log log = LogFactory.GetLogger("FixGUIOutCar");
            try
            {
                CWICCard   cwiccd = new CWICCard();
                CWLocation cwlctn = new CWLocation();
                Customer   cust   = null;
                #region
                Location loc = null;
                if (type == 1)
                {
                    #region
                    ////是卡号
                    //ICCard iccd = cwiccd.Find(ic => ic.UserCode == uiccd);
                    //if (iccd == null)
                    //{
                    //    resp.Message = "不是本系统用卡,iccode - " + uiccd;
                    //    return Json(resp, JsonRequestBehavior.AllowGet);
                    //}
                    //if (iccd.CustID == 0)
                    //{
                    //    resp.Message = "当前用卡为临时用卡,无法完成操作! ICCode - " + uiccd;
                    //    return Json(resp, JsonRequestBehavior.AllowGet);
                    //}
                    //cust = cwiccd.FindCust(iccd.CustID);
                    #endregion
                    loc = cwlctn.FindLocation(l => l.ICCode == uiccd);
                }
                else if (type == 2)
                {
                    loc = cwlctn.FindLocation(l => l.PlateNum == uiccd);
                }
                if (loc == null)
                {
                    resp.Message = "当前用户没有存车! Proof - " + uiccd;
                    return(Json(resp, JsonRequestBehavior.AllowGet));
                }
                int             sno   = Convert.ToInt32(loc.ICCode);
                SaveCertificate scert = new CWSaveProof().Find(s => s.SNO == sno);
                if (scert != null)
                {
                    cust = new CWICCard().FindCust(scert.CustID);
                }
                if (type == 3)
                {
                    //是车主姓名
                    cust = cwiccd.FindCust(cc => cc.UserName == uiccd);
                }
                if (cust == null)
                {
                    resp.Message = "不是注册用户,无法进行操作!iccode - " + uiccd;
                    return(Json(resp, JsonRequestBehavior.AllowGet));
                }
                if (cust.Type == EnmICCardType.Temp)
                {
                    resp.Message = "临时用户,不在此界面缴费! iccode - " + uiccd;
                    return(Json(resp, JsonRequestBehavior.AllowGet));
                }
                if (DateTime.Compare(DateTime.Now, cust.Deadline) > 0)
                {
                    resp.Message = "当前用户已欠费,请缴费后出车! iccode - " + uiccd + " ,Deadline- " + cust.Deadline.ToString();
                    return(Json(resp, JsonRequestBehavior.AllowGet));
                }
                ////如果是以车牌或用户名取车,
                //if (type > 1)
                //{
                //    loc = cwlctn.FindLocation(lc => lc.PlateNum == cust.PlateNum);
                //    //以车牌找不到存车车辆,则以卡号进行查询
                //    if (loc == null)
                //    {
                //        //以绑定的卡号查询
                //        ICCard iccd = cwiccd.Find(ic => ic.CustID == cust.ID);
                //        if (iccd != null)
                //        {
                //            loc = cwlctn.FindLocation(l => l.ICCode == iccd.UserCode);
                //        }
                //    }
                //}
                #endregion
                resp = new CWTaskTransfer(hallID, warehouse).FixGUIGetCar(loc);
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            #endregion
            return(Json(resp, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 9
0
        public ActionResult Edit(CustomerModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            CWICCard cwiccd = new CWICCard();

            #region 验证用户名、车牌号
            //顾客姓名保证唯一的
            Customer other = cwiccd.FindCust(cu => cu.UserName == model.UserName && cu.ID != model.ID);
            if (other != null)
            {
                ModelState.AddModelError("", "当前顾客名-  " + model.UserName +
                                         " 已被占用,其车牌号- " + other.PlateNum + " ,请输入唯一的用户名!");
                return(View(model));
            }
            //车牌号码保证唯一的
            other = cwiccd.FindCust(cu => cu.PlateNum == model.PlateNum && cu.ID != model.ID);
            if (other != null)
            {
                ModelState.AddModelError("", "当前车牌号-  " + model.PlateNum +
                                         " 已被绑定,其顾客名- " + other.UserName + " ,请输入正确的车牌号!");
                return(View(model));
            }
            #endregion
            #region
            Customer cust    = cwiccd.FindCust(model.ID);
            Location origloc = null;
            //原来是否绑定
            if (cust.Type == EnmICCardType.FixedLocation)
            {
                origloc = new CWLocation().FindLocation(l => l.Warehouse == cust.Warehouse && l.Address == cust.LocAddress);
            }

            //是固定卡时
            if (model.Type == EnmICCardType.FixedLocation)
            {
                #region
                if (model.Warehouse == 0 || string.IsNullOrEmpty(model.LocAddress))
                {
                    ModelState.AddModelError("", "固定卡,请指定绑定的库区及车位号!");
                    return(View(model));
                }
                Location lctn = new CWLocation().FindLocation(lc => lc.Warehouse == model.Warehouse && lc.Address == model.LocAddress);
                if (lctn == null)
                {
                    ModelState.AddModelError("", "固定卡,请正确的库区及车位地址!");
                    return(View(model));
                }
                else
                {
                    //固定车位时,当前车位没有存车
                    if (lctn.Status != EnmLocationStatus.Space)
                    {
                        ModelState.AddModelError("", "当前车位:" + lctn.Address + " 已存车,卡号- " + lctn.ICCode + " ,请等待取车完成后再绑定!");
                        return(View(model));
                    }
                }

                Customer custo = cwiccd.FindCust(cc => cc.Warehouse == model.Warehouse && cc.LocAddress == model.LocAddress);
                if (custo != null)
                {
                    if (custo.ID != cust.ID)
                    {
                        ModelState.AddModelError("", "当前车位已被别的用户绑定");
                        return(View(model));
                    }
                }
                cust.Type       = model.Type;
                cust.Warehouse  = (int)model.Warehouse;
                cust.LocAddress = model.LocAddress;

                //释放原车位
                if (origloc != null)
                {
                    if (origloc.Address != lctn.Address)
                    {
                        SingleCallback.Instance().WatchFixLocation(origloc, 0, "", "", "");
                    }
                }
                //绑定当前车位
                SingleCallback.Instance().WatchFixLocation(lctn, 1, cust.UserName, cust.Deadline.ToString(), cust.PlateNum);
                #endregion
            }
            else
            {
                cust.Type       = model.Type;
                cust.Warehouse  = 0;
                cust.LocAddress = "";
                cust.StartDTime = DateTime.Parse("2017-1-1");
                cust.Deadline   = DateTime.Parse("2017-1-1");

                //释放原车位
                if (origloc != null)
                {
                    SingleCallback.Instance().WatchFixLocation(origloc, 0, "", "", "");
                }
            }

            ICCard oriIccd = cwiccd.Find(ic => ic.CustID == model.ID);
            ICCard newIccd = null;
            if (!string.IsNullOrEmpty(model.UserCode))
            {
                newIccd = cwiccd.Find(ic => ic.UserCode == model.UserCode);
                if (newIccd == null)
                {
                    ModelState.AddModelError("", "当前卡号没有注册!");
                    return(View(model));
                }
            }
            if (oriIccd == null)
            {
                //原先没有绑定的
                if (newIccd != null)
                {
                    newIccd.CustID = cust.ID;
                    cwiccd.Update(newIccd);
                }
            }
            else
            {
                if (newIccd == null)
                {
                    //释放原来卡号
                    //释放旧卡
                    oriIccd.CustID = 0;
                    cwiccd.Update(oriIccd);
                }
                else //两卡都存在
                {
                    //不是同一张卡
                    if (oriIccd.UserCode != newIccd.UserCode)
                    {
                        #region
                        if (newIccd.Status != EnmICCardStatus.Normal)
                        {
                            ModelState.AddModelError("", "卡已挂失或注销,无法绑定用户!");
                            return(View(model));
                        }
                        if (newIccd.CustID != 0)
                        {
                            Customer oricust = cwiccd.FindCust(newIccd.CustID);
                            if (oricust != null)
                            {
                                ModelState.AddModelError("", "该卡已被绑定,车主姓名:" + oricust.UserName);
                                return(View(model));
                            }
                        }
                        #endregion
                        //释放旧卡
                        oriIccd.CustID = 0;
                        cwiccd.Update(oriIccd);
                        //绑定新卡
                        newIccd.CustID = cust.ID;
                        cwiccd.Update(newIccd);
                    }
                }
            }

            //允许更新
            cust.PlateNum      = model.PlateNum;
            cust.MobilePhone   = model.MobilePhone;
            cust.UserName      = model.UserName;
            cust.FamilyAddress = model.FamilyAddress;

            cwiccd.UpdateCust(cust);


            #region 更新指纹
            CWFingerPrint cwfprint = new CWFingerPrint();
            if (model.FingerPrint1 != "")
            {
                int         fpvalue = Convert.ToInt32(model.FingerPrint1);
                FingerPrint fp      = cwfprint.Find(fi => fi.SN_Number == fpvalue);
                if (fp != null)
                {
                    if (fp.CustID == 0)
                    {
                        fp.CustID = cust.ID;
                        cwfprint.Update(fp);
                    }
                }
            }
            if (model.FingerPrint2 != "")
            {
                int         fpvalue = Convert.ToInt32(model.FingerPrint2);
                FingerPrint fp      = cwfprint.Find(fi => fi.SN_Number == fpvalue);
                if (fp != null)
                {
                    if (fp.CustID == 0)
                    {
                        fp.CustID = cust.ID;
                        cwfprint.Update(fp);
                    }
                }
            }
            if (model.FingerPrint3 != "")
            {
                int         fpvalue = Convert.ToInt32(model.FingerPrint3);
                FingerPrint fp      = cwfprint.Find(fi => fi.SN_Number == fpvalue);
                if (fp != null)
                {
                    if (fp.CustID == 0)
                    {
                        fp.CustID = cust.ID;
                        cwfprint.Update(fp);
                    }
                }
            }
            #endregion

            #endregion
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 10
0
        public ActionResult Add(CustomerModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            CWICCard cwiccd = new CWICCard();
            //顾客姓名保证唯一的
            Customer other = cwiccd.FindCust(cu => cu.UserName == model.UserName);

            if (other != null)
            {
                ModelState.AddModelError("", "当前顾客名-  " + model.UserName + " 已被占用,其车牌号- " + other.PlateNum + " ,请输入唯一的用户名!");
                return(View(model));
            }
            string plate = "";

            foreach (char vl in model.PlateNum)
            {
                if (Char.IsLetter(vl))
                {
                    plate += char.ToUpper(vl);
                }
                else
                {
                    plate += vl;
                }
            }

            model.PlateNum = plate;

            //车牌号码保证唯一的
            other = cwiccd.FindCust(cu => cu.PlateNum == model.PlateNum);
            if (other != null)
            {
                ModelState.AddModelError("", "当前车牌号-  " + model.PlateNum + " 已被绑定,其顾客名- " + other.UserName + " ,请输入正确的车牌号!");
                return(View(model));
            }
            Location lctn = null;

            #region
            if (model.Type == EnmICCardType.FixedLocation)
            {
                if (model.Warehouse == 0 || string.IsNullOrEmpty(model.LocAddress))
                {
                    ModelState.AddModelError("", "固定车位卡,请指定绑定车位!");
                    return(View(model));
                }
                lctn = new CWLocation().FindLocation(lc => lc.Warehouse == model.Warehouse && lc.Address == model.LocAddress);
                if (lctn == null)
                {
                    ModelState.AddModelError("", "绑定车位不存在,地址-" + model.LocAddress);
                    return(View(model));
                }
                else
                {
                    //固定车位时,当前车位没有存车
                    if (lctn.Status != EnmLocationStatus.Space)
                    {
                        ModelState.AddModelError("", "当前车位:" + lctn.Address + " 已存车,卡号- " + lctn.ICCode + " ,请等待取车完成后再绑定!");
                        return(View(model));
                    }
                }
            }

            ICCard iccd = null;
            if (!string.IsNullOrEmpty(model.UserCode))
            {
                #region
                iccd = cwiccd.Find(ic => ic.UserCode == model.UserCode);
                if (iccd == null)
                {
                    ModelState.AddModelError("", "当前用户卡号没有注册,请确保该卡已完成制卡!");
                    return(View(model));
                }
                if (iccd.Status != EnmICCardStatus.Normal)
                {
                    ModelState.AddModelError("", "该卡已挂失或注销,无法完成操作!");
                    return(View(model));
                }
                if (iccd.CustID != 0)
                {
                    Customer cust = cwiccd.FindCust(iccd.CustID);
                    if (cust != null)
                    {
                        ModelState.AddModelError("", "该卡已被绑定,车主姓名:" + cust.UserName);
                        return(View(model));
                    }
                }
                #endregion
            }

            Customer addcust = new Customer();
            if (model.Type == EnmICCardType.FixedLocation)
            {
                Customer cust = cwiccd.FindCust(cc => cc.Warehouse == model.Warehouse && cc.LocAddress == model.LocAddress);
                if (cust != null)
                {
                    ModelState.AddModelError("", "该车位已被其他卡绑定,无法使用该车位- " + model.LocAddress + " ,Warehouse- " + model.Warehouse);
                    return(View(model));
                }
                addcust.Warehouse  = (int)model.Warehouse;
                addcust.LocAddress = model.LocAddress;
            }

            addcust.UserName      = model.UserName;
            addcust.PlateNum      = model.PlateNum;
            addcust.FamilyAddress = model.FamilyAddress;
            addcust.MobilePhone   = model.MobilePhone;
            addcust.Type          = EnmICCardType.Temp;
            if ((int)model.Type > 0)
            {
                addcust.Type = model.Type;
            }
            addcust.StartDTime = DateTime.Parse("2017-1-1");
            addcust.Deadline   = DateTime.Parse("2017-1-1");

            Response resp = cwiccd.AddCust(addcust);
            if (resp.Code == 1)
            {
                //如果有卡号,则绑定顾客于卡号
                if (iccd != null)
                {
                    iccd.CustID = addcust.ID;
                    resp        = cwiccd.Update(iccd);
                }

                #region 绑定指纹,更新指纹信息
                CWFingerPrint fprint = new CWFingerPrint();
                if (!string.IsNullOrEmpty(model.FingerPrint1))
                {
                    Int32       sn     = Convert.ToInt32(model.FingerPrint1);
                    FingerPrint finger = fprint.Find(p => p.SN_Number == sn);
                    if (finger != null)
                    {
                        finger.CustID = addcust.ID;
                        fprint.Update(finger);
                    }
                }
                if (!string.IsNullOrEmpty(model.FingerPrint2))
                {
                    Int32       sn     = Convert.ToInt32(model.FingerPrint2);
                    FingerPrint finger = fprint.Find(p => p.SN_Number == sn);
                    if (finger != null)
                    {
                        finger.CustID = addcust.ID;
                        fprint.Update(finger);
                    }
                }
                if (!string.IsNullOrEmpty(model.FingerPrint3))
                {
                    Int32       sn     = Convert.ToInt32(model.FingerPrint3);
                    FingerPrint finger = fprint.Find(p => p.SN_Number == sn);
                    if (finger != null)
                    {
                        finger.CustID = addcust.ID;
                        fprint.Update(finger);
                    }
                }
                #endregion
            }

            if (addcust.Type == EnmICCardType.FixedLocation)
            {
                SingleCallback.Instance().WatchFixLocation(lctn, 1, addcust.UserName, addcust.Deadline.ToString(), addcust.PlateNum);
            }

            #endregion
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 推送设备信息
        /// </summary>
        /// <param name="entity"></param>
        private void FileWatch_DeviceWatchEvent(int type, Device smg)
        {
            try
            {
                Clients.All.feedbackDevice(smg);

                #region 推送至LED显示
                if (smg.Type != EnmSMGType.Hall)
                {
                    return;
                }

                int    ttype  = 0;
                string iccode = "";
                if (smg.TaskID != 0)
                {
                    ImplementTask itask = new CWTask().Find(smg.TaskID);
                    if (itask != null)
                    {
                        ttype = (int)itask.Type;
                        #region
                        if (itask.Type == EnmTaskType.GetCar ||
                            itask.Type == EnmTaskType.TempGet)
                        {
                            Location loc = new CWLocation().FindLocation(l => l.ICCode == itask.ICCardCode);
                            if (loc != null)
                            {
                                if (!string.IsNullOrEmpty(loc.PlateNum))
                                {
                                    iccode = loc.PlateNum;
                                }
                                else
                                {
                                    if (loc.ICCode.Length == 4)
                                    {
                                        iccode = "卡号" + loc.ICCode;
                                    }
                                    else
                                    {
                                        iccode = "指纹" + loc.ICCode;
                                    }
                                }
                            }
                        }
                        else if (itask.Type == EnmTaskType.SaveCar)
                        {
                            PlateMappingDev map = new CWPlate().FindPlate(smg.Warehouse, smg.DeviceCode);
                            if (map != null)
                            {
                                if (!string.IsNullOrEmpty(map.PlateNum))
                                {
                                    iccode = map.PlateNum;
                                }
                                else
                                {
                                    string   ccd = itask.ICCardCode;
                                    Location loc = new CWLocation().FindLocation(d => d.ICCode == ccd);
                                    if (loc != null)
                                    {
                                        if (!string.IsNullOrEmpty(loc.PlateNum))
                                        {
                                            iccode = loc.PlateNum;
                                        }
                                        else
                                        {
                                            if (!string.IsNullOrEmpty(ccd))
                                            {
                                                if (ccd.Length == 4)
                                                {
                                                    iccode = "卡号" + ccd;
                                                }
                                                else
                                                {
                                                    iccode = "指纹" + ccd;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        #endregion
                    }
                }
                else
                {
                    if (smg.InStep == 0 && smg.OutStep == 0)
                    {
                        iccode = "欢迎光临";
                    }
                }
                if (smg.Mode != EnmModel.Automatic)
                {
                    ttype  = 10;
                    iccode = "欢迎光临";
                }

                var data = new
                {
                    Warehouse = smg.Warehouse,
                    HallID    = smg.DeviceCode,
                    TaskType  = ttype,
                    ICCode    = ""
                };
                string json = JsonConvert.SerializeObject(data);

                Clients.All.DeviceStateToLed(json);

                //需要发送时再发送
                if (!string.IsNullOrEmpty(iccode))
                {
                    var iccd = new
                    {
                        Warehouse = smg.Warehouse,
                        HallID    = smg.DeviceCode,
                        Message   = iccode
                    };
                    string jsonIccd = JsonConvert.SerializeObject(iccd);
                    Clients.All.ICCodeInfoToLed(jsonIccd);
                }
                #endregion
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 推送车位信息
        /// </summary>
        /// <param name="loc"></param>
        private void FileWatch_LctnWatchEvent(int type, Location loca)
        {
            try
            {
                #region 更新车位状态
                if (loca != null)
                {
                    Customer cust     = new CWICCard().FindFixLocationByAddress(loca.Warehouse, loca.Address);
                    int      isfix    = 0;
                    string   custname = "";
                    string   deadline = "";
                    string   platenum = "";
                    if (cust != null)
                    {
                        isfix    = 1;
                        custname = cust.UserName;
                        deadline = cust.Deadline.ToString();
                        platenum = cust.PlateNum;
                    }

                    LocsMapping map = new LocsMapping
                    {
                        Warehouse = loca.Warehouse,
                        Address   = loca.Address,
                        LocSide   = loca.LocSide,
                        LocColumn = loca.LocColumn,
                        LocLayer  = loca.LocLayer,
                        Type      = loca.Type,
                        Status    = loca.Status,
                        LocSize   = loca.LocSize,
                        ICCode    = loca.ICCode,
                        WheelBase = loca.WheelBase,
                        CarWeight = loca.CarWeight,
                        CarSize   = loca.CarSize,
                        InDate    = loca.InDate.ToString(),
                        PlateNum  = loca.PlateNum,
                        IsFixLoc  = isfix,
                        CustName  = custname,
                        Deadline  = deadline,
                        RcdPlate  = platenum
                    };

                    Clients.All.feedbackLocInfo(map);
                }
                #endregion
                #region 更新统计信息
                Task.Factory.StartNew(() =>
                {
                    var info = new CWLocation().GetLocStatisInfo();
                    Clients.All.feedbackStatistInfo(info);

                    var data = new
                    {
                        small = info.SmallSpace,
                        big   = info.BigSpace
                    };
                    string json = JsonConvert.SerializeObject(data);
                    Clients.All.LocStateToLed(json);
                });
                #endregion
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
        }
Ejemplo n.º 13
0
        public ActionResult RemoteTempGetInterface()
        {
            Response resp = new Response();

            #region
            Log log = LogFactory.GetLogger("RemoteTempGetInterface");
            try
            {
                byte[] bytes = new byte[Request.InputStream.Length];
                Request.InputStream.Read(bytes, 0, bytes.Length);
                string req = System.Text.Encoding.UTF8.GetString(bytes);
                //显示,记录
                log.Info(req);
                JObject jo = (JObject)JsonConvert.DeserializeObject(req);

                string plate = jo["platenum"].ToString();
                if (string.IsNullOrEmpty(plate))
                {
                    log.Info("参数错误,车牌为空的!");
                    resp.Message = "参数错误";
                    return(Json(resp));
                }
                Location loc = new CWLocation().FindLocation(lc => lc.PlateNum == plate);
                if (loc == null)
                {
                    log.Error("APP取物时,找不到取车位,plate - " + plate);
                    resp.Message = "没有存车";
                    return(Json(resp));
                }
                CWTask        motsk = new CWTask();
                ImplementTask task  = motsk.Find(tk => tk.ICCardCode == loc.ICCode);
                if (task != null)
                {
                    log.Error("APP取物时,车位正在作业,iccode - " + loc.ICCode + " ,plate - " + plate);
                    resp.Message = "正在作业";
                    return(Json(resp));
                }
                WorkTask queue = motsk.FindQueue(qu => qu.ICCardCode == loc.ICCode);
                if (queue != null)
                {
                    log.Error("APP取物时,已经加入队列,iccode - " + loc.ICCode + " ,plate - " + plate);
                    resp.Message = "已经加入队列";
                    return(Json(resp));
                }
                if (loc.Type != EnmLocationType.Normal)
                {
                    log.Error("APP取物时,车位已被禁用,address - " + loc.Address);
                    resp.Message = "车位已被禁用";
                    return(Json(resp));
                }
                //分配车厅
                int hallcode = new CWDevice().AllocateHall(loc, false);

                Device moHall = new CWDevice().Find(d => d.DeviceCode == hallcode);
                if (moHall != null)
                {
                    resp = motsk.TempGetCar(moHall, loc);
                }
                else
                {
                    resp.Message = "找不到合适车厅";
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                resp.Message = "系统异常";
            }
            #endregion
            return(Json(resp));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// APP,预定、取消预定车位
        /// </summary>
        /// <returns></returns>
        public ActionResult RemoteBookLoc()
        {
            Response resp = new Response();
            Log      log  = LogFactory.GetLogger("RemoteBookLoc");

            #region
            try
            {
                byte[] bytes = new byte[Request.InputStream.Length];
                Request.InputStream.Read(bytes, 0, bytes.Length);
                string req = System.Text.Encoding.UTF8.GetString(bytes);
                //显示,记录
                log.Info(req);
                JObject jo    = (JObject)JsonConvert.DeserializeObject(req);
                string  type  = jo["ptype"].ToString();
                string  wh    = jo["warehouse"].ToString();
                string  proof = jo["proof"].ToString();
                string  plate = jo["platenum"].ToString();

                if (string.IsNullOrEmpty(proof) ||
                    string.IsNullOrEmpty(type))
                {
                    log.Error("参数错误,车位尺寸或接口类型 有为空的!");
                    resp.Message = "参数错误";
                    return(Json(resp));
                }
                if (string.IsNullOrEmpty(plate))
                {
                    log.Error("参数错误:车位预定时,车牌为空的!");
                    resp.Message = "参数错误";
                    return(Json(resp));
                }
                CWLocation cwlctn = new CWLocation();

                int deftype = Convert.ToInt32(type);
                //车位预定
                if (deftype == 3)
                {
                    Location lctn = cwlctn.FindLocation(l => l.PlateNum == plate);
                    if (lctn != null)
                    {
                        if (lctn.Status == EnmLocationStatus.Book)
                        {
                            resp.Message = "当前车辆已预约";
                        }
                        else
                        {
                            resp.Message = "当前车辆已存车";
                        }
                        log.Error("当前车辆已存在,不允许预约!");
                        return(Json(resp));
                    }

                    string checkcode = "122";
                    if (proof == "111")
                    {
                        checkcode = "121";
                    }
                    Location loc = new AllocateLocByBook().AllocateLoc(checkcode);
                    if (loc != null)
                    {
                        loc.Status   = EnmLocationStatus.Book;
                        loc.PlateNum = plate;
                        loc.InDate   = DateTime.Now;
                        cwlctn.UpdateLocation(loc);

                        resp.Code    = 1;
                        resp.Message = "预定成功";

                        log.Info("预定成功, checkcode - " + proof + " ,address - " + loc.Address + " ,locsize - " + loc.LocSize);
                    }
                    else
                    {
                        resp.Message = "找不到合适车位";
                    }
                }
                else if (deftype == 4)
                {
                    Location loc = cwlctn.FindLocation(lc => lc.PlateNum == plate && lc.Status == EnmLocationStatus.Book);
                    if (loc != null)
                    {
                        loc.Status   = EnmLocationStatus.Space;
                        loc.PlateNum = "";
                        loc.InDate   = DateTime.Parse("2017-1-1");
                        cwlctn.UpdateLocation(loc);

                        resp.Code    = 1;
                        resp.Message = "取消预定成功";
                    }
                    else
                    {
                        resp.Message = "车辆没有预定车位";
                    }
                }
                else
                {
                    resp.Message = "接口类型不正确,type- " + type;
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                resp.Message = "系统异常";
            }
            #endregion
            return(Json(resp));
        }
Ejemplo n.º 15
0
        public ActionResult RemoteCancelGetCarIFace()
        {
            Response resp = new Response();
            Log      log  = LogFactory.GetLogger("RemoteCancelGetCarIFace");

            #region 取消取车
            try
            {
                byte[] bytes = new byte[Request.InputStream.Length];
                Request.InputStream.Read(bytes, 0, bytes.Length);
                string req = System.Text.Encoding.UTF8.GetString(bytes);
                //显示,记录
                log.Info(req);
                JObject jo     = (JObject)JsonConvert.DeserializeObject(req);
                string  iccode = jo["iccode"].ToString();
                string  plate  = jo["platenum"].ToString();

                CWTask     motask = new CWTask();
                CWLocation cwlctn = new CWLocation();
                #region  用
                //if (!string.IsNullOrEmpty(iccode))
                //{
                //    WorkTask mtsk = motask.FindQueue(mt => mt.ICCardCode == iccode);
                //    if (mtsk != null)
                //    {
                //        Location loc = cwlctn.FindLocation(lc => lc.ICCode == iccode);
                //        loc.Status = EnmLocationStatus.Occupy;
                //        cwlctn.UpdateLocation(loc);

                //        resp = motask.DeleteQueue(mtsk.ID);
                //        return Json(resp);
                //    }
                //}
                #endregion
                if (!string.IsNullOrEmpty(plate))
                {
                    Location loc = cwlctn.FindLocation(lc => lc.PlateNum == plate);
                    if (loc != null)
                    {
                        WorkTask mtsk = motask.FindQueue(mt => mt.ICCardCode == loc.ICCode);
                        if (mtsk != null)
                        {
                            loc.Status = EnmLocationStatus.Occupy;
                            cwlctn.UpdateLocation(loc);

                            motask.DeleteQueue(mtsk.ID);
                            resp.Code    = 1;
                            resp.Message = "取消成功";
                            return(Json(resp));
                        }
                        else
                        {
                            resp.Code    = 1;
                            resp.Message = "当前车辆还没有取车";
                        }
                    }
                    else
                    {
                        resp.Message = "车辆不在库里";
                    }
                }
                else
                {
                    resp.Message = "车牌不允许为空";
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            #endregion
            return(Json(resp));
        }
Ejemplo n.º 16
0
        /// <summary>
        /// APP,远程取车,只允许使用车牌取车
        /// </summary>
        /// <returns></returns>
        public ActionResult RemoteGetCarInterface()
        {
            Response resp = new Response();
            Log      log  = LogFactory.GetLogger("RemoteGetCarInterface");

            #region
            try
            {
                CWDevice cwdevice = new CWDevice();

                byte[] bytes = new byte[Request.InputStream.Length];
                Request.InputStream.Read(bytes, 0, bytes.Length);
                string req = System.Text.Encoding.UTF8.GetString(bytes);
                //显示,记录
                log.Info(req);
                JObject jo        = (JObject)JsonConvert.DeserializeObject(req);
                string  warehouse = jo["warehouse"].ToString();
                string  hallID    = jo["hallID"].ToString();
                string  plate     = jo["plateNum"].ToString();

                if (string.IsNullOrEmpty(plate))
                {
                    log.Error("车牌号为空的!");
                    resp.Message = "参数错误";
                    return(Json(resp));
                }
                #region 暂不用
                //int wh = Convert.ToInt32(warehouse);
                //int hcode = Convert.ToInt32(hallID);

                //Device moHall = cwdevice.Find(d => d.Warehouse == wh && d.DeviceCode == hcode);
                //if (moHall == null)
                //{
                //    log.Error("APP取车时,查找不到车厅,warehouse- " + warehouse + " ,hallID- " + hallID);
                //    resp.Message = "找不到车厅";
                //    return Json(resp);
                //}
                //if (moHall.Mode != EnmModel.Automatic)
                //{
                //    log.Error("APP取车时,车厅模式不是全自动 , Mode - " + moHall.Mode.ToString());
                //    resp.Message = "车厅不是全自动";
                //    return Json(resp);
                //}
                //if (moHall.HallType == EnmHallType.Entrance)
                //{
                //    log.Error("APP取车时,车厅不是出车厅,halltype - " + moHall.HallType.ToString());
                //    resp.Message = "车厅不是全自动";
                //    return Json(resp);
                //}
                #endregion
                Location loc = new CWLocation().FindLocation(lc => lc.PlateNum == plate);
                if (loc == null)
                {
                    log.Error("APP取车时,找不到取车位,plate - " + plate);
                    resp.Message = "没有存车";
                    return(Json(resp));
                }
                CWTask        motsk = new CWTask();
                ImplementTask task  = motsk.Find(tk => tk.ICCardCode == loc.ICCode && tk.IsComplete == 0);
                if (task != null)
                {
                    log.Error("APP取车时,车位正在作业,iccode - " + loc.ICCode + " ,plate - " + plate);
                    resp.Message = "正在作业";
                    return(Json(resp));
                }
                WorkTask queue = motsk.FindQueue(qu => qu.ICCardCode == loc.ICCode);
                if (queue != null)
                {
                    log.Error("APP取车时,已经加入队列,iccode - " + loc.ICCode + " ,plate - " + plate);
                    resp.Message = "已经加入队列";
                    return(Json(resp));
                }
                if (loc.Type != EnmLocationType.Normal)
                {
                    log.Error("APP取车时,车位已被禁用,address - " + loc.Address);
                    resp.Message = "车位已被禁用";
                    return(Json(resp));
                }
                if (loc.Status != EnmLocationStatus.Occupy)
                {
                    log.Error("APP取车时,当前车位正在任务业,address - " + loc.Address + " ,status - " + loc.Status.ToString());
                    resp.Message = "车位已被禁用";
                    return(Json(resp));
                }
                int mcount = new CWTask().FindQueueList(q => q.IsMaster == 2).Count();
                if (mcount > 6)
                {
                    log.Error("APP取车时,取车队列已满");
                    resp.Message = "取车队列已满";
                    return(Json(resp));
                }

                //分配车厅
                int    hallcode = new CWDevice().AllocateHall(loc, false);
                Device moHall   = new CWDevice().Find(d => d.DeviceCode == hallcode);

                if (moHall != null)
                {
                    resp = motsk.DealOSwipedCard(moHall, loc);

                    log.Info("APP取车,取车车位 - " + loc.Address + " ,出车车厅 - " + moHall.DeviceCode);
                }
                else
                {
                    resp.Message = "找不到合适车厅";
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                resp.Message = "系统异常";
            }
            #endregion
            return(Json(resp));
        }