31d69c11 by 周伟奇

fix bug

1 parent 188c4102
...@@ -902,6 +902,7 @@ NYYH_CLASSIFY = 17 ...@@ -902,6 +902,7 @@ NYYH_CLASSIFY = 17
902 MS_CLASSIFY = 21 902 MS_CLASSIFY = 21
903 MS_ERROR_COL = (5, 6) 903 MS_ERROR_COL = (5, 6)
904 WECHART_CLASSIFY = 12 904 WECHART_CLASSIFY = 12
905 ALI_WECHART_CLASSIFY = {12, 13}
905 WECHART_ERROR_COL = (1, 2) 906 WECHART_ERROR_COL = (1, 2)
906 WECHART_HEADERS_MAPPING = copy.deepcopy(HEADERS_MAPPING) 907 WECHART_HEADERS_MAPPING = copy.deepcopy(HEADERS_MAPPING)
907 WECHART_HEADERS_MAPPING.update( 908 WECHART_HEADERS_MAPPING.update(
......
...@@ -91,7 +91,7 @@ class Command(BaseCommand, LoggerMixin): ...@@ -91,7 +91,7 @@ class Command(BaseCommand, LoggerMixin):
91 else: 91 else:
92 res_list.append((pno, ino, part_idx, consts.RES_FAILED)) 92 res_list.append((pno, ino, part_idx, consts.RES_FAILED))
93 93
94 wb = BSWorkbook(set(), set(), set()) 94 wb = BSWorkbook(set(), set(), set(), set())
95 wb.simple_license_rebuild(license_summary, consts.DOC_SCHEME_LIST[0]) 95 wb.simple_license_rebuild(license_summary, consts.DOC_SCHEME_LIST[0])
96 wb.save(excel_path) 96 wb.save(excel_path)
97 except Exception as e: 97 except Exception as e:
......
...@@ -489,9 +489,10 @@ class Command(BaseCommand, LoggerMixin): ...@@ -489,9 +489,10 @@ class Command(BaseCommand, LoggerMixin):
489 salary_keyword = Keywords.objects.filter( 489 salary_keyword = Keywords.objects.filter(
490 type=KeywordsType.SALARY.value, on_off=True).values_list('keyword', flat=True) 490 type=KeywordsType.SALARY.value, on_off=True).values_list('keyword', flat=True)
491 loan_keyword = Keywords.objects.filter( 491 loan_keyword = Keywords.objects.filter(
492 type__in=[KeywordsType.LOAN.value, KeywordsType.ALI_WECHART.value], on_off=True).values_list( 492 type=KeywordsType.LOAN.value, on_off=True).values_list('keyword', flat=True)
493 'keyword', flat=True) 493 wechat_keyword = Keywords.objects.filter(
494 wb = BSWorkbook(interest_keyword, salary_keyword, loan_keyword) 494 type=KeywordsType.ALI_WECHART.value, on_off=True).values_list('keyword', flat=True)
495 wb = BSWorkbook(interest_keyword, salary_keyword, loan_keyword, wechat_keyword)
495 for img_path, res in ocr_1_res.items(): 496 for img_path, res in ocr_1_res.items():
496 pno, ino = self.parse_img_path(img_path) 497 pno, ino = self.parse_img_path(img_path)
497 part_idx = 1 498 part_idx = 1
......
...@@ -13,7 +13,7 @@ from apps.doc import consts ...@@ -13,7 +13,7 @@ from apps.doc import consts
13 13
14 class BSWorkbook(Workbook): 14 class BSWorkbook(Workbook):
15 15
16 def __init__(self, interest_keyword, salary_keyword, loan_keyword, *args, **kwargs): 16 def __init__(self, interest_keyword, salary_keyword, loan_keyword, wechat_keyword, *args, **kwargs):
17 super().__init__(*args, **kwargs) 17 super().__init__(*args, **kwargs)
18 locale.setlocale(locale.LC_NUMERIC, 'en_US.UTF-8') 18 locale.setlocale(locale.LC_NUMERIC, 'en_US.UTF-8')
19 self.meta_sheet_title = '关键信息提取和展示' 19 self.meta_sheet_title = '关键信息提取和展示'
...@@ -24,6 +24,7 @@ class BSWorkbook(Workbook): ...@@ -24,6 +24,7 @@ class BSWorkbook(Workbook):
24 self.interest_keyword = interest_keyword 24 self.interest_keyword = interest_keyword
25 self.salary_keyword = salary_keyword 25 self.salary_keyword = salary_keyword
26 self.loan_keyword = loan_keyword 26 self.loan_keyword = loan_keyword
27 self.wechat_keyword = wechat_keyword
27 self.proof_res = ('对', '错') 28 self.proof_res = ('对', '错')
28 self.loan_fill = PatternFill("solid", fgColor="00FFCC00") 29 self.loan_fill = PatternFill("solid", fgColor="00FFCC00")
29 self.amount_fill = PatternFill("solid", fgColor="00FFFF00") 30 self.amount_fill = PatternFill("solid", fgColor="00FFFF00")
...@@ -309,6 +310,7 @@ class BSWorkbook(Workbook): ...@@ -309,6 +310,7 @@ class BSWorkbook(Workbook):
309 else: # 364,92 310 else: # 364,92
310 pre_idx = period_idx 311 pre_idx = period_idx
311 res_str = '{0}.{1}'.format(res_str[:pre_idx], res_str[period_idx + 1:]) 312 res_str = '{0}.{1}'.format(res_str[:pre_idx], res_str[period_idx + 1:])
313 res_str = res_str[:period_idx].replace('.', '') + res_str[period_idx:]
312 return res_str 314 return res_str
313 315
314 @staticmethod 316 @staticmethod
...@@ -372,6 +374,10 @@ class BSWorkbook(Workbook): ...@@ -372,6 +374,10 @@ class BSWorkbook(Workbook):
372 result_idx = len(header) - 1 374 result_idx = len(header) - 1
373 375
374 tmp_ws = self.create_sheet('tmp_ws') 376 tmp_ws = self.create_sheet('tmp_ws')
377 if classify in consts.ALI_WECHART_CLASSIFY:
378 high_light_keyword = self.wechat_keyword
379 else:
380 high_light_keyword = self.loan_keyword
375 for month in sorted(month_mapping.keys()): 381 for month in sorted(month_mapping.keys()):
376 # 3.1.拷贝数据 382 # 3.1.拷贝数据
377 parts = month_mapping.get(month) 383 parts = month_mapping.get(month)
...@@ -419,7 +425,7 @@ class BSWorkbook(Workbook): ...@@ -419,7 +425,7 @@ class BSWorkbook(Workbook):
419 elif summary_cell_value in self.salary_keyword: 425 elif summary_cell_value in self.salary_keyword:
420 tmp_ws.append((summary_cell_value, date_cell_value, amount_cell_value)) 426 tmp_ws.append((summary_cell_value, date_cell_value, amount_cell_value))
421 # 贷款关键词高亮 427 # 贷款关键词高亮
422 elif summary_cell_value in self.loan_keyword: 428 elif summary_cell_value in high_light_keyword:
423 summary_cell.fill = self.amount_fill 429 summary_cell.fill = self.amount_fill
424 if amount_cell is not None: 430 if amount_cell is not None:
425 amount_cell.fill = self.amount_fill 431 amount_cell.fill = self.amount_fill
......
...@@ -456,7 +456,7 @@ afc_sql = """ ...@@ -456,7 +456,7 @@ afc_sql = """
456 """ 456 """
457 457
458 keywords_sql = """ 458 keywords_sql = """
459 INSERT INTO afc.dbo.keywords (keyword, type, update_time, create_time) VALUES 459 INSERT INTO keywords (keyword, type, update_time, create_time) VALUES
460 (N'利息', 0, N'2020-11-09 16:14:58.000', N'2020-11-09 16:14:59.000'), 460 (N'利息', 0, N'2020-11-09 16:14:58.000', N'2020-11-09 16:14:59.000'),
461 (N'结息', 0, N'2020-11-09 16:14:58.000', N'2020-11-09 16:14:59.000'), 461 (N'结息', 0, N'2020-11-09 16:14:58.000', N'2020-11-09 16:14:59.000'),
462 (N'工资', 1, N'2020-11-09 16:14:58.000', N'2020-11-09 16:14:59.000'), 462 (N'工资', 1, N'2020-11-09 16:14:58.000', N'2020-11-09 16:14:59.000'),
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!