afc ht part2
Showing
3 changed files
with
80 additions
and
0 deletions
| ... | @@ -1598,6 +1598,31 @@ HMH_COMPARE_LOGIC = { | ... | @@ -1598,6 +1598,31 @@ HMH_COMPARE_LOGIC = { |
| 1598 | '签字': ('借款人签字/盖章', 'se_common_compare', {}, '抵押登记豁免函签字需人工核查'), | 1598 | '签字': ('借款人签字/盖章', 'se_common_compare', {}, '抵押登记豁免函签字需人工核查'), |
| 1599 | } | 1599 | } |
| 1600 | 1600 | ||
| 1601 | SE_AFC_CON_FIELD = ['合同编号-每页', '所购车辆价格-小写-重要条款', '车架号-重要条款', '贷款本金金额-重要条款', '贷款期限-重要条款', | ||
| 1602 | '车辆贷款本金金额-重要条款', '附加产品融资贷款本金总额-重要条款', '所购车辆价格', '车架号', '经销商', | ||
| 1603 | '贷款本金金额', '车辆贷款本金金额', '附加产品融资贷款本金总额', '贷款期限', '还款账号', '户名', '开户行', | ||
| 1604 | '还款计划表', '项目1', '用途总金额', '贷款本金', '附加产品融资贷款本金总金额', '购置税校验'] | ||
| 1605 | |||
| 1606 | HT_COMPARE_LOGIC = { | ||
| 1607 | '合同编号-每页': ('合同编号-每页', 'se_list_compare', {}, '合同编号与系统不一致'), | ||
| 1608 | '所购车辆价格-小写-重要条款': ('所购车辆价格-小写-重要条款', 'se_amount_str_compare', {}, '合同首页中车辆价格与系统不一致'), | ||
| 1609 | '车架号-重要条款': ('车架号-重要条款', 'se_common_compare', {}, '合同首页中车架号与系统不一致'), | ||
| 1610 | '贷款本金金额-重要条款': ('贷款本金金额-重要条款', 'se_amount_str_compare', {}, '合同首页中贷款本金与系统不一致'), | ||
| 1611 | '贷款期限-重要条款': ('贷款期限-重要条款', 'se_common_compare', {}, '合同首页中贷款期限与系统不一致'), | ||
| 1612 | '车辆贷款本金金额-重要条款': ('车辆贷款本金金额-重要条款', 'se_amount_str_compare', {}, '车辆贷款本金金额-重要条款'), | ||
| 1613 | '附加产品融资贷款本金总额-重要条款': ('附加产品融资贷款本金总额-重要条款', 'se_amount_str_compare', {}, '合同首页中附加产品融资金额与系统不一致'), | ||
| 1614 | '所购车辆价格': ('所购车辆价格', 'se_amount_str_compare', {}, '主合同页中车辆价格与系统不一致'), | ||
| 1615 | '车架号': ('车架号', 'se_common_compare', {}, '主合同页中车架号与系统不一致'), | ||
| 1616 | '经销商': ('经销商', 'se_common_compare', {}, '主合同页中经销商与系统不一致'), | ||
| 1617 | '贷款本金金额': ('贷款本金金额', 'se_amount_str_compare', {}, '主合同页中贷款本金金额与系统不一致'), | ||
| 1618 | '车辆贷款本金金额': ('车辆贷款本金金额', 'se_amount_str_compare', {}, '主合同页中车辆贷款本金金额与系统不一致'), | ||
| 1619 | '附加产品融资贷款本金总额': ('附加产品融资贷款本金总额', 'se_amount_str_compare', {}, '主合同页中附加产品融资贷款本金总额与系统不一致'), | ||
| 1620 | '贷款期限': ('贷款期限', 'se_common_compare', {}, '主合同页中贷款期限与系统不一致'), | ||
| 1621 | '还款账号': ('还款账号', 'se_common_compare', {}, '主合同页中还款账号与系统不一致'), | ||
| 1622 | '户名': ('户名', 'se_common_compare', {}, '主合同页中户名与系统不一致'), | ||
| 1623 | '开户行': ('开户行', 'se_both_contain_compare', {}, '主合同页中开户行与系统不一致'), | ||
| 1624 | } | ||
| 1625 | |||
| 1601 | # MVC_OCR_FIELD = 'mvc_ocr' | 1626 | # MVC_OCR_FIELD = 'mvc_ocr' |
| 1602 | 1627 | ||
| 1603 | SE_DETECT_CARD = [UCI_EN, JYPZ_EN, HMH_EN, DDA_EN] | 1628 | SE_DETECT_CARD = [UCI_EN, JYPZ_EN, HMH_EN, DDA_EN] |
| ... | @@ -1616,6 +1641,7 @@ SE_COMPARE_FIELD = { | ... | @@ -1616,6 +1641,7 @@ SE_COMPARE_FIELD = { |
| 1616 | DDA_EN: (DDA_OCR_FIELD, DDA_COMPARE_LOGIC, False), | 1641 | DDA_EN: (DDA_OCR_FIELD, DDA_COMPARE_LOGIC, False), |
| 1617 | HMH_EN: (HMH_OCR_FIELD, HMH_COMPARE_LOGIC, False), | 1642 | HMH_EN: (HMH_OCR_FIELD, HMH_COMPARE_LOGIC, False), |
| 1618 | JYPZ_EN: (JYPZ_OCR_FIELD, JYPZ_COMPARE_LOGIC, False), | 1643 | JYPZ_EN: (JYPZ_OCR_FIELD, JYPZ_COMPARE_LOGIC, False), |
| 1644 | AFC_CONTRACT_EN: (HT_FIELD, HT_COMPARE_LOGIC, False) | ||
| 1619 | } | 1645 | } |
| 1620 | 1646 | ||
| 1621 | 1647 | ... | ... |
| ... | @@ -1672,6 +1672,41 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -1672,6 +1672,41 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
| 1672 | return result_field_list, no_ocr_result, field_img_path_dict | 1672 | return result_field_list, no_ocr_result, field_img_path_dict |
| 1673 | 1673 | ||
| 1674 | 1674 | ||
| 1675 | def se_afc_contract_compare(license_en, ocr_res_dict, strip_list): | ||
| 1676 | ocr_field, compare_logic, _ = consts.SE_COMPARE_FIELD[license_en] | ||
| 1677 | ocr_res_str = ocr_res_dict.get(ocr_field) | ||
| 1678 | |||
| 1679 | result_field_list = [] | ||
| 1680 | field_img_path_dict = dict() | ||
| 1681 | |||
| 1682 | if ocr_res_str is not None: | ||
| 1683 | ocr_res_list = json.loads(ocr_res_str) | ||
| 1684 | ocr_res = ocr_res_list.pop() | ||
| 1685 | |||
| 1686 | for name, value in strip_list: | ||
| 1687 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) | ||
| 1688 | |||
| 1689 | if isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list): | ||
| 1690 | result = getattr(cp, compare_logic[name][1])(value, ocr_str_or_list, **compare_logic[name][2]) | ||
| 1691 | if isinstance(ocr_str_or_list, list): | ||
| 1692 | ocr_str = '、'.join(ocr_str_or_list) | ||
| 1693 | else: | ||
| 1694 | ocr_str = ocr_str_or_list | ||
| 1695 | else: | ||
| 1696 | result = consts.RESULT_N | ||
| 1697 | ocr_str = empty_str | ||
| 1698 | |||
| 1699 | img_path = empty_str | ||
| 1700 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value | ||
| 1701 | result_field_list.append((name, value, result, ocr_str, img_path, error_type, compare_logic[name][3])) | ||
| 1702 | else: | ||
| 1703 | for name, value in strip_list: | ||
| 1704 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value, | ||
| 1705 | '{0}未找到'.format(license_en))) | ||
| 1706 | |||
| 1707 | return result_field_list, field_img_path_dict | ||
| 1708 | |||
| 1709 | |||
| 1675 | def se_mvc34_compare(license_en, ocr_res_dict, field_list): | 1710 | def se_mvc34_compare(license_en, ocr_res_dict, field_list): |
| 1676 | ocr_field, compare_logic, _ = consts.SE_COMPARE_FIELD[license_en] | 1711 | ocr_field, compare_logic, _ = consts.SE_COMPARE_FIELD[license_en] |
| 1677 | ocr_res_str = ocr_res_dict.get(ocr_field) | 1712 | ocr_res_str = ocr_res_dict.get(ocr_field) |
| ... | @@ -1850,6 +1885,8 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -1850,6 +1885,8 @@ def se_compare_process(compare_info, ocr_res_dict): |
| 1850 | failure_field = [] | 1885 | failure_field = [] |
| 1851 | if license_en == consts.MVC34_EN: | 1886 | if license_en == consts.MVC34_EN: |
| 1852 | result_field_list, field_img_path_dict = se_mvc34_compare(license_en, ocr_res_dict, strip_list) | 1887 | result_field_list, field_img_path_dict = se_mvc34_compare(license_en, ocr_res_dict, strip_list) |
| 1888 | elif license_en == consts.AFC_CONTRACT_EN: | ||
| 1889 | result_field_list, field_img_path_dict = se_afc_contract_compare(license_en, ocr_res_dict, strip_list) | ||
| 1853 | else: | 1890 | else: |
| 1854 | result_field_list, _, field_img_path_dict = se_compare_license(license_en, ocr_res_dict, strip_list) | 1891 | result_field_list, _, field_img_path_dict = se_compare_license(license_en, ocr_res_dict, strip_list) |
| 1855 | for name, value, result, ocr_str, img_path, error_type, cn_reason in result_field_list: | 1892 | for name, value, result, ocr_str, img_path, error_type, cn_reason in result_field_list: | ... | ... |
| ... | @@ -153,6 +153,15 @@ class Comparison: | ... | @@ -153,6 +153,15 @@ class Comparison: |
| 153 | 153 | ||
| 154 | return self.build_res(input_str == compare_str), compare_str | 154 | return self.build_res(input_str == compare_str), compare_str |
| 155 | 155 | ||
| 156 | def se_list_compare(self, input_str, ocr_str_or_list, **kwargs): | ||
| 157 | if isinstance(ocr_str_or_list, list): | ||
| 158 | for item in ocr_str_or_list: | ||
| 159 | if item != input_str: | ||
| 160 | return self.RESULT_N | ||
| 161 | return self.RESULT_Y | ||
| 162 | else: | ||
| 163 | return self.RESULT_N | ||
| 164 | |||
| 156 | def se_name_compare(self, input_str, ocr_str, **kwargs): | 165 | def se_name_compare(self, input_str, ocr_str, **kwargs): |
| 157 | if kwargs.get('is_passport'): | 166 | if kwargs.get('is_passport'): |
| 158 | input_tmp = input_str.upper().replace(' ', '') | 167 | input_tmp = input_str.upper().replace(' ', '') |
| ... | @@ -280,6 +289,14 @@ class Comparison: | ... | @@ -280,6 +289,14 @@ class Comparison: |
| 280 | else: | 289 | else: |
| 281 | return self.RESULT_Y | 290 | return self.RESULT_Y |
| 282 | 291 | ||
| 292 | def se_amount_str_compare(self, input_str, ocr_str, **kwargs): | ||
| 293 | if input_str == ocr_str: | ||
| 294 | return self.RESULT_Y | ||
| 295 | else: | ||
| 296 | ocr_tmp = ocr_str.replace('元', '').replace(',', '') | ||
| 297 | input_tmp = input_str.replace('元', '').replace(',', '') | ||
| 298 | return self.build_res(ocr_tmp == input_tmp) | ||
| 299 | |||
| 283 | def se_amount_compare(self, input_str, ocr_str, **kwargs): | 300 | def se_amount_compare(self, input_str, ocr_str, **kwargs): |
| 284 | if input_str == ocr_str: | 301 | if input_str == ocr_str: |
| 285 | return self.RESULT_Y | 302 | return self.RESULT_Y | ... | ... |
-
Please register or sign in to post a comment