Exemplo n.º 1
0
    def setUp(self):

        self.rectangle_4 = Rectangle(50, 80, 4)
        self.rectangle_5 = Rectangle(50, 80, 5)

        self.grid_1 = Grid(200, 1500, 1)
        self.grid_2 = Grid(100, 100, 2)
        self.grid_3 = Grid(100, 80, 3)
    def getUnstackedRectangles(self,
                               brand='all',
                               color='all',
                               grid_width='all',
                               for_cutting=False,
                               coupage_batch="batch"):
        if color != 'all' and brand != 'all' and grid_width != 'all':
            rectangles_dict = self.rectangles_collection.find({
                "isStacked": {
                    "$eq": False
                },
                "color":
                color,
                "coupage_batch":
                coupage_batch,
                "brand":
                brand,
                "grid_width":
                grid_width
            })
        else:
            rectangles_dict = self.rectangles_collection.find({
                "isStacked": {
                    "$eq": False
                },
                "coupage_batch":
                coupage_batch
            })

        rectangles = []
        for rectangle in rectangles_dict:
            if not for_cutting:
                rectangles.append(
                    Rectangle(width=rectangle['width'],
                              height=rectangle['height'],
                              name=rectangle['name'],
                              article_name=rectangle['article_name'],
                              material=rectangle['material'],
                              brand=rectangle['brand'],
                              color=rectangle['color'],
                              grid_width=rectangle['grid_width'],
                              client_name=rectangle['client_name'],
                              coupage_batch=rectangle["coupage_batch"]))
            elif for_cutting:
                rectangles.append(
                    Rectangle(width=rectangle['exact_width'],
                              height=rectangle['exact_height'],
                              name=rectangle['name'],
                              article_name=rectangle['article_name'],
                              material=rectangle['material'],
                              brand=rectangle['brand'],
                              color=rectangle['color'],
                              grid_width=rectangle['grid_width'],
                              client_name=rectangle['client_name'],
                              coupage_batch=rectangle["coupage_batch"]))

        return rectangles
    def getRectangles(self, grid, for_cutting=False, sort=False):
        print("Loading rectangles within grid " + str(grid.getName()) +
              " from database")

        rectangles_dict = self.rectangles_collection.find(
            {"grid_number": {
                "$eq": grid.getName()
            }})

        if sort == True:
            # sort on area: length * width
            rectangles_dict = reversed(
                sorted(rectangles_dict,
                       key=lambda k: k['exact_width'] * k['exact_height']))

        rectangles = []
        for rectangle in rectangles_dict:
            if for_cutting == True:
                rectangles.append(
                    Rectangle(rectangle['exact_width'],
                              rectangle['exact_height'],
                              rectangle['name'],
                              article_name=rectangle['article_name'],
                              material=rectangle['material'],
                              brand=rectangle['brand'],
                              color=rectangle['color'],
                              position=[
                                  rectangle['x position'],
                                  rectangle['y position']
                              ],
                              grid_number=rectangle['grid_number'],
                              is_stacked=rectangle['isStacked'],
                              client_name=rectangle['client_name'],
                              coupage_batch=rectangle["coupage_batch"]))
            else:
                rectangles.append(
                    Rectangle(rectangle['width'],
                              rectangle['height'],
                              rectangle['name'],
                              article_name=rectangle['article_name'],
                              material=rectangle['material'],
                              brand=rectangle['brand'],
                              color=rectangle['color'],
                              position=[
                                  rectangle['x position'],
                                  rectangle['y position']
                              ],
                              grid_number=rectangle['grid_number'],
                              is_stacked=rectangle['isStacked'],
                              client_name=rectangle['client_name'],
                              coupage_batch=rectangle["coupage_batch"]))
            print("Rectangle " + str(rectangle['name']) +
                  " loaded from database")
        return rectangles
Exemplo n.º 4
0
    def stackStandardRectangles(
        self, sizes=Rectangle.getStandardSizesSortedOnMostSold()):
        print("Try stacking standard rectangles")

        for size in self.standard_sizes_to_fill:
            while True:

                if not self.stackingStopped():
                    rectangle = Rectangle(
                        width=size[0],
                        height=size[1],
                        client_name="Voorraad_" + str(size[0]) + "x" +
                        str(size[1]) + "_" + str(uuid.uuid4())[-4:],
                        name="Voorraad_" + str(size[0]) + "x" + str(size[1]) +
                        "_" + str(uuid.uuid4())[-4:],
                        grid_width=self.grid.getWidth(),
                        brand=self.grid.getBrand(),
                        color=self.grid.getColor())

                    self.db_manager.addRectangle(rectangle)
                    self.setRectangle(rectangle)

                    try:
                        print("Grid height = " + str(self.grid.getHeight()))
                        self.stackOriginalOrRotatedRectangleAndUpdateDatabase()
                    except RotatedAndOriginalRectangleDoNotFitError:
                        self.db_manager.removeRectangle(rectangle)
                        break

                else:
                    break
Exemplo n.º 5
0
 def setUp(self):
     self.rectangle = Rectangle(width=50,
                                height=50,
                                name="123456",
                                brand="kokos",
                                grid_width=100)
     self.db_manager = DatabaseManager()
    def getRectangle(self, rectangle_number, for_cutting=False):
        print("Getting rectangle " + str(rectangle_number) + " from database")
        query = {"name": str(rectangle_number)}

        document = self.rectangles_collection.find_one(query)
        if not for_cutting:
            rectangle = Rectangle(
                width=document['width'],
                height=document['height'],
                name=document['name'],
                article_name=document['article_name'],
                material=document['material'],
                brand=document['brand'],
                color=document['color'],
                grid_width=document['grid_width'],
                position=[document['x position'], document['y position']],
                grid_number=document['grid_number'],
                is_stacked=document['isStacked'],
                client_name=document['client_name'],
                coupage_batch=document["coupage_batch"])
        else:
            rectangle = Rectangle(
                width=document['exact_width'],
                height=document['exact_height'],
                name=document['name'],
                article_name=document['article_name'],
                material=document['material'],
                brand=document['brand'],
                color=document['color'],
                grid_width=document['grid_width'],
                position=[document['x position'], document['y position']],
                grid_number=document['grid_number'],
                is_stacked=document['isStacked'],
                client_name=document['client_name'],
                coupage_batch=document["coupage_batch"])

        return rectangle
Exemplo n.º 7
0
    def __init__(self, data_logger=DataLogger()):
        self.db_manager = DatabaseManager()
        self.setStandardSizesToFill([])
        self.setFillOrdersWithSmallerGridWidths(False)

        self.rectangles = []
        self.is_stacking = False

        # current rectangle to stack in current grid
        self.rectangle = Rectangle()
        self.grid = Grid()
        self.setDataLogger(data_logger)

        # stacking position of current rectangle
        self.stacking_position = []

        # stacking position of current rectangle rotated
        self.stacking_position_rotated = []
Exemplo n.º 8
0
    def convertOrdersToRectangles(self, orders):
        unstacked_rectangles = []
        self.data_logger.setTotalRectanglesToStack(len(orders))

        for index, row in orders.iterrows():
            try:
                width = self.getWidth(row)
                height = self.getHeight(row)
                name = self.getName(row)
                brand = self.getBrand(row)
                coupage_batch = self.getCoupageBatch(row)
                client_name = self.getClientName(row)
                color = self.getColor(row)
                quantity = self.getQuantity(row)
                grid_width = self.getGridWidth(row)
                material = self.getMaterial(row)
                article_name = self.getArticleName(row)

                # print("Material set in excel parser: " + str(material))
                if quantity > 1:
                    for i in range(1, quantity + 1):
                        rectangle = Rectangle(width=width,
                                              height=height,
                                              name=name + '-' + str(i),
                                              article_name=article_name,
                                              material=material,
                                              brand=brand,
                                              color=color,
                                              grid_width=grid_width,
                                              quantity=quantity,
                                              client_name=client_name,
                                              coupage_batch=coupage_batch)
                        unstacked_rectangles.append(rectangle)
                else:
                    # cut rectangle in two when width and height are larger then grid width
                    if width > grid_width and height > grid_width:
                        if width > height:
                            rectangle_part1 = Rectangle(
                                width=width / 2.0,
                                height=height,
                                name=name + 'part1',
                                article_name=article_name,
                                material=material,
                                brand=brand,
                                color=color,
                                grid_width=grid_width,
                                quantity=quantity,
                                client_name=client_name + "-part1",
                                coupage_batch=coupage_batch)
                            rectangle_part2 = Rectangle(
                                width=width / 2.0,
                                height=height,
                                name=name + 'part2',
                                article_name=article_name,
                                material=material,
                                brand=brand,
                                color=color,
                                grid_width=grid_width,
                                quantity=quantity,
                                client_name=client_name + "-part2",
                                coupage_batch=coupage_batch)
                        elif height > width:
                            rectangle_part1 = Rectangle(
                                width=width,
                                height=height / 2.0,
                                name=name + 'part1',
                                article_name=article_name,
                                material=material,
                                brand=brand,
                                color=color,
                                grid_width=grid_width,
                                quantity=quantity,
                                client_name=client_name + "-part1",
                                coupage_batch=coupage_batch)
                            rectangle_part2 = Rectangle(
                                width=width,
                                height=height / 2.0,
                                name=name + 'part2',
                                article_name=article_name,
                                material=material,
                                brand=brand,
                                color=color,
                                grid_width=grid_width,
                                quantity=quantity,
                                client_name=client_name + "-part2",
                                coupage_batch=coupage_batch)

                        unstacked_rectangles.append(rectangle_part1)
                        unstacked_rectangles.append(rectangle_part2)
                    else:
                        rectangle = Rectangle(width=width,
                                              height=height,
                                              name=name,
                                              article_name=article_name,
                                              material=material,
                                              brand=brand,
                                              color=color,
                                              grid_width=grid_width,
                                              quantity=quantity,
                                              client_name=client_name,
                                              coupage_batch=coupage_batch)
                        unstacked_rectangles.append(rectangle)

            except Exception as e:
                name = self.getName(row)
                print("Something went wrong parsing order " + str(name) +
                      ": " + str(e))
                self.data_logger.addErrorData("Order " + str(name) + ": " +
                                              str(e))
                continue

        if len(unstacked_rectangles) == 0:
            raise EmptyExcelError

        return unstacked_rectangles
Exemplo n.º 9
0
 def setUp(self):
     self.rectangle_1 = Rectangle(100, 100, 1)
     self.rectangle_2 = Rectangle(200, 100, 1)
     self.rectangle_3 = Rectangle(198, 100, 1)
     self.rectangle_4 = Rectangle(100, 100, 1)