Beispiel #1
0
        /// <summary>
        /// 没有任何作业时,如果缓存位被占用,则强制回挪,
        /// TV分配,挪移车位分配
        /// </summary>
        /// <param name="frlct"></param>
        /// <param name="tolct"></param>
        /// <returns></returns>
        public Device PPYAllocateTvOfTransfer(Location frlct, out Location tolct)
        {
            tolct = null;
            CWLocation      cwlctn    = new CWLocation();
            CWICCard        cwiccd    = new CWICCard();
            List <Location> allLocLst = cwlctn.FindLocList();
            var             query     = from loc in allLocLst
                                        where loc.Type == EnmLocationType.Normal &&
                                        loc.Status == EnmLocationStatus.Space &&
                                        loc.Region == frlct.Region &&
                                        cwiccd.FindFixLocationByAddress(loc.Warehouse, loc.Address) == null &&
                                        loc.NeedBackup == 0 &&
                                        compareSize(loc.LocSize, frlct.LocSize) >= 0
                                        orderby Math.Abs(frlct.LocColumn - loc.LocColumn)
                                        select loc;

            List <Location> lctnLst = query.ToList();

            if (lctnLst.Count > 0)
            {
                tolct = lctnLst.FirstOrDefault();

                Device tv = new CWDevice().Find(d => d.Region == frlct.Region);
                return(tv);
            }
            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// 6174平面移动库挪移车位查找,库区只有一个车位尺寸
        /// </summary>
        /// <param name="frLct"></param>
        /// <returns></returns>
        public Location PPYAllocateLctnNeedTransfer(Location frLct)
        {
            CWLocation cwlctn = new CWLocation();
            CWICCard   cwiccd = new CWICCard();

            List <Location> lctnLst = cwlctn.FindLocList();
            //找出1、2边空闲的车位
            var query_same = from loc in lctnLst
                             where loc.Type == EnmLocationType.Normal &&
                             loc.Status == EnmLocationStatus.Space &&
                             loc.Region == frLct.Region &&
                             loc.LocSide != 3 &&
                             compareSize(loc.LocSize, frLct.LocSize) >= 0 &&
                             cwiccd.FindFixLocationByAddress(loc.Warehouse, loc.Address) == null
                             orderby Math.Abs(frLct.LocColumn - loc.LocColumn)
                             select loc;

            List <Location> availLst = new List <Location>();

            foreach (Location loc in query_same)
            {
                //如果是1边车位,后面的车位要是空闲或占用的
                if (loc.LocSide == 1)
                {
                    string   backAddrs = string.Format((loc.LocSide + 2).ToString() + loc.Address.Substring(1));
                    Location back      = cwlctn.FindLocation(lc => lc.Address == backAddrs);
                    if (back != null)
                    {
                        if (back.Status == EnmLocationStatus.Space ||
                            back.Status == EnmLocationStatus.Occupy)
                        {
                            availLst.Add(loc);
                        }
                    }
                }
                else
                {
                    availLst.Add(loc);
                }
            }

            //再找缓存车位
            var query_temp = from loc in lctnLst
                             where loc.Type == EnmLocationType.Temporary &&
                             loc.Status == EnmLocationStatus.Space &&
                             loc.Region == frLct.Region &&
                             compareSize(loc.LocSize, frLct.LocSize) >= 0
                             orderby Math.Abs(frLct.LocColumn - loc.LocColumn)
                             select loc;

            availLst.AddRange(query_temp);
            if (availLst.Count > 0)
            {
                return(availLst[0]);
            }
            return(null);
        }
Beispiel #3
0
        /// <summary>
        /// 添加,修改车位的入库时间,
        /// </summary>
        /// <param name="rcd"></param>
        /// <returns></returns>
        public Response Add(RemotePayFeeRcd rcd)
        {
            Log      log  = LogFactory.GetLogger("CWRemoteServer add");
            Response resp = new Response();

            try
            {
                CWLocation cwlctn = new CWLocation();
                Location   loc    = cwlctn.FindLocation(lc => lc.ICCode == rcd.strICCardID);
                if (loc == null)
                {
                    loc = cwlctn.FindLocation(lc => lc.PlateNum == rcd.strPlateNum);
                }
                if (loc != null)
                {
                    //修改车位的入库时间
                    loc.InDate = DateTime.Now;
                    cwlctn.UpdateLocation(loc);

                    rcd.Warehouse  = loc.Warehouse;
                    rcd.LocAddress = loc.Address;

                    log.Info("云服务下发付款成功通知,strICCardID- " + rcd.strICCardID + " ,strPlateNum- " + rcd.strPlateNum + " ,wh- " + loc.Warehouse + " ,address- " + loc.Address);

                    return(manager.Add(rcd));
                }
                else
                {
                    resp.Message = "找不到存车卡号";
                    log.Info("云服务下发缴费通知时,在库内找不到对应车位,strICCardID- " + rcd.strICCardID + " ,strPlateNum- " + rcd.strPlateNum);
                }
            }
            catch (Exception ex)
            {
                resp.Message = "出现异常- " + ex.ToString();
                log.Error(ex.ToString());
            }
            return(resp);
        }
Beispiel #4
0
        /// <summary>
        /// 分配车位:
        /// 1、优先分配中间区域的车位
        /// 2、判断ETV可达,车厅可达
        /// </summary>
        /// <param name="checkcode"></param>
        /// <returns></returns>
        public Location AllocateLoc(string checkcode)
        {
            //优先分配中间区域的车位
            int middlecolmn = 9;

            CWLocation cwlctn   = new CWLocation();
            CWDevice   cwdevice = new CWDevice();
            CWTask     cwtask   = new CWTask();
            CWICCard   cwiccd   = new CWICCard();

            #region 依距车厅的远近找出所有车位的集合
            List <Location> allLocLst  = cwlctn.FindLocList();
            List <Customer> fixCustLst = cwiccd.FindCustList(cu => cu.Type == EnmICCardType.FixedLocation || cu.Type == EnmICCardType.VIP);
            //排除固定车位
            List <Location> suitLocsLst = allLocLst.FindAll(lc => fixCustLst.Exists(cc => cc.LocAddress == lc.Address && cc.Warehouse == lc.Warehouse) == false);


            List <Location> sameLctnLst = new List <Location>();

            var locList_small = from loc in suitLocsLst
                                where loc.Type == EnmLocationType.Normal &&
                                loc.Status == EnmLocationStatus.Space &&
                                string.Compare(loc.LocSize, checkcode) == 0
                                orderby loc.LocSide ascending, Math.Abs(loc.LocColumn - middlecolmn) ascending
            select loc;

            var locList_big = from loc in suitLocsLst
                              where loc.Type == EnmLocationType.Normal &&
                              loc.Status == EnmLocationStatus.Space &&
                              string.Compare(loc.LocSize, checkcode) > 0
                              orderby loc.LocSide ascending, Math.Abs(loc.LocColumn - middlecolmn) ascending
            select loc;

            sameLctnLst.AddRange(locList_small);
            sameLctnLst.AddRange(locList_big);

            List <Location> lctnLst = new List <Location>();
            #region 如果是重列车位,优先分配前面车位是空闲的,其次是占用的,最后才是执行中的
            List <Location> spaceLctnLst  = new List <Location>();
            List <Location> occupyLctnLst = new List <Location>();
            List <Location> otherLctnLst  = new List <Location>();
            foreach (Location loc in sameLctnLst)
            {
                if (loc.LocSide == 4)
                {
                    #region 判断前面车位状态
                    string   fwdAddrs = "2" + loc.Address.Substring(1);
                    Location forward  = cwlctn.FindLocation(l => l.Address == fwdAddrs);
                    if (forward != null)
                    {
                        if (forward.Type == EnmLocationType.Normal)
                        {
                            if (forward.Status == EnmLocationStatus.Space)
                            {
                                spaceLctnLst.Add(loc);
                            }
                            else if (forward.Status == EnmLocationStatus.Occupy)
                            {
                                occupyLctnLst.Add(loc);
                            }
                            else
                            {
                                otherLctnLst.Add(loc);
                            }
                        }
                    }
                    #endregion
                }
                else if (loc.LocSide == 2)
                {
                    #region 判断后面车位状态
                    string   bckAddrs = "4" + loc.Address.Substring(1);
                    Location back     = cwlctn.FindLocation(l => l.Address == bckAddrs);
                    if (back != null)
                    {
                        if (back.Type == EnmLocationType.Normal)
                        {
                            if (back.Status == EnmLocationStatus.Space)
                            {
                                spaceLctnLst.Add(loc);
                            }
                            else if (back.Status == EnmLocationStatus.Occupy)
                            {
                                occupyLctnLst.Add(loc);
                            }
                            else
                            {
                                otherLctnLst.Add(loc);
                            }
                        }
                        else //禁用的
                        {
                            spaceLctnLst.Add(loc);
                        }
                    }

                    #endregion
                }
                else
                {
                    spaceLctnLst.Add(loc);
                }
            }
            lctnLst.AddRange(spaceLctnLst);
            lctnLst.AddRange(occupyLctnLst);
            lctnLst.AddRange(otherLctnLst);
            #endregion

            if (lctnLst.Count == 0)
            {
                return(null);
            }

            List <Device> nEtvList     = cwdevice.FindList(d => d.Type == EnmSMGType.ETV);
            WorkScope     workscope    = new WorkScope(nEtvList);
            List <Device> availHallLst = cwdevice.FindList(d => d.Type == EnmSMGType.Hall && d.Mode == EnmModel.Automatic);
            List <Device> availEtvLst  = nEtvList.FindAll(d => d.Mode == EnmModel.Automatic);

            if (availEtvLst.Count == 0 ||
                availHallLst.Count == 0)
            {
                return(null);
            }

            if (availEtvLst.Count == 2 && availHallLst.Count == 2)
            {
                return(lctnLst.FirstOrDefault());
            }
            if (availEtvLst.Count == 1)
            {
                CScope scope = workscope.GetEtvScope(availEtvLst[0]);
                if (availHallLst.Count == 2)
                {
                    foreach (Location loc in lctnLst)
                    {
                        if (loc.LocColumn >= scope.LeftCol && loc.LocColumn <= scope.RightCol)
                        {
                            return(loc);
                        }
                    }
                }
                else
                {
                    Device hall      = availHallLst[0];
                    int    hallcolmn = Convert.ToInt32(hall.Address.Substring(1, 2));
                    if (hallcolmn >= scope.LeftCol && hallcolmn <= scope.RightCol)
                    {
                        foreach (Location loc in lctnLst)
                        {
                            if (loc.LocColumn >= scope.LeftCol && loc.LocColumn <= scope.RightCol)
                            {
                                return(loc);
                            }
                        }
                    }
                }
            }

            #endregion

            return(null);
        }
Beispiel #5
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);
        }
