Exemplo n.º 1
0
 public Response Update(SaveCertificate entity)
 {
     return(manager.Update(entity));
 }
Exemplo n.º 2
0
 public Response Delete(SaveCertificate proof)
 {
     return(manager.Delete(proof));
 }
Exemplo n.º 3
0
 public Response Add(SaveCertificate entity)
 {
     return(manager.Add(entity));
 }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        /// <summary>
        /// APP,扫码或其它存车,
        /// </summary>
        /// <returns></returns>
        public ActionResult SaveCarInterface()
        {
            Response resp = new Response();

            #region
            Log log = LogFactory.GetLogger("SaveCarInterface");
            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 warehouse = jo["warehouse"].ToString();
                string hallID    = jo["hallID"].ToString();
                string iccode    = jo["iccode"].ToString();
                string plate     = jo["plateNum"].ToString();

                if (string.IsNullOrEmpty(hallID))
                {
                    log.Error("APP存车,hallID为空!");
                    resp.Message = "参数错误,hallID为空!";
                    return(Json(resp));
                }
                if (string.IsNullOrEmpty(plate))
                {
                    log.Error("APP存车,车牌号为空!");
                    resp.Message = "参数错误,车牌号为空!";
                    return(Json(resp));
                }

                int wh   = 1;
                int code = Convert.ToInt32(hallID);

                CWDevice cwdevice = new CWDevice();
                CWTask   motsk    = new CWTask();

                Device moHall = cwdevice.Find(dev => dev.Warehouse == wh && dev.DeviceCode == code);
                if (moHall == null)
                {
                    log.Error("APP存车时, 找不到车厅设备. warehouse - " + warehouse + " ,hallID - " + hallID);
                    resp.Message = "找不到车厅";
                    return(Json(resp));
                }
                if (moHall.Mode != EnmModel.Automatic)
                {
                    log.Error("APP存车时, 车厅不是全自动. warehouse - " + warehouse + " ,hallID - " + hallID);
                    resp.Message = "车厅不是全自动";
                    return(Json(resp));
                }
                if (moHall.HallType == EnmHallType.Entrance ||
                    moHall.HallType == EnmHallType.EnterOrExit)
                {
                    if (moHall.TaskID == 0)
                    {
                        //车厅无车,不能存车
                        log.Error("APP存车时, 车厅无车,不能存车. ");
                        resp.Message = "车厅无车,不能存车";
                        return(Json(resp));
                    }
                    ImplementTask tsk = motsk.Find(moHall.TaskID);
                    if (tsk == null)
                    {
                        log.Error("APP存车时, 依车厅TaskID找不到作业信息,TaskID-" + moHall.TaskID + "  hallCode-" + moHall.DeviceCode);
                        //系统故障
                        resp.Message = "系统异常,找不到作业";
                        return(Json(resp));
                    }
                    if (tsk.Status != EnmTaskStatus.ICarInWaitFirstSwipeCard &&
                        tsk.Status != EnmTaskStatus.TempOCarOutWaitforDrive)
                    {
                        log.Error("APP存车时,不是处于刷卡阶段");
                        resp.Message = "不是处于刷卡阶段";
                        return(Json(resp));
                    }
                    if (tsk.PlateNum != plate)
                    {
                        log.Error("APP存车时,入库识别车牌与给定车牌不一致");
                        resp.Message = "APP绑定车牌与车辆车牌不一致";
                        return(Json(resp));
                    }

                    CWICCard cwiccd = new CWICCard();

                    if (tsk.Type == EnmTaskType.SaveCar)
                    {
                        string   physiccode = "1234567890";
                        Customer cust       = cwiccd.FindCust(cc => cc.PlateNum == plate);
                        if (cust != null)
                        {
                            ICCard iccd = cwiccd.Find(ic => ic.CustID == cust.ID);
                            if (iccd != null)
                            {
                                iccode     = iccd.UserCode;
                                physiccode = iccd.PhysicCode;
                            }
                        }
                        CWSaveProof cwsaveproof = new CWSaveProof();
                        if (string.IsNullOrEmpty(iccode))
                        {
                            iccode = cwsaveproof.GetMaxSNO().ToString();
                        }

                        SaveCertificate scert = new SaveCertificate();
                        scert.IsFingerPrint = 2;
                        scert.Proof         = physiccode;
                        scert.SNO           = Convert.ToInt32(iccode);
                        //添加凭证到存车库中
                        Response respe = cwsaveproof.Add(scert);

                        tsk.PlateNum = plate;
                        //更新作业状态为第二次刷卡,启动流程
                        motsk.DealISwipedSecondCard(tsk, iccode);

                        resp.Code    = 1;
                        resp.Message = "流程进行中";
                        return(Json(resp));
                    }
                    else if (tsk.Type == EnmTaskType.TempGet)
                    {
                        motsk.DealAPPSwipeThreeCard(tsk);
                    }
                }
                else
                {
                    log.Error("APP存车时,不是进(进出)车厅");
                    resp.Message = "不是进(进出)车厅";
                    return(Json(resp));
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                resp.Message = "系统异常";
            }
            #endregion
            return(Json(resp));
        }