1c6d880f by 周伟奇

add license

1 parent c1c49a8e
...@@ -168,7 +168,7 @@ class BSWorkbook(Workbook): ...@@ -168,7 +168,7 @@ class BSWorkbook(Workbook):
168 month_mapping.setdefault(month_list[-1], []).insert( 168 month_mapping.setdefault(month_list[-1], []).insert(
169 0, (ws.title, idx_list[-1] + min_row, ws.max_row, 0)) 169 0, (ws.title, idx_list[-1] + min_row, ws.max_row, 0))
170 170
171 def build_metadata_rows(self, classify, confidence, role, code, print_time, start_date, end_date): 171 def build_metadata_rows(self, confidence, code, print_time, start_date, end_date):
172 if start_date is None or end_date is None: 172 if start_date is None or end_date is None:
173 timedelta = None 173 timedelta = None
174 else: 174 else:
...@@ -176,10 +176,6 @@ class BSWorkbook(Workbook): ...@@ -176,10 +176,6 @@ class BSWorkbook(Workbook):
176 metadata_rows = [ 176 metadata_rows = [
177 ('流水识别置信度', confidence), 177 ('流水识别置信度', confidence),
178 self.blank_row, 178 self.blank_row,
179 ('分类结果', classify),
180 self.blank_row,
181 ('户名', role),
182 self.blank_row,
183 self.code_header, 179 self.code_header,
184 ] 180 ]
185 metadata_rows.extend(code) 181 metadata_rows.extend(code)
...@@ -200,19 +196,19 @@ class BSWorkbook(Workbook): ...@@ -200,19 +196,19 @@ class BSWorkbook(Workbook):
200 ms = self.create_sheet('{0}({1})'.format(self.meta_sheet_title, card)) 196 ms = self.create_sheet('{0}({1})'.format(self.meta_sheet_title, card))
201 return ms 197 return ms
202 198
203 def build_meta_sheet(self, card, classify, confidence, role, code, print_time, start_date, end_date): 199 def build_meta_sheet(self, card, confidence, code, print_time, start_date, end_date):
204 metadata_rows = self.build_metadata_rows(classify, confidence, role, code, print_time, start_date, end_date) 200 metadata_rows = self.build_metadata_rows(confidence, code, print_time, start_date, end_date)
205 ms = self.create_meta_sheet(card) 201 ms = self.create_meta_sheet(card)
206 for row in metadata_rows: 202 for row in metadata_rows:
207 ms.append(row) 203 ms.append(row)
208 return ms 204 return ms
209 205
210 def build_month_sheet(self, role, month_mapping, ms, is_reverse): 206 def build_month_sheet(self, card, month_mapping, ms, is_reverse):
211 tmp_ws = self.create_sheet('tmp_ws') 207 tmp_ws = self.create_sheet('tmp_ws')
212 for month in sorted(month_mapping.keys()): 208 for month in sorted(month_mapping.keys()):
213 # 3.1.拷贝数据 209 # 3.1.拷贝数据
214 parts = month_mapping.get(month) 210 parts = month_mapping.get(month)
215 new_ws = self.create_sheet('{0}({1})'.format(month, role)) 211 new_ws = self.create_sheet('{0}({1})'.format(month, card[-6:]))
216 new_ws.append(consts.FIXED_HEADERS) 212 new_ws.append(consts.FIXED_HEADERS)
217 for part in parts: 213 for part in parts:
218 ws = self.get_sheet_by_name(part[0]) 214 ws = self.get_sheet_by_name(part[0])
...@@ -338,9 +334,7 @@ class BSWorkbook(Workbook): ...@@ -338,9 +334,7 @@ class BSWorkbook(Workbook):
338 334
339 # 2.元信息提取表 335 # 2.元信息提取表
340 ms = self.build_meta_sheet(card, 336 ms = self.build_meta_sheet(card,
341 summary['classify'],
342 summary['confidence'], 337 summary['confidence'],
343 summary['role'],
344 summary['code'], 338 summary['code'],
345 summary['print_time'], 339 summary['print_time'],
346 start_date, 340 start_date,
...@@ -359,13 +353,16 @@ class BSWorkbook(Workbook): ...@@ -359,13 +353,16 @@ class BSWorkbook(Workbook):
359 self.remove(self.get_sheet_by_name(sheet)) 353 self.remove(self.get_sheet_by_name(sheet))
360 354
361 def license_rebuild(self, license_summary): 355 def license_rebuild(self, license_summary):
362 for en_key, cn_key in consts.LICENSE_ORDER: 356 for classify, (_, name) in consts.LICENSE_ORDER:
363 ws = self.create_sheet(cn_key) 357 res = license_summary.get(classify)
364 for bl in license_summary.get(en_key, []): 358 if res is None:
359 continue
360 ws = self.create_sheet(name)
361 for bl in res:
365 for bl_field in bl: 362 for bl_field in bl:
366 ws.append(bl_field) 363 ws.append(bl_field)
367 ws.append((None, )) 364 ws.append((None, ))
368 365
369 def rebuild(self, bs_summary, license_summary): 366 def rebuild(self, bs_summary, license_summary):
370 self.bs_rebuild(bs_summary) 367 self.bs_rebuild(bs_summary)
371 # self.license_rebuild(license_summary) 368 self.license_rebuild(license_summary)
......
...@@ -25,7 +25,7 @@ class PDFHandler: ...@@ -25,7 +25,7 @@ class PDFHandler:
25 def __init__(self, path, img_dir_path): 25 def __init__(self, path, img_dir_path):
26 self.path = path 26 self.path = path
27 self.img_dir_path = img_dir_path 27 self.img_dir_path = img_dir_path
28 self.img_info_list = [] 28 self.img_path_list = []
29 self.xref_set = set() 29 self.xref_set = set()
30 30
31 def get_img_save_path(self, pno, img_index=0, ext='png'): 31 def get_img_save_path(self, pno, img_index=0, ext='png'):
...@@ -38,7 +38,7 @@ class PDFHandler: ...@@ -38,7 +38,7 @@ class PDFHandler:
38 pm = page.getPixmap(matrix=trans_2, alpha=False) 38 pm = page.getPixmap(matrix=trans_2, alpha=False)
39 img_save_path = self.get_img_save_path(page.number) 39 img_save_path = self.get_img_save_path(page.number)
40 pm.writePNG(img_save_path) 40 pm.writePNG(img_save_path)
41 self.img_info_list.append((img_save_path, page.number, 0)) 41 self.img_path_list.append(img_save_path)
42 42
43 @staticmethod 43 @staticmethod
44 def getimage(pix): 44 def getimage(pix):
...@@ -88,7 +88,7 @@ class PDFHandler: ...@@ -88,7 +88,7 @@ class PDFHandler:
88 with open(img_save_path, "wb") as f: 88 with open(img_save_path, "wb") as f:
89 f.write(img_data) 89 f.write(img_data)
90 self.xref_set.add(xref) 90 self.xref_set.add(xref)
91 self.img_info_list.append((img_save_path, pno, img_index)) 91 self.img_path_list.append(img_save_path)
92 92
93 @staticmethod 93 @staticmethod
94 def split_il(il): 94 def split_il(il):
...@@ -179,7 +179,7 @@ class PDFHandler: ...@@ -179,7 +179,7 @@ class PDFHandler:
179 img_save_path = self.get_img_save_path(pno, img_index, im_list[0][2]) 179 img_save_path = self.get_img_save_path(pno, img_index, im_list[0][2])
180 new_img.save(img_save_path) 180 new_img.save(img_save_path)
181 page_to_png = False 181 page_to_png = False
182 self.img_info_list.append((img_save_path, pno, img_index)) 182 self.img_path_list.append(img_save_path)
183 183
184 # 3.3 碎图分组大于2、全过滤、含特殊filter,特殊处理:整个页面保存为png图片 184 # 3.3 碎图分组大于2、全过滤、含特殊filter,特殊处理:整个页面保存为png图片
185 if page_to_png: 185 if page_to_png:
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!