add asp
Showing
5 changed files
with
125 additions
and
260 deletions
| ... | @@ -1438,12 +1438,15 @@ SE_AFC_CON_MAP = { | ... | @@ -1438,12 +1438,15 @@ SE_AFC_CON_MAP = { |
| 1438 | '见证人日期': (7, 8, '见证人签字', '日期'), | 1438 | '见证人日期': (7, 8, '见证人签字', '日期'), |
| 1439 | 1439 | ||
| 1440 | '还款计划表': (3, 3, '还款计划表', None), | 1440 | '还款计划表': (3, 3, '还款计划表', None), |
| 1441 | |||
| 1442 | 'ASP项目详情-重要条款': (None, 1, '附加产品融资贷款本金总金额明细', None), | ||
| 1443 | 'ASP项目详情': (None, 4, '附加产品融资贷款本金总金额明细', None), | ||
| 1441 | } | 1444 | } |
| 1442 | 1445 | ||
| 1443 | SE_AFC_CON_FIELD = ['合同编号-每页', '所购车辆价格-小写-重要条款', '车架号-重要条款', '贷款本金金额-重要条款', '贷款期限-重要条款', | 1446 | SE_AFC_CON_FIELD = ['合同编号-每页', '所购车辆价格-小写-重要条款', '车架号-重要条款', '贷款本金金额-重要条款', '贷款期限-重要条款', |
| 1444 | '车辆贷款本金金额-重要条款', '附加产品融资贷款本金总额-重要条款', '所购车辆价格', '车架号', '经销商', | 1447 | '车辆贷款本金金额-重要条款', '附加产品融资贷款本金总额-重要条款', '所购车辆价格', '车架号', '经销商', |
| 1445 | '贷款本金金额', '车辆贷款本金金额', '附加产品融资贷款本金总额', '贷款期限', '还款账号', '户名', '开户行', | 1448 | '贷款本金金额', '车辆贷款本金金额', '附加产品融资贷款本金总额', '贷款期限', '还款账号', '户名', '开户行', |
| 1446 | '还款计划表', '见证人签字', '见证人日期'] | 1449 | '还款计划表', '见证人签字', '见证人日期', 'ASP项目详情-重要条款', '购置税校验', 'ASP项目详情'] |
| 1447 | 1450 | ||
| 1448 | # '项目1', '用途总金额', '贷款本金', '附加产品融资贷款本金总金额', '购置税校验' | 1451 | # '项目1', '用途总金额', '贷款本金', '附加产品融资贷款本金总金额', '购置税校验' |
| 1449 | 1452 | ||
| ... | @@ -1470,7 +1473,10 @@ ROLE_LIST = [ | ... | @@ -1470,7 +1473,10 @@ ROLE_LIST = [ |
| 1470 | ('保证人日期2', 'Guarantor', 1, '有', False, False), | 1473 | ('保证人日期2', 'Guarantor', 1, '有', False, False), |
| 1471 | ] | 1474 | ] |
| 1472 | 1475 | ||
| 1476 | GZS_REASON_1 = '此申请有ASP产品,需人工核查' | ||
| 1477 | GZS_REASON_2 = 'ASP购置税金额小于系统金额' | ||
| 1473 | GZS_NAME = '车辆购置税' | 1478 | GZS_NAME = '车辆购置税' |
| 1479 | ASP_SUM_NAME = '附加产品融资贷款本金总金额' | ||
| 1474 | GZS_STATUS = ['Y', 'N', 'O'] | 1480 | GZS_STATUS = ['Y', 'N', 'O'] |
| 1475 | SCHEDULE_SPLIT_STR = '、' | 1481 | SCHEDULE_SPLIT_STR = '、' |
| 1476 | 1482 | ||
| ... | @@ -1668,6 +1674,9 @@ HT_COMPARE_LOGIC = { | ... | @@ -1668,6 +1674,9 @@ HT_COMPARE_LOGIC = { |
| 1668 | '见证人日期': ('见证人日期', 'se_date_contain_compare', {}, '合同见证人签字日期不符合逻辑'), | 1674 | '见证人日期': ('见证人日期', 'se_date_contain_compare', {}, '合同见证人签字日期不符合逻辑'), |
| 1669 | 1675 | ||
| 1670 | '还款计划表': ('还款计划表', 'se_schedule_compare', {}, '还款计划表与系统不一致'), | 1676 | '还款计划表': ('还款计划表', 'se_schedule_compare', {}, '还款计划表与系统不一致'), |
| 1677 | |||
| 1678 | 'ASP项目详情-重要条款': ('ASP项目详情-重要条款', 'se_asp_compare', {}, '(重要条款)ASP名称或者金额与系统不一致'), | ||
| 1679 | 'ASP项目详情': ('ASP项目详情', 'se_asp_compare', {}, 'ASP名称或者金额与系统不一致'), | ||
| 1671 | } | 1680 | } |
| 1672 | 1681 | ||
| 1673 | 1682 | ... | ... |
| ... | @@ -548,7 +548,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -548,7 +548,7 @@ class Command(BaseCommand, LoggerMixin): |
| 548 | head_fields.append(a) | 548 | head_fields.append(a) |
| 549 | else: | 549 | else: |
| 550 | head_fields = [] | 550 | head_fields = [] |
| 551 | for a, b in side_field_order: | 551 | for a, b in field_order: |
| 552 | if isinstance(b, str): | 552 | if isinstance(b, str): |
| 553 | head_fields.append(a) | 553 | head_fields.append(a) |
| 554 | row = [] | 554 | row = [] | ... | ... |
| ... | @@ -863,6 +863,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -863,6 +863,8 @@ class Command(BaseCommand, LoggerMixin): |
| 863 | for key, (pno_not_asp, pno_asp, key1, key2) in consts.SE_AFC_CON_MAP.items(): | 863 | for key, (pno_not_asp, pno_asp, key1, key2) in consts.SE_AFC_CON_MAP.items(): |
| 864 | pno = pno_asp if is_asp else pno_not_asp | 864 | pno = pno_asp if is_asp else pno_not_asp |
| 865 | if pno is None: | 865 | if pno is None: |
| 866 | if isinstance(pno_asp, int): | ||
| 867 | continue | ||
| 866 | end_idx = 9 if is_asp else 8 | 868 | end_idx = 9 if is_asp else 8 |
| 867 | for i in range(1, end_idx): | 869 | for i in range(1, end_idx): |
| 868 | res.setdefault(key, list()).append(page_info_dict.get(str(i), {}).get(key1, '')) | 870 | res.setdefault(key, list()).append(page_info_dict.get(str(i), {}).get(key1, '')) | ... | ... |
| ... | @@ -117,19 +117,6 @@ def img_process(section_img_path, section_position, section_angle): | ... | @@ -117,19 +117,6 @@ def img_process(section_img_path, section_position, section_angle): |
| 117 | return image | 117 | return image |
| 118 | 118 | ||
| 119 | 119 | ||
| 120 | # class FakePOS: | ||
| 121 | # | ||
| 122 | # def __init__(self, | ||
| 123 | # application_id, | ||
| 124 | # first_submmison_date, | ||
| 125 | # application_version, | ||
| 126 | # customer_type): | ||
| 127 | # self.application_id = application_id | ||
| 128 | # self.first_submmison_date = first_submmison_date | ||
| 129 | # self.application_version = application_version | ||
| 130 | # self.customer_type = customer_type | ||
| 131 | |||
| 132 | |||
| 133 | def name_check(ocr_res_dict, second_ocr_field, second_compare_list, second_id_num, name): | 120 | def name_check(ocr_res_dict, second_ocr_field, second_compare_list, second_id_num, name): |
| 134 | id_field = second_compare_list[1][1] | 121 | id_field = second_compare_list[1][1] |
| 135 | name_field = second_compare_list[0][1] | 122 | name_field = second_compare_list[0][1] |
| ... | @@ -146,11 +133,6 @@ def name_check(ocr_res_dict, second_ocr_field, second_compare_list, second_id_nu | ... | @@ -146,11 +133,6 @@ def name_check(ocr_res_dict, second_ocr_field, second_compare_list, second_id_nu |
| 146 | 133 | ||
| 147 | 134 | ||
| 148 | def get_order_dict(src_dict, order_tuple): | 135 | def get_order_dict(src_dict, order_tuple): |
| 149 | # if consts.SECOND_ID_TYPE_FIELD in src_dict: | ||
| 150 | # if src_dict.get(consts.SECOND_ID_TYPE_FIELD) not in consts.SECOND_ID_TYPE_COMPARE: | ||
| 151 | # src_dict.pop(consts.SECOND_ID_TYPE_FIELD, None) | ||
| 152 | # src_dict.pop(consts.SECOND_ID_FIELD, None) | ||
| 153 | |||
| 154 | order_dict = OrderedDict({}) | 136 | order_dict = OrderedDict({}) |
| 155 | for field in order_tuple: | 137 | for field in order_tuple: |
| 156 | if field in src_dict: | 138 | if field in src_dict: |
| ... | @@ -940,7 +922,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -940,7 +922,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
| 940 | ('businessLicenseDueDate', id_info.get('idExpiryDate', '')), | 922 | ('businessLicenseDueDate', id_info.get('idExpiryDate', '')), |
| 941 | ] | 923 | ] |
| 942 | license_dict[consts.BL_EN] = bl_field_input | 924 | license_dict[consts.BL_EN] = bl_field_input |
| 943 | # all_id_num.append(id_num) | 925 | all_id_num.append(id_num) |
| 944 | if individual_info.get('customersubType', '') == 'Corporate': | 926 | if individual_info.get('customersubType', '') == 'Corporate': |
| 945 | company_info_list.append((customer_name, id_num)) | 927 | company_info_list.append((customer_name, id_num)) |
| 946 | 928 | ||
| ... | @@ -1100,19 +1082,20 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1100,19 +1082,20 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
| 1100 | schedule_list.append(tmp_str) | 1082 | schedule_list.append(tmp_str) |
| 1101 | schedule_list_str = consts.SCHEDULE_SPLIT_STR.join(schedule_list) | 1083 | schedule_list_str = consts.SCHEDULE_SPLIT_STR.join(schedule_list) |
| 1102 | 1084 | ||
| 1085 | vehicle_principal_str = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0')) | ||
| 1103 | afc_contract_input = [ | 1086 | afc_contract_input = [ |
| 1104 | (consts.SE_AFC_CON_FIELD[0], full_no), | 1087 | (consts.SE_AFC_CON_FIELD[0], full_no), |
| 1105 | (consts.SE_AFC_CON_FIELD[1], amount), | 1088 | (consts.SE_AFC_CON_FIELD[1], amount), |
| 1106 | (consts.SE_AFC_CON_FIELD[2], vin_no), | 1089 | (consts.SE_AFC_CON_FIELD[2], vin_no), |
| 1107 | (consts.SE_AFC_CON_FIELD[3], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))), | 1090 | (consts.SE_AFC_CON_FIELD[3], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))), |
| 1108 | (consts.SE_AFC_CON_FIELD[4], str(cms_info.get('terms', '0'))), | 1091 | (consts.SE_AFC_CON_FIELD[4], str(cms_info.get('terms', '0'))), |
| 1109 | (consts.SE_AFC_CON_FIELD[5], str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0'))), | 1092 | (consts.SE_AFC_CON_FIELD[5], vehicle_principal_str), |
| 1110 | (consts.SE_AFC_CON_FIELD[6], str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.0'))), | 1093 | (consts.SE_AFC_CON_FIELD[6], str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.0'))), |
| 1111 | (consts.SE_AFC_CON_FIELD[7], amount), | 1094 | (consts.SE_AFC_CON_FIELD[7], amount), |
| 1112 | (consts.SE_AFC_CON_FIELD[8], vin_no), | 1095 | (consts.SE_AFC_CON_FIELD[8], vin_no), |
| 1113 | (consts.SE_AFC_CON_FIELD[9], cms_info.get('dealerName', '')), | 1096 | (consts.SE_AFC_CON_FIELD[9], cms_info.get('dealerName', '')), |
| 1114 | (consts.SE_AFC_CON_FIELD[10], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))), | 1097 | (consts.SE_AFC_CON_FIELD[10], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))), |
| 1115 | (consts.SE_AFC_CON_FIELD[11], str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0'))), | 1098 | (consts.SE_AFC_CON_FIELD[11], vehicle_principal_str), |
| 1116 | (consts.SE_AFC_CON_FIELD[12], str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.0'))), | 1099 | (consts.SE_AFC_CON_FIELD[12], str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.0'))), |
| 1117 | (consts.SE_AFC_CON_FIELD[13], str(cms_info.get('terms', '0'))), | 1100 | (consts.SE_AFC_CON_FIELD[13], str(cms_info.get('terms', '0'))), |
| 1118 | (consts.SE_AFC_CON_FIELD[14], account_no), | 1101 | (consts.SE_AFC_CON_FIELD[14], account_no), |
| ... | @@ -1121,48 +1104,51 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1121,48 +1104,51 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
| 1121 | (consts.SE_AFC_CON_FIELD[17], schedule_list_str), | 1104 | (consts.SE_AFC_CON_FIELD[17], schedule_list_str), |
| 1122 | ] | 1105 | ] |
| 1123 | 1106 | ||
| 1124 | # asp_list = [] | ||
| 1125 | # for asp_info in cms_info.get('associatedServices', []): | ||
| 1126 | # asp_list.append( | ||
| 1127 | # ( | ||
| 1128 | # asp_info.get('associatedServices', ''), | ||
| 1129 | # asp_info.get('price', 0.0), | ||
| 1130 | # asp_info.get('financed', 0.0) | ||
| 1131 | # ) | ||
| 1132 | # ) | ||
| 1133 | |||
| 1134 | if str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.00')) == '0.00': | 1107 | if str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.00')) == '0.00': |
| 1135 | afc_contract_input.pop(5) | 1108 | afc_contract_input.pop(5) |
| 1136 | afc_contract_input.pop(5) | 1109 | afc_contract_input.pop(5) |
| 1137 | afc_contract_input.pop(9) | 1110 | afc_contract_input.pop(9) |
| 1138 | afc_contract_input.pop(9) | 1111 | afc_contract_input.pop(9) |
| 1112 | else: | ||
| 1113 | asp_list = [] | ||
| 1114 | gzs_status = consts.GZS_STATUS[1] | ||
| 1115 | gzs_price = '0.00' | ||
| 1116 | for asp_info in cms_info.get('associatedServices', []): | ||
| 1117 | tmp_asp_name = asp_info.get('associatedServices') | ||
| 1118 | if isinstance(tmp_asp_name, str) and len(tmp_asp_name) > 0: | ||
| 1119 | if gzs_status == consts.GZS_STATUS[1] and tmp_asp_name.find(consts.GZS_NAME) != -1: | ||
| 1120 | gzs_status = consts.GZS_STATUS[2] | ||
| 1121 | gzs_price = asp_info.get('price', '0.00') | ||
| 1122 | asp_list.append( | ||
| 1123 | ( | ||
| 1124 | tmp_asp_name, | ||
| 1125 | asp_info.get('price', '0.00'), | ||
| 1126 | asp_info.get('financed', '0.00') | ||
| 1127 | ) | ||
| 1128 | ) | ||
| 1129 | |||
| 1130 | fin_total = 0 | ||
| 1131 | for asp_name, _, asp_fin in asp_list: | ||
| 1132 | if gzs_status == consts.GZS_STATUS[2] and asp_name.find(consts.GZS_NAME) == -1: | ||
| 1133 | gzs_status = consts.GZS_STATUS[0] | ||
| 1134 | fin_total += float(asp_fin) | ||
| 1135 | asp_list.append( | ||
| 1136 | ( | ||
| 1137 | consts.ASP_SUM_NAME, | ||
| 1138 | '', | ||
| 1139 | format(fin_total, '.2f') | ||
| 1140 | ) | ||
| 1141 | ) | ||
| 1142 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[20], asp_list)) | ||
| 1143 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[22], asp_list)) | ||
| 1139 | 1144 | ||
| 1140 | # if len(asp_list) > 0: | 1145 | # CMS Vehicle Price / 1.13 * 10 % |
| 1141 | # fin_total = 0 | 1146 | gzs_list = [gzs_status] |
| 1142 | # gzs_status = consts.GZS_STATUS[1] | 1147 | if gzs_status != consts.GZS_STATUS[1]: |
| 1143 | # for asp_name, asp_price, asp_fin in asp_list: | 1148 | gzs_value = float(vehicle_principal_str) * 0.1 / 1.13 |
| 1144 | # if gzs_status == consts.GZS_STATUS[1]: | 1149 | gzs_list.append(gzs_value) |
| 1145 | # if consts.GZS_NAME in asp_name: | 1150 | gzs_list.append(float(gzs_price)) |
| 1146 | # gzs_status = consts.GZS_STATUS[0] | 1151 | afc_contract_input.append((consts.SE_AFC_CON_FIELD[21], gzs_list)) |
| 1147 | # if gzs_status == consts.GZS_STATUS[0]: | ||
| 1148 | # if consts.GZS_NAME not in asp_name: | ||
| 1149 | # gzs_status = consts.GZS_STATUS[2] | ||
| 1150 | # afc_contract_input.extend( | ||
| 1151 | # [ | ||
| 1152 | # (consts.SE_AFC_CON_FIELD[18], asp_name), | ||
| 1153 | # (consts.SE_AFC_CON_FIELD[19], str(asp_price)), | ||
| 1154 | # (consts.SE_AFC_CON_FIELD[20], str(asp_fin)), | ||
| 1155 | # ] | ||
| 1156 | # ) | ||
| 1157 | # fin_total += asp_fin | ||
| 1158 | # afc_contract_input.append((consts.SE_AFC_CON_FIELD[21], str(fin_total))) | ||
| 1159 | # | ||
| 1160 | # # CMS Vehicle Price / 1.13 * 10 % | ||
| 1161 | # gzs_list = [gzs_status] | ||
| 1162 | # if gzs_status != consts.GZS_STATUS[1]: | ||
| 1163 | # gzs_value = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', 0.0) * 0.1 / 1.13) | ||
| 1164 | # gzs_list.append(gzs_value) | ||
| 1165 | # afc_contract_input.append((consts.SE_AFC_CON_FIELD[22], consts.SPLIT_STR.join(gzs_list))) | ||
| 1166 | 1152 | ||
| 1167 | # '借款人签字及时间', 'Borrower', 0, 0, True | 1153 | # '借款人签字及时间', 'Borrower', 0, 0, True |
| 1168 | online_sign = cms_info.get('contractSource', 'Online Sign') == 'Online Sign' | 1154 | online_sign = cms_info.get('contractSource', 'Online Sign') == 'Online Sign' |
| ... | @@ -1365,173 +1351,6 @@ def get_se_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1365,173 +1351,6 @@ def get_se_compare_info(last_obj, application_entity, detect_list): |
| 1365 | return compare_info | 1351 | return compare_info |
| 1366 | 1352 | ||
| 1367 | 1353 | ||
| 1368 | # def rebuild_compare_info(last_obj, application_id): | ||
| 1369 | # { | ||
| 1370 | # "content": { | ||
| 1371 | # "financeCompany": "宝马汽车金融有限公司", | ||
| 1372 | # "contractNo": "CH-B100000123", | ||
| 1373 | # "status": "HIL", | ||
| 1374 | # "branch": "宝马汽车金融有限公司", | ||
| 1375 | # "fpCampaign": "Q1_2021_BMW_BASIC", | ||
| 1376 | # "applicationVersion": 1, | ||
| 1377 | # "submissionDate": {}, | ||
| 1378 | # "mortgageType": "Mortgage Contract", | ||
| 1379 | # "dealerRegion": "West", | ||
| 1380 | # "insuranceRealNameCity": false, | ||
| 1381 | # "totalFinanceAmount": 1234.56, | ||
| 1382 | # "terms": 24, | ||
| 1383 | # "dealerName": "乐山长宝汽车销售服务有限公司", | ||
| 1384 | # "tier": "2", | ||
| 1385 | # "province": "四川省", | ||
| 1386 | # "fapiaoIssuerDealer": "乐山长宝汽车销售服务有限公司", | ||
| 1387 | # "customerName": "蔡红", | ||
| 1388 | # "customerIdNo": "511102196706080000", | ||
| 1389 | # "vehicleStatus": "Used", | ||
| 1390 | # "applicationSource": "eApp", | ||
| 1391 | # "contractSource": "Online Sign", | ||
| 1392 | # "applicationRating": 100, | ||
| 1393 | # "applicantInformation": [ | ||
| 1394 | # { | ||
| 1395 | # "applicantType": "Borrower", | ||
| 1396 | # "customersubType": "TCCOR", | ||
| 1397 | # "selfEmployedSubType": "CSIBM", | ||
| 1398 | # "name": "李四", | ||
| 1399 | # "legalRepName": "张三", | ||
| 1400 | # "dateOfBirth": {}, | ||
| 1401 | # "nationality": "中国", | ||
| 1402 | # "establishmentDate": {}, | ||
| 1403 | # "IDInformation": [ | ||
| 1404 | # { | ||
| 1405 | # "idType": "ITARI", | ||
| 1406 | # "idNum": "111111199404251100", | ||
| 1407 | # "idExpiryDate": {} | ||
| 1408 | # } | ||
| 1409 | # ] | ||
| 1410 | # } | ||
| 1411 | # ], | ||
| 1412 | # "autoApprovedDetails": { | ||
| 1413 | # "aaType": "CAA1" | ||
| 1414 | # }, | ||
| 1415 | # "financialInformation": { | ||
| 1416 | # "vehiclePrice": 1234.56, | ||
| 1417 | # "grossPrice": 1234.56, | ||
| 1418 | # "associatedServicePrice": 1234.56, | ||
| 1419 | # "vehiclePrincipal": 1234.56, | ||
| 1420 | # "associatedServicePrincipal": 1234.56, | ||
| 1421 | # "originationPrincipal": 1234.56, | ||
| 1422 | # "totalDownPayment": 1234.56, | ||
| 1423 | # "vehicleDownPaymentRatio": 1234.56, | ||
| 1424 | # "optionAmount": 1234.56, | ||
| 1425 | # "sumOfMSRPAndOption": 1234.56 | ||
| 1426 | # }, | ||
| 1427 | # "paymentSchedule": [ | ||
| 1428 | # { | ||
| 1429 | # "no": 3, | ||
| 1430 | # "grossRentalAmount": 1234.56 | ||
| 1431 | # } | ||
| 1432 | # ], | ||
| 1433 | # "associatedServices": [ | ||
| 1434 | # { | ||
| 1435 | # "associatedServices": "机动车保险", | ||
| 1436 | # "price": 1234.56, | ||
| 1437 | # "financed": 1234.56, | ||
| 1438 | # "total": 1234.56 | ||
| 1439 | # } | ||
| 1440 | # ], | ||
| 1441 | # "vehicleInformation": { | ||
| 1442 | # "vinNo": "LBV23482934DJFKD" | ||
| 1443 | # }, | ||
| 1444 | # "bankAccountDetails": { | ||
| 1445 | # "bankName": "中国银行", | ||
| 1446 | # "accountHolderName": "张三", | ||
| 1447 | # "accountNo": "12312123123123124" | ||
| 1448 | # }, | ||
| 1449 | # "insuranceDetails": { | ||
| 1450 | # "insuranceType": "ComprehensiveInsurance", | ||
| 1451 | # "insuranceAmount": "60000000", | ||
| 1452 | # "startDate": {}, | ||
| 1453 | # "endDate": {} | ||
| 1454 | # }, | ||
| 1455 | # "corporateFinancialInformation": { | ||
| 1456 | # "hashCode": "238231", | ||
| 1457 | # "borrowerName": "张三", | ||
| 1458 | # "fiscalYear": 2019, | ||
| 1459 | # "totaAssets": 1234.56, | ||
| 1460 | # "totalLiabilitiesAndOwnersEquity": 1234.56, | ||
| 1461 | # "cashAndCashEquivalentAtEndOfPeriod": 1234.56, | ||
| 1462 | # "netProfit": 1234.56 | ||
| 1463 | # }, | ||
| 1464 | # "settlemnetVerification": { | ||
| 1465 | # "applicationNo": "CH-B100000123" | ||
| 1466 | # } | ||
| 1467 | # } | ||
| 1468 | # } | ||
| 1469 | |||
| 1470 | # cms_info = json.loads(last_obj.content) | ||
| 1471 | # | ||
| 1472 | # fake_pos = FakePOS(application_id, | ||
| 1473 | # cms_info.get('submissionDate', ''), | ||
| 1474 | # cms_info.get('applicationVersion', 1), | ||
| 1475 | # cms_info.get('applicantInformation', [])[0].get('customersubType', '')) | ||
| 1476 | # | ||
| 1477 | # fake_pos.bank_info = json.dumps( | ||
| 1478 | # { | ||
| 1479 | # 'accountNo': decode_des(cms_info.get('bankAccountDetails', {}).get('accountNo', ''), des_key), | ||
| 1480 | # 'bankName': cms_info.get('bankAccountDetails', {}).get('bankName', ''), | ||
| 1481 | # 'accountHolderName': cms_info.get('bankAccountDetails', {}).get('accountHolderName', ''), | ||
| 1482 | # } | ||
| 1483 | # ) | ||
| 1484 | # | ||
| 1485 | # fake_pos.vehicle_info = json.dumps( | ||
| 1486 | # { | ||
| 1487 | # 'vehicleStatus': cms_info.get('vehicleStatus', ''), | ||
| 1488 | # 'vinNo': cms_info.get('vehicleInformation', {}).get('vinNo', ''), | ||
| 1489 | # 'dealer': cms_info.get('dealerName', ''), | ||
| 1490 | # 'vehicleTransactionAmount': str(cms_info.get('totalFinanceAmount', '')), | ||
| 1491 | # } | ||
| 1492 | # ) | ||
| 1493 | # | ||
| 1494 | # individual_cus_info = [] | ||
| 1495 | # for individual_cus in cms_info.get('applicantInformation', []): | ||
| 1496 | # id_type = id_num = id_date = second_id_type = second_id_num = None | ||
| 1497 | # for idx, id_info in enumerate(individual_cus.get('', [])): | ||
| 1498 | # if idx > 1: | ||
| 1499 | # break | ||
| 1500 | # elif idx == 0: | ||
| 1501 | # id_type = id_info.get('idType') | ||
| 1502 | # id_num = decode_des(id_info.get('idNum')) | ||
| 1503 | # id_date = id_info.get('idExpiryDate') | ||
| 1504 | # else: | ||
| 1505 | # second_id_type = id_info.get('idType') | ||
| 1506 | # second_id_num = decode_des(id_info.get('idNum')) | ||
| 1507 | # individual_cus_info.append( | ||
| 1508 | # { | ||
| 1509 | # 'applicantType': consts.APPLICANT_TYPE_MAP.get(individual_cus.get('applicantType')), | ||
| 1510 | # 'customerType': individual_cus.get('customersubType'), | ||
| 1511 | # | ||
| 1512 | # 'idType': id_type, | ||
| 1513 | # 'idNum': id_num, | ||
| 1514 | # 'idExpiryDate': id_date, | ||
| 1515 | # | ||
| 1516 | # 'customerName': individual_cus.get('name'), | ||
| 1517 | # 'dateOfBirth': individual_cus.get('dateOfBirth', ''), | ||
| 1518 | # 'hukouProvince': cms_info.get('province', ''), | ||
| 1519 | # | ||
| 1520 | # 'secondIdType': second_id_type, | ||
| 1521 | # 'secondIdNum': second_id_num, | ||
| 1522 | # | ||
| 1523 | # 'companyName': individual_cus.get('name'), | ||
| 1524 | # 'selfEmployedSubType': individual_cus.get('selfEmployedSubType', ''), | ||
| 1525 | # } | ||
| 1526 | # ) | ||
| 1527 | # | ||
| 1528 | # fake_pos.individual_cus_info = json.dumps(individual_cus_info) | ||
| 1529 | # | ||
| 1530 | # fake_pos.corporate_cus_info = None | ||
| 1531 | # | ||
| 1532 | # return fake_pos | ||
| 1533 | |||
| 1534 | |||
| 1535 | def se_compare_license(license_en, ocr_res_dict, field_list): | 1354 | def se_compare_license(license_en, ocr_res_dict, field_list): |
| 1536 | ocr_field, compare_logic, special_expiry_date = consts.SE_COMPARE_FIELD[license_en] | 1355 | ocr_field, compare_logic, special_expiry_date = consts.SE_COMPARE_FIELD[license_en] |
| 1537 | 1356 | ||
| ... | @@ -1710,21 +1529,46 @@ def se_afc_contract_compare(license_en, ocr_res_dict, strip_list): | ... | @@ -1710,21 +1529,46 @@ def se_afc_contract_compare(license_en, ocr_res_dict, strip_list): |
| 1710 | for name, value in strip_list: | 1529 | for name, value in strip_list: |
| 1711 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) | 1530 | ocr_str_or_list = ocr_res.get(compare_logic[name][0]) |
| 1712 | 1531 | ||
| 1713 | if isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list): | 1532 | if name == consts.SE_AFC_CON_FIELD[21]: |
| 1533 | if len(value) == 3: | ||
| 1534 | reason = [] | ||
| 1535 | gzs_verify = value[1] >= value[2] | ||
| 1536 | if gzs_verify: | ||
| 1537 | if value[0] == consts.GZS_STATUS[0]: | ||
| 1538 | reason.append(consts.GZS_REASON_1) | ||
| 1539 | result = consts.RESULT_N | ||
| 1540 | else: | ||
| 1541 | result = consts.RESULT_Y | ||
| 1542 | else: | ||
| 1543 | if value[0] == consts.GZS_STATUS[0]: | ||
| 1544 | reason.append(consts.GZS_REASON_1) | ||
| 1545 | result = consts.RESULT_N | ||
| 1546 | reason.append(consts.GZS_REASON_2) | ||
| 1547 | else: | ||
| 1548 | result = consts.RESULT_N | ||
| 1549 | reason = consts.GZS_REASON_1 | ||
| 1550 | ocr_str = empty_str | ||
| 1551 | elif isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list): | ||
| 1714 | result = getattr(cp, compare_logic[name][1])(value, ocr_str_or_list, **compare_logic[name][2]) | 1552 | result = getattr(cp, compare_logic[name][1])(value, ocr_str_or_list, **compare_logic[name][2]) |
| 1715 | if isinstance(ocr_str_or_list, list): | 1553 | if isinstance(ocr_str_or_list, list): |
| 1716 | ocr_str = json.dumps(ocr_str_or_list) | 1554 | ocr_str = json.dumps(ocr_str_or_list) |
| 1717 | else: | 1555 | else: |
| 1718 | ocr_str = ocr_str_or_list | 1556 | ocr_str = ocr_str_or_list |
| 1557 | reason = compare_logic[name][3] | ||
| 1719 | else: | 1558 | else: |
| 1720 | result = consts.RESULT_N | 1559 | result = consts.RESULT_N |
| 1721 | ocr_str = empty_str | 1560 | ocr_str = empty_str |
| 1561 | reason = compare_logic[name][3] | ||
| 1722 | 1562 | ||
| 1723 | img_path = empty_str | 1563 | img_path = empty_str |
| 1724 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value | 1564 | error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value |
| 1725 | result_field_list.append((name, value, result, ocr_str, img_path, error_type, compare_logic[name][3])) | 1565 | if isinstance(value, list): |
| 1566 | value = json.dumps(value) | ||
| 1567 | result_field_list.append((name, value, result, ocr_str, img_path, error_type, reason)) | ||
| 1726 | else: | 1568 | else: |
| 1727 | for name, value in strip_list: | 1569 | for name, value in strip_list: |
| 1570 | if isinstance(value, list): | ||
| 1571 | value = json.dumps(value) | ||
| 1728 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value, | 1572 | result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value, |
| 1729 | '{0}未找到'.format(license_en))) | 1573 | '{0}未找到'.format(license_en))) |
| 1730 | 1574 | ||
| ... | @@ -1919,7 +1763,10 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -1919,7 +1763,10 @@ def se_compare_process(compare_info, ocr_res_dict): |
| 1919 | failed_count += 1 | 1763 | failed_count += 1 |
| 1920 | successful_at_this_level = False | 1764 | successful_at_this_level = False |
| 1921 | failure_field.append(name) | 1765 | failure_field.append(name) |
| 1766 | if isinstance(cn_reason, str): | ||
| 1922 | cn_reason_list.append(cn_reason) | 1767 | cn_reason_list.append(cn_reason) |
| 1768 | elif isinstance(cn_reason, list): | ||
| 1769 | cn_reason_list.extend(cn_reason) | ||
| 1923 | compare_result.append( | 1770 | compare_result.append( |
| 1924 | { | 1771 | { |
| 1925 | consts.HEAD_LIST[0]: info_key, | 1772 | consts.HEAD_LIST[0]: info_key, |
| ... | @@ -2116,34 +1963,3 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True | ... | @@ -2116,34 +1963,3 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True |
| 2116 | tmp_ca_result.extend(tmp_se_result) | 1963 | tmp_ca_result.extend(tmp_se_result) |
| 2117 | ocr_res_dict[consts.IC_OCR_FIELD] = json.dumps(tmp_ca_result) | 1964 | ocr_res_dict[consts.IC_OCR_FIELD] = json.dumps(tmp_ca_result) |
| 2118 | se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms) | 1965 | se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res_dict, is_cms) |
| 2119 | |||
| 2120 | |||
| 2121 | # @app.task | ||
| 2122 | # def forwarding_station(application_id, entity): | ||
| 2123 | # compare_log.info('{0} [forward start] [application_id={1}] [entity={2}]'.format(e_log_base, application_id, entity)) | ||
| 2124 | # doc_class = HILDoc if entity in consts.HIL_SET else AFCDoc | ||
| 2125 | # entity_prefix = consts.HIL_PREFIX if entity in consts.HIL_SET else consts.AFC_PREFIX | ||
| 2126 | # for (classify_1, classify_2), prefix in consts.FILE_NAME_PREFIX_MAP.get(entity): | ||
| 2127 | # try: | ||
| 2128 | # file_list = ecm.search(application_id, entity, prefix.format(application_id)) # TODO 获取最新文件 | ||
| 2129 | # except Exception as e: | ||
| 2130 | # compare_log.error('{0} [search failed] [application_id={1}] [entity={2}] [error={3}]'.format( | ||
| 2131 | # e_log_base, application_id, entity, traceback.format_exc())) | ||
| 2132 | # else: | ||
| 2133 | # compare_log.info('{0} [search end] [application_id={1}] [entity={2}] [file_list={3}]'.format( | ||
| 2134 | # e_log_base, application_id, entity, file_list)) | ||
| 2135 | # for object_name, object_id in file_list: | ||
| 2136 | # doc = doc_class.objects.create( | ||
| 2137 | # metadata_version_id=object_id, | ||
| 2138 | # application_id=application_id, | ||
| 2139 | # document_name=object_name, | ||
| 2140 | # document_scheme='SETTLEMENT', | ||
| 2141 | # data_source='POS', | ||
| 2142 | # upload_finish_time=datetime.now(), | ||
| 2143 | # ) | ||
| 2144 | # task = consts.SPLIT_STR.join([entity_prefix, str(doc.id), str(classify_1), str(classify_2)]) | ||
| 2145 | # enqueue_res = rh.enqueue([task], False) | ||
| 2146 | # compare_log.info('{0} [upload success] [res={1}] [application_id={2}] [entity={3}] [object_name={4}] ' | ||
| 2147 | # '[object_id={5}] [doc_id={6}]'.format(e_log_base, enqueue_res, application_id, entity, | ||
| 2148 | # object_name, object_id, doc.id)) | ||
| 2149 | # compare_log.info('{0} [forward end] [application_id={1}] [entity={2}]'.format(e_log_base, application_id, entity)) | ... | ... |
| ... | @@ -185,6 +185,34 @@ class Comparison: | ... | @@ -185,6 +185,34 @@ class Comparison: |
| 185 | else: | 185 | else: |
| 186 | return self.RESULT_N | 186 | return self.RESULT_N |
| 187 | 187 | ||
| 188 | def se_asp_compare(self, input_list, ocr_str_or_list, **kwargs): | ||
| 189 | if isinstance(ocr_str_or_list, list): | ||
| 190 | try: | ||
| 191 | for asp_name, asp_price, asp_fin in input_list[:-1]: | ||
| 192 | for row_list in ocr_str_or_list: | ||
| 193 | if len(row_list) != 3: | ||
| 194 | continue | ||
| 195 | if row_list[0].find(asp_name) == -1: | ||
| 196 | continue | ||
| 197 | if float(row_list[1].replace(',', '')) == float(asp_price) and \ | ||
| 198 | float(row_list[2].replace(',', '')) == float(asp_fin): | ||
| 199 | break | ||
| 200 | else: | ||
| 201 | return self.RESULT_N | ||
| 202 | |||
| 203 | _, _, sum_fin = input_list[-1] | ||
| 204 | if float(ocr_str_or_list[-1][-1].replace(',', '')) == float(sum_fin): | ||
| 205 | return self.RESULT_Y | ||
| 206 | else: | ||
| 207 | return self.RESULT_N | ||
| 208 | except Exception as e: | ||
| 209 | return self.RESULT_N | ||
| 210 | else: | ||
| 211 | return self.RESULT_N | ||
| 212 | |||
| 213 | def se_gzs_compare(self, input_str, ocr_str_or_list, **kwargs): | ||
| 214 | pass | ||
| 215 | |||
| 188 | def se_name_compare(self, input_str, ocr_str, **kwargs): | 216 | def se_name_compare(self, input_str, ocr_str, **kwargs): |
| 189 | if kwargs.get('is_passport'): | 217 | if kwargs.get('is_passport'): |
| 190 | input_tmp = input_str.upper().replace(' ', '') | 218 | input_tmp = input_str.upper().replace(' ', '') |
| ... | @@ -265,7 +293,17 @@ class Comparison: | ... | @@ -265,7 +293,17 @@ class Comparison: |
| 265 | if kwargs.get('today', False): | 293 | if kwargs.get('today', False): |
| 266 | return self.build_res(self.is_after_today(ocr_str)) | 294 | return self.build_res(self.is_after_today(ocr_str)) |
| 267 | else: | 295 | else: |
| 268 | return self.build_res(input_str == ocr_str) | 296 | res = self.build_res(input_str == ocr_str) |
| 297 | if res == self.RESULT_Y: | ||
| 298 | return res | ||
| 299 | else: | ||
| 300 | try: | ||
| 301 | ocr_date = datetime.strptime(ocr_str, "%Y-%m-%d") | ||
| 302 | input_date = datetime.strptime(input_str, "%Y-%m-%d") | ||
| 303 | return self.build_res(input_date == ocr_date) | ||
| 304 | except Exception as e: | ||
| 305 | return self.RESULT_N | ||
| 306 | |||
| 269 | 307 | ||
| 270 | def ca_date_compare(self, input_str, ocr_str, **kwargs): | 308 | def ca_date_compare(self, input_str, ocr_str, **kwargs): |
| 271 | if kwargs.get('long', False): | 309 | if kwargs.get('long', False): | ... | ... |
-
Please register or sign in to post a comment