示例#1
0
    def _buildModel(self):
        batches, specs = self._processDir()

        self._root = TreeNode(None, None)

        for batch in batches:
            newNode = TreeNode(batch, self._root)
            spec = specs.get(batch.name)
            if spec:
                for s in spec:
                    newNode.append_child(TreeNode(s, newNode))
            self._root.append_child(newNode)
示例#2
0
    def _buildModel(self):
        self._root = TreeNode(None, None)

        devices = [
            DeviceItem(0, 1, '1324B1Y'),
            DeviceItem(1, 1, '1324B2Y'),
            DeviceItem(2, 1, '1324B3Y')
        ]

        for dev in devices:
            newNode = TreeNode(dev, self._root)
            newNode.append_child(
                TreeNode(
                    RigTypeItem(0, 2, 'Статика', 'ПП 23.10.1123',
                                'БКВП 111111.239841'), newNode))
            newNode.append_child(
                TreeNode(
                    RigTypeItem(0, 2, 'Динамика', 'ПП 23.10.1123',
                                'БКВП 111111.239841'), newNode))
            newNode.append_child(
                TreeNode(
                    RigTypeItem(0, 2, 'Надежность', 'ПП 23.10.1123',
                                'БКВП 111111.239841'), newNode))
            newNode.append_child(
                TreeNode(RigTypeItem(0, 2, 'Тепло/холод', 'ПП 23.10.1123', ''),
                         newNode))
            self._root.append_child(newNode)

        return
示例#3
0
    def _buildModel(self):
        self._root = TreeNode(None, None)

        projects = [
            ProjectItem(0, 1, 'Преобразователь'),
            ProjectItem(1, 1, 'Высотка'),
            ProjectItem(2, 1, 'Дискрет')
        ]

        for proj in projects:
            tier1_node = TreeNode(proj, self._root)

            tier2_node = TreeNode(DeviceItem(0, 2, 'Устройство1'), tier1_node)
            tier2_node.append_child(
                TreeNode(RigTypeItem(0, 3, 'Статика'), tier2_node))

            tier1_node.append_child(tier2_node)

            self._root.append_child(tier1_node)

        return
示例#4
0
class BatchDomain:

    def __init__(self):
        self._workDir = ''
        self._root = TreeNode(None, None)

    def init(self):
        print(f'init batch domain for dir {self._workDir}')
        self._buildModel()

    def _buildModel(self):
        batches, specs = self._processDir()

        self._root = TreeNode(None, None)

        for batch in batches:
            newNode = TreeNode(batch, self._root)
            spec = specs.get(batch.name)
            if spec:
                for s in spec:
                    newNode.append_child(TreeNode(s, newNode))
            self._root.append_child(newNode)

    def _processDir(self):

        batches = list()
        specs_dict = dict()

        def checkFileEntry(entry):
            return entry.is_file() and entry.path.endswith('.xlsx') and 'ЗАПУСК' in entry.path

        def excelFiles():
            with os.scandir(self._workDir) as entries:
                for entry in entries:
                    if checkFileEntry(entry):
                        yield os.path.normpath(entry.path)

        for index, file in enumerate(excelFiles()):
            batch = Path(file).resolve().stem
            date_from_batch = batch[-7:].replace('_', '-')
            total_specs, needed_specs, specs_list = self._parseExcelFile(file=file)
            specs_received = sum(map(lambda el: int(el.is_received), specs_list))
            specs_dict[batch] = specs_list
            batches.append(BatchItem(rowid=index + 1, tier=StatTreeModel.TIER_1, name=batch, specs_needed=needed_specs,
                                     specs_total=total_specs, specs_received=specs_received,
                                     date=date_from_batch))

        return batches, specs_dict

    def _parseExcelFile(self, file):
        wb = openpyxl.load_workbook(file)
        ws = wb.active
        specs = list()
        total_specs = 0
        needed_specs = 0
        for row in list(ws.rows)[1:]:
            if all(row):
                rowid, desc, chip, fio, is_needed, board_date, is_received = [el.value for el in row]
                total_specs += 1
                if is_needed and is_needed == '+':
                    specs.append(SpecItem(rowid=rowid, name=f'{chip} - {desc}', developer=fio, is_received=False if is_received == '-' else True))
                    needed_specs += 1
        wb.close()
        return total_specs, needed_specs, specs


    @property
    def workDir(self):
        return self._workDir

    @workDir.setter
    def workDir(self, name):
        if os.path.isdir(name):
            self._workDir = os.path.normpath(name)
            self.init()
