Exemple #1
0
        /// <summary>
        /// 依指纹特性值,查找对应的顾客及存车车位
        /// </summary>
        /// <param name="strTZ"></param>
        /// <returns></returns>
        public Response FindCustByFPrintFeacture(string strTZ)
        {
            Response resp = new Response();
            Log      log  = LogFactory.GetLogger("FindCustByFPrintFeacture");

            try
            {
                FingerPrint origPrint = null;
                byte[]      current   = FPrintBase64.Base64FingerDataToHex(strTZ);

                List <FingerPrint> printList = manager.FindList().ToList();
                foreach (FingerPrint fp in printList)
                {
                    byte[] orig = FPrintBase64.Base64FingerDataToHex(fp.FingerInfo);
                    if (orig == null)
                    {
                        log.Debug("指纹-" + fp.FingerInfo + " ,转化为Byte失败!");
                    }

                    int iRet = FiPrintMatch.FPIMatch(current, orig, 3);
                    if (iRet == 0)
                    {
                        origPrint = fp;
                        break;
                    }
                }
                if (origPrint != null)
                {
                    resp.Code = 1;
                    RetFPring iRet = new RetFPring();
                    iRet.SNNumber = origPrint.SN_Number.ToString();
                    Customer cust = new CWICCard().FindCust(origPrint.CustID);
                    if (cust != null)
                    {
                        iRet.UserName = cust.UserName;
                        iRet.Plate    = cust.PlateNum;
                    }
                    Location loc = new CWLocation().FindLocation(lc => lc.ICCode == origPrint.SN_Number.ToString());
                    if (loc != null)
                    {
                        iRet.Warehouse = loc.Warehouse.ToString();
                        iRet.LocAddrs  = loc.Address;
                    }
                    resp.Message = "找到匹配注册指纹";
                    resp.Data    = iRet;
                }
                else
                {
                    //注册指纹库内没有匹配的,则查询存车指纹库
                    SaveCertificate        sproof      = null;
                    CWSaveProof            cwsaveproof = new CWSaveProof();
                    List <SaveCertificate> proofLst    = cwsaveproof.FindList(p => p.IsFingerPrint == 1);
                    foreach (SaveCertificate cert in proofLst)
                    {
                        byte[] orig = FPrintBase64.Base64FingerDataToHex(cert.Proof);
                        if (orig == null)
                        {
                            log.Debug("存车指纹库: 指纹 - " + cert.SNO + " ,转化为Byte失败!");
                            continue;
                        }
                        byte[] psMB  = orig;
                        int    nback = FiPrintMatch.FPIMatch(psMB, current, 3);
                        //比对成功
                        if (nback == 0)
                        {
                            sproof = cert;
                            break;
                        }
                    }
                    if (sproof != null)
                    {
                        resp.Code = 1;
                        RetFPring iRet = new RetFPring();
                        iRet.SNNumber = sproof.SNO.ToString();

                        Location loc = new CWLocation().FindLocation(lc => lc.ICCode == iRet.SNNumber);
                        if (loc != null)
                        {
                            iRet.Warehouse = loc.Warehouse.ToString();
                            iRet.LocAddrs  = loc.Address;
                        }
                        resp.Message = "存车指纹库内找到匹配指纹";
                        resp.Data    = iRet;
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            return(resp);
        }
Exemple #2
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);
        }
Exemple #3
0
        /// <summary>
        /// 查询临时用户费用
        /// </summary>
        public Response GetTempUserInfo(string iccode, bool isPlate)
        {
            Log        log    = LogFactory.GetLogger("CWTariff.GetTempUserInfo");
            Response   resp   = new Response();
            CWICCard   cwiccd = new CWICCard();
            CWLocation cwlctn = new CWLocation();

            try
            {
                Location     loc  = null;
                TempUserInfo info = new TempUserInfo();
                #region 暂不用
                //if (!isPlate)
                //{
                //    #region
                //    ICCard iccd = cwiccd.Find(ic=>ic.UserCode==iccode);
                //    if (iccd == null)
                //    {
                //        resp.Message = "不是本系统卡!";
                //        return resp;
                //    }
                //    if (iccd.CustID != 0)
                //    {
                //        Customer cust = cwiccd.FindCust(iccd.CustID);
                //        if (cust != null)
                //        {
                //            if (cust.Type != EnmICCardType.Temp)
                //            {
                //                resp.Message = "该用户不是临时用户!";
                //                return resp;
                //            }
                //        }
                //    }
                //    loc = cwlctn.FindLocation(lc=>lc.ICCode==iccode);
                //    if (loc == null)
                //    {
                //        resp.Message = "当前卡号没有存车!";
                //        return resp;
                //    }
                //    #endregion
                //}
                //else
                //{
                //    #region
                //    loc = cwlctn.FindLocation(l=>l.PlateNum==iccode);
                //    if (loc == null)
                //    {
                //        resp.Message = "当前输入车牌没有存车!";
                //        return resp;
                //    }
                //    string proof = loc.ICCode;
                //    Customer cust = null;
                //    #region
                //    if (Convert.ToInt32(proof) >= 10000) //是指纹激活的
                //    {
                //        int sno = Convert.ToInt32(proof);
                //        FingerPrint print = new CWFingerPrint().Find(p => p.SN_Number == sno);
                //        if (print == null)
                //        {
                //            //上位控制系统故障
                //            resp.Message = "找不到注册指纹,系统异常!";
                //            return resp;
                //        }
                //        cust = new CWICCard().FindCust(print.CustID);
                //        if (cust == null)
                //        {
                //            //上位控制系统故障
                //            resp.Message = "指纹没有绑定用户,系统异常!";
                //            return resp;
                //        }
                //    }
                //    else
                //    {
                //        ICCard iccd = new CWICCard().Find(ic => ic.UserCode == proof);
                //        if (iccd == null)
                //        {
                //            //上位控制系统故障
                //            resp.Message = "上位控制系统异常,找不到卡号!";
                //            return resp;
                //        }
                //        if (iccd.CustID != 0)
                //        {
                //            cust = new CWICCard().FindCust(iccd.CustID);
                //        }
                //    }
                //    #endregion
                //    if (cust != null)
                //    {
                //        if (cust.Type != EnmICCardType.Temp)
                //        {
                //            resp.Message = "该用户不是临时用户!";
                //            return resp;
                //        }
                //    }
                //    #endregion
                //}
                #endregion
                if (isPlate)
                {
                    //是车牌
                    loc = cwlctn.FindLocation(l => l.PlateNum == iccode);
                }
                else
                {
                    loc = cwlctn.FindLocation(l => l.ICCode == iccode);
                }
                if (loc == null)
                {
                    resp.Message = "当前车牌没有存车!Proof - " + iccode;
                    return(resp);
                }
                int             sno   = Convert.ToInt32(loc.ICCode);
                SaveCertificate scert = new CWSaveProof().Find(s => s.SNO == sno);
                if (scert != null)
                {
                    Customer cust = new CWICCard().FindCust(scert.CustID);
                    if (cust != null)
                    {
                        if (cust.Type != EnmICCardType.Temp)
                        {
                            resp.Message = "该用户不是临时用户!";
                            return(resp);
                        }
                    }
                }

                CWTask        cwtask = new CWTask();
                ImplementTask itask  = cwtask.FindITask(tk => tk.ICCardCode == loc.ICCode && tk.IsComplete == 0);
                if (itask != null)
                {
                    resp.Message = "正在作业,无法查询!";
                    return(resp);
                }
                WorkTask queue = cwtask.FindQueue(q => q.ICCardCode == loc.ICCode);
                if (queue != null)
                {
                    resp.Message = "已经加入取车队列,无法查询!";
                    return(resp);
                }

                info.CCode   = iccode;
                info.InDate  = loc.InDate.ToString();
                info.OutDate = DateTime.Now.ToString();
                TimeSpan span = DateTime.Now - loc.InDate;
                info.SpanTime = (span.Days > 0 ? span.Days + "天" : " ") + (span.Hours > 0 ? span.Hours + "小时" : " ") +
                                (span.Minutes >= 0 ? span.Minutes + "分" : " ") + (span.Seconds >= 0 ? span.Seconds + "秒" : " ");
                float fee = 0;
                resp = this.CalculateTempFee(loc.InDate, DateTime.Now, out fee);
                if (resp.Code == 0)
                {
                    return(resp);
                }
                info.NeedFee   = fee.ToString();
                info.Warehouse = loc.Warehouse;

                int hallID = new CWDevice().AllocateHall(loc, false);
                info.HallID = hallID;

                resp.Code    = 1;
                resp.Message = "查询成功";
                resp.Data    = info;
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            return(resp);
        }
Exemple #4
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);
        }