fix afc contract bank
Showing
3 changed files
with
42 additions
and
20 deletions
... | @@ -1484,17 +1484,17 @@ SE_HIL_CON_1_MAP = { | ... | @@ -1484,17 +1484,17 @@ SE_HIL_CON_1_MAP = { |
1484 | '承租人证件号': (1, 1, 7, '承租人-证件号码', None), | 1484 | '承租人证件号': (1, 1, 7, '承租人-证件号码', None), |
1485 | '承租人签字': (6, 6, 7, '签字页-承租人姓名', None), | 1485 | '承租人签字': (6, 6, 7, '签字页-承租人姓名', None), |
1486 | 1486 | ||
1487 | '共同承租人姓名': (1, 1, 7, '共同承租人-姓名', None), | 1487 | '共同承租人姓名': (1, 1, 7, '保证人1-姓名', None), |
1488 | '共同承租人证件号': (1, 1, 7, '共同承租人-证件号码', None), | 1488 | '共同承租人证件号': (1, 1, 7, '保证人1-证件号码', None), |
1489 | '共同承租人签字': (6, 6, 7, '签字页-共同承租人姓名', None), | 1489 | '共同承租人签字': (6, 6, 7, '签字页-保证人1姓名', None), |
1490 | 1490 | ||
1491 | '保证人姓名1': (1, 1, 7, '保证人1-姓名', None), | 1491 | '保证人姓名1': (1, 1, 7, '保证人2-姓名', None), |
1492 | '保证人证件号1': (1, 1, 7, '保证人1-证件号码', None), | 1492 | '保证人证件号1': (1, 1, 7, '保证人2-证件号码', None), |
1493 | '保证人签字1': (6, 6, 7, '签字页-保证人1姓名', None), | 1493 | '保证人签字1': (6, 6, 7, '签字页-保证人2姓名', None), |
1494 | 1494 | ||
1495 | '保证人姓名2': (1, 1, 7, '保证人2-姓名', None), | 1495 | '保证人姓名2': (1, 1, 7, '保证人3-姓名', None), |
1496 | '保证人证件号2': (1, 1, 7, '保证人2-证件号码', None), | 1496 | '保证人证件号2': (1, 1, 7, '保证人3-证件号码', None), |
1497 | '保证人签字2': (6, 6, 7, '签字页-保证人2姓名', None), | 1497 | '保证人签字2': (6, 6, 7, '签字页-保证人3姓名', None), |
1498 | } | 1498 | } |
1499 | 1499 | ||
1500 | SE_HIL_CON_2_MAP = { | 1500 | SE_HIL_CON_2_MAP = { |
... | @@ -1532,6 +1532,7 @@ SE_AFC_CON_FIELD = ['合同编号-每页', '所购车辆价格-小写-重要条 | ... | @@ -1532,6 +1532,7 @@ SE_AFC_CON_FIELD = ['合同编号-每页', '所购车辆价格-小写-重要条 |
1532 | '车辆贷款本金金额-重要条款', '附加产品融资贷款本金总额-重要条款', '所购车辆价格', '车架号', '经销商', | 1532 | '车辆贷款本金金额-重要条款', '附加产品融资贷款本金总额-重要条款', '所购车辆价格', '车架号', '经销商', |
1533 | '贷款本金金额', '车辆贷款本金金额', '附加产品融资贷款本金总额', '贷款期限', '还款账号', '户名', '开户行', | 1533 | '贷款本金金额', '车辆贷款本金金额', '附加产品融资贷款本金总额', '贷款期限', '还款账号', '户名', '开户行', |
1534 | '还款计划表', '见证人签字', '见证人日期', 'ASP项目详情-重要条款', '购置税校验', 'ASP项目详情'] | 1534 | '还款计划表', '见证人签字', '见证人日期', 'ASP项目详情-重要条款', '购置税校验', 'ASP项目详情'] |
1535 | AFC_CON_BANK_FIELD = ['还款账号', '户名', '开户行'] | ||
1535 | 1536 | ||
1536 | # '承租人姓名', '承租人证件号码', '承租人法定代表人或授权代表' | 1537 | # '承租人姓名', '承租人证件号码', '承租人法定代表人或授权代表' |
1537 | SE_HIL_CON_1_FIELD = ['合同编号-每页', '合同编号-正文', '车辆识别代码', '车辆卖方', '车辆原始销售价格', '融资成本总额', '租期', | 1538 | SE_HIL_CON_1_FIELD = ['合同编号-每页', '合同编号-正文', '车辆识别代码', '车辆卖方', '车辆原始销售价格', '融资成本总额', '租期', | ... | ... |
... | @@ -1275,7 +1275,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1275,7 +1275,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
1275 | hil_contract_2_input.append((key, empty_str)) | 1275 | hil_contract_2_input.append((key, empty_str)) |
1276 | contract_info[consts.HIL_CONTRACT_2_EN] = hil_contract_2_input | 1276 | contract_info[consts.HIL_CONTRACT_2_EN] = hil_contract_2_input |
1277 | compare_info['contract'] = contract_info | 1277 | compare_info['contract'] = contract_info |
1278 | return compare_info, cms_info.get('applicationVersion', 1) | 1278 | return compare_info, cms_info.get('applicationVersion', 1), is_gsyh |
1279 | else: | 1279 | else: |
1280 | # AFC合同----------------------------------------------------------------------------------------------------------- | 1280 | # AFC合同----------------------------------------------------------------------------------------------------------- |
1281 | vehicle_principal_str = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0')) | 1281 | vehicle_principal_str = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0')) |
... | @@ -1331,7 +1331,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1331,7 +1331,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
1331 | 1331 | ||
1332 | contract_info[consts.AFC_CONTRACT_EN] = afc_contract_input | 1332 | contract_info[consts.AFC_CONTRACT_EN] = afc_contract_input |
1333 | compare_info['contract'] = contract_info | 1333 | compare_info['contract'] = contract_info |
1334 | return compare_info, cms_info.get('applicationVersion', 1) | 1334 | return compare_info, cms_info.get('applicationVersion', 1), is_gsyh |
1335 | 1335 | ||
1336 | 1336 | ||
1337 | def get_se_compare_info(last_obj, application_entity, detect_list): | 1337 | def get_se_compare_info(last_obj, application_entity, detect_list): |
... | @@ -1507,7 +1507,7 @@ def get_se_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1507,7 +1507,7 @@ def get_se_compare_info(last_obj, application_entity, detect_list): |
1507 | other_info[consts.HMH_EN] = hmh_field_input | 1507 | other_info[consts.HMH_EN] = hmh_field_input |
1508 | compare_info['other'] = other_info | 1508 | compare_info['other'] = other_info |
1509 | 1509 | ||
1510 | return compare_info | 1510 | return compare_info, is_gsyh |
1511 | 1511 | ||
1512 | 1512 | ||
1513 | def se_bs_compare(license_en, ocr_res_dict, strip_list): | 1513 | def se_bs_compare(license_en, ocr_res_dict, strip_list): |
... | @@ -1801,7 +1801,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -1801,7 +1801,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
1801 | return result_field_list, no_ocr_result, field_img_path_dict | 1801 | return result_field_list, no_ocr_result, field_img_path_dict |
1802 | 1802 | ||
1803 | 1803 | ||
1804 | def se_contract_compare(license_en, ocr_res_dict, strip_list): | 1804 | def se_contract_compare(license_en, ocr_res_dict, strip_list, is_gsyh): |
1805 | ocr_field, compare_logic, _ = consts.SE_COMPARE_FIELD[license_en] | 1805 | ocr_field, compare_logic, _ = consts.SE_COMPARE_FIELD[license_en] |
1806 | ocr_res_str = ocr_res_dict.get(ocr_field) | 1806 | ocr_res_str = ocr_res_dict.get(ocr_field) |
1807 | 1807 | ||
... | @@ -1834,8 +1834,19 @@ def se_contract_compare(license_en, ocr_res_dict, strip_list): | ... | @@ -1834,8 +1834,19 @@ def se_contract_compare(license_en, ocr_res_dict, strip_list): |
1834 | ocr_str = empty_str | 1834 | ocr_str = empty_str |
1835 | else: | 1835 | else: |
1836 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) | 1836 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) |
1837 | if isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list): | 1837 | if ocr_str_or_list is None and license_en == consts.AFC_CONTRACT_EN \ |
1838 | result = getattr(cp, compare_logic[name][1])(value, ocr_str_or_list, **compare_logic[name][2]) | 1838 | and is_gsyh is True and name in consts.AFC_CON_BANK_FIELD: |
1839 | result = consts.RESULT_Y | ||
1840 | ocr_str = empty_str | ||
1841 | reason = compare_logic[name][3] | ||
1842 | elif isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list): | ||
1843 | if license_en == consts.AFC_CONTRACT_EN and is_gsyh is True and name in consts.AFC_CON_BANK_FIELD: | ||
1844 | update_args = {'is_gsyh': is_gsyh} | ||
1845 | for k, v in compare_logic[name][2].items(): | ||
1846 | update_args[k] = v | ||
1847 | else: | ||
1848 | update_args = compare_logic[name][2] | ||
1849 | result = getattr(cp, compare_logic[name][1])(value, ocr_str_or_list, **update_args) | ||
1839 | if isinstance(ocr_str_or_list, list): | 1850 | if isinstance(ocr_str_or_list, list): |
1840 | ocr_str = json.dumps(ocr_str_or_list, ensure_ascii=False) | 1851 | ocr_str = json.dumps(ocr_str_or_list, ensure_ascii=False) |
1841 | else: | 1852 | else: |
... | @@ -1847,6 +1858,9 @@ def se_contract_compare(license_en, ocr_res_dict, strip_list): | ... | @@ -1847,6 +1858,9 @@ def se_contract_compare(license_en, ocr_res_dict, strip_list): |
1847 | reason = compare_logic[name][3] | 1858 | reason = compare_logic[name][3] |
1848 | 1859 | ||
1849 | # img_path = empty_str | 1860 | # img_path = empty_str |
1861 | if name not in compare_logic: | ||
1862 | img_path = empty_str | ||
1863 | else: | ||
1850 | img_path = ocr_res.get(consts.IMG_PATH_KEY, {}).get(compare_logic[name][0], empty_str) if result == consts.RESULT_N else empty_str | 1864 | img_path = ocr_res.get(consts.IMG_PATH_KEY, {}).get(compare_logic[name][0], empty_str) if result == consts.RESULT_N else empty_str |
1851 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value | 1865 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value |
1852 | if isinstance(value, list): | 1866 | if isinstance(value, list): |
... | @@ -1980,7 +1994,7 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): | ... | @@ -1980,7 +1994,7 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list): |
1980 | return result_field_list, field_img_path_dict | 1994 | return result_field_list, field_img_path_dict |
1981 | 1995 | ||
1982 | 1996 | ||
1983 | def se_compare_process(compare_info, ocr_res_dict): | 1997 | def se_compare_process(compare_info, ocr_res_dict, is_gsyh): |
1984 | # individualCusInfo | 1998 | # individualCusInfo |
1985 | # corporateCusInfo | 1999 | # corporateCusInfo |
1986 | # vehicleInfo | 2000 | # vehicleInfo |
... | @@ -2057,7 +2071,7 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -2057,7 +2071,7 @@ def se_compare_process(compare_info, ocr_res_dict): |
2057 | if license_en == consts.MVC34_EN: | 2071 | if license_en == consts.MVC34_EN: |
2058 | result_field_list, field_img_path_dict = se_mvc34_compare(license_en, ocr_res_dict, strip_list) | 2072 | result_field_list, field_img_path_dict = se_mvc34_compare(license_en, ocr_res_dict, strip_list) |
2059 | elif license_en in [consts.HIL_CONTRACT_1_EN, consts.HIL_CONTRACT_2_EN, consts.HIL_CONTRACT_3_EN, consts.AFC_CONTRACT_EN]: | 2073 | elif license_en in [consts.HIL_CONTRACT_1_EN, consts.HIL_CONTRACT_2_EN, consts.HIL_CONTRACT_3_EN, consts.AFC_CONTRACT_EN]: |
2060 | result_field_list, field_img_path_dict = se_contract_compare(license_en, ocr_res_dict, strip_list) | 2074 | result_field_list, field_img_path_dict = se_contract_compare(license_en, ocr_res_dict, strip_list, is_gsyh) |
2061 | elif license_en == consts.BS_EN: | 2075 | elif license_en == consts.BS_EN: |
2062 | result_field_list, field_img_path_dict = se_bs_compare(license_en, ocr_res_dict, strip_list) | 2076 | result_field_list, field_img_path_dict = se_bs_compare(license_en, ocr_res_dict, strip_list) |
2063 | else: | 2077 | else: |
... | @@ -2135,11 +2149,12 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res | ... | @@ -2135,11 +2149,12 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res |
2135 | # if is_cms: | 2149 | # if is_cms: |
2136 | # last_obj = rebuild_compare_info(last_obj, application_id) | 2150 | # last_obj = rebuild_compare_info(last_obj, application_id) |
2137 | if is_cms: | 2151 | if is_cms: |
2138 | compare_info, application_version = get_se_cms_compare_info(last_obj, application_entity, detect_list) | 2152 | compare_info, application_version, is_gsyh = get_se_cms_compare_info( |
2153 | last_obj, application_entity, detect_list) | ||
2139 | else: | 2154 | else: |
2140 | compare_info = get_se_compare_info(last_obj, application_entity, detect_list) | 2155 | compare_info, is_gsyh = get_se_compare_info(last_obj, application_entity, detect_list) |
2141 | application_version = last_obj.application_version | 2156 | application_version = last_obj.application_version |
2142 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, cn_failure_reason_str, bs_failure_reason_str = se_compare_process(compare_info, ocr_res_dict) | 2157 | compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, cn_failure_reason_str, bs_failure_reason_str = se_compare_process(compare_info, ocr_res_dict, is_gsyh) |
2143 | compare_log.info('{0} [SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( | 2158 | compare_log.info('{0} [SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format( |
2144 | log_base, application_entity, application_id, ocr_res_id, compare_result)) | 2159 | log_base, application_entity, application_id, ocr_res_id, compare_result)) |
2145 | except Exception as e: | 2160 | except Exception as e: | ... | ... |
... | @@ -258,6 +258,9 @@ class Comparison: | ... | @@ -258,6 +258,9 @@ class Comparison: |
258 | return self.build_res(input_s == ocr_s) | 258 | return self.build_res(input_s == ocr_s) |
259 | 259 | ||
260 | def se_common_compare(self, input_str, ocr_str, **kwargs): | 260 | def se_common_compare(self, input_str, ocr_str, **kwargs): |
261 | if kwargs.get('is_gsyh', False): | ||
262 | if ocr_str == '' or ocr_str is None: | ||
263 | return self.RESULT_Y | ||
261 | if kwargs.get('remove_space', False): | 264 | if kwargs.get('remove_space', False): |
262 | input_str = input_str.replace(' ', '') | 265 | input_str = input_str.replace(' ', '') |
263 | return self.build_res(input_str == ocr_str) | 266 | return self.build_res(input_str == ocr_str) |
... | @@ -354,6 +357,9 @@ class Comparison: | ... | @@ -354,6 +357,9 @@ class Comparison: |
354 | return self.RESULT_Y | 357 | return self.RESULT_Y |
355 | 358 | ||
356 | def se_both_contain_compare(self, input_str, ocr_str, **kwargs): | 359 | def se_both_contain_compare(self, input_str, ocr_str, **kwargs): |
360 | if kwargs.get('is_gsyh', False): | ||
361 | if ocr_str == '' or ocr_str is None: | ||
362 | return self.RESULT_Y | ||
357 | if ocr_str.find(input_str) == -1 and input_str.find(ocr_str) == -1: | 363 | if ocr_str.find(input_str) == -1 and input_str.find(ocr_str) == -1: |
358 | return self.RESULT_N | 364 | return self.RESULT_N |
359 | else: | 365 | else: | ... | ... |
-
Please register or sign in to post a comment