From 796b2deef42214d8ba3e3b87b9f4d6314b23b816 Mon Sep 17 00:00:00 2001 From: chaopower Date: Tue, 7 May 2024 17:59:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B1=87=E6=80=BB=EF=BC=8Cba?= =?UTF-8?q?rcode=E9=9D=9E16=E4=BD=8D=EF=BC=8C=E5=88=99=E6=8C=89=E5=90=8E8?= =?UTF-8?q?=E4=BD=8D=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/t7.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tools/t7.py b/tools/t7.py index 854754a..c3e6c0f 100644 --- a/tools/t7.py +++ b/tools/t7.py @@ -493,12 +493,14 @@ class AutoLayout: # 非正常barcode barcode_mask = ori_library_df['indexi5i7'].str.len() != 16 + ori_library_df.loc[barcode_mask, 'indexi5i7'] = ori_library_df.loc[barcode_mask, 'indexi5'].str[-8:] + \ + ori_library_df.loc[barcode_mask, 'indexi7'].str[-8:] ori_library_df['note'] = '' ori_library_df.loc[~numeric_mask, 'note'] = 'data_needed 列非数字' ori_library_df.loc[~time_mask, 'note'] = 'time 列非日期' - ori_library_df.loc[barcode_mask, 'note'] = '非16位barcode' - no_ori_data = ori_library_df[~(numeric_mask & time_mask) | barcode_mask] + # ori_library_df.loc[barcode_mask, 'note'] = '非16位barcode' + no_ori_data = ori_library_df[~(numeric_mask & time_mask)] self.no_assign_data.extend(no_ori_data.to_dict('records')) @@ -693,6 +695,7 @@ class AutoLayout: writer = pd.ExcelWriter(outputpath) res = list() + sum_res = list() chip_loc = 1 librarynum = 0 for chip_idx, chip_assignments in self.index_assignments.items(): @@ -725,10 +728,27 @@ class AutoLayout: # df.to_excel(writer, sheet_name=chipname, index=False) res.extend(df.to_dict('records')) chip_loc += 1 + + sum_list = list() + for library, library_df in df.groupby('samplename'): + sum_list.append(dict( + 二次拆分=library, + 客户=library_df['companynamea'].values[0], + 类型=library_df['classification'].values[0], + 打折前=library_df['orderdatavolume'].sum() + )) + df_sum = pd.DataFrame(sum_list) + sum_res.append({'sheetname': chipname, 'data': df_sum}) + res_df = pd.DataFrame(res) res_df = pd.concat([pd.DataFrame(self.items), res_df]).reset_index(drop=True) res_df.to_excel(writer, sheet_name='assignment', index=False) + for sum_sheet in sum_res: + sheetname = sum_sheet.get('sheetname') + df_data = sum_sheet.get('data') + df_data.to_excel(writer, sheet_name=sheetname, index=False) + no_assign_df = pd.DataFrame(self.no_assign_data) if not no_assign_df.empty: no_assign_df = no_assign_df.applymap(lambda x: format_date(x) if isinstance(x, pd.Timestamp) else x)