Example #1
0
        /// <summary>
        /// 找出ETV作业范围内包含的出车厅的集合
        /// </summary>
        /// <param name="eScope">etv的作业范围</param>
        /// <param name="halls">车厅集合</param>
        /// <param name="address">车位地址</param>
        /// <param name="region">车位区域</param>
        /// <returns></returns>
        private IList <CSMG> NearHallLists(CScope eScope, IList <CSMG> halls, string address, int region)
        {
            IList <CSMG> lists = new List <CSMG>();

            foreach (CSMG hall in halls)
            {
                int col = clcCommom.GetColOfAddress(hall.Address);
                if (col >= eScope.LeftCol && col <= eScope.RightCol)
                {
                    lists.Add(hall);
                }
            }
            if (lists.Count > 1)
            {
                return(SortedHallByAddress(address, region, lists));
            }
            return(lists);
        }
Example #2
0
 /// <summary>
 /// 从ETV集合中,找出作业范围包含车位地址的ETV
 /// </summary>
 /// <param name="EtvLists">ETV集合</param>
 /// <param name="dicScope">ETV的作业范围集合</param>
 /// <param name="address">要包含的地址</param>
 /// <returns></returns>
 protected int FindEtvScopeInLocation(IList <CSMG> EtvLists, Dictionary <CSMG, CScope> dicScope, string address)
 {
     try
     {
         CWSMG cwsmg = new CWSMG();
         int   col   = clcCommom.GetColOfAddress(address);
         foreach (CSMG smg in EtvLists)
         {
             if (cwsmg.CheckEtvMode(smg.ID))
             {
                 CScope scope = dicScope[smg];
                 if (col >= scope.LeftCol && col <= scope.RightCol)
                 {
                     return(smg.ID);
                 }
             }
         }
         return(0);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #3
0
 public CEquip(int lefCol, int rightCol)
 {
     PhysicWorkScope = new CScope(lefCol, rightCol);
     WorkScope       = new CScope();
     MaxWorkScope    = new CScope();
 }
Example #4
0
        /// <summary>
        /// 临时卡/定期卡 分配原则:先从ETV的作业范围找出可达车厅的ETV集合,从集合中找出与车厅区域一致的ETV
        /// 依ETV作业范围,找出适合车型的最近的车位。
        /// </summary>
        /// <param name="smgID">移动设备ID</param>
        /// <param name="CarSize">车辆外形</param>
        /// <param name="hall">当前存车车厅</param>
        /// <param name="lcts">所有车位集合</param>
        /// <param name="SMGs">所有移动设备集合</param>
        /// <returns></returns>
        public CLocation Allocate(out int smgID, string CarSize, CSMG hall, IList <CLocation> lcts, IList <CSMG> SMGs)
        {
            pHall     = hall;
            carsize   = CarSize;
            locations = lcts;
            ETVList   = SMGs; //建立ETV工作区域

            CLocation lct = null;
            CSMG      smg = null;

            smgID = 0;
            Dictionary <CSMG, CScope> workScope    = mScopeService.DicWorkScope;
            Dictionary <CSMG, CScope> maxWorkScope = mScopeService.DicMaxScope;

            #region 记录日志
            try
            {
                StringBuilder sb = new StringBuilder();
                foreach (CSMG esmg in SMGs)
                {
                    CScope workspe = workScope[esmg];
                    CScope maxspe  = maxWorkScope[esmg];
                    sb.AppendLine(string.Format("Etv" + esmg.ID + "  工作范围:" + workspe.LeftCol + "-" + workspe.RightCol + "  物理范围:" + maxspe.LeftCol + "-" + maxspe.RightCol));
                }
                new CWSException(sb.ToString(), 2);
            }
            catch
            { }
            #endregion
            //获取工作范围内能到达车厅列的ETV的集合
            IList <CSMG> workEtvList = AddressInEtvWorkScope(pHall.Region, pHall.Address, workScope);
            if (workEtvList.Count > 0)
            {
                AllocateLctAndEtv(out smg, out lct, workEtvList, workScope, false); //先找ETV,再找车位的
            }
            if (lct == null || smg == null)                                         //工作范围内没有可达的ETV,则从最大工作范围内查找
            {
                IList <CSMG> maxWorkList = AddressInEtvWorkScope(pHall.Region, pHall.Address, maxWorkScope);
                if (maxWorkList.Count > 0)
                {
                    AllocateLctAndEtv(out smg, out lct, maxWorkList, maxWorkScope, true);
                }
            }
            //如果再找不到的话,则判断当前ETV集合,找出模式为全自动的,强制分配,车位也依全库分配
            CWSMG cwsmg = new CWSMG();
            if (lct == null || smg == null)
            {
                List <CSMG> etvsList = new List <CSMG>();
                var         lastList = from ee in SMGs
                                       where cwsmg.CheckEtvMode(ee.ID) == true &&
                                       ee.Available == true
                                       orderby Math.Abs(ee.Region - hall.Region)
                                       select ee;

                etvsList.AddRange(lastList.ToList());
                foreach (CSMG se in lastList)
                {
                    CScope scope = maxWorkScope[se];
                    lct = this.AllocateLocation(scope, true);
                    if (lct != null)
                    {
                        smg = se;
                        break;
                    }
                }
            }
            if (smg != null)
            {
                smgID = smg.ID;
            }
            return(lct);
        }
Example #5
0
        /// <summary>
        /// 固定卡存车:可达进车厅的Etv集合,找出空闲的,可达车位的ETV
        /// </summary>
        /// <param name="hall"></param>
        /// <param name="etvs"></param>
        /// <returns></returns>
        public int AllocateEtv(CSMG hall, CLocation toLct, IList <CSMG> etvs)
        {
            int etvID  = 0;
            int lctCol = clcCommom.GetColOfAddress(toLct.Address);

            ETVList = etvs;
            Dictionary <CSMG, CScope> workScope = mScopeService.DicWorkScope;

            IList <CSMG> workETVList = AddressInEtvWorkScope(hall.Region, hall.Address, workScope);

            if (workETVList.Count > 0)
            {
                IList <CSMG> freeEtvList = FreeDeviceListOfWorkScope(workETVList);
                if (freeEtvList.Count == 0)
                {
                    //无空闲ETV,则从工作范围内找出离车厅最近且可达车位的ETV
                    etvID = FindEtvScopeInLocation(workETVList, workScope, toLct.Address);
                }
                else if (freeEtvList.Count == 1)
                {
                    CSMG   etv   = freeEtvList[0];
                    CScope scope = mScopeService.DicWorkScope[etv];
                    if (scope.LeftCol <= lctCol && scope.RightCol >= lctCol)
                    {
                        etvID = etv.ID;
                    }
                    else
                    {
                        etvID = FindEtvScopeInLocation(workETVList, workScope, toLct.Address);
                    }
                }
                else
                {
                    foreach (CSMG smg in freeEtvList)
                    {
                        CScope scope = mScopeService.DicWorkScope[smg];
                        if (scope.LeftCol <= lctCol && scope.RightCol >= lctCol)
                        {
                            etvID = smg.ID;
                            break;
                        }
                    }
                }
            }

            //如果工作范围内找不出可达车位的ETV,则从物理范围内找出可达的
            if (etvID == 0)
            {
                Dictionary <CSMG, CScope> maxWorkScope = mScopeService.DicMaxScope;
                IList <CSMG> maxWorkEtvList            = AddressInEtvWorkScope(hall.Region, hall.Address, maxWorkScope); //找出能到达车厅的
                if (maxWorkEtvList.Count > 0)
                {
                    etvID = FindEtvScopeInLocation(maxWorkEtvList, maxWorkScope, toLct.Address); //找出能到达车位的
                }
            }

            //找出模式为全自动的,强制分配
            if (etvID == 0)
            {
                CWSMG       cwsmg    = new CWSMG();
                List <CSMG> etvsList = new List <CSMG>();
                var         lastList = from ee in etvs
                                       where cwsmg.CheckEtvMode(ee.ID) == true
                                       orderby Math.Abs(ee.Region - hall.Region)
                                       select ee;

                etvsList.AddRange(lastList.ToList());
                if (etvsList.Count > 1)
                {
                    etvID = etvsList[0].ID;
                }
            }
            return(etvID);
        }
Example #6
0
        /// <summary>
        /// 依ETV作业区域找出区域内最近的车位
        /// </summary>
        /// <param name="scope">当前ETV作业区域</param>
        /// <returns></returns>
        private CLocation AllocateLocation(CScope scope, bool isMax)
        {
            int hallCol = clcCommom.GetColOfAddress(pHall.Address);
            List <CLocation> locationList = new List <CLocation>();
            //同区域低车
            var lcta = from lct in locations
                       where lct.Type == CLocation.EnmLocationType.Normal &&
                       (lct.List >= scope.LeftCol && lct.List <= scope.RightCol) &&
                       lct.Status == CLocation.EnmLocationStatus.Space &&
                       lct.Region == pHall.Region &&
                       string.Compare(lct.Size, carsize) == 0
                       orderby lct.Index ascending
                       select lct;

            locationList.AddRange(lcta);
            //不同区域低车
            var lctb = from lct in locations
                       where lct.Type == CLocation.EnmLocationType.Normal &&
                       (lct.List >= scope.LeftCol && lct.List <= scope.RightCol) &&
                       lct.Status == CLocation.EnmLocationStatus.Space &&
                       lct.Region != pHall.Region &&
                       string.Compare(lct.Size, carsize) == 0
                       orderby Math.Abs(hallCol - lct.List), lct.Index ascending
            select lct;

            locationList.AddRange(lctb);

            if (isMax)
            {
                //同区域高车
                var lctc = from lct in locations
                           where lct.Type == CLocation.EnmLocationType.Normal &&
                           (lct.List >= scope.LeftCol && lct.List <= scope.RightCol) &&
                           lct.Status == CLocation.EnmLocationStatus.Space &&
                           lct.Region == pHall.Region &&
                           string.Compare(lct.Size, carsize) > 0
                           orderby lct.Index ascending
                           select lct;
                locationList.AddRange(lctc);
                //不同区域高车
                var lctd = from lct in locations
                           where lct.Type == CLocation.EnmLocationType.Normal &&
                           (lct.List >= scope.LeftCol && lct.List <= scope.RightCol) &&
                           lct.Status == CLocation.EnmLocationStatus.Space &&
                           lct.Region != pHall.Region &&
                           string.Compare(lct.Size, carsize) > 0
                           orderby Math.Abs(hallCol - lct.List), lct.Index ascending
                select lct;

                locationList.AddRange(lctd);
            }
            //取第一个车位
            if (locationList.Count > 0)
            {
                foreach (CLocation cltn in locationList)
                {
                    if (cltn.Status == CLocation.EnmLocationStatus.Space && cltn.Type == CLocation.EnmLocationType.Normal)
                    {
                        if (new CWICCard().FindFixICCard(cltn.Address) == null && cltn.ICCardCode == "")
                        {
                            return(cltn);
                        }
                    }
                }
            }
            return(null);
        }
Example #7
0
 public EtvMaxScope(CSMG pEtv, IList <CSMG> pEtvList, CScope physicScope)
 {
     cETV             = pEtv;
     etvList          = pEtvList;
     mPhysicWorkScope = physicScope;
 }
Example #8
0
        /// <summary>
        /// 厅外刷卡取车:先从ETV工作范围内找出可达车位的ETV集合(依工作区域大小排序),再找出空闲的ETV集合
        /// 先从空闲ETV集合中找出可达出车厅的ETV,如果找不到,再从工作范围内找出车位的ETV集合找出可达出车厅的ETV
        /// 再找不到的,则从最大作业范围内找出可达车位的ETV集合,再从中找出可达车厅的且是可用的ETV
        /// </summary>
        public int AllocateEtv(CLocation lct, string hall_Address, IList <CSMG> Etvs)
        {
            int eID     = 0;
            int hallCol = clcCommom.GetColOfAddress(hall_Address);

            ETVList = Etvs;
            Dictionary <CSMG, CScope> workScope    = mScopeService.DicWorkScope;
            Dictionary <CSMG, CScope> maxWorkScope = mScopeService.DicMaxScope;

            #region 记录日志
            try
            {
                StringBuilder sb = new StringBuilder();
                foreach (CSMG esmg in Etvs)
                {
                    CScope workspe = workScope[esmg];
                    CScope maxspe  = maxWorkScope[esmg];
                    sb.AppendLine(string.Format("Etv" + esmg.ID + "  工作范围:" + workspe.LeftCol + "-" + workspe.RightCol + "  物理范围:" + maxspe.LeftCol + "-" + maxspe.RightCol));
                }
                new CWSException(sb.ToString(), 2);
            }
            catch
            { }
            #endregion

            //找出工作范围内可达车位的ETV集合
            IList <CSMG> EtvWorkList = AddressInEtvWorkScope(lct.Region, lct.Address, workScope);
            if (EtvWorkList.Count > 0)
            {
                IList <CSMG> FreeEtvList = FreeDeviceListOfWorkScope(EtvWorkList);
                if (FreeEtvList.Count == 0)
                {
                    //无空闲的ETV,从工作范围可达车位的ETV集合中找出可达出车厅的ETV
                    eID = FindEtvScopeInLocation(EtvWorkList, workScope, hall_Address);
                }
                else if (FreeEtvList.Count == 1)
                {
                    CSMG   etv   = FreeEtvList[0];
                    CScope scope = workScope[etv];
                    if (hallCol >= scope.LeftCol && hallCol <= scope.RightCol)
                    {
                        eID = etv.ID;
                    }
                    else
                    {
                        eID = FindEtvScopeInLocation(EtvWorkList, workScope, hall_Address);
                    }
                }
                else
                {
                    foreach (CSMG smg in FreeEtvList)
                    {
                        CScope scope = workScope[smg];
                        if (hallCol >= scope.LeftCol && hallCol <= scope.RightCol)
                        {
                            eID = smg.ID;
                            break;
                        }
                    }
                }
            }

            //如果从工作范围内找不到可达出车厅的ETV,则从物理作业范围内找出可用的ETV
            if (eID == 0)
            {
                IList <CSMG> maxWorkEtvList = AddressInEtvWorkScope(lct.Region, lct.Address, maxWorkScope); //到达车位
                if (maxWorkEtvList.Count > 0)
                {
                    eID = FindEtvScopeInLocation(maxWorkEtvList, maxWorkScope, hall_Address); //到达车厅
                }
            }

            //找出模式为全自动的,强制分配
            if (eID == 0)
            {
                CWSMG       cwsmg    = new CWSMG();
                List <CSMG> etvsList = new List <CSMG>();
                var         lastList = from ee in Etvs
                                       where cwsmg.CheckEtvMode(ee.ID) == true
                                       orderby Math.Abs(ee.Region - lct.Region)
                                       select ee;

                etvsList.AddRange(lastList.ToList());
                if (etvsList.Count > 1)
                {
                    eID = etvsList[0].ID;
                }
            }
            return(eID);
        }
Example #9
0
        /// <summary>
        /// 缴费出车:依作业范围内找出可达车位的ETV集合1,找出空闲的ETV集合2,
        /// 依集合2找出最近的ETV,如果找不到,查找集合2,
        /// 后依ETV可达的作业范围找出距离车位最近的出车厅,如果找不到,则依ETV的物理范围找出
        /// 距离最近的车厅
        /// </summary>
        public void AllocateEtvAndHall(IList <CSMG> Etvs, IList <CSMG> Halls, CLocation lct, out CSMG Etv, out CSMG Hall)
        {
            Etv     = null;
            Hall    = null;
            ETVList = Etvs;
            Dictionary <CSMG, CScope> dicWork    = mScopeService.DicWorkScope;
            Dictionary <CSMG, CScope> dicMaxWork = mScopeService.DicMaxScope;

            #region 记录日志
            try
            {
                StringBuilder sb = new StringBuilder();
                foreach (CSMG esmg in Etvs)
                {
                    CScope workspe = dicWork[esmg];
                    CScope maxspe  = dicMaxWork[esmg];
                    sb.AppendLine(string.Format("Etv" + esmg.ID + "  工作范围:" + workspe.LeftCol + "-" + workspe.RightCol + "  物理范围:" + maxspe.LeftCol + "-" + maxspe.RightCol));
                }
                new CWSException(sb.ToString(), 2);
            }
            catch
            { }
            #endregion

            IList <CSMG> EtvWorkList = AddressInEtvWorkScope(lct.Region, lct.Address, dicWork);
            if (EtvWorkList.Count > 0)
            {
                IList <CSMG> freeWorkList = FreeDeviceListOfWorkScope(EtvWorkList);
                if (freeWorkList.Count == 0)
                {
                    Etv = NearestEtvToAddress(lct.Address, EtvWorkList, lct.Region);
                }
                else if (freeWorkList.Count == 1)
                {
                    Etv = freeWorkList[0];
                }
                else //从空闲ETV集合中查找
                {
                    Etv = NearestEtvToAddress(lct.Address, freeWorkList, lct.Region);
                }
            }
            else   //从最大作业范围内找出
            {
                IList <CSMG> maxWorkList = AddressInEtvWorkScope(lct.Region, lct.Address, dicMaxWork);
                foreach (CSMG allocateEtv in maxWorkList)
                {
                    if (new CWSMG().CheckEtvMode(allocateEtv.ID))
                    {
                        Etv = allocateEtv;
                        break;
                    }
                }
            }
            //找好ETV后,找出合适的车厅
            if (Etv != null)
            {
                CScope scope = dicWork[Etv];
                //先分配在此区域内的车厅,如果两个车厅都不可达,才能考虑跨区分配
                IList <CSMG> availHalls = NearHallLists(scope, Halls, lct.Address, lct.Region);
                if (availHalls.Count > 0)
                {
                    IList <CSMG> freeHalls = new List <CSMG>();
                    foreach (CSMG hall in availHalls)
                    {
                        if (hall.nIsWorking == 0)
                        {
                            freeHalls.Add(hall);
                        }
                    }
                    if (freeHalls.Count > 0)
                    {
                        Hall = freeHalls[0];
                    }
                    else
                    {
                        Hall = availHalls[0];
                    }
                }
                //ETV工作范围内不包含可用的出车厅,则从物理范围内查找
                if (Hall == null)
                {
                    CScope       mScope   = dicMaxWork[Etv];
                    IList <CSMG> maxHalls = NearHallLists(mScope, Halls, lct.Address, lct.Region);
                    if (maxHalls.Count > 0)
                    {
                        Hall = maxHalls[0];
                    }
                }
            }
        }