コード例 #1
0
ファイル: test_clock_client.py プロジェクト: wiz21b/koi
    def test_employee_in_and_out(self):

        self._scan(BarCodeIdentifier.code_for(TaskActionReportType.day_out))
        self.assertEqual( ClockErrors.identify_first.value,
                          self.mem_logger.last_error().code)

        # Employee badge

        employee = dao.employee_dao.find_by_id(self.employee_id)
        bc_employee = BarCodeIdentifier.code_for(employee)
        self._scan(bc_employee)
        assert not self.mem_logger.last_error()

        self._scan(BarCodeIdentifier.code_for(TaskActionReportType.day_in))

        assert self._on_screen( MainWindow.PresenceActionScreen)

        sleep(3)

        self._scan(bc_employee)

        assert self._on_screen( MainWindow.UserInformationScreen)


        self._scan(BarCodeIdentifier.code_for(TaskActionReportType.day_out))

        assert self._on_screen( MainWindow.PresenceActionScreen)

        self._scan(bc_employee)

        assert self._on_screen( MainWindow.UserInformationScreen)

        self.assertEqual(1, session().query(TimeTrack).join(Task).join(TaskForPresence).count())
コード例 #2
0
ファイル: test_clock_client.py プロジェクト: wiz21b/koi
    def test_two_operations_without_machine(self):
        order = self._make_order()
        dao.order_dao.change_order_state(order.order_id, OrderStatusType.order_ready_for_production)
        operation = order.parts[0].operations[0]

        operation2 = self._operation_dao.make()
        operation2.production_file_id = order.parts[0].production_file[0].production_file_id
        operation2.description = u"lorem ipsum dolor amet lorem ipsum dolor amet sic transit gloria mundi" + chr(233)
        operation2.operation_model = self.opdef_op
        session().add(operation2)
        session().commit()

        employee = dao.employee_dao.find_by_id(self.employee_id)
        bc_employee = BarCodeIdentifier.code_for(employee)
        self._scan(bc_employee)

        bc_operation = BarCodeIdentifier.code_for(operation)
        self._scan(bc_operation)
        self.assertEqual(1, session().query(TaskActionReport).filter(TaskActionReport.kind == TaskActionReportType.start_task).count())

        bc_operation2 = BarCodeIdentifier.code_for(operation2)
        self._scan(bc_operation2)
        self.assertEqual(2, session().query(TaskActionReport).filter(TaskActionReport.kind == TaskActionReportType.start_task).count())

        self._scan(bc_employee)
        self._scan(bc_employee)

        self._scan(bc_operation)
        self.assertEqual(1, session().query(TaskActionReport).filter(TaskActionReport.kind == TaskActionReportType.stop_task).count())

        self._scan(bc_operation2)
        self.assertEqual(2, session().query(TaskActionReport).filter(TaskActionReport.kind == TaskActionReportType.stop_task).count())
コード例 #3
0
ファイル: test_clock_client.py プロジェクト: wiz21b/koi
    def test_operation_with_machine(self):
        order = self._make_order()
        dao.order_dao.change_order_state(order.order_id, OrderStatusType.order_ready_for_production)
        operation = order.parts[0].operations[0]

        machine = self._make_machine("Jones & shipman 1307 zala yop", operation.operation_definition_id)

        app = self.app
        self.window.setFocus(Qt.OtherFocusReason)

        # Employee badge

        employee = dao.employee_dao.find_by_id(self.employee_id)
        bc_employee = BarCodeIdentifier.code_for(employee)
        self._scan(bc_employee)
        assert not self.mem_logger.last_error()

        # Operation selection

        bc_operation = BarCodeIdentifier.code_for(operation)
        self._scan(bc_operation)


        # The operation is tied to a machine => machine selection

        bc_machine = BarCodeIdentifier.code_for(machine)
        self._scan(bc_machine)


        # self._scan(bc_employee)
        # self._scan(bc_employee)


        # The task is started

        self.assertEqual(1, session().query(TaskActionReport).filter(TaskActionReport.kind == TaskActionReportType.start_task).count())
        session().commit()


        # Now we start the scenario over to stop the task

        # self._scan(bc_employee)
        self._scan(bc_operation)
        # self.app.exec_()

        self._scan(bc_machine)

        self.assertEqual(1, session().query(TaskActionReport).filter(TaskActionReport.kind == TaskActionReportType.stop_task).count())
        session().commit()
コード例 #4
0
ファイル: test_clock_client.py プロジェクト: wiz21b/koi
    def test_order(self):
        order = self._order_dao.make("Test order",self.customer)
        order.state = OrderStatusType.order_ready_for_production
        self._order_dao.save(order)
        bc_order = BarCodeIdentifier.code_for(order,self.opdef_order)
        session().close()

        app = self.app
        self.window.setFocus(Qt.OtherFocusReason)

        employee = dao.employee_dao.find_by_id(self.employee_id)
        bc = BarCodeIdentifier.code_for(employee)
        self._scan(bc)

        self._scan(bc_order)
