/// <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); }
/// <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); }
/// <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> /// 巷道堆垛式---要生成挪移作业时,挪移车位的查找 /// </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); }
/// <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); }