Пример #1
0
        private List<VerticalBlock> AddExtraBlock(RowBlock rBlock, List<VerticalBlock> vBlocks)
        {
            int length = rBlock.MaxLength - rBlock.Length;

            List<VerticalBlock> extraBlocks =
                vBlocks.Where(
                    v => (v.Length <= length & v.Width <= rBlock.Width) | (v.Length <= rBlock.Width & v.Width <= length))
                    .OrderByDescending(v => v.RealVolume)
                    .ToList();
            List<VerticalBlock> tempBlocks =
                vBlocks.Where(
                    v =>
                        ((v.Length <= length & v.Width <= rBlock.Width) | (v.Length <= rBlock.Width & v.Width <= length)) ==
                        false).ToList();
            if (extraBlocks.Count() + tempBlocks.Count() != vBlocks.Count())
            {
                MessageBox.Show("Ошибка при фильтрации блоков. AddExtraBlock");
            }
            if (extraBlocks.Any())
            {
                VerticalBlock extraBlock = extraBlocks[0];
                //MessageBox.Show("Подобрано дополнительных блоков: " + extraBlocks.Count().ToString());
                if (extraBlock.Length > (rBlock.MaxLength - rBlock.Length) | extraBlock.Width > rBlock.Width)
                {
                    extraBlock.RotateH();
                }

                rBlock.Add(extraBlock, vehicle.Width);

                tempBlocks.AddRange(extraBlocks.Where(v => v != extraBlock));
            }
            return tempBlocks;
        }
Пример #2
0
 private void CreateRows(List<VerticalBlock> vBlocks, int sameWidth, List<RowBlock> rBlocks)
 {
     List<VerticalBlock> sameBlock =
         vBlocks.Where(s => s.IsSuitableWidth(sameWidth)).OrderByDescending(s => s.Width).ToList();
     while (sameBlock.Any())
     {
         List<VerticalBlock> tempBlocks = new List<VerticalBlock>();
         RowBlock rBlock = new RowBlock();
         foreach (VerticalBlock s in sameBlock)
         {
             VerticalBlock tempS;
             if (s.Length <= sameWidth & s.Length > sameWidth - 100) //если нужно, то поворачиваем блок
             {
                 tempS = s.Clone() as VerticalBlock;
                 tempS.RotateH();
             }
             else
             {
                 tempS = s;
             }
             if (tempS.Length > vehicle.Width)
             {
                 /*пропускаем блок т.к. он не подходит по ширине и длине*/
             }
             else if (rBlock.Add(tempS, vehicle.Width) == false)
             {
                 tempBlocks.Add(tempS);
             }
         }
         if (rBlock.Count > 0)
         {
             rBlocks.Add(rBlock);
         }
         sameBlock = tempBlocks.ToList();
     }
 }
Пример #3
0
        private void AddCabinToRow(Container c)
        {
            VerticalBlock vBlock = new VerticalBlock();
            if (vBlock.Add(c, 10000) == false)
            {
                MessageBox.Show("Ошибка добавления кабины в вертикальный блок.Сообщите администратору");
                return;
            }
            //добавляем вертикальный ряд в горизонтальный ряд
            RowBlock rBlock = new RowBlock();
            rBlock.Add(vBlock, vehicle.MaxLength);

            if (vehicle.MaxLength >= rBlock.Width & vehicle.Tonnage >= rBlock.Mass + vehicle.Mass)
            {
                AddRowToVehicle(rBlock);
            }
            else
            {
                //помещаем кабину в список невместившихся контейнеров
                wasteList.Add(c);
            }
        }
Пример #4
0
        private List<Container> ProcessingChassis(List<Container> tempList, int maxTonnage)
        {
            List<Container> tempRama =
                tempList.Where(s => s.Length > 1500 & s.Width > 6000).OrderBy(s => s.Width).ToList();
            tempList = tempList.Where(s => s.Length <= 1500 | s.Width <= 6000).ToList();
            if (!tempRama.Any())
            {
                return tempList;
            }
            HorizontalBlock hBlock = new HorizontalBlock();
            hBlock.RowCount = 2;
            hBlock.Width = tempRama[0].Width + 800;
            hBlock.Length = 2400;
            //добавляем в подушку ящики размеров 1200х800х800
            List<Container> temp500 = tempList.Where(s => s.Length == 1200 & s.Width == 800 & s.Height == 800).ToList();
            if (temp500.Count() >= 6)
            {
                tempList = tempList.Where(s => s.Length != 1200 | s.Width != 800 | s.Height != 800).ToList();
                foreach (Container c in temp500)
                {
                    if (hBlock.Add(c))
                    {
                        /*продолжаем*/
                    }
                    else
                    {
                        tempList.Add(c);
                    }
                }
            }
            //добавляем в подушку ящики размеров 1100х800х720
            temp500 = tempList.Where(s => s.Length == 1100 & s.Width == 800 & s.Height == 720).ToList();

            if (NotEmpty() | temp500.Count() >= 6)
            {
                tempList = tempList.Where(s => s.Length != 1100 | s.Width != 800 | s.Height != 720).ToList();
                foreach (Container c in temp500)
                {
                    if (!hBlock.Add(c))
                    {
                        tempList.Add(c);
                    }
                }
            }

            VerticalBlock vBlock = new VerticalBlock();
            if (hBlock.NotEmpty() & (vehicle.Mass + hBlock.Mass) <= maxTonnage)
            {
                vBlock.Add(hBlock, vehicle.Height - 250);
            }
            else
            {
                hBlock.ToContainerList(tempList);
            }

            foreach (Container r in tempRama)
            {
                if ((vehicle.Mass + r.Mass) <= maxTonnage)
                {
                    if (vBlock.Add(r, vehicle.Height - 350) == false)
                    {
                        MessageBox.Show("не удалось добавить раму в вертикальный блок.Сообщите администратору");
                        tempList.Add(r);
                    }
                }
            }
            RowBlock rBlock = new RowBlock();
            rBlock.Add(vBlock, vehicle.Width);
            AddRowToVehicle(rBlock);
            return tempList;
        }