コード例 #1
0
def oracle_data_import(user, passwd, host, database, user_group,
                       file_with_path):
    oracle_file = zCSV.CsvFile(file_with_path)
    oracle_file.del_lines_begin(8)
    print(oracle_file)
    oracle_info = oracle_file.get_oracle_data()
    print(oracle_info)
    read_return = oracle_data_read(
        user, passwd, host, database, ['[AutoNo]', '[Unit Length]'],
        ['[Order Num]', '[Batch Id]'], ['%d', '%d'],
        (int(oracle_info[0]['Order Num']), int(oracle_info[0]['Batch Id'])))
    if read_return:
        print('Batch is already in database')
        return -2
    sql = genSQL.OracleData_SQL().insert_sql_head()
    # print(sql)
    s_values = genSQL.OracleData_SQL().insert_sql_values(
        oracle_info, user, user_group)
    db = dbunit.DBUnit(user, passwd, host, database)
    # print(s_values)
    insert_return = db.write(sql, s_values)
    if insert_return == -1:
        print('Insert Data Error!')
    else:
        print('Insert Data OK!')
    return insert_return
コード例 #2
0
def df_purlin_dim_import(user, passwd, host, database, csv_file):
    file_ = zCSV.CsvFile(csv_file)
    dims = file_.get_std_dim()
    exit_dims = []
    insert_return = -1
    if dims:
        for dim in dims:
            exit_dim = df_purlin_dim_read(user, passwd, host, database,
                                          ['part_no'], ['draw_no', 'part_no'],
                                          ['%s', '%s'],
                                          (dim['draw_no'], dim['part_no']))
            if exit_dim:
                exit_dims.append(exit_dim)
            else:
                sql = genSQL.PurlinDimSQL().insert_sql_head()
                # print(sql)
                s_values = genSQL.PurlinDimSQL().insert_sql_values(dim)
                db = dbunit.DBUnit(user, passwd, host, database)
                # print(s_values)
                insert_return = db.write(sql, s_values)
                if insert_return == -1:
                    print('Insert Data Error!')
                else:
                    print('Insert Data OK!')
    return exit_dims, insert_return
コード例 #3
0
ファイル: zConvert_code.py プロジェクト: zanweb/zTransform
 def get_z_profile_list(self):
     file_name = 'Z.csv'
     if not os.path.isfile(file_name):
         QMessageBox.warning(self, '警告', file_name + '  文件不存在!\n请将它拷贝到安装目录下!', QMessageBox.Yes)
         # exit()
         return
     csv_file = zCSV.CsvFile(file_name)
     self.z_profile = csv_file.get_z_list()
コード例 #4
0
ファイル: zConvert_code.py プロジェクト: zanweb/zTransform
 def get_hole_name(self):
     file_name = 'holeName.csv'
     if not os.path.isfile(file_name):
         QMessageBox.warning(self, '警告', file_name + '  文件不存在!\n请将它拷贝到安装目录下!', QMessageBox.Ok)
         # exit()
         return
     csv_file = zCSV.CsvFile(file_name)
     self.home_name = csv_file.get_hole_name()
     return self.home_name
コード例 #5
0
 def get_item_list(self):
     seq_file = self.oracle_file
     if seq_file:
         csv_file = zCSV.CsvFile(seq_file)
         csv_file.del_lines_begin(8)
         self.item_list = csv_file.get_seq_list()
     else:
         QMessageBox.warning(self, '错误', '没有制作清单文件!\n请指定Oracle制作清单文件!',
                             QMessageBox.Ok)
         return
コード例 #6
0
ファイル: zConvert_code.py プロジェクト: zanweb/zTransform
 def get_item_list(self):
     seq_file = zFBase.get_indicate_ext_file(self.in_folder, 'CSV')
     if seq_file:
         file_name = seq_file[0] + '.csv'
         file_full_path = os.path.join(self.in_folder, file_name)
         csv_file = zCSV.CsvFile(file_full_path)
         csv_file.del_lines_begin(8)
         self.item_list = csv_file.get_seq_list()
         # print(self.item_list)
     else:
         QMessageBox.warning(self, '错误', '没有制作清单文件!\n请在NC文件夹内添加制作清单文件!\n程序将关闭!', QMessageBox.Ok)
         # exit()
         return
コード例 #7
0
 def slitting_save_to_csv(self):
     file_with_path = QFileDialog.getExistingDirectory(None, '请指定目标文件目录:')
     file_with_path += '/' + time.strftime('%y%m%d%H%M%S', time.localtime())  # str(random.randint(0, 9))
     file_with_path += '.CSV'
     csv_save = zCSV.CsvFile(file_with_path)
     ok = csv_save.write_slitting_list(self.list_make)
     if ok:
         QMessageBox.information(self, '保存文件信息', '文件已保存!\n' + file_with_path, QMessageBox.Ok)
         # fin = self.update_oracle_date_complete(self.list_make)
         # if not fin:
         #     QMessageBox.information(self, '数据库更新信息', '数据库更新完成!', QMessageBox.Ok)
         # else:
         #     QMessageBox.warning(self, '数据库更新警告', '数据库更新问题!\n 请联系相关人员!', QMessageBox.Ok)
     else:
         QMessageBox.warning(self, '保存文件', '文件未保存!\n 请联系相关人员!', QMessageBox.Ok)