コード例 #5
0
ファイル: test_clock_client.py プロジェクト: wiz21b/koi
    def test_employee_out(self):

        self._scan(BarCodeIdentifier.code_for(TaskActionReportType.day_out))
        self.assertEqual( ClockErrors.identify_first.value,
                          self.mem_logger.last_error().code)

        # Employee badge

        employee = dao.employee_dao.find_by_id(self.employee_id)
        bc_employee = BarCodeIdentifier.code_for(employee)
        self._scan(bc_employee)
        assert not self.mem_logger.last_error()

        self._scan(BarCodeIdentifier.code_for(TaskActionReportType.day_out))



        assert self._on_screen( MainWindow.PresenceActionScreen)

        self._scan(bc_employee)

        assert self._on_screen( MainWindow.UserInformationScreen)

        # See if employee out cuts the current activities

        order = self._make_order()
        dao.order_dao.change_order_state(order.order_id, OrderStatusType.order_ready_for_production)
        operation = order.parts[0].operations[0]

        bc_operation = BarCodeIdentifier.code_for(operation)
        self._scan(bc_operation)


        # Scan out...
        self._scan(bc_employee)
        self.app.processEvents()
        sleep(3) # Need this so that the interval is big enough (if too small it will be ignored)
        self.app.processEvents()
        self._scan(BarCodeIdentifier.code_for(TaskActionReportType.day_out))


        # session().query(TaskOnOperation).filter(TaskOnOperation.operation_id == operation.operation_id)

        mainlog.debug("Operation id = {}".format(operation.operation_id))
        self.show_timetracking()

        self.assertEqual(1, session().query(TimeTrack).join(Task).join(TaskOnOperation).filter(TaskOnOperation.operation_id == operation.operation_id).count())