示例#5
0
class ProjectDomain:
    def __init__(self):
        self._workDir = ''
        self._root = TreeNode(None, None)

    def init(self):
        print(f'init project domain for dir {self._workDir}')
        self._buildModel()

    def _buildModel(self):
        self._root = TreeNode(None, None)

        projects = [
            ProjectItem(0, 1, 'Преобразователь'),
            ProjectItem(1, 1, 'Высотка'),
            ProjectItem(2, 1, 'Дискрет')
        ]

        for proj in projects:
            tier1_node = TreeNode(proj, self._root)

            tier2_node = TreeNode(DeviceItem(0, 2, 'Устройство1'), tier1_node)
            tier2_node.append_child(
                TreeNode(RigTypeItem(0, 3, 'Статика'), tier2_node))

            tier1_node.append_child(tier2_node)

            self._root.append_child(tier1_node)

        return

    def _processDir(self):

        batches = list()
        specs_dict = dict()

        def checkFileEntry(entry):
            return entry.is_file() and entry.path.endswith('.xlsx')

        def excelFiles():
            with os.scandir(self._workDir) as entries:
                for entry in entries:
                    if checkFileEntry(entry):
                        yield os.path.normpath(entry.path)

        for index, file in enumerate(excelFiles()):
            batch = Path(file).resolve().stem
            total_specs, needed_specs, specs_list = self._parseExcelFile(
                file=file)
            specs_dict[batch] = specs_list
            batches.append(
                DeviceItem(rowid=index + 1,
                           tier=StatTreeModel.TIER_1,
                           name=batch))

        return batches, specs_dict

    def _parseExcelFile(self, file):
        wb = openpyxl.load_workbook(file)
        ws = wb.active
        specs = list()
        total_specs = 0
        needed_specs = 0
        for row in list(ws.rows)[1:]:
            if all(row):
                rowid, desc, chip, fio, is_needed, board_date, is_received = [
                    el.value for el in row
                ]
                total_specs += 1
                if is_needed and is_needed == '+':
                    specs.append(
                        RigTypeItem(rowid=rowid, name=f'{chip} - {desc}'))
                    needed_specs += 1
        wb.close()
        return total_specs, needed_specs, specs

    @property
    def workDir(self):
        return self._workDir

    @workDir.setter
    def workDir(self, name):
        if os.path.isdir(name):
            self._workDir = os.path.normpath(name)
            self.init()
示例#6
0
class DeviceDomain:
    def __init__(self):
        self._workDir = ''
        self._root = TreeNode(None, None)

    def init(self):
        print(f'init device domain for dir {self._workDir}')
        self._buildModel()

    def _buildModel(self):
        self._root = TreeNode(None, None)

        devices = [
            DeviceItem(0, 1, '1324B1Y'),
            DeviceItem(1, 1, '1324B2Y'),
            DeviceItem(2, 1, '1324B3Y')
        ]

        for dev in devices:
            newNode = TreeNode(dev, self._root)
            newNode.append_child(
                TreeNode(
                    RigTypeItem(0, 2, 'Статика', 'ПП 23.10.1123',
                                'БКВП 111111.239841'), newNode))
            newNode.append_child(
                TreeNode(
                    RigTypeItem(0, 2, 'Динамика', 'ПП 23.10.1123',
                                'БКВП 111111.239841'), newNode))
            newNode.append_child(
                TreeNode(
                    RigTypeItem(0, 2, 'Надежность', 'ПП 23.10.1123',
                                'БКВП 111111.239841'), newNode))
            newNode.append_child(
                TreeNode(RigTypeItem(0, 2, 'Тепло/холод', 'ПП 23.10.1123', ''),
                         newNode))
            self._root.append_child(newNode)

        return

    def _processDir(self):

        batches = list()
        specs_dict = dict()

        def checkFileEntry(entry):
            return entry.is_file() and entry.path.endswith('.xlsx')

        def excelFiles():
            with os.scandir(self._workDir) as entries:
                for entry in entries:
                    if checkFileEntry(entry):
                        yield os.path.normpath(entry.path)

        for index, file in enumerate(excelFiles()):
            batch = Path(file).resolve().stem
            total_specs, needed_specs, specs_list = self._parseExcelFile(
                file=file)
            specs_dict[batch] = specs_list
            batches.append(
                DeviceItem(rowid=index + 1,
                           tier=StatTreeModel.TIER_1,
                           name=batch))

        return batches, specs_dict

    def _parseExcelFile(self, file):
        wb = openpyxl.load_workbook(file)
        ws = wb.active
        specs = list()
        total_specs = 0
        needed_specs = 0
        for row in list(ws.rows)[1:]:
            if all(row):
                rowid, desc, chip, fio, is_needed, board_date, is_received = [
                    el.value for el in row
                ]
                total_specs += 1
                if is_needed and is_needed == '+':
                    specs.append(
                        RigTypeItem(rowid=rowid, name=f'{chip} - {desc}'))
                    needed_specs += 1
        wb.close()
        return total_specs, needed_specs, specs

    @property
    def workDir(self):
        return self._workDir

    @workDir.setter
    def workDir(self, name):
        if os.path.isdir(name):
            self._workDir = os.path.normpath(name)
            self.init()