コード例 #8
0
 def check_source_files_exit(self):
     file_exist = []
     file_not_exist = []
     item_names = self.get_item_names()
     if self.data_source_type == 'NC':
         nc_file_list = zFBase.get_indicate_ext_file(
             self.source_folder, 'nc1')
         if nc_file_list:
             for each_item in item_names:
                 if each_item in nc_file_list:
                     file_exist.append(each_item)
                 else:
                     file_not_exist.append(each_item)
             return file_exist, file_not_exist
         else:
             QMessageBox.warning(self, 'nc文件:', '目录中没有NC文件!')
             return 0
     if self.data_source_type == 'CSV':
         # 从csv的文件夹中读取
         all_parts = []  # 所有csv文件中的parts(lysaght)
         all_parts_no = []
         csv_files = zFBase.get_indicate_ext_file(self.source_folder, 'csv')
         if csv_files:
             for csv_name in csv_files:
                 csv_file_path = self.source_folder + '/' + str(
                     csv_name) + '.csv'
                 csv_file = zCSV.CsvFile(csv_file_path)
                 csv_parts = csv_file.get_lysaght_punch()
                 all_parts.extend(csv_parts)
                 all_parts_no = [no.part_no for no in all_parts]
             # print(all_parts_no)
             miss_parts = list(
                 set(item_names).difference(set(all_parts_no)))
             if miss_parts:
                 QMessageBox.warning(
                     self, '工程数据缺失',
                     '缺失如下零件csv数据, 请补充数据!!!\n' + str(miss_parts),
                     QMessageBox.Ok)
                 return 0
             else:
                 self.lysaght_parts = all_parts
                 return item_names, miss_parts
コード例 #9
0
    def process_csv_to_dtr(self):
        if not self.list_make:
            QMessageBox.warning(self, '警告', '没有适合制作的零件!')
            return
        list_auto = []
        for dic in self.list_make:
            list_auto.append(dic['AutoNo'])
        # 获取制作列表的构件名
        list_make_files = []
        for dic in self.list_make:
            list_make_files.append(dic['Item'])
        list_make_files = list(set(list_make_files))  # 零件去重
        # print(list_make_files)

        # 从csv的文件夹中读取
        all_parts = []  # 所有csv文件中的parts(lyasght)
        all_parts_no = []
        self.csv_folder = QFileDialog.getExistingDirectory(None, '请指定csv文件目录:')
        csv_files = zFBase.get_indicate_ext_file(self.csv_folder, 'csv')
        if csv_files:
            for csv in csv_files:
                csv_file_path = self.csv_folder + '/' + str(csv) + '.csv'
                csv_file = zCSV.CsvFile(csv_file_path)
                csv_parts = csv_file.get_lysaght_punch()
                all_parts.extend(csv_parts)
                all_parts_no = [no.part_no for no in all_parts]
            # print(all_parts_no)
            miss_parts = list(set(list_make_files).difference(set(all_parts_no)))
            if miss_parts:
                QMessageBox.warning(self, '工程数据缺失', '缺失如下零件csv数据, 请补充数据!!!\n' + str(miss_parts), QMessageBox.Ok)
                return 0

            # 获取清单数据
            QMessageBox.information(self, '工程数据文件', '工程数据文件齐全,开始转换。', QMessageBox.Ok)
            # 指定输出文件夹
            self.out_folder = QFileDialog.getExistingDirectory(self, '获取转换后的文件夹:')
            # 获取制作清单数据结构
            list_auto_int = [int(x) for x in list_auto]
            # print(list_auto_int)
            tuple_auto = tuple(list_auto_int)
            read_return = dbFunctions.oracle_data_read_in_auto(self.user, self.pass_word, self.server,
                                                               self.database, tuple_auto)
            all_parts_make = []
            for part in all_parts:
                if part.part_no in list_make_files:
                    all_parts_make.append(part)

            try:
                # 检查lysaght-parts是否crash? False--需要, True--不需要
                if False:
                    crash_parts = []
                else:
                    crash_parts = check_lysaght_parts_crash(all_parts_make)
                if crash_parts:
                    info = ''
                    for part in crash_parts:
                        info += part.part_no + ','
                    info += '继续?'
                    reply = QMessageBox.warning(self, '警告', '下列零件孔位y轴上有碰撞\n' + info, QMessageBox.Yes | QMessageBox.No)
                    if reply == QMessageBox.No:
                        return
                cut_list, no_pattern_list, parts = lysaght_csv_from_oracle_to_dtr(read_return, all_parts_make)

                # 此处重新构建cut_list,和parts
                print('重新建构----', cut_list, '\nparts\n', parts, '\n')
                cut_list, parts, unable_splice = process_half_cut(cut_list, parts)
                self.save_dtr_files(cut_list, no_pattern_list, parts, unable_splice)
            except Exception as e:
                print(e)
        else:
            QMessageBox.warning(self, "警告", '此目录下没有csv文件!')
        return