Beispiel #6
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);
        }
Beispiel #7
0
        /// <summary>
        /// 依ETV作业范围,找出符合尺寸的车位
        /// 如果是重列车位,则前面的车位,一定是空闲的
        /// </summary>
        /// <param name="etv"></param>
        /// <returns></returns>
        public Location AllocateLocOfEtvScope(Device etv, string checkcode)
        {
            CWLocation cwlctn = new CWLocation();
            CWDevice cwdevice = new CWDevice();
            CWTask cwtask = new CWTask();
            CWICCard cwiccd = new CWICCard();

            List<Device> nEtvList = cwdevice.FindList(d => d.Type == EnmSMGType.ETV);
            WorkScope workscope = new WorkScope(nEtvList);
            CScope scope = workscope.GetEtvScope(etv);
            int etvColmn = Convert.ToInt32(etv.Address.Substring(1, 2));

            List<Location> allLocsLst = cwlctn.FindLocList();
            List<Customer> fixCustLst = cwiccd.FindCustList(cu => cu.Type == EnmICCardType.FixedLocation || cu.Type == EnmICCardType.VIP);
            //排除固定车位
            List<Location> suitLocsLst = allLocsLst.FindAll(lc => fixCustLst.Exists(cc => cc.LocAddress == lc.Address && cc.Warehouse == lc.Warehouse) == false);

            var queryLstsmall = from loc in suitLocsLst
                                where loc.Type == EnmLocationType.Normal &&
                                      loc.Status == EnmLocationStatus.Space &&
                                      compareSize(loc.LocSize, checkcode) == 1 &&
                                      cwiccd.FindFixLocationByAddress(loc.Warehouse, loc.Address) == null
                                orderby Math.Abs(loc.LocColumn - etvColmn) ascending,
                                        loc.LocSide ascending
                                select loc;

            List<Location> priorLocsLst = new List<Location>();
            List<Location> nextLocsLst = new List<Location>();
            foreach (Location loc in queryLstsmall)
            {
                if (loc.LocColumn >= scope.LeftCol && loc.LocColumn <= scope.RightCol)
                {
                    #region
                    if (loc.LocSide == 2)
                    {
                        #region 如果后边的车位在作业,则最后分配
                        string bckAddrs = "4" + loc.Address.Substring(1);
                        Location back = cwlctn.FindLocation(l => l.Address == bckAddrs);
                        if (back != null)
                        {
                            if (back.Type == EnmLocationType.Normal)
                            {
                                if (back.Status == EnmLocationStatus.Space)
                                {
                                    priorLocsLst.Add(loc);
                                }
                                else
                                {
                                    nextLocsLst.Add(loc);
                                }
                            }
                            else if (back.Type == EnmLocationType.Disable)
                            {
                                priorLocsLst.Add(loc);
                            }
                        }
                        #endregion
                    }
                    else if (loc.LocSide == 4)
                    {
                        #region 如果是重列,则前面的车位一定是空闲的
                        string fwdAddrs = "2" + loc.Address.Substring(1);
                        Location forward = cwlctn.FindLocation(l => l.Address == fwdAddrs);
                        if (forward != null)
                        {
                            if (forward.Type == EnmLocationType.Normal &&
                                forward.Status == EnmLocationStatus.Space)
                            {
                                priorLocsLst.Add(loc);
                            }
                        }
                        #endregion
                    }
                    else if (loc.LocSide == 1)
                    {
                        priorLocsLst.Add(loc);
                    }
                    #endregion
                }
            }
            if (priorLocsLst.Count > 0)
            {
                return priorLocsLst[0];
            }
            if (nextLocsLst.Count > 0)
            {
                return nextLocsLst[0];
            }

            var queryLstbig = from loc in suitLocsLst
                              where loc.Type == EnmLocationType.Normal &&
                                    loc.Status == EnmLocationStatus.Space &&
                                    compareSize(loc.LocSize, checkcode) > 1 &&
                                    cwiccd.FindFixLocationByAddress(loc.Warehouse, loc.Address) == null
                              orderby Math.Abs(loc.LocColumn - etvColmn) ascending,
                                      loc.LocSide ascending
                              select loc;

            List<Location> priorLocsLstbig = new List<Location>();
            List<Location> nextLocsLstbig = new List<Location>();
            foreach (Location loc in queryLstbig)
            {
                if (loc.LocColumn >= scope.LeftCol && loc.LocColumn <= scope.RightCol)
                {
                    #region
                    if (loc.LocSide == 2)
                    {
                        #region 如果后边的车位在作业,则最后分配
                        string bckAddrs = "4" + loc.Address.Substring(1);
                        Location back = cwlctn.FindLocation(l => l.Address == bckAddrs);
                        if (back != null)
                        {
                            if (back.Type == EnmLocationType.Normal)
                            {
                                if (back.Status == EnmLocationStatus.Space)
                                {
                                    priorLocsLstbig.Add(loc);
                                }
                                else
                                {
                                    nextLocsLstbig.Add(loc);
                                }
                            }
                            else if (back.Type == EnmLocationType.Disable)
                            {
                                priorLocsLstbig.Add(loc);
                            }
                        }
                        #endregion
                    }
                    else if (loc.LocSide == 4)
                    {
                        #region 如果是重列,则前面的车位一定是空闲的
                        string fwdAddrs = "2" + loc.Address.Substring(1);
                        Location forward = cwlctn.FindLocation(l => l.Address == fwdAddrs);
                        if (forward != null)
                        {
                            if (forward.Type == EnmLocationType.Normal &&
                                forward.Status == EnmLocationStatus.Space)
                            {
                                priorLocsLstbig.Add(loc);
                            }
                        }
                        #endregion
                    }
                    else if (loc.LocSide == 1)
                    {
                        priorLocsLstbig.Add(loc);
                    }
                    #endregion
                }
            }

            if (priorLocsLstbig.Count > 0)
            {
                return priorLocsLstbig[0];
            }
            if (nextLocsLstbig.Count > 0)
            {
                return nextLocsLstbig[0];
            }

            return null;
        }
        /// <summary>
        /// 存车时,分配车位及ETV
        /// </summary>
        /// <param name="checkCode">外形尺寸</param>
        /// <param name="cust">顾客</param>
        /// <param name="hall">车厅</param>
        /// <param name="smg">ETV 设备号</param>
        /// <returns></returns>
        public Location IAllocateLocation(string checkCode, Customer cust, Device hall, out int smg)
        {
            Log log = LogFactory.GetLogger("AllocateLocation.IAllocateLocation");

            smg = 0;

            int warehouse = hall.Warehouse;
            int hallCode  = hall.DeviceCode;
            int hallCol   = Convert.ToInt32(hall.Address.Substring(1, 2));

            Location   lct    = null;
            CWTask     cwtask = new CWTask();
            CWLocation cwlctn = new CWLocation();

            if (cust.Type == EnmICCardType.Temp ||
                cust.Type == EnmICCardType.Periodical)
            {
                #region 判断是否是预定了车位
                lct = cwlctn.FindLocation(cc => cc.Type == EnmLocationType.Normal && cc.Status == EnmLocationStatus.Book && cc.PlateNum == cust.PlateNum);
                if (lct != null)
                {
                    log.Info("当前车牌已预定车位,address-" + lct.Address + " ,wh- " + lct.Warehouse + " ,plate- " + cust.PlateNum + " ,cust- " + cust.UserName);
                    if (compareSize(lct.LocSize, checkCode) >= 0)
                    {
                        //分配ETV
                        Device dev = PXDAllocateEtvOfFixLoc(hall, lct);
                        if (dev != null)
                        {
                            smg = dev.DeviceCode;
                        }
                        return(lct);
                    }
                    else
                    {
                        log.Info("当前预定车位,address-" + lct.Address + " ,wh- " + lct.Warehouse + " ,locsize- " + lct.LocSize + ",carsize- " + checkCode + " 尺寸不合适,按临时卡分配");
                        //释放预定的车位
                        lct.Status   = EnmLocationStatus.Space;
                        lct.PlateNum = "";
                        lct.InDate   = DateTime.Parse("2017-1-1");
                        cwlctn.UpdateLocation(lct);
                        //按临时车位处理
                        lct = this.PXDAllocate(hall, checkCode, out smg);
                    }
                }
                else  //没有预定车位,按临时车处理
                {
                    lct = this.PXDAllocate(hall, checkCode, out smg);
                }
                #endregion
            }
            else if (cust.Type == EnmICCardType.FixedLocation)
            {
                if (cust.Warehouse != warehouse)
                {
                    //车辆停在其他库区
                    cwtask.AddNofication(warehouse, hallCode, "16.wav");
                    return(null);
                }
                lct = new CWLocation().FindLocation(l => l.Warehouse == cust.Warehouse && l.Address == cust.LocAddress);
                if (lct == null)
                {
                    cwtask.AddNofication(warehouse, hallCode, "20.wav");
                    log.Error("固定车位时,依地址找不到对应车位,address - " + cust.LocAddress);
                    return(null);
                }

                if (lct != null)
                {
                    if (compareSize(lct.LocSize, checkCode) < 0)
                    {
                        //车位尺寸与车辆不匹配
                        cwtask.AddNofication(warehouse, hallCode, "61.wav");
                        return(null);
                    }
                }
                if (lct.Type != EnmLocationType.Normal)
                {
                    cwtask.AddNofication(warehouse, hallCode, "69.wav");
                    return(null);
                }
                //如果是重列车位,判断前面车位是否是正常的
                if (lct.NeedBackup == 1)
                {
                    string   fwdaddrs = (lct.LocSide - 2).ToString() + lct.Address.Substring(1);
                    Location forward  = new CWLocation().FindLocation(l => l.Address == fwdaddrs);
                    if (forward != null)
                    {
                        if (forward.Type != EnmLocationType.Normal)
                        {
                            //前面车位已被禁用
                            cwtask.AddNofication(warehouse, hallCode, "15.wav");
                            return(null);
                        }
                    }
                }
                //分配ETV
                Device dev = PXDAllocateEtvOfFixLoc(hall, lct);
                if (dev != null)
                {
                    smg = dev.DeviceCode;
                }
            }
            return(lct);
        }
        /// <summary>
        /// 巷道堆垛临时卡车位分配
        /// </summary>
        /// <returns></returns>
        private Location PXDAllocate(Device hall, string checkCode, out int smg)
        {
            smg = 0;
            #region
            CWLocation cwlctn   = new CWLocation();
            CWDevice   cwdevice = new CWDevice();
            CWTask     cwtask   = new CWTask();
            CWICCard   cwiccd   = new CWICCard();

            List <Device> nEtvList  = cwdevice.FindList(d => d.Type == EnmSMGType.ETV);
            WorkScope     workscope = new WorkScope(nEtvList);
            int           hallColmn = Convert.ToInt32(hall.Address.Substring(1, 2));
            List <Device> reachHall = new List <Device>();
            #region 找出可达车厅、可用的ETV集合
            foreach (Device dev in nEtvList)
            {
                CScope scope = workscope.GetEtvScope(dev);
                if (scope.LeftCol <= hallColmn && hallColmn <= scope.RightCol)
                {
                    if (dev.IsAble == 1)
                    {
                        reachHall.Add(dev);
                    }
                }
            }
            #endregion

            List <Location> lctnLst = new List <Location>();
            #region 依距车厅的远近找出所有车位的集合
            List <Location> allLocLst  = cwlctn.FindLocList();
            List <Customer> fixCustLst = cwiccd.FindCustList(cu => cu.Type == EnmICCardType.FixedLocation || cu.Type == EnmICCardType.VIP);
            //排除固定车位
            allLocLst = allLocLst.FindAll(lc => fixCustLst.Exists(cc => cc.LocAddress == lc.Address && cc.Warehouse == lc.Warehouse) == false);

            #region 车位尺寸一致
            List <Location> sameLctnLst = new List <Location>();

            #region
            #region 首先 分配与车厅同一个区域的,车位尺寸一致的, 4-2-1依次排列,
            var L42_locList_small = from loc in allLocLst
                                    where loc.Type == EnmLocationType.Normal &&
                                    loc.Status == EnmLocationStatus.Space &&
                                    compareSize(loc.LocSize, checkCode) == 1 &&
                                    loc.LocSide != 1 &&
                                    loc.Region == hall.Region
                                    orderby Math.Abs(loc.LocColumn - hallColmn) ascending,
                loc.LocSide descending
            select loc;

            //1边
            var L1_locList_small = from loc in allLocLst
                                   where loc.Type == EnmLocationType.Normal &&
                                   loc.Status == EnmLocationStatus.Space &&
                                   compareSize(loc.LocSize, checkCode) == 1 &&
                                   loc.LocSide == 1 &&
                                   loc.Region == hall.Region
                                   orderby Math.Abs(loc.LocColumn - hallColmn) ascending
                                   select loc;

            #endregion
            sameLctnLst.AddRange(L42_locList_small);
            sameLctnLst.AddRange(L1_locList_small);

            #region 再次分配与车厅同一个区域,车位尺寸(仅宽度)偏大点的
            var L42_locList_width = from loc in allLocLst
                                    where loc.Type == EnmLocationType.Normal &&
                                    loc.Status == EnmLocationStatus.Space &&
                                    compareSize(loc.LocSize, checkCode) == 2 &&
                                    loc.LocSide != 1 &&
                                    loc.Region == hall.Region
                                    orderby Math.Abs(loc.LocColumn - hallColmn) ascending,
                loc.LocSide descending
            select loc;

            //1边
            var L1_locList_width = from loc in allLocLst
                                   where loc.Type == EnmLocationType.Normal &&
                                   loc.Status == EnmLocationStatus.Space &&
                                   compareSize(loc.LocSize, checkCode) == 2 &&
                                   loc.LocSide == 1 &&
                                   loc.Region == hall.Region
                                   orderby Math.Abs(loc.LocColumn - hallColmn) ascending
                                   select loc;

            #endregion
            sameLctnLst.AddRange(L42_locList_width);
            sameLctnLst.AddRange(L1_locList_width);

            #region 再分配与车厅不是同一个区域的
            //4边2边
            var L42_locList_small_dif = from loc in allLocLst
                                        where loc.Type == EnmLocationType.Normal &&
                                        loc.Status == EnmLocationStatus.Space &&
                                        compareSize(loc.LocSize, checkCode) == 1 &&
                                        loc.LocSide != 1 &&
                                        loc.Region != hall.Region
                                        orderby Math.Abs(loc.LocColumn - hallColmn) ascending,
                loc.LocSide descending
            select loc;

            //1边
            var L1_locList_small_dif = from loc in allLocLst
                                       where loc.Type == EnmLocationType.Normal &&
                                       loc.Status == EnmLocationStatus.Space &&
                                       compareSize(loc.LocSize, checkCode) == 1 &&
                                       loc.LocSide == 1 &&
                                       loc.Region != hall.Region
                                       orderby Math.Abs(loc.LocColumn - hallColmn) ascending
                                       select loc;

            #endregion
            sameLctnLst.AddRange(L42_locList_small_dif);
            sameLctnLst.AddRange(L1_locList_small_dif);

            #region 再次分配与车厅不同区域,车位尺寸(仅宽度)偏大点的
            var L42_locList_width_dif = from loc in allLocLst
                                        where loc.Type == EnmLocationType.Normal &&
                                        loc.Status == EnmLocationStatus.Space &&
                                        compareSize(loc.LocSize, checkCode) == 2 &&
                                        loc.LocSide != 1 &&
                                        loc.Region != hall.Region
                                        orderby Math.Abs(loc.LocColumn - hallColmn) ascending,
                loc.LocSide descending
            select loc;

            //1边
            var L1_locList_width_dif = from loc in allLocLst
                                       where loc.Type == EnmLocationType.Normal &&
                                       loc.Status == EnmLocationStatus.Space &&
                                       compareSize(loc.LocSize, checkCode) == 2 &&
                                       loc.LocSide == 1 &&
                                       loc.Region != hall.Region
                                       orderby Math.Abs(loc.LocColumn - hallColmn) ascending
                                       select loc;

            #endregion
            sameLctnLst.AddRange(L42_locList_width_dif);
            sameLctnLst.AddRange(L1_locList_width_dif);
            #endregion

            #region 如果是重列车位,优先分配前面车位是空闲的,其次是占用的,最后才是执行中的
            List <Location> spaceLctnLst  = new List <Location>();
            List <Location> occupyLctnLst = new List <Location>();
            List <Location> otherLctnLst  = new List <Location>();
            foreach (Location loc in sameLctnLst)
            {
                if (loc.LocSide == 4)
                {
                    #region 判断前面车位状态
                    string   fwdAddrs = "2" + loc.Address.Substring(1);
                    Location forward  = cwlctn.FindLocation(l => l.Address == fwdAddrs);
                    if (forward != null)
                    {
                        if (forward.Type == EnmLocationType.Normal)
                        {
                            if (forward.Status == EnmLocationStatus.Space)
                            {
                                spaceLctnLst.Add(loc);
                            }
                            else if (forward.Status == EnmLocationStatus.Occupy)
                            {
                                occupyLctnLst.Add(loc);
                            }
                            else
                            {
                                otherLctnLst.Add(loc);
                            }
                        }
                    }
                    #endregion
                }
                else if (loc.LocSide == 2)
                {
                    #region 判断后面车位状态
                    string   bckAddrs = "4" + loc.Address.Substring(1);
                    Location back     = cwlctn.FindLocation(l => l.Address == bckAddrs);
                    if (back != null)
                    {
                        if (back.Type == EnmLocationType.Normal)
                        {
                            if (back.Status == EnmLocationStatus.Space)
                            {
                                spaceLctnLst.Add(loc);
                            }
                            else if (back.Status == EnmLocationStatus.Occupy)
                            {
                                occupyLctnLst.Add(loc);
                            }
                            else
                            {
                                otherLctnLst.Add(loc);
                            }
                        }
                        else //禁用的
                        {
                            spaceLctnLst.Add(loc);
                        }
                    }

                    #endregion
                }
                else
                {
                    spaceLctnLst.Add(loc);
                }
            }
            lctnLst.AddRange(spaceLctnLst);
            lctnLst.AddRange(occupyLctnLst);
            lctnLst.AddRange(otherLctnLst);
            #endregion

            #endregion

            #region 车位尺寸是大的
            List <Location> bigLctnLst = new List <Location>();

            #region
            #region 首先 分配与车厅同一个区域的,车位尺寸一致的, 4-2-1依次排列,
            var L42_locList_big = from loc in allLocLst
                                  where loc.Type == EnmLocationType.Normal &&
                                  loc.Status == EnmLocationStatus.Space &&
                                  compareSize(loc.LocSize, checkCode) == 3 &&
                                  loc.LocSide != 1 &&
                                  loc.Region == hall.Region
                                  orderby Math.Abs(loc.LocColumn - hallColmn) ascending,
                loc.LocSide descending
            select loc;

            //1边
            var L1_locList_big = from loc in allLocLst
                                 where loc.Type == EnmLocationType.Normal &&
                                 loc.Status == EnmLocationStatus.Space &&
                                 compareSize(loc.LocSize, checkCode) == 3 &&
                                 loc.LocSide == 1 &&
                                 loc.Region == hall.Region
                                 orderby Math.Abs(loc.LocColumn - hallColmn) ascending
                                 select loc;

            #endregion
            bigLctnLst.AddRange(L42_locList_big);
            bigLctnLst.AddRange(L1_locList_big);

            #region 再分配与车厅不是同一个区域的
            var L42_locList_big_dif = from loc in allLocLst
                                      where loc.Type == EnmLocationType.Normal &&
                                      loc.Status == EnmLocationStatus.Space &&
                                      compareSize(loc.LocSize, checkCode) == 3 &&
                                      loc.LocSide != 1 &&
                                      loc.Region != hall.Region
                                      orderby Math.Abs(loc.LocColumn - hallColmn) ascending,
                loc.LocSide descending
            select loc;

            //1边
            var L1_locList_big_dif = from loc in allLocLst
                                     where loc.Type == EnmLocationType.Normal &&
                                     loc.Status == EnmLocationStatus.Space &&
                                     compareSize(loc.LocSize, checkCode) == 3 &&
                                     loc.LocSide == 1 &&
                                     loc.Region != hall.Region
                                     orderby Math.Abs(loc.LocColumn - hallColmn) ascending
                                     select loc;

            #endregion
            bigLctnLst.AddRange(L42_locList_big_dif);
            bigLctnLst.AddRange(L1_locList_big_dif);

            #endregion

            #region 如果是重列车位,优先分配前面车位是空闲的,其次是占用的,最后才是执行中的
            List <Location> spaceLctnLst_big  = new List <Location>();
            List <Location> occupyLctnLst_big = new List <Location>();
            List <Location> otherLctnLst_big  = new List <Location>();
            foreach (Location loc in bigLctnLst)
            {
                if (loc.LocSide == 4)
                {
                    #region 判断前面车位状态
                    string   fwdAddrs = "2" + loc.Address.Substring(1);
                    Location forward  = cwlctn.FindLocation(l => l.Address == fwdAddrs);
                    if (forward != null)
                    {
                        if (forward.Type == EnmLocationType.Normal)
                        {
                            if (forward.Status == EnmLocationStatus.Space)
                            {
                                spaceLctnLst_big.Add(loc);
                            }
                            else if (forward.Status == EnmLocationStatus.Occupy)
                            {
                                occupyLctnLst_big.Add(loc);
                            }
                            else
                            {
                                otherLctnLst_big.Add(loc);
                            }
                        }
                    }
                    #endregion
                }
                else if (loc.LocSide == 2)
                {
                    #region 判断后面车位状态
                    string   bckAddrs = "4" + loc.Address.Substring(1);
                    Location back     = cwlctn.FindLocation(l => l.Address == bckAddrs);
                    if (back != null)
                    {
                        if (back.Type == EnmLocationType.Normal)
                        {
                            if (back.Status == EnmLocationStatus.Space)
                            {
                                spaceLctnLst_big.Add(loc);
                            }
                            else if (back.Status == EnmLocationStatus.Occupy)
                            {
                                occupyLctnLst_big.Add(loc);
                            }
                            else
                            {
                                otherLctnLst_big.Add(loc);
                            }
                        }
                        else //禁用的
                        {
                            spaceLctnLst_big.Add(loc);
                        }
                    }

                    #endregion
                }
                else
                {
                    spaceLctnLst_big.Add(loc);
                }
            }
            lctnLst.AddRange(spaceLctnLst_big);
            lctnLst.AddRange(occupyLctnLst_big);
            lctnLst.AddRange(otherLctnLst_big);
            #endregion

            #endregion
            #endregion
            if (reachHall.Count == 1)
            {
                CScope scope = workscope.GetEtvScope(reachHall[0]);
                //只要一个ETV可达车厅,
                //依作业范围,找出在TV范围内的车位
                foreach (Location loc in lctnLst)
                {
                    if (scope.LeftCol <= loc.LocColumn && loc.LocColumn <= scope.RightCol)
                    {
                        smg = reachHall[0].DeviceCode;
                        return(loc);
                    }
                }
            }
            else if (reachHall.Count == 2)
            {
                //如果有两个空闲的
                List <Device> freeEtvs = reachHall.FindAll(ch => ch.TaskID == 0);
                if (freeEtvs.Count == 2)
                {
                    #region
                    freeEtvs = reachHall.OrderBy(h => Math.Abs(h.Region - hall.Region)).ToList();
                    foreach (Device dev in freeEtvs)
                    {
                        CScope scope = workscope.GetEtvScope(dev);
                        foreach (Location loc in lctnLst)
                        {
                            if (scope.LeftCol <= loc.LocColumn && loc.LocColumn <= scope.RightCol)
                            {
                                smg = dev.DeviceCode;
                                return(loc);
                            }
                        }
                    }
                    #endregion
                }
                else if (freeEtvs.Count == 1)
                {
                    #region
                    Device dev = freeEtvs[0];
                    if (dev.Region == hall.Region)
                    {
                        #region
                        smg = dev.DeviceCode;
                        CScope scope = workscope.GetEtvScope(dev);
                        foreach (Location loc in lctnLst)
                        {
                            if (scope.LeftCol <= loc.LocColumn && loc.LocColumn <= scope.RightCol)
                            {
                                return(loc);
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        #region
                        //如果不是同一区域的
                        //判断另一个ETV在执行什么样的动作,
                        //另一台ETV要不要跨区作业
                        Device other = reachHall.Find(h => h.DeviceCode != dev.DeviceCode);
                        if (other.TaskID != 0)
                        {
                            ImplementTask task = cwtask.Find(other.TaskID);
                            if (task != null)
                            {
                                string toAddrs = "";
                                if (task.Status == EnmTaskStatus.TWaitforLoad ||
                                    task.Status == EnmTaskStatus.TWaitforMove)
                                {
                                    toAddrs = task.FromLctAddress;
                                }
                                else
                                {
                                    toAddrs = task.ToLctAddress;
                                }
                                int toCol = Convert.ToInt32(toAddrs.Substring(1, 2));
                                //正在作业TV
                                int currCol = Convert.ToInt32(other.Address.Substring(1, 2));
                                //空闲TV
                                int freeCol = Convert.ToInt32(dev.Address.Substring(1, 2));

                                //空闲TV在右侧,即2号ETV空闲
                                if (currCol < freeCol)
                                {
                                    #region TV2空闲
                                    if (hallColmn >= toCol + 3)
                                    {
                                        //1#车厅不在范围内,则允许2#ETV动作
                                        smg = dev.DeviceCode;
                                        CScope scope = workscope.GetEtvScope(dev);
                                        foreach (Location loc in lctnLst)
                                        {
                                            if (scope.LeftCol <= loc.LocColumn && loc.LocColumn <= scope.RightCol)
                                            {
                                                return(loc);
                                            }
                                        }
                                    }
                                    #endregion
                                }
                                else
                                {
                                    #region 1#TV空闲
                                    if (hallColmn <= toCol - 3)
                                    {
                                        //2#车厅不在范围内,则允许1#ETV动作
                                        smg = dev.DeviceCode;
                                        CScope scope = workscope.GetEtvScope(dev);
                                        foreach (Location loc in lctnLst)
                                        {
                                            if (scope.LeftCol <= loc.LocColumn && loc.LocColumn <= scope.RightCol)
                                            {
                                                return(loc);
                                            }
                                        }
                                    }
                                    #endregion
                                }
                            }
                        }
                        #endregion
                    }
                    #endregion
                }
                List <Device> orderbyEtvs = reachHall.OrderBy(dr => Math.Abs(dr.Region - hall.Region)).ToList();
                #region 两个都在忙或上述找不到时,则依车厅区域内的ETV优先,分配ETV
                foreach (Device devc in orderbyEtvs)
                {
                    CScope scope = workscope.GetEtvScope(devc);
                    foreach (Location loc in lctnLst)
                    {
                        if (scope.LeftCol <= loc.LocColumn && loc.LocColumn <= scope.RightCol)
                        {
                            smg = devc.DeviceCode;
                            return(loc);
                        }
                    }
                }

                #endregion
            }
            #endregion
            return(null);
        }
Beispiel #10
0
        /// <summary>
        /// 巷道堆垛式---要生成挪移作业时,挪移车位的查找
        /// </summary>
        /// <param name="nEtv"></param>
        /// <param name="frLct"></param>
        /// <returns></returns>
        public Location AllocateTvNeedTransfer(Device nEtv, Location frLct)
        {
            CWDevice   cwdevice = new CWDevice();
            CWLocation cwlctn   = new CWLocation();
            CWICCard   cwiccd   = new CWICCard();

            int           warehouse = nEtv.Warehouse;
            List <Device> nEtvList  = cwdevice.FindList(d => d.Type == EnmSMGType.ETV);
            WorkScope     workscope = new WorkScope(nEtvList);
            CScope        scope     = workscope.GetEtvScope(nEtv);

            List <Location> availLst      = new List <Location>();
            List <Location> backOccupyLst = new List <Location>();
            List <Location> lctnLst       = cwlctn.FindLocList();
            //先找出相同区域的,尺寸一致的,如果是2边车位,则后面的车位不能是作业的车位
            var query_same = from loc in lctnLst
                             where loc.Type == EnmLocationType.Normal &&
                             loc.Status == EnmLocationStatus.Space &&
                             loc.Region == frLct.Region &&
                             loc.LocSide != 4 &&
                             (compareSize(loc.LocSize, frLct.LocSize) == 1 ||
                              compareSize(loc.LocSize, frLct.LocSize) == 2) &&
                             cwiccd.FindFixLocationByAddress(loc.Warehouse, loc.Address) == null
                             orderby Math.Abs(frLct.LocColumn - loc.LocColumn), loc.LocSide ascending
            select loc;

            foreach (Location loc in query_same)
            {
                if (loc.LocSide == 2)
                {
                    string   backAddrs = string.Format((loc.LocSide + 2).ToString() + loc.Address.Substring(1));
                    Location back      = cwlctn.FindLocation(lc => lc.Address == backAddrs);
                    if (back != null)
                    {
                        if (back.Status == EnmLocationStatus.Space)
                        {
                            availLst.Add(loc);
                        }
                        else if (back.Status == EnmLocationStatus.Occupy)
                        {
                            backOccupyLst.Add(loc);
                        }
                    }
                }
                else
                {
                    availLst.Add(loc);
                }
            }
            availLst.AddRange(backOccupyLst);
            //再找缓存车位
            var query_temp = from loc in lctnLst
                             where loc.Type == EnmLocationType.Temporary &&
                             loc.Status == EnmLocationStatus.Space &&
                             compareSize(loc.LocSize, frLct.LocSize) > 0
                             orderby Math.Abs(loc.Region - frLct.Region)
                             select loc;

            availLst.AddRange(query_temp);
            //最后找不同区域的,尺寸一致的,如果是2边车位,则后面的车位不能是作业的车位
            var query_diff = from loc in lctnLst
                             where loc.Type == EnmLocationType.Normal &&
                             loc.Status == EnmLocationStatus.Space &&
                             loc.Region != frLct.Region &&
                             loc.LocSide != 4 &&
                             (compareSize(loc.LocSize, frLct.LocSize) == 1 ||
                              compareSize(loc.LocSize, frLct.LocSize) == 2) &&
                             cwiccd.FindFixLocationByAddress(loc.Warehouse, loc.Address) == null
                             orderby Math.Abs(frLct.LocColumn - loc.LocColumn), loc.LocSide ascending
            select loc;

            List <Location> backOccupyLst_Big = new List <Location>();

            foreach (Location loc in query_diff)
            {
                if (loc.LocSide == 2)
                {
                    string   backAddrs = string.Format((loc.LocSide + 2).ToString() + loc.Address.Substring(1));
                    Location back      = cwlctn.FindLocation(lc => lc.Address == backAddrs);
                    if (back != null)
                    {
                        if (back.Status == EnmLocationStatus.Space)
                        {
                            availLst.Add(loc);
                        }
                        else if (back.Status == EnmLocationStatus.Occupy)
                        {
                            backOccupyLst_Big.Add(loc);
                        }
                    }
                }
                else
                {
                    availLst.Add(loc);
                }
            }
            availLst.AddRange(backOccupyLst_Big);

            foreach (Location loc in availLst)
            {
                if (scope.LeftCol <= loc.LocColumn && loc.LocColumn <= scope.RightCol)
                {
                    return(loc);
                }
            }
            return(null);
        }
Beispiel #11
0
        /// <summary>
        /// 没有任何作业时,如果缓存位被占用,则强制回挪,
        /// TV分配,挪移车位分配
        /// </summary>
        /// <param name="frlct"></param>
        /// <param name="tolct"></param>
        /// <returns></returns>
        public Device AllocateTvOfTransport(Location frlct, out Location toLct)
        {
            toLct = null;
            CWDevice   cwdevice = new CWDevice();
            CWLocation cwlctn   = new CWLocation();
            CWICCard   cwiccd   = new CWICCard();

            List <Device> nEtvList  = cwdevice.FindList(d => d.Type == EnmSMGType.ETV);
            WorkScope     workscope = new WorkScope(nEtvList);
            int           locColmn  = frlct.LocColumn;

            List <Device> availableLst = new List <Device>();

            #region 可达车位、可用的ETV集合
            foreach (Device dev in nEtvList)
            {
                if (dev.IsAble == 1)
                {
                    CScope scope = workscope.GetEtvScope(dev);
                    if (scope.LeftCol <= locColmn && locColmn <= scope.RightCol)
                    {
                        availableLst.Add(dev);
                    }
                }
            }
            #endregion

            List <Location> allLocLst = cwlctn.FindLocList();
            var             query     = from loc in allLocLst
                                        where loc.Type == EnmLocationType.Normal &&
                                        loc.Status == EnmLocationStatus.Space &&
                                        cwiccd.FindFixLocationByAddress(loc.Warehouse, loc.Address) == null &&
                                        (loc.LocSide == 1 || loc.LocSide == 2) &&
                                        compareSize(loc.LocSize, frlct.LocSize) > 0
                                        orderby Math.Abs(frlct.LocColumn - loc.LocColumn),
                            loc.LocSide ascending
            select loc;

            List <Location> lctnLst = query.ToList();

            if (availableLst.Count == 0)
            {
                return(null);
            }
            if (availableLst.Count == 1)
            {
                CScope scope = workscope.GetEtvScope(availableLst[0]);
                foreach (Location loc in lctnLst)
                {
                    if (scope.LeftCol <= loc.LocColumn && loc.LocColumn <= scope.RightCol)
                    {
                        toLct = loc;
                        return(availableLst[0]);
                    }
                }
            }
            else
            {
                List <Device> orderbyLst = availableLst.OrderBy(d => Math.Abs(d.Region - frlct.Region)).ToList();
                foreach (Device dev in orderbyLst)
                {
                    CScope scope = workscope.GetEtvScope(dev);
                    foreach (Location loc in lctnLst)
                    {
                        if (scope.LeftCol <= loc.LocColumn && loc.LocColumn <= scope.RightCol)
                        {
                            toLct = loc;
                            return(availableLst[0]);
                        }
                    }
                }
            }
            return(null);
        }
Beispiel #12
0
        public LocStatInfo GetLocStatisInfo()
        {
            int total  = 0;
            int occupy = 0;
            int space  = 0;
            int fix    = 0;
            int bspace = 0;
            int sspace = 0;

            try
            {
                CWICCard        cwiccd   = new CWICCard();
                List <Location> locLst   = new CWLocation().FindLocList();
                List <Customer> custsLst = cwiccd.FindCustList(cu => cu.Type == EnmICCardType.FixedLocation || cu.Type == EnmICCardType.VIP);

                for (int i = 0; i < locLst.Count; i++)
                {
                    Location loc = locLst[i];
                    #region
                    if (loc.Type != EnmLocationType.Hall &&
                        loc.Type != EnmLocationType.Invalid)
                    {
                        total++;
                    }
                    bool isFixLoc = false;
                    if (custsLst.Exists(cc => cc.LocAddress == loc.Address && cc.Warehouse == loc.Warehouse))
                    {
                        fix++;
                        isFixLoc = true;
                    }
                    if (loc.Type == EnmLocationType.Normal)
                    {
                        if (loc.Status == EnmLocationStatus.Space)
                        {
                            if (!isFixLoc)
                            {
                                space++;
                                if (loc.LocSize.Length == 3)
                                {
                                    string last = loc.LocSize.Substring(2);
                                    if (last == "1")
                                    {
                                        sspace++;
                                    }
                                    else if (last == "2")
                                    {
                                        bspace++;
                                    }
                                }
                            }
                        }
                        else if (loc.Status == EnmLocationStatus.Occupy)
                        {
                            occupy++;
                        }
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                Log log = LogFactory.GetLogger("GetLocStatisInfoAsync");
                log.Error(ex.ToString());
            }
            LocStatInfo info = new LocStatInfo();
            info.Total      = total;
            info.Occupy     = occupy;
            info.Space      = space;
            info.SmallSpace = sspace;
            info.BigSpace   = bspace;
            info.FixLoc     = fix;

            return(info);
        }
Beispiel #13
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);
        }
Beispiel #14
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);
        }