role name highlight & modify amount highlight
Showing
1 changed file
with
19 additions
and
11 deletions
... | @@ -403,7 +403,7 @@ class BSWorkbook(Workbook): | ... | @@ -403,7 +403,7 @@ class BSWorkbook(Workbook): |
403 | row_value[1] = '\n'.join(append_list) | 403 | row_value[1] = '\n'.join(append_list) |
404 | return row_value | 404 | return row_value |
405 | 405 | ||
406 | def build_month_sheet(self, ms, card, month_mapping, is_reverse, statistics_header_info, max_column, classify): | 406 | def build_month_sheet(self, ms, role_name, card, month_mapping, is_reverse, statistics_header_info, max_column, classify): |
407 | summary_cell_idx = statistics_header_info.get(consts.SUMMARY_KEY) | 407 | summary_cell_idx = statistics_header_info.get(consts.SUMMARY_KEY) |
408 | date_cell_idx = statistics_header_info.get(consts.DATE_KEY) | 408 | date_cell_idx = statistics_header_info.get(consts.DATE_KEY) |
409 | amount_cell_idx = statistics_header_info.get(consts.AMOUNT_KEY) # None or src or append | 409 | amount_cell_idx = statistics_header_info.get(consts.AMOUNT_KEY) # None or src or append |
... | @@ -450,7 +450,7 @@ class BSWorkbook(Workbook): | ... | @@ -450,7 +450,7 @@ class BSWorkbook(Workbook): |
450 | 450 | ||
451 | amount_mapping = {} | 451 | amount_mapping = {} |
452 | amount_fill_row = set() | 452 | amount_fill_row = set() |
453 | loan_fill_row = set() | 453 | fill_row = set() |
454 | 454 | ||
455 | # 添加筛选 | 455 | # 添加筛选 |
456 | new_ws.auto_filter.ref = 'A1:{0}{1}'.format(get_column_letter(new_ws.max_column), new_ws.max_row) | 456 | new_ws.auto_filter.ref = 'A1:{0}{1}'.format(get_column_letter(new_ws.max_column), new_ws.max_row) |
... | @@ -475,7 +475,13 @@ class BSWorkbook(Workbook): | ... | @@ -475,7 +475,13 @@ class BSWorkbook(Workbook): |
475 | 475 | ||
476 | # 贷款关键词高亮 | 476 | # 贷款关键词高亮 |
477 | if summary_cell is not None and summary_cell_value in high_light_keyword: | 477 | if summary_cell is not None and summary_cell_value in high_light_keyword: |
478 | loan_fill_row.add(summary_cell.row) | 478 | fill_row.add(summary_cell.row) |
479 | |||
480 | # 户名高亮 | ||
481 | for cell in rows: | ||
482 | if cell.value == role_name: | ||
483 | fill_row.add(summary_cell.row) | ||
484 | break | ||
479 | 485 | ||
480 | # 3.3.余额转数值 | 486 | # 3.3.余额转数值 |
481 | over_success = False | 487 | over_success = False |
... | @@ -514,12 +520,13 @@ class BSWorkbook(Workbook): | ... | @@ -514,12 +520,13 @@ class BSWorkbook(Workbook): |
514 | amount_cell.number_format = numbers.FORMAT_NUMBER_00 | 520 | amount_cell.number_format = numbers.FORMAT_NUMBER_00 |
515 | if date_cell is not None and isinstance(date_cell_value, str): | 521 | if date_cell is not None and isinstance(date_cell_value, str): |
516 | same_amount_mapping = amount_mapping.get(date_cell_value[:10], {}) | 522 | same_amount_mapping = amount_mapping.get(date_cell_value[:10], {}) |
517 | fill_rows = same_amount_mapping.get(-amount_cell.value) | 523 | fill_rows_set = same_amount_mapping.get(-amount_cell.value, set()) |
518 | if fill_rows: | 524 | if len(fill_rows_set) > 0: |
519 | amount_fill_row.add(amount_cell.row) | 525 | amount_fill_row.add(amount_cell.row) |
520 | amount_fill_row.update(fill_rows) | 526 | amount_fill_row.add(fill_rows_set.pop()) |
521 | amount_mapping.setdefault(date_cell_value[:10], {}).setdefault( | 527 | else: |
522 | amount_cell.value, []).append(amount_cell.row) | 528 | amount_mapping.setdefault(date_cell_value[:10], {}).setdefault( |
529 | amount_cell.value, set()).add(amount_cell.row) | ||
523 | 530 | ||
524 | # 3.5.核对结果 | 531 | # 3.5.核对结果 |
525 | if amount_success and over_success and amount_cell.row > 2: | 532 | if amount_success and over_success and amount_cell.row > 2: |
... | @@ -553,7 +560,7 @@ class BSWorkbook(Workbook): | ... | @@ -553,7 +560,7 @@ class BSWorkbook(Workbook): |
553 | # if amount_cell is not None: | 560 | # if amount_cell is not None: |
554 | # amount_cell.fill = self.amount_fill | 561 | # amount_cell.fill = self.amount_fill |
555 | 562 | ||
556 | for row in loan_fill_row: | 563 | for row in fill_row: |
557 | for cell in new_ws[row]: | 564 | for cell in new_ws[row]: |
558 | cell.fill = self.amount_fill | 565 | cell.fill = self.amount_fill |
559 | 566 | ||
... | @@ -598,6 +605,7 @@ class BSWorkbook(Workbook): | ... | @@ -598,6 +605,7 @@ class BSWorkbook(Workbook): |
598 | new_card = self.get_new_card(card) | 605 | new_card = self.get_new_card(card) |
599 | # 1.原表表头收集、按照月份分割 | 606 | # 1.原表表头收集、按照月份分割 |
600 | # 1.1 总结首行信息 | 607 | # 1.1 总结首行信息 |
608 | role_name = summary.get('role', consts.UNKNOWN_ROLE) | ||
601 | classify = summary.get('classify', 0) | 609 | classify = summary.get('classify', 0) |
602 | sheet_header_info = {} | 610 | sheet_header_info = {} |
603 | header_info = {} | 611 | header_info = {} |
... | @@ -634,7 +642,7 @@ class BSWorkbook(Workbook): | ... | @@ -634,7 +642,7 @@ class BSWorkbook(Workbook): |
634 | 642 | ||
635 | # 2.元信息提取表 | 643 | # 2.元信息提取表 |
636 | confidence = self.get_confidence(max_find_count) | 644 | confidence = self.get_confidence(max_find_count) |
637 | ms = self.build_meta_sheet(summary.get('role', consts.UNKNOWN_ROLE), | 645 | ms = self.build_meta_sheet(role_name, |
638 | new_card, | 646 | new_card, |
639 | confidence, | 647 | confidence, |
640 | summary.get('code'), | 648 | summary.get('code'), |
... | @@ -648,7 +656,7 @@ class BSWorkbook(Workbook): | ... | @@ -648,7 +656,7 @@ class BSWorkbook(Workbook): |
648 | for month_list in month_mapping.values(): | 656 | for month_list in month_mapping.values(): |
649 | month_list.sort(key=lambda x: x[-1], reverse=is_reverse) | 657 | month_list.sort(key=lambda x: x[-1], reverse=is_reverse) |
650 | 658 | ||
651 | self.build_month_sheet(ms, new_card, month_mapping, is_reverse, statistics_header_info, max_column, classify) | 659 | self.build_month_sheet(ms, role_name, new_card, month_mapping, is_reverse, statistics_header_info, max_column, classify) |
652 | 660 | ||
653 | # 4.删除原表 | 661 | # 4.删除原表 |
654 | for sheet in sheets_list: | 662 | for sheet in sheets_list: | ... | ... |
-
Please register or sign in to post a comment