コード例 #6
0
ファイル: rlab.py プロジェクト: wiz21b/koi
def print_employees_badges(dao):
    global header_text
    global sub_header_text

    header_text = ""
    sub_header_text = _("Employees badges")
    s = ParagraphStyle(name="zou", fontName='Helvetica', alignment=TA_CENTER)

    badges_per_line = 3
    array = []
    row = []

    employees = dao.employee_dao.all()

    if len(employees) == 0:
        return

    i = 0
    for employee in employees:
        row.append([
            Paragraph(employee.fullname, s),
            platypus.Spacer(0, 0.25 * cm),
            createBarcodeDrawing('EAN13',
                                 value=str(
                                     BarCodeIdentifier.code_for(employee)),
                                 barHeight=1 * cm)
        ])
        i = i + 1
        if i == badges_per_line:
            array.append(row)
            row = []
            i = 0
    if i > 0:
        array.append(row)

    t = platypus.Table(array,
                       repeatRows=0,
                       colWidths=[6 * cm] * badges_per_line,
                       rowHeights=[3 * cm] *
                       len(array))  # Repeat the table header

    ts = platypus.TableStyle([('FONT', (0, 0), (-1, -1), 'Helvetica', 8)])
    ts.add('ALIGN', (0, 0), (-1, -1), 'CENTER')
    ts.add('VALIGN', (0, 0), (-1, -1), 'MIDDLE')

    ts.add("LEFTPADDING", (0, 0), (-1, -1), 0)
    ts.add("RIGHTPADDING", (0, 0), (-1, -1), 0)
    ts.add('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black)
    ts.add('BOX', (0, 0), (-1, -1), 0.25, colors.black)

    t.setStyle(ts)
    complete_document = []
    complete_document.append(t)

    filename = make_pdf_filename("EmployeeBadges")
    ladderDoc = start_PDF(filename)
    ladderDoc.build(complete_document, canvasmaker=NumberedCanvas)
    open_pdf(filename)
コード例 #7
0
ファイル: test_clock_client.py プロジェクト: wiz21b/koi
    def test_employee_select(self):
        app = self.app
        self.window.setFocus(Qt.OtherFocusReason)

        employee = dao.employee_dao.find_by_id(self.employee_id)
        bc = BarCodeIdentifier.code_for(employee)

        self._scan(bc)
        assert not self.mem_logger.last_error()
コード例 #8
0
ファイル: test_clock_client.py プロジェクト: wiz21b/koi
    def test_bad_bar_codes_unbillable(self):

        employee = dao.employee_dao.find_by_id(self.employee_id)
        bc_employee = BarCodeIdentifier.code_for(employee)
        self._scan(bc_employee)

        #### Unbillable operation bad badge

        bad_unbillable = OperationDefinition()
        bad_unbillable.operation_definition_id = 999
        bad_unbillable.imputable = True
        bad_unbillable.on_order = False
        bad_unbillable.on_operation = False

        bc_unbillable = BarCodeIdentifier.code_for(bad_unbillable)


        self._scan(bc_unbillable)
        assert self.mem_logger.last_error().code == ServerErrors.operation_definition_unknown.value
コード例 #9
0
ファイル: test_clock_client.py プロジェクト: wiz21b/koi
    def test_unbillable(self):

        nonbillable_op = self._operation_definition_dao.find_by_id(self.nonbillable_op_id)
        bc_unbillable = BarCodeIdentifier.code_for(nonbillable_op)

        employee = dao.employee_dao.find_by_id(self.employee_id)
        bc_employee = BarCodeIdentifier.code_for(employee)

        # Starting the work

        self._scan(bc_employee)
        self._scan(bc_unbillable)

        assert self._on_screen( MainWindow.UnbillableOperationStartedScreen)

        sleep(3) # Need this so that the interval is big enough (if too small it will be ignored)

        # Finishing the work

        self._scan(bc_employee)
        self._scan(bc_unbillable)

        assert self._on_screen( MainWindow.UnbillableOperationFinishedScreen)
コード例 #10
0
ファイル: test_clock_client.py プロジェクト: wiz21b/koi
    def test_inactive_unbillable(self):

        employee = dao.employee_dao.find_by_id(self.employee_id)
        bc_employee = BarCodeIdentifier.code_for(employee)
        self._scan(bc_employee)


        bad_unbillable = OperationDefinition()
        bad_unbillable.short_id = "ZZ"
        bad_unbillable.description = "Zulu"
        bad_unbillable.imputable = False
        bad_unbillable.on_order = False
        bad_unbillable.on_operation = False
        period = OperationDefinitionPeriod()
        period.start_date, period.end_date = date(2010,1,1), None
        bad_unbillable.periods.append(period)

        self._operation_definition_dao.save(bad_unbillable)

        bc_unbillable = BarCodeIdentifier.code_for(bad_unbillable)
        self._scan(bc_unbillable)

        assert self._on_screen( MainWindow.UserInformationScreen)
コード例 #11
0
ファイル: test_integration.py プロジェクト: wiz21b/koi
    def test_create_order_and_report_on_order(self):

        # python test_integration.py TestEditOrderParts.test_create_order_and_report_on_order

        app = self.app
        widget = self.widget
        mw = self.mw
        clock_server = ClockServer(dao)

        self._make_basic_preorder()
        app.processEvents()

        widget._set_state(OrderStatusType.order_ready_for_production)
        self.prepare_to_click_dialog("confirm_estimate_sent")

        # Save
        QTest.keyEvent(QTest.Click, app.focusWidget(), Qt.Key_S,
                       Qt.ControlModifier)  # modifier, delay
        app.processEvents()
        app.processEvents()
        app.processEvents()

        self.assertTrue(widget._current_order.order_id > 0)

        order = dao.order_dao.find_by_id(widget._current_order.order_id)
        bc = BarCodeIdentifier.code_for(order, self.opdef_order)

        employee_id = dao.employee_dao.any().employee_id
        d1 = datetime(2013, 0o5, 26, 8)
        # clock_server.recordPointage(bc,employee_id, datetime.strftime(d1, "%Y%m%dT%H:%M:%S"),"Nostromo")
        d2 = datetime(2013, 0o5, 26, 10, 54)
        # clock_server.recordPointage(bc,employee_id, datetime.strftime(d2, "%Y%m%dT%H:%M:%S"),"Nostromo")

        self.server = JsonCallWrapper(ClockService(),
                                      JsonCallWrapper.IN_PROCESS_MODE)
        self.server.record_pointage_on_order(
            order.order_id, self.opdef_order.operation_definition_id,
            employee_id, d1, "nostromo", TaskActionReportType.start_task, None)

        self.server.record_pointage_on_order(
            order.order_id, self.opdef_order.operation_definition_id,
            employee_id, d2, "nostromo", TaskActionReportType.stop_task, None)

        order = dao.order_dao.find_by_id(widget._current_order.order_id)

        widget.edit_new_order(
            self.customer.customer_id)  # Force the order reset below
        app.processEvents()
        widget.reset_order(order.order_id, overwrite=True)
        app.processEvents()
コード例 #12
0
ファイル: order_report.py プロジェクト: wiz21b/koi
def make_operation_boxes(operation_ndx, op, opNumberStyle):
    s = ParagraphStyle(name = "zou", fontName = 'Helvetica', fontSize=12) #, borderWidth=1, borderColor=colors.black)
    centered = ParagraphStyle(name = "zou", fontName = 'Helvetica-bold', fontSize=14) #, borderWidth=1, borderColor=colors.black) alignment=TA_CENTER,

    operation_number = Paragraph("{}".format(operation_ndx), opNumberStyle)

    if op.operation_model and op.operation_model.description:
        model = Paragraph(op.operation_model.short_id,centered) # short_id / description
    else:
        model = None

    if op.operation_model and op.operation_model.imputable:
        code = BarCodeIdentifier.code_for(op)
        # humanReadable : remove the numbers under the barcode
        barcode = createBarcodeDrawing('EAN13',value=str(code),width=4*cm,barHeight=1*cm,humanReadable=False)
        mainlog.debug("Barcode for {} is {}".format(op, code))
        #graphic = GraphicalAnnotation(code,1*cm)
    else:
        barcode = None
        graphic = None

    full_desc = ""
    if op.description:
        # full_desc = u"<b>{}</b>".format(crlf_to_br(op.description))
        assignee = ''
        if op.assignee:
            assignee = op.assignee.fullname
        full_desc = u"<b>{}</b><br/>{}".format(escape_html(op.description), escape_html(assignee))
    else:
        full_desc = "---"

    data_ops = [[operation_number,
                 barcode,
                 model,
                 Paragraph(full_desc,s)]]
    t = platypus.Table(data_ops, repeatRows=0, colWidths=compute_strut( [1.5*cm, 4.5*cm, 1.5*cm, None], 19.5*cm) )
    ts = platypus.TableStyle()

    # ts.add('LINEABOVE', (0, len(data_ops)-1), (-1, len(data_ops)-1), 0.5, colors.black)
    ts.add('GRID',(0,0),(-1,-1),0.5,colors.black)
    ts.add('LINEBEFORE', (0, 0), (0, -1), 1, colors.black)
    ts.add('LINEAFTER', (-1, 0), (-1, -1), 1, colors.black)
    ts.add('LINEABOVE', (0, 0), (-1, 0), 1, colors.black)
    ts.add('LINEBELOW', (0, 0), (-1, 0), 0, colors.white)
    ts.add('VALIGN', (2, 0), (-1, -1), 'TOP')
    t.setStyle(ts)

    return t
コード例 #13
0
ファイル: test_clock_client.py プロジェクト: wiz21b/koi
    def test_bad_bar_codes(self):
        order = self._make_order()
        dao.order_dao.change_order_state(order.order_id, OrderStatusType.order_ready_for_production)
        operation = order.parts[0].operations[0]
        machine = self._make_machine("Test1", operation.operation_definition_id)
        employee = dao.employee_dao.find_by_id(self.employee_id)


        app = self.app
        self.window.setFocus(Qt.OtherFocusReason)

        #### Employee bad badge

        bad_employee = Employee()
        bad_employee.employee_id = 999
        bc_employee = BarCodeIdentifier.code_for(bad_employee)
        self._scan(bc_employee)

        assert self.mem_logger.last_error().code == ServerErrors.unknown_employee_id.value


        #### Operation bad badge

        employee = dao.employee_dao.find_by_id(self.employee_id)
        bc_employee = BarCodeIdentifier.code_for(employee)
        self._scan(bc_employee)

        # Operation selection

        bad_operation = Operation()
        bad_operation.operation_id = 9999
        bc_operation = BarCodeIdentifier.code_for(bad_operation)
        self._scan(bc_operation)

        assert self.mem_logger.last_error().code == ServerErrors.operation_unknown.value

        # Try again, with the good one
        bc_operation = BarCodeIdentifier.code_for(operation)
        self._scan(bc_operation)


        #### Machine bad badge

        bad_machine = Machine()
        bad_machine.resource_id = 999
        bc_machine = BarCodeIdentifier.code_for(bad_machine)
        self._scan(bc_machine)

        assert self.mem_logger.last_error().code == ServerErrors.unknown_machine.value

        # Try again
        bc_machine = BarCodeIdentifier.code_for(machine)
        self._scan(bc_machine)

        assert self._on_screen( MainWindow.OperationStartedScreen)
コード例 #14
0
ファイル: server.py プロジェクト: wiz21b/koi
    def getTaskInformation(self, task_id):
        try:
            mainlog.debug("getTaskInformation, task id = {}".format(task_id))

            data = BarCodeIdentifier.barcode_to_id(task_id)

            if data[0] == Operation:
                operation_id = data[1]
                t = self.dao.task_dao.task_for_operation(operation_id)
            else:
                e = "Can't get that object, I don't recognize it"
                raise xmlrpclib.Fault(1000, e)

            return rpctools.sqla_to_hash(t)

        except Exception as e:
            mainlog.exception(e)
            e = "Task {} not found".format(task_id)
            mainlog.error(e)
            raise xmlrpclib.Fault(1000, e)
コード例 #15
0
    def _barcodeToTask(self, barcode, additional_data):
        data = None
        try:
            data = BarCodeIdentifier.barcode_to_id(barcode)
        except Exception as ex:
            raise ServerException(ServerErrors.barcode_syntax_invalid, barcode)

        if data[0] == Operation:
            operation_id = data[1]
            machine_id = additional_data
            task_id, h = self._recordTaskOnOperation(operation_id, machine_id)
            return task_id, h

        elif data[0] == OperationDefinition:
            operation_definition_id = data[1]
            task_id, h = self._recordTaskOnNonBillable(operation_definition_id)
            return task_id, h

        elif data[0] == Order and data[1] == OperationDefinition:
            order_id = data[2]
            operation_definition_id = data[3]
            task_id, h = self._recordTaskOnOrder(order_id,
                                                 operation_definition_id)
            # self.dao.task_dao.task_for_order(order_id,operation_definition_id)
            return task_id, h

        elif data[0] in (TaskActionReportType.day_in,
                         TaskActionReportType.day_out):
            task_id = dao.task_action_report_dao.presence_task().task_id
            h = dict()
            h['task_type'] = 'TaskForPresence'
            h['action_kind'] = data[0]

            return task_id, h

        else:
            raise ServerException(ServerErrors.barcode_invalid, barcode)
コード例 #16
0
ファイル: rlab.py プロジェクト: wiz21b/koi
def print_presence_tasks(dao):
    global header_text, sub_header_text
    header_text = ""
    sub_header_text = _("Presence tasks")

    s = ParagraphStyle(name="zou", fontName='Helvetica', alignment=TA_CENTER)
    topstyle = ParagraphStyle(name="zou",
                              fontName='Helvetica-Bold',
                              alignment=TA_CENTER,
                              fontSize=24)

    array = []
    row = []

    row.append([
        Paragraph(_("Clock IN"), topstyle),
        platypus.Spacer(0, 1 * cm),
        createBarcodeDrawing(
            'EAN13',
            value=str(BarCodeIdentifier.code_for(TaskActionReportType.day_in)),
            width=10 * cm,
            height=4 * cm),
        platypus.Spacer(0, 0.5 * cm)
    ])
    array.append(row)

    array.append([])

    row = []
    row.append([
        Paragraph(_("Clock OUT"), topstyle),
        platypus.Spacer(0, 1 * cm),
        createBarcodeDrawing('EAN13',
                             value=str(
                                 BarCodeIdentifier.code_for(
                                     TaskActionReportType.day_out)),
                             width=10 * cm,
                             height=4 * cm),
        platypus.Spacer(0, 0.5 * cm)
    ])
    array.append(row)

    t = platypus.Table(array, repeatRows=1)  # Repeat the table header

    ts = platypus.TableStyle([('FONT', (0, 0), (-1, -1), 'Helvetica', 8)])
    ts.add('ALIGN', (0, 0), (-1, -1), 'CENTER')
    ts.add('VALIGN', (0, 0), (-1, -1), 'MIDDLE')

    ts.add("LEFTPADDING", (0, 0), (-1, -1), 0)
    ts.add("RIGHTPADDING", (0, 0), (-1, -1), 0)
    ts.add('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black)
    ts.add('BOX', (0, 0), (-1, -1), 0.25, colors.black)

    t.setStyle(ts)
    complete_document = []
    complete_document.append(t)

    filename = make_pdf_filename("NonBillableTasks")
    ladderDoc = start_PDF(filename)
    ladderDoc.build(complete_document, canvasmaker=NumberedCanvas)
    open_pdf(filename)
コード例 #17
0
ファイル: order_report.py プロジェクト: wiz21b/koi
def print_one_part(part,complete_document):
    # Build up a table with accompanying style

    # data_ops = [ ['Poste',None,u'Op\u00E9ration',None] ]

    # We build up a data model and the appropriate styling information

    big_order_nr = ParagraphStyle(name = "subtitle", fontName = 'Helvetica-Bold', fontSize=24, leading=26)
    subtitle = ParagraphStyle(name = "subtitle", fontName = 'Helvetica-Bold', fontSize=18, leading=20)
    s = ParagraphStyle(name = "zou", fontName = 'Helvetica', fontSize=14, leading=16) #, borderWidth=1, borderColor=colors.black)
    opNumberStyle = ParagraphStyle(name = "zou", fontName = 'Helvetica-bold', alignment=TA_CENTER, fontSize=28,leading=28) #, borderWidth=1, borderColor=colors.black)
    centered = ParagraphStyle(name = "zou", fontName = 'Helvetica-bold', alignment=TA_CENTER, fontSize=14) #, borderWidth=1, borderColor=colors.black)

    titles_row = []

    if part.production_file and len(part.production_file[0].operations) > 0:

        # print part.description
        # print len(part.production_file[0].operations)

        data_ops = [[Paragraph(part.human_identifier,big_order_nr),
                     Paragraph(crlf_to_br(part.description),subtitle)],
                    [None,
                     Paragraph(_("Quantity : {} - Deadline: {}").format(part.qty, date_to_dmy(part.deadline)),subtitle)]]
        t = platypus.Table(data_ops, repeatRows=0, colWidths=[3*cm, 19.5*cm - 3*cm])
        ts = platypus.TableStyle()
        ts.add('GRID',(0,0),(-1,-1),0.5,colors.black)
        ts.add('VALIGN', (0, 0), (-1, -1), 'TOP')
        ts.add('ALIGN', (0, 0), (1, -1), 'RIGHT')
        t.setStyle(ts)
        complete_document.append(t)

        # desc = u"<u>{}</u> {}".format(part.human_identifier,crlf_to_br(part.description))
        # complete_document.append(Paragraph(desc,subtitle))
        complete_document.append(platypus.Spacer(1,30))

        data_ops = [ ]
        ts = platypus.TableStyle()
        operation_ndx = 1
        for op in part.production_file[0].operations:

            if op.operation_model and op.operation_model.description:
                model = Paragraph(op.operation_model.short_id,centered)
            else:
                model = None

            if op.operation_model and op.operation_model.imputable:
                code = BarCodeIdentifier.code_for(op)
                barcode = createBarcodeDrawing('EAN13',value=str(code),width=6*cm,barHeight=2*cm)
                mainlog.debug("Barcode for {} is {}".format(op, code))
                graphic = GraphicalAnnotation(code,1*cm)
            else:
                barcode = None
                graphic = None

            full_desc = ""
            if op.description:
                full_desc = u"<b>{}</b> {}".format(escape_html(op.description), op.assignee.fullname)
            else:
                full_desc = "---"

            data_ops.append([Paragraph("{}".format(operation_ndx), opNumberStyle),
                             model,
                             None,
                             Paragraph(full_desc,s),
                             barcode, # barcode, graphic
                             graphic ])
            ts.add('LINEABOVE', (0, len(data_ops)-1), (-1, len(data_ops)-1), 0.5, colors.black)

            # if op.note and len(op.note) > 0:
            #     note = u"<b>Note:</b>{}".format(op.note.replace("\n","<br/>"))
            #     data_ops.append([None,None,Paragraph(note,s),None,None ])
            #     y = len(data_ops)-2
            #     ts.add('SPAN', (3,y), (4, y+1))
            operation_ndx += 1

        ts.add('GRID',(0,0),(1,-1),0.5,colors.black)
        ts.add('BOX',(0,0),(-1,-1),0.5,colors.black)
        ts.add('ALIGN', (0, 0), (1, -1), 'RIGHT')
        ts.add('ALIGN', (2, 0), (-1, -1), 'RIGHT')
        ts.add('VALIGN', (0, 0), (-1, -1), 'TOP')
        # ts.add('VALIGN', (0, 0), (0, -1), 'MIDDLE')

        ts.add('VALIGN', (4, 0), (4, -1), 'MIDDLE')
        ts.add('ALIGN',  (3, 0), (4, -1), 'RIGHT')

        ts.add("LEFTPADDING", (0, 0), (-1, -1), 0)
        ts.add("RIGHTPADDING", (0, 0), (2, -1), 0)
        ts.add("BOTTOMPADDING", (0, 0), (-1, -1), 0.75/2*cm)
        ts.add("TOPPADDING", (1, 0), (-1, -1), 0.25*cm) # .75/2*cm)
        ts.add('LINEABOVE', (0, 0), (-1, 0), 1, colors.black)
        ts.add('LINEBELOW', (0, len(data_ops)-1), (-1, len(data_ops)-1), 1, colors.black)

        t = platypus.Table(data_ops, repeatRows=0, colWidths=[1.5*cm,1.5*cm,0.5*cm,8.5*cm,6.5*cm,1*cm]) # Repeat the table header
        # t = platypus.Table(data_ops, repeatRows=1, colWidths=[3*cm,1*cm,0.5*cm,13*cm,1*cm,1*cm]) # Repeat the table header
        t.setStyle(ts)
コード例 #18
0
ファイル: test_clock_client.py プロジェクト: wiz21b/koi
    def test_operation_with_2_machines(self):
        order = self._make_order()
        dao.order_dao.change_order_state(order.order_id, OrderStatusType.order_ready_for_production)
        operation = order.parts[0].operations[0]
        operation.description = "lorem ipsum dolor amet lorem ipsum dolor amet sic transit gloria mundi"

        machine1 = self._make_machine("Test1 Zimmer Johnson", operation.operation_definition_id)
        machine2 = self._make_machine("Machine2 12457", operation.operation_definition_id)

        app = self.app
        self.window.setFocus(Qt.OtherFocusReason)

        # Employee badge

        employee = dao.employee_dao.find_by_id(self.employee_id)
        bc_employee = BarCodeIdentifier.code_for(employee)
        self._scan(bc_employee)
        assert not self.mem_logger.last_error()

        # Operation selection

        bc_operation = BarCodeIdentifier.code_for(operation)
        self._scan(bc_operation)

        # The operation is tied to a machine => machine selection

        bc_machine1 = BarCodeIdentifier.code_for(machine1)
        mainlog.debug("*** --- " * 40)
        self._scan(bc_machine1)


        self.assertEqual(1, session().query(TaskActionReport).filter(TaskActionReport.kind == TaskActionReportType.start_task).count())
        session().commit()

        # Start the scenario again for a second task on a second machine

        self._scan(bc_employee)
        mainlog.debug(bc_employee)
        mainlog.debug("testtt : {} / {}".format(self.employee_id,bc_employee))


        self._scan(bc_operation)
        # app.exec_()


        mainlog.debug("Active Operation")
        for op in session().query(Operation).all():
            mainlog.debug(op)

        mainlog.debug("Active Operation + join")
        for op, task_id in session().query(Operation,TaskOnOperation.task_id).outerjoin(TaskOnOperation, TaskOnOperation.machine_id == machine2.machine_id).all():
            mainlog.debug(op)
            mainlog.debug(task_id)


        bc_machine2 = BarCodeIdentifier.code_for(machine2)


        mainlog.debug("Active TaskOnOperation")
        for task in session().query(TaskOnOperation).all():
            mainlog.debug("Task id:{} operation:{} machine:{}".format(task.task_id, task.operation_id, task.machine_id))
        for tar in session().query(TaskActionReport).all():
            mainlog.debug(tar)
        session().commit()


        mainlog.debug("*** --- " * 40)
        self._scan(bc_machine2)



        mainlog.debug("Active TaskOnOperation")
        for task in session().query(TaskOnOperation).all():
            mainlog.debug("Task id:{} operation:{} machine:{}".format(task.task_id, task.operation_id, task.machine_id))
        for tar in session().query(TaskActionReport).all():
            mainlog.debug(tar)
        session().commit()



        self.assertEqual(2, session().query(TaskOnOperation).count())

        self.assertEqual(2, session().query(TaskActionReport).filter(TaskActionReport.kind == TaskActionReportType.start_task).count())
        session().commit()

        # app.exec_()


        # Now we start the scenario over to stop one of the task

        # self._scan(bc_employee)
        self._scan(bc_operation)

        # self.app.exec_()

        self._scan(bc_machine1)

        self.assertEqual(1, session().query(TaskActionReport).filter(TaskActionReport.kind == TaskActionReportType.stop_task).count())
        session().commit()
コード例 #19
0
ファイル: rlab.py プロジェクト: wiz21b/koi
def print_non_billable_tasks(dao):
    global header_text, sub_header_text
    header_text = ""
    sub_header_text = _("Non billable tasks")

    s = ParagraphStyle(name="zou", fontName='Helvetica', alignment=TA_CENTER)
    complete_document = []

    tasks_per_line = 3
    array = []
    row = []

    operation_definitions_list = dao.operation_definition_dao.all_imputable_unbillable(
        date.today())
    # FIXME If I don't do this, then accesing opdef description
    # after session close reopens the session...
    operation_definitions = [(opdef.description,
                              BarCodeIdentifier.code_for(opdef))
                             for opdef in operation_definitions_list]
    session().commit()

    if len(operation_definitions) > 0:
        i = 0
        for description, barcode in operation_definitions:
            row.append([
                Paragraph(description, s),
                platypus.Spacer(0, 0.5 * cm),
                createBarcodeDrawing('EAN13',
                                     value=str(barcode),
                                     width=5 * cm,
                                     height=2 * cm),
                platypus.Spacer(0, 0.5 * cm)
            ])
            i = i + 1
            if i == tasks_per_line:
                array.append(row)
                row = []
                i = 0

        t = platypus.Table(array,
                           repeatRows=1,
                           colWidths=[6 * cm] *
                           tasks_per_line)  # Repeat the table header

        ts = platypus.TableStyle([('FONT', (0, 0), (-1, -1), 'Helvetica', 8)])
        ts.add('ALIGN', (0, 0), (-1, -1), 'CENTER')
        ts.add('VALIGN', (0, 0), (-1, -1), 'MIDDLE')

        ts.add("LEFTPADDING", (0, 0), (-1, -1), 0)
        ts.add("RIGHTPADDING", (0, 0), (-1, -1), 0)
        ts.add('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black)
        ts.add('BOX', (0, 0), (-1, -1), 0.25, colors.black)

        t.setStyle(ts)
        complete_document.append(t)

    else:
        complete_document.append(
            Paragraph(
                _("There currently are no unbillable operations defined"), s))

    filename = make_pdf_filename("NonBillableTasks")
    ladderDoc = start_PDF(filename)
    ladderDoc.build(complete_document, canvasmaker=NumberedCanvas)
    open_pdf(filename)
コード例 #20
0
ファイル: order_report.py プロジェクト: wiz21b/koi
def make_boxes(operation_ndx, op, test_mode=False):
    s = ParagraphStyle(name = "Regular", fontName = 'Helvetica', fontSize=12) #, borderWidth=1, borderColor=colors.black)
    c = ParagraphStyle(name = "Centered", fontName = 'Helvetica', alignment=TA_CENTER, fontSize=12) #, borderWidth=1, borderColor=colors.black)

    if op.operation_model and op.operation_model.description:
        model = Paragraph(op.operation_model.short_id,c) # short_id / description
    else:
        model = None

    barcode_width = 3*cm
    if op.operation_model and op.operation_model.imputable:
        code = BarCodeIdentifier.code_for(op)
        # humanReadable : remove the numbers under the barcode
        barcode = createBarcodeDrawing('EAN13',value=str(code),width=barcode_width,barHeight=1*cm,humanReadable=False)
        mainlog.debug("Barcode for {} is {}".format(op, code))
    else:
        barcode = None


    full_desc = ""
    if op.description:
        # full_desc = u"<b>{}</b>".format(crlf_to_br(op.description))
        assignee = ''
        if op.assignee:
            assignee = op.assignee.fullname
        full_desc = escape_html(op.description)

        if test_mode and operation_ndx % 2 == 1:
            full_desc = LOREM_IPSUM[0:len(op.description)]

    else:
        full_desc = "---"

    op_ndx = "{:02}".format(operation_ndx)

    data_ops = [[ Paragraph(op_ndx,c),    model,                   barcode,            None,   Paragraph("Stop",c), Paragraph("Val1",c), Paragraph("Descriptif / remarque",c), None,   Paragraph("Acc",c), Paragraph("Ref",c), Paragraph("Val2",c), Paragraph("Mac",c)],
                [ "",                     "",                      "",                 None,   "",                  "",                  "",                                   None,   "",                 "",                 "",                  ""],
                [ Paragraph(full_desc,s), "",                      "",                 None,   "",                  "",                  "",                                   None,   "",                 "",                 "",                  ""]]

    # 1.16 = EAN13 quiet zone proportion
    col_widths= [ 0.8*cm,                 0.8*cm,                  barcode_width*1.16, 0.1*cm, 1.5*cm,              1.5*cm,              None,                                 0.1*cm, 1.1*cm,             1.1*cm,             1.5*cm,              1.1*cm]

    t = platypus.Table(data_ops, repeatRows=0, colWidths=compute_strut( col_widths, 19.5*cm) )

    ts = platypus.TableStyle()

    # Tuples are (x,y)
    ts.add('BOX',(0,0),(-1,-1),1,colors.black)
    ts.add('LINEBELOW', (4, 0), (-1, 0), 0.5, colors.black)
    # Two inner grids not to overwrite the fine linebelow
    ts.add('INNERGRID',(0,0),(-1,0),1,colors.black)
    ts.add('INNERGRID',(0,1),(-1,1),1,colors.black)
    ts.add('BOX',(0,2),(-1,2),1,colors.black)

    ts.add('ALIGN',(0,0),(-1,0),"CENTER")
    ts.add('VALIGN',(0,0),(2,0),"MIDDLE")

    # First row vertical spans
    ts.add('SPAN',(0,0),(0,1))
    ts.add('LEFTPADDING',(0,0),(-1,0),0)
    ts.add('RIGHTPADDING',(0,0),(-1,0),0)

    ts.add('SPAN',(1,0),(1,1))
    ts.add('SPAN',(2,0),(2,1))

    # Separators
    ts.add('SPAN',(3,0),(3,1))
    ts.add('SPAN',(7,0),(7,1))

    ts.add('LEADING', (0, 1), (-1, 1), 1.4*cm) # Sets the row height

    # ts.add('LINEBEFORE', (3, 0), (3, 1), 1, colors.black)
    # ts.add('LINEBEFORE', (7, 0), (7, 1), 1, colors.black)

    ts.add('TOPPADDING',(4,0),(-1,0),0)
    ts.add('BOTTOMPADDING',(4,0),(-1,0),3)

    # Last row horizontal span
    ts.add('SPAN',(0,2),(-1,2))
    ts.add('TOPPADDING',(0,2),(-1,2),6)
    ts.add('BOTTOMPADDING',(0,2),(-1,2),12)

    t.setStyle(ts)

    return t
コード例 #21
0
ファイル: test_clock_client.py プロジェクト: wiz21b/koi
    def test_operation(self):
        order = self._order_dao.make(u"Test order"+chr(233),self.customer)
        order.state = OrderStatusType.order_definition # OrderStatusType.order_ready_for_production
        self._order_dao.save(order)

        order_part = self._order_part_dao.make(order)
        order_part.description = u"Part 1" + chr(233)
        order_part.position = 1
        self._order_part_dao.save(order_part)

        pf = self._production_file_dao.make()
        pf.order_part = order_part
        order_part.production_file = [pf]
        session().add(pf)
        session().flush()

        operation = self._operation_dao.make()
        operation.production_file = pf
        operation.description = u"operation desc" + chr(233)
        operation.operation_model = self.opdef_op
        session().add(operation)
        session().commit()

        bc_operation = BarCodeIdentifier.code_for(operation)
        order_id = order.order_id
        session().close()

        app = self.app
        self.window.setFocus(Qt.OtherFocusReason)

        # Scan employee; this hsould result in a presence task.
        employee = dao.employee_dao.find_by_id(self.employee_id)
        bc = BarCodeIdentifier.code_for(employee)
        self._scan(bc)

        # At this point, the operation exists but is not imputable
        # because the order is not in production.
        # Therefore scanning it shll produce no effect.

        self._scan(bc_operation)

        self.assertEqual( ServerErrors.order_part_not_in_production_unknown.value,
                          self.mem_logger.last_error().code)
        self.assertEqual(0, session().query(TaskActionReport).filter(TaskActionReport.kind == TaskActionReportType.start_task).count())

        order = dao.order_dao.find_by_id(order_id)
        order.state = OrderStatusType.order_ready_for_production
        self._order_dao.save(order)
        session().close()

        self.mem_logger.clear_errors()

        # Start task
        self._scan(bc_operation)

        # app.exec_()
        mainlog.debug(" *** !!! "*10)
        assert not self.mem_logger.last_error()
        self.assertEqual(1, session().query(TaskActionReport).filter(TaskActionReport.kind == TaskActionReportType.start_task).count())

        # FIXME missing asserts

        # End task
        self._scan(bc_operation)
        assert not self.mem_logger.last_error()

        self.assertEqual(1, session().query(TaskActionReport).filter(TaskActionReport.kind == TaskActionReportType.start_task).count())
        self.assertEqual(1, session().query(TaskActionReport).filter(TaskActionReport.kind == TaskActionReportType.stop_task).count())
        assert session().query(TaskActionReport).count() == 3 # 2 + presence
        session().commit()
コード例 #22
0
def print_machines_barcodes():
    global header_text
    global sub_header_text

    s = ParagraphStyle(name="zou",
                       fontName='Helvetica',
                       fontSize=14,
                       alignment=TA_CENTER)
    title_style = ParagraphStyle(name="regular",
                                 fontName='Helvetica',
                                 fontSize=24,
                                 spaceBefore=34,
                                 spaceAfter=34)
    zone_style = ParagraphStyle(name="zone-style",
                                fontName='Helvetica-Bold',
                                fontSize=24,
                                spaceBefore=34,
                                spaceAfter=34)

    badges_per_line = 3

    smachines = sort_machines(machine_service.all_machines())

    # I need an instance to call barcode identifier
    barcode_machine = Machine()

    if len(smachines) == 0:
        return

    complete_document = []
    for clock_zone in sorted(smachines.keys()):

        complete_document.append(
            Paragraph(u">>> {}".format(clock_zone or _("Without zone")),
                      zone_style))

        machines = smachines[clock_zone]

        if not machines:
            continue

        for operation_name, machines in machines.items():

            array = []
            row = []
            i = 0
            for machine in machines:

                barcode_machine.resource_id = machine.resource_id
                bc = createBarcodeDrawing(
                    'EAN13',
                    value=str(BarCodeIdentifier.code_for(barcode_machine)),
                    width=5.5 * cm,
                    barHeight=1.5 * cm)

                row.append([
                    Paragraph(u"{}".format(machine.fullname), s),
                    platypus.Spacer(0, 0.25 * cm), bc
                ])
                i = i + 1
                if i == badges_per_line:
                    array.append(row)
                    row = []
                    i = 0

            # Handle the last non complete row
            if i > 0:
                array.append(row)

            t = platypus.Table(array,
                               repeatRows=0,
                               colWidths=[6.5 * cm] * badges_per_line,
                               rowHeights=[3 * cm] * len(array))

            ts = platypus.TableStyle([('FONT', (0, 0), (-1, -1), 'Helvetica',
                                       8)])
            ts.add('ALIGN', (0, 0), (-1, -1), 'CENTER')
            ts.add('VALIGN', (0, 0), (-1, -1), 'MIDDLE')

            ts.add("LEFTPADDING", (0, 0), (-1, -1), 0)
            ts.add("RIGHTPADDING", (0, 0), (-1, -1), 0)
            ts.add('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black)
            ts.add('BOX', (0, 0), (-1, -1), 0.25, colors.black)

            t.setStyle(ts)

            complete_document.append(
                KeepTogether([Paragraph(operation_name, title_style), t]))

        # complete_document.append( Paragraph(_("Operation {}").format(opid), title_style))
        # complete_document.append(t)
        complete_document.append(PageBreak())

    filename = make_pdf_filename("MachineBarcodes_")
    ladderDoc = basic_PDF(filename)
    ladderDoc.title = ""
    ladderDoc.subject = _(u"Machines bar codes")

    ladderDoc.build(complete_document, canvasmaker=NumberedCanvas)
    open_pdf(filename)
コード例 #23
0
ファイル: rlab.py プロジェクト: wiz21b/koi
def print_indirects_without_order():
    for opdef in dao.operation_definition_dao.all_indirect(False):
        print(BarCodeIdentifier.code_for(opdef))