fix bs compare
Showing
3 changed files
with
123 additions
and
34 deletions
| ... | @@ -1410,7 +1410,7 @@ SE_STAMP_VALUE = '有' | ... | @@ -1410,7 +1410,7 @@ SE_STAMP_VALUE = '有' | 
| 1410 | SE_LAYOUT_VALUE = '旧版-旧打印、新版-新打印' | 1410 | SE_LAYOUT_VALUE = '旧版-旧打印、新版-新打印' | 
| 1411 | SE_GB_NEW_FIELD = ['vinNo'] | 1411 | SE_GB_NEW_FIELD = ['vinNo'] | 
| 1412 | SE_GB_USED_FIELD = ['customerName', 'idNum', 'date'] | 1412 | SE_GB_USED_FIELD = ['customerName', 'idNum', 'date'] | 
| 1413 | SE_BS_FIELD = ['户名', '打印日期', '流水日期', '(担保人)户名', '(担保人)打印日期', '(担保人)流水日期'] | 1413 | SE_BS_FIELD = ['户名', '打印日期', '流水日期', '(担保人1)户名', '(担保人1)打印日期', '(担保人1)流水日期', '(担保人2)户名', '(担保人2)打印日期', '(担保人2)流水日期'] | 
| 1414 | SE_HMH_FIELD = ['借款人/承租人姓名', '借款人/承租人证件号', '申请号', '渠道', '签字'] | 1414 | SE_HMH_FIELD = ['借款人/承租人姓名', '借款人/承租人证件号', '申请号', '渠道', '签字'] | 
| 1415 | SE_BD_FIELD = ['被保险人姓名', '被保险人证件号码', '车架号', '机动车损失保险金额', '第三者责任保险金额', '绝对免赔率', '保险起始日期', '保险截止日期', '保单章', '第一受益人', '保险费合计'] | 1415 | SE_BD_FIELD = ['被保险人姓名', '被保险人证件号码', '车架号', '机动车损失保险金额', '第三者责任保险金额', '绝对免赔率', '保险起始日期', '保险截止日期', '保单章', '第一受益人', '保险费合计'] | 
| 1416 | JDMPV_VALUE = ['-', '--', '0%', '0.00', '/', '0'] | 1416 | JDMPV_VALUE = ['-', '--', '0%', '0.00', '/', '0'] | 
| ... | @@ -1781,11 +1781,14 @@ BD_COMPARE_LOGIC = { | ... | @@ -1781,11 +1781,14 @@ BD_COMPARE_LOGIC = { | 
| 1781 | 1781 | ||
| 1782 | BS_COMPARE_LOGIC = { | 1782 | BS_COMPARE_LOGIC = { | 
| 1783 | '户名': ('role', 'se_one_compare', {}, '主共借人未提供银行流水'), | 1783 | '户名': ('role', 'se_one_compare', {}, '主共借人未提供银行流水'), | 
| 1784 | '(担保人)户名': ('role', 'se_one_compare', {}, '担保人未提供银行流水'), | 1784 | '(担保人1)户名': ('role', 'se_name_compare', {}, '担保人1未提供银行流水'), | 
| 1785 | '(担保人2)户名': ('role', 'se_name_compare', {}, '担保人2未提供银行流水'), | ||
| 1785 | '打印日期': ('print_time', 'se_bs_print_date_compare', {}, '主共借人银行流水打印日期超过15天'), | 1786 | '打印日期': ('print_time', 'se_bs_print_date_compare', {}, '主共借人银行流水打印日期超过15天'), | 
| 1786 | '(担保人)打印日期': ('print_time', 'se_bs_print_date_compare', {}, '担保人银行流水打印日期超过15天'), | 1787 | '(担保人1)打印日期': ('print_time', 'se_bs_print_date_compare', {}, '担保人1银行流水打印日期超过15天'), | 
| 1788 | '(担保人2)打印日期': ('print_time', 'se_bs_print_date_compare', {}, '担保人2银行流水打印日期超过15天'), | ||
| 1787 | '流水日期': ('date', 'se_bs_date_compare', {}, '主共借人银行流水日期不满足3个月'), | 1789 | '流水日期': ('date', 'se_bs_date_compare', {}, '主共借人银行流水日期不满足3个月'), | 
| 1788 | '(担保人)流水日期': ('date', 'se_bs_date_compare', {}, '担保人银行流水日期不满足3个月'), | 1790 | '(担保人1)流水日期': ('date', 'se_bs_date_compare', {}, '担保人1银行流水日期不满足3个月'), | 
| 1791 | '(担保人2)流水日期': ('date', 'se_bs_date_compare', {}, '担保人2银行流水日期不满足3个月'), | ||
| 1789 | } | 1792 | } | 
| 1790 | 1793 | ||
| 1791 | SPECIAL_REASON = '主共借人未提供银行流水,含担保人需人工查看直系亲属关系' | 1794 | SPECIAL_REASON = '主共借人未提供银行流水,含担保人需人工查看直系亲属关系' | ... | ... | 
| ... | @@ -312,21 +312,21 @@ class BSWorkbook(Workbook): | ... | @@ -312,21 +312,21 @@ class BSWorkbook(Workbook): | 
| 312 | (ws.title, idx_list[i] + min_row, idx_list[i + 1] + min_row - 1, day_mean)) | 312 | (ws.title, idx_list[i] + min_row, idx_list[i + 1] + min_row - 1, day_mean)) | 
| 313 | 313 | ||
| 314 | def build_metadata_rows(self, confidence, code, verify_list, print_time, start_date, end_date, res_count_tuple, is_verify_classify): | 314 | def build_metadata_rows(self, confidence, code, verify_list, print_time, start_date, end_date, res_count_tuple, is_verify_classify): | 
| 315 | metadata_rows = [ | 315 | metadata_rows = [('流水识别置信度', confidence)] | 
| 316 | ('流水识别置信度', confidence), | ||
| 317 | ('图片总数', res_count_tuple[0]), | ||
| 318 | ('识别成功', res_count_tuple[1]), | ||
| 319 | self.blank_row, | ||
| 320 | ] | ||
| 321 | |||
| 322 | verify_highlight_row = [] | ||
| 323 | if is_verify_classify: | 316 | if is_verify_classify: | 
| 324 | verify_res = '疑似伪造' if len(verify_list) > 0 else '正常' | 317 | verify_res = '疑似伪造' if len(verify_list) > 0 else '正常' | 
| 318 | else: | ||
| 319 | verify_res = '' | ||
| 325 | metadata_rows.append(('流水检测结果', verify_res)) | 320 | metadata_rows.append(('流水检测结果', verify_res)) | 
| 326 | if len(verify_list) > 0: | 321 | metadata_rows.append(('图片总数', res_count_tuple[0])) | 
| 322 | metadata_rows.append(('识别成功', res_count_tuple[1])) | ||
| 323 | metadata_rows.append(self.blank_row) | ||
| 324 | |||
| 325 | verify_highlight_row = [] | ||
| 326 | if is_verify_classify and len(verify_list) > 0: | ||
| 327 | metadata_rows.append(self.verify_header) | 327 | metadata_rows.append(self.verify_header) | 
| 328 | metadata_rows.extend(verify_list) | 328 | metadata_rows.extend(verify_list) | 
| 329 | for r in range(5, len(metadata_rows)+1): | 329 | for r in range(6, len(metadata_rows)+1): | 
| 330 | verify_highlight_row.append(r) | 330 | verify_highlight_row.append(r) | 
| 331 | 331 | ||
| 332 | metadata_rows.append(self.blank_row) | 332 | metadata_rows.append(self.blank_row) | 
| ... | @@ -355,14 +355,18 @@ class BSWorkbook(Workbook): | ... | @@ -355,14 +355,18 @@ class BSWorkbook(Workbook): | 
| 355 | ms = self.create_sheet('{0}{1}({2})'.format(self.meta_sheet_title, role_name, card)) | 355 | ms = self.create_sheet('{0}{1}({2})'.format(self.meta_sheet_title, role_name, card)) | 
| 356 | for row in metadata_rows: | 356 | for row in metadata_rows: | 
| 357 | ms.append(row) | 357 | ms.append(row) | 
| 358 | |||
| 359 | if len(verify_highlight_row) > 0: | ||
| 360 | for cell in ms[2]: | ||
| 361 | cell.fill = self.amount_fill | ||
| 358 | for row in verify_highlight_row: | 362 | for row in verify_highlight_row: | 
| 359 | for cell in ms[row]: | 363 | for cell in ms[row]: | 
| 360 | cell.fill = self.amount_fill | 364 | cell.fill = self.amount_fill | 
| 361 | if res_count_tuple[0] != res_count_tuple[1]: | 365 | if res_count_tuple[0] != res_count_tuple[1]: | 
| 362 | for cell in ms[2]: | ||
| 363 | cell.fill = self.amount_fill | ||
| 364 | for cell in ms[3]: | 366 | for cell in ms[3]: | 
| 365 | cell.fill = self.amount_fill | 367 | cell.fill = self.amount_fill | 
| 368 | for cell in ms[4]: | ||
| 369 | cell.fill = self.amount_fill | ||
| 366 | return ms | 370 | return ms | 
| 367 | 371 | ||
| 368 | @staticmethod | 372 | @staticmethod | ... | ... | 
| ... | @@ -880,7 +880,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -880,7 +880,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | 
| 880 | company_info_list = [] | 880 | company_info_list = [] | 
| 881 | 881 | ||
| 882 | # 个人信息证件--------------------------------------------------------------------------------------------------------- | 882 | # 个人信息证件--------------------------------------------------------------------------------------------------------- | 
| 883 | province = cms_info.get('province', '') | 883 | # province = cms_info.get('province', '') | 
| 884 | for individual_info in cms_info.get('applicantInformation', []): | 884 | for individual_info in cms_info.get('applicantInformation', []): | 
| 885 | all_id_num = [] | 885 | all_id_num = [] | 
| 886 | 886 | ||
| ... | @@ -1082,12 +1082,19 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1082,12 +1082,19 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | 
| 1082 | dbr_bs_role_list = [] | 1082 | dbr_bs_role_list = [] | 
| 1083 | for dbr_bs_role, _, _ in main_role_info.get(consts.APPLICANT_TYPE_ORDER[2], []): | 1083 | for dbr_bs_role, _, _ in main_role_info.get(consts.APPLICANT_TYPE_ORDER[2], []): | 
| 1084 | dbr_bs_role_list.append(dbr_bs_role) | 1084 | dbr_bs_role_list.append(dbr_bs_role) | 
| 1085 | if len(dbr_bs_role_list) > 0: | 1085 | |
| 1086 | if len(dbr_bs_role_list) >= 1: | ||
| 1086 | bs_field_input.extend([ | 1087 | bs_field_input.extend([ | 
| 1087 | (consts.SE_BS_FIELD[3], dbr_bs_role_list), | 1088 | (consts.SE_BS_FIELD[3], dbr_bs_role_list[0]), | 
| 1088 | (consts.SE_BS_FIELD[4], first_submission_date), | 1089 | (consts.SE_BS_FIELD[4], first_submission_date), | 
| 1089 | (consts.SE_BS_FIELD[5], '90天'), | 1090 | (consts.SE_BS_FIELD[5], '90天'), | 
| 1090 | ]) | 1091 | ]) | 
| 1092 | if len(dbr_bs_role_list) >= 2: | ||
| 1093 | bs_field_input.extend([ | ||
| 1094 | (consts.SE_BS_FIELD[6], dbr_bs_role_list[1]), | ||
| 1095 | (consts.SE_BS_FIELD[7], first_submission_date), | ||
| 1096 | (consts.SE_BS_FIELD[8], '90天'), | ||
| 1097 | ]) | ||
| 1091 | bs_info[consts.BS_EN] = bs_field_input | 1098 | bs_info[consts.BS_EN] = bs_field_input | 
| 1092 | compare_info['Bank Statement'] = bs_info | 1099 | compare_info['Bank Statement'] = bs_info | 
| 1093 | 1100 | ||
| ... | @@ -1522,7 +1529,8 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list): | ... | @@ -1522,7 +1529,8 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list): | 
| 1522 | 1529 | ||
| 1523 | if ocr_res_str is not None: | 1530 | if ocr_res_str is not None: | 
| 1524 | pre_field_list = strip_list[:3] | 1531 | pre_field_list = strip_list[:3] | 
| 1525 | suf_field_list = strip_list[3:] | 1532 | dbr1_field_list = strip_list[3:6] | 
| 1533 | dbr2_field_list = strip_list[6:] | ||
| 1526 | 1534 | ||
| 1527 | ocr_res_list = json.loads(ocr_res_str) | 1535 | ocr_res_list = json.loads(ocr_res_str) | 
| 1528 | # length = len(ocr_res_list) | 1536 | # length = len(ocr_res_list) | 
| ... | @@ -1558,14 +1566,46 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list): | ... | @@ -1558,14 +1566,46 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list): | 
| 1558 | max_correct_count = correct_count | 1566 | max_correct_count = correct_count | 
| 1559 | pre_best_res = pre_tmp_res_part | 1567 | pre_best_res = pre_tmp_res_part | 
| 1560 | 1568 | ||
| 1561 | # 担保人 | 1569 | # 担保人1 | 
| 1562 | suf_best_res = {} | 1570 | dbr1_best_res = {} | 
| 1563 | if len(suf_field_list) > 0: | 1571 | if len(dbr1_field_list) > 0: | 
| 1572 | max_correct_count = 0 | ||
| 1573 | for ocr_res in ocr_res_list: | ||
| 1574 | correct_count = 0 | ||
| 1575 | dbr1_tmp_res_part = {} | ||
| 1576 | for idx, (name, value) in enumerate(dbr1_field_list): | ||
| 1577 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) | ||
| 1578 | if isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list): | ||
| 1579 | result = getattr(cp, compare_logic[name][1])(value, ocr_str_or_list, **compare_logic[name][2]) | ||
| 1580 | if isinstance(ocr_str_or_list, list): | ||
| 1581 | ocr_str = json.dumps(ocr_str_or_list, ensure_ascii=False) | ||
| 1582 | else: | ||
| 1583 | ocr_str = ocr_str_or_list | ||
| 1584 | reason = compare_logic[name][3] | ||
| 1585 | else: | ||
| 1586 | result = consts.RESULT_N | ||
| 1587 | ocr_str = empty_str | ||
| 1588 | reason = compare_logic[name][3] | ||
| 1589 | |||
| 1590 | if idx == 0 and result == consts.RESULT_N: | ||
| 1591 | break | ||
| 1592 | |||
| 1593 | if result == consts.RESULT_Y: | ||
| 1594 | correct_count += 1 | ||
| 1595 | dbr1_tmp_res_part[name] = (result, ocr_str, reason) | ||
| 1596 | |||
| 1597 | if correct_count > 0 and correct_count >= max_correct_count: | ||
| 1598 | max_correct_count = correct_count | ||
| 1599 | dbr1_best_res = dbr1_tmp_res_part | ||
| 1600 | |||
| 1601 | # 担保人2 | ||
| 1602 | dbr2_best_res = {} | ||
| 1603 | if len(dbr1_field_list) > 0: | ||
| 1564 | max_correct_count = 0 | 1604 | max_correct_count = 0 | 
| 1565 | for ocr_res in ocr_res_list: | 1605 | for ocr_res in ocr_res_list: | 
| 1566 | correct_count = 0 | 1606 | correct_count = 0 | 
| 1567 | suf_tmp_res_part = {} | 1607 | dbr2_tmp_res_part = {} | 
| 1568 | for idx, (name, value) in enumerate(suf_field_list): | 1608 | for idx, (name, value) in enumerate(dbr2_field_list): | 
| 1569 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) | 1609 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) | 
| 1570 | if isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list): | 1610 | if isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list): | 
| 1571 | result = getattr(cp, compare_logic[name][1])(value, ocr_str_or_list, **compare_logic[name][2]) | 1611 | result = getattr(cp, compare_logic[name][1])(value, ocr_str_or_list, **compare_logic[name][2]) | 
| ... | @@ -1584,11 +1624,30 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list): | ... | @@ -1584,11 +1624,30 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list): | 
| 1584 | 1624 | ||
| 1585 | if result == consts.RESULT_Y: | 1625 | if result == consts.RESULT_Y: | 
| 1586 | correct_count += 1 | 1626 | correct_count += 1 | 
| 1587 | suf_tmp_res_part[name] = (result, ocr_str, reason) | 1627 | dbr2_tmp_res_part[name] = (result, ocr_str, reason) | 
| 1588 | 1628 | ||
| 1589 | if correct_count > 0 and correct_count >= max_correct_count: | 1629 | if correct_count > 0 and correct_count >= max_correct_count: | 
| 1590 | max_correct_count = correct_count | 1630 | max_correct_count = correct_count | 
| 1591 | suf_best_res = suf_tmp_res_part | 1631 | dbr2_best_res = dbr2_tmp_res_part | 
| 1632 | |||
| 1633 | dbr_ok = False | ||
| 1634 | # 有担保人 | ||
| 1635 | if len(dbr1_field_list) > 0: | ||
| 1636 | # 有担保人12 | ||
| 1637 | if len(dbr2_field_list) > 0: | ||
| 1638 | if len(dbr1_best_res) > 0 and len(dbr2_best_res) > 0: | ||
| 1639 | dbr_ok = True | ||
| 1640 | # 有担保人1 | ||
| 1641 | else: | ||
| 1642 | if len(dbr1_best_res) > 0: | ||
| 1643 | dbr_ok = True | ||
| 1644 | # 无担保人 | ||
| 1645 | # else: | ||
| 1646 | # pass | ||
| 1647 | |||
| 1648 | best_res_empty = False | ||
| 1649 | if len(pre_best_res) == 0 and len(dbr1_best_res) == 0 and len(dbr2_best_res) == 0: | ||
| 1650 | best_res_empty = True | ||
| 1592 | 1651 | ||
| 1593 | for name, value in pre_field_list: | 1652 | for name, value in pre_field_list: | 
| 1594 | if len(pre_best_res) > 0: | 1653 | if len(pre_best_res) > 0: | 
| ... | @@ -1596,7 +1655,9 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list): | ... | @@ -1596,7 +1655,9 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list): | 
| 1596 | else: | 1655 | else: | 
| 1597 | result = consts.RESULT_N | 1656 | result = consts.RESULT_N | 
| 1598 | ocr_str = empty_str | 1657 | ocr_str = empty_str | 
| 1599 | if len(suf_field_list) > 0 and len(suf_best_res) > 0: | 1658 | if best_res_empty: | 
| 1659 | reason = consts.SPECIAL_REASON_3 | ||
| 1660 | elif dbr_ok: # 有担保人且担保人都提供了流水 | ||
| 1600 | reason = consts.SPECIAL_REASON | 1661 | reason = consts.SPECIAL_REASON | 
| 1601 | else: | 1662 | else: | 
| 1602 | reason = compare_logic[pre_field_list[0][0]][3] | 1663 | reason = compare_logic[pre_field_list[0][0]][3] | 
| ... | @@ -1606,17 +1667,38 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list): | ... | @@ -1606,17 +1667,38 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list): | 
| 1606 | value = json.dumps(value, ensure_ascii=False) | 1667 | value = json.dumps(value, ensure_ascii=False) | 
| 1607 | result_field_list.append((name, value, result, ocr_str, img_path, error_type, reason)) | 1668 | result_field_list.append((name, value, result, ocr_str, img_path, error_type, reason)) | 
| 1608 | 1669 | ||
| 1609 | if len(suf_field_list) > 0: | 1670 | if len(dbr1_field_list) > 0: | 
| 1610 | for name, value in suf_field_list: | 1671 | for name, value in dbr1_field_list: | 
| 1611 | if len(suf_best_res) > 0: | 1672 | if len(dbr1_best_res) > 0: | 
| 1612 | result, ocr_str, reason = suf_best_res[name] | 1673 | result, ocr_str, reason = dbr1_best_res[name] | 
| 1613 | else: | 1674 | else: | 
| 1614 | result = consts.RESULT_N | 1675 | result = consts.RESULT_N | 
| 1615 | ocr_str = empty_str | 1676 | ocr_str = empty_str | 
| 1616 | if len(pre_best_res) > 0: | 1677 | if best_res_empty: | 
| 1678 | reason = consts.SPECIAL_REASON_3 | ||
| 1679 | elif len(pre_best_res) > 0: | ||
| 1680 | reason = consts.SPECIAL_REASON_2 | ||
| 1681 | else: | ||
| 1682 | reason = compare_logic[dbr1_field_list[0][0]][3] | ||
| 1683 | img_path = empty_str | ||
| 1684 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value | ||
| 1685 | if isinstance(value, list): | ||
| 1686 | value = json.dumps(value, ensure_ascii=False) | ||
| 1687 | result_field_list.append((name, value, result, ocr_str, img_path, error_type, reason)) | ||
| 1688 | |||
| 1689 | if len(dbr2_field_list) > 0: | ||
| 1690 | for name, value in dbr2_field_list: | ||
| 1691 | if len(dbr2_best_res) > 0: | ||
| 1692 | result, ocr_str, reason = dbr2_best_res[name] | ||
| 1693 | else: | ||
| 1694 | result = consts.RESULT_N | ||
| 1695 | ocr_str = empty_str | ||
| 1696 | if best_res_empty: | ||
| 1697 | reason = consts.SPECIAL_REASON_3 | ||
| 1698 | elif len(pre_best_res) > 0: | ||
| 1617 | reason = consts.SPECIAL_REASON_2 | 1699 | reason = consts.SPECIAL_REASON_2 | 
| 1618 | else: | 1700 | else: | 
| 1619 | reason = compare_logic[suf_field_list[0][0]][3] | 1701 | reason = compare_logic[dbr2_field_list[0][0]][3] | 
| 1620 | img_path = empty_str | 1702 | img_path = empty_str | 
| 1621 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value | 1703 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value | 
| 1622 | if isinstance(value, list): | 1704 | if isinstance(value, list): | ... | ... | 
- 
Please register or sign in to post a comment