예제 #1
0
        /// <summary>
        /// 数据入库
        /// </summary>
        /// <param name="orig"></param>
        /// <returns></returns>
        public Response LocationIn(Location orig)
        {
            Response resp      = new Response();
            int      warehouse = orig.Warehouse;
            string   Addrs     = orig.Address;
            Location loc       = new CWLocation().FindLocation(lc => lc.Warehouse == warehouse && lc.Address == Addrs);

            if (loc == null)
            {
                resp.Message = "找不到车位-" + Addrs;
                return(resp);
            }
            if (loc.Type != EnmLocationType.Normal)
            {
                resp.Message = "车位不可用,请使用另一个";
                return(resp);
            }
            if (loc.Status != EnmLocationStatus.Space)
            {
                resp.Message = "当前车位不是空闲的,无法使用该车位!";
                return(resp);
            }
            if (string.Compare(loc.LocSize, orig.CarSize) < 0)
            {
                resp.Message = "车位尺寸不匹配,无法完成操作!";
                return(resp);
            }
            SaveCertificate scert = new SaveCertificate();

            scert.IsFingerPrint = 2;
            int proof = Convert.ToInt32(orig.ICCode);

            if (proof >= 10000)
            {
                //是指纹时,找出是否注册了
                FingerPrint fprint = new CWFingerPrint().Find(fp => fp.SN_Number == proof);
                if (fprint == null)
                {
                    resp.Message = "当前凭证是指纹编号,但库里找不到注册的指纹";
                    return(resp);
                }
                scert.Proof  = fprint.FingerInfo;
                scert.SNO    = fprint.SN_Number;
                scert.CustID = fprint.CustID;
            }
            else
            {
                ICCard iccode = new CWICCard().Find(ic => ic.UserCode == orig.ICCode);
                if (iccode == null)
                {
                    resp.Message = "请先注册当前卡号,再使用!";
                    return(resp);
                }
                if (iccode.Status != EnmICCardStatus.Normal)
                {
                    resp.Message = "该卡已注销或挂失!";
                    return(resp);
                }
                scert.Proof  = iccode.PhysicCode;
                scert.SNO    = Convert.ToInt32(iccode.UserCode);
                scert.CustID = iccode.CustID;
            }
            #region 判断存车指纹库中,是否有该记录,如果有,则需更换信息
            CWSaveProof     cwsaveprooft = new CWSaveProof();
            SaveCertificate svcert       = cwsaveprooft.Find(s => s.Proof == scert.Proof);
            if (svcert != null)
            {
                resp.Message = "存车指纹库中存在该记录,当前卡号不可用!";
                return(resp);
            }
            #endregion
            Location lctn = new CWLocation().FindLocation(l => l.ICCode == orig.ICCode);
            if (lctn != null)
            {
                resp.Message = "该卡已被使用,车位 - " + lctn.Address;
                return(resp);
            }
            ImplementTask itask = new CWTask().Find(tsk => tsk.ICCardCode == orig.ICCode);
            if (itask != null)
            {
                resp.Message = "该卡正在作业,无法使用";
                return(resp);
            }
            WorkTask wtask = new CWTask().FindQueue(wk => wk.ICCardCode == orig.ICCode);
            if (wtask != null)
            {
                resp.Message = "该卡已加入队列,无法使用";
                return(resp);
            }

            loc.Status    = EnmLocationStatus.Occupy;
            loc.ICCode    = orig.ICCode;
            loc.WheelBase = orig.WheelBase;
            loc.CarSize   = orig.CarSize;
            loc.PlateNum  = orig.PlateNum;
            loc.InDate    = orig.InDate;
            loc.ImagePath = "";

            resp = new CWLocation().UpdateLocation(loc);

            string     rcdmsg = "数据入库,卡号 - " + loc.ICCode + " 车位 - " + loc.Address + " 轴距 - " + loc.WheelBase + " 外形 - " + loc.CarSize;
            OperateLog olog   = new OperateLog
            {
                Description = rcdmsg,
                CreateDate  = DateTime.Now,
                OptName     = ""
            };
            new CWOperateRecordLog().AddOperateLog(olog);

            //添加到指纹库中
            cwsaveprooft.Add(scert);

            #region 推送停车记录给云平台
            ParkingRecord pkRecord = new ParkingRecord
            {
                TaskType   = 0,
                LocAddrs   = loc.Address,
                Proof      = loc.ICCode,
                PlateNum   = loc.PlateNum,
                carpicture = loc.ImagePath,
                CarSize    = Convert.ToInt32(loc.CarSize),
                LocSize    = Convert.ToInt32(loc.LocSize),
                InDate     = loc.InDate.ToString()
            };
            CloudCallback.Instance().WatchParkingRcd(pkRecord);
            #endregion

            return(resp);
        }
예제 #2
0
        /// <summary>
        /// 数据出库
        /// </summary>
        /// <param name="wh"></param>
        /// <param name="addrs"></param>
        /// <returns></returns>
        public Response LocationOut(int warehouse, string Addrs)
        {
            Response resp = new Response();
            Location loc  = FindLocation(lc => lc.Warehouse == warehouse && lc.Address == Addrs);

            if (loc == null)
            {
                resp.Message = "找不到车位-" + Addrs;
                return(resp);
            }
            #region 推送停车记录给云平台
            ParkingRecord pkRecord = new ParkingRecord
            {
                TaskType   = 1,
                LocAddrs   = loc.Address,
                Proof      = loc.ICCode,
                PlateNum   = loc.PlateNum,
                carpicture = loc.ImagePath,
                CarSize    = string.IsNullOrEmpty(loc.CarSize) ? 0 : Convert.ToInt32(loc.CarSize),
                LocSize    = string.IsNullOrEmpty(loc.LocSize) ? 0 : Convert.ToInt32(loc.LocSize),
                InDate     = loc.InDate.ToString()
            };
            CloudCallback.Instance().WatchParkingRcd(pkRecord);
            #endregion

            string iccd = loc.ICCode;

            loc.Status    = EnmLocationStatus.Space;
            loc.ICCode    = "";
            loc.WheelBase = 0;
            loc.CarSize   = "";
            loc.InDate    = DateTime.Parse("2017-1-1");
            loc.PlateNum  = "";
            loc.ImagePath = "";

            resp = new CWLocation().UpdateLocation(loc);

            string     rcdmsg = "数据出库,卡号 - " + iccd + " 车位 - " + loc.Address;
            OperateLog olog   = new OperateLog
            {
                Description = rcdmsg,
                CreateDate  = DateTime.Now,
                OptName     = ""
            };
            new CWOperateRecordLog().AddOperateLog(olog);

            #region  除存车指纹库记录
            if (!string.IsNullOrEmpty(iccd))
            {
                CWSaveProof     cwsaveproof = new CWSaveProof();
                int             sno         = Convert.ToInt32(iccd);
                SaveCertificate scert       = cwsaveproof.Find(d => d.SNO == sno);
                if (scert != null)
                {
                    cwsaveproof.Delete(scert.ID);
                }
            }
            #endregion

            return(resp);
        }