add hil contract compare
Showing
4 changed files
with
124 additions
and
34 deletions
This diff is collapsed.
Click to expand it.
| ... | @@ -909,11 +909,10 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -909,11 +909,10 @@ class Command(BaseCommand, LoggerMixin): |
| 909 | ) | 909 | ) |
| 910 | return res | 910 | return res |
| 911 | 911 | ||
| 912 | def rebuild_contract(self, contract_result_compare): | 912 | def rebuild_contract(self, license_summary, contract_result_compare): |
| 913 | res_list = [] | ||
| 914 | for classify, page_info_dict in contract_result_compare.items(): | 913 | for classify, page_info_dict in contract_result_compare.items(): |
| 915 | res = {} | ||
| 916 | if classify == consts.CONTRACT_CLASSIFY: | 914 | if classify == consts.CONTRACT_CLASSIFY: |
| 915 | res = {} | ||
| 917 | is_asp = page_info_dict.get(consts.ASP_KEY, False) | 916 | is_asp = page_info_dict.get(consts.ASP_KEY, False) |
| 918 | for key, (pno_not_asp, pno_asp, key1, key2) in consts.SE_AFC_CON_MAP.items(): | 917 | for key, (pno_not_asp, pno_asp, key1, key2) in consts.SE_AFC_CON_MAP.items(): |
| 919 | pno = pno_asp if is_asp else pno_not_asp | 918 | pno = pno_asp if is_asp else pno_not_asp |
| ... | @@ -927,8 +926,26 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -927,8 +926,26 @@ class Command(BaseCommand, LoggerMixin): |
| 927 | res[key] = page_info_dict.get(str(pno), {}).get(key1, '') | 926 | res[key] = page_info_dict.get(str(pno), {}).get(key1, '') |
| 928 | else: | 927 | else: |
| 929 | res[key] = page_info_dict.get(str(pno), {}).get(key1, {}).get(key2, '') | 928 | res[key] = page_info_dict.get(str(pno), {}).get(key1, {}).get(key2, '') |
| 930 | res_list.append(res) | 929 | |
| 931 | return res_list | 930 | license_summary[classify] = [res] |
| 931 | else: | ||
| 932 | res = {} | ||
| 933 | for key, (pno1, pno2, end_idx, key1, key2) in consts.SE_HIL_CON_MAP[classify].items(): | ||
| 934 | if pno1 is None: | ||
| 935 | for i in range(1, end_idx): | ||
| 936 | res.setdefault(key, list()).append(page_info_dict.get(str(i), {}).get(key1, '')) | ||
| 937 | elif key2 is None: | ||
| 938 | tmp_res = page_info_dict.get(str(pno1), {}).get(key1) | ||
| 939 | if tmp_res is None and isinstance(pno2, int): | ||
| 940 | tmp_res = page_info_dict.get(str(pno2), {}).get(key1, '') | ||
| 941 | res[key] = tmp_res | ||
| 942 | else: | ||
| 943 | tmp_res = page_info_dict.get(str(pno1), {}).get(key1, {}).get(key2) | ||
| 944 | if tmp_res is None and isinstance(pno2, int): | ||
| 945 | tmp_res = page_info_dict.get(str(pno2), {}).get(key1, {}).get(key2, '') | ||
| 946 | res[key] = tmp_res | ||
| 947 | |||
| 948 | license_summary[classify] = [res] | ||
| 932 | 949 | ||
| 933 | def rebuild_bs_summary(self, bs_summary, unknown_summary): | 950 | def rebuild_bs_summary(self, bs_summary, unknown_summary): |
| 934 | # bs_summary = { | 951 | # bs_summary = { |
| ... | @@ -1659,9 +1676,7 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -1659,9 +1676,7 @@ class Command(BaseCommand, LoggerMixin): |
| 1659 | finally: | 1676 | finally: |
| 1660 | # TODO 识别结果存一张表,方便跑报表 | 1677 | # TODO 识别结果存一张表,方便跑报表 |
| 1661 | 1678 | ||
| 1662 | contract_result_compare_rebuild = self.rebuild_contract(contract_result_compare) | 1679 | self.rebuild_contract(license_summary, contract_result_compare) |
| 1663 | if len(contract_result_compare_rebuild) > 0: | ||
| 1664 | license_summary[consts.CONTRACT_CLASSIFY] = contract_result_compare_rebuild | ||
| 1665 | 1680 | ||
| 1666 | bs_rebuild = self.rebuild_bs(merged_bs_summary) | 1681 | bs_rebuild = self.rebuild_bs(merged_bs_summary) |
| 1667 | if len(bs_rebuild) > 0: | 1682 | if len(bs_rebuild) > 0: | ... | ... |
| ... | @@ -925,7 +925,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -925,7 +925,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
| 925 | license_dict[consts.BL_EN] = bl_field_input | 925 | license_dict[consts.BL_EN] = bl_field_input |
| 926 | all_id_num.append(id_num) | 926 | all_id_num.append(id_num) |
| 927 | if individual_info.get('customersubType', '') == 'Corporate': | 927 | if individual_info.get('customersubType', '') == 'Corporate': |
| 928 | company_info_list.append((customer_name, id_num)) | 928 | company_info_list.append((customer_name, id_num, legal_name)) |
| 929 | 929 | ||
| 930 | # SME营业执照--------------------------------------------------------------------------------------------------- | 930 | # SME营业执照--------------------------------------------------------------------------------------------------- |
| 931 | if individual_info.get('customersubType', '').startswith('Self Employed'): | 931 | if individual_info.get('customersubType', '').startswith('Self Employed'): |
| ... | @@ -1091,7 +1091,6 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1091,7 +1091,6 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
| 1091 | bs_info[consts.BS_EN] = bs_field_input | 1091 | bs_info[consts.BS_EN] = bs_field_input |
| 1092 | compare_info['Bank Statement'] = bs_info | 1092 | compare_info['Bank Statement'] = bs_info |
| 1093 | 1093 | ||
| 1094 | |||
| 1095 | # 抵押登记豁免函---------------------------------------------------------------------------------------------------- | 1094 | # 抵押登记豁免函---------------------------------------------------------------------------------------------------- |
| 1096 | other_info = {} | 1095 | other_info = {} |
| 1097 | full_no = cms_info.get('settlemnetVerification', {}).get('applicationNo', '') | 1096 | full_no = cms_info.get('settlemnetVerification', {}).get('applicationNo', '') |
| ... | @@ -1156,13 +1155,13 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1156,13 +1155,13 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
| 1156 | 1155 | ||
| 1157 | # 保单 ----------------------------------------------------------------------------------------------------------- | 1156 | # 保单 ----------------------------------------------------------------------------------------------------------- |
| 1158 | is_insurance = 0 | 1157 | is_insurance = 0 |
| 1158 | fp_campaign = cms_info.get('fpCampaign', '') | ||
| 1159 | insurance_type = cms_info.get('insuranceDetails', {}).get('insuranceType', '') | 1159 | insurance_type = cms_info.get('insuranceDetails', {}).get('insuranceType', '') |
| 1160 | if insurance_type == 'Waive Insurance' and isinstance(insurance_price, str): | 1160 | if insurance_type == 'Waive Insurance' and isinstance(insurance_price, str): |
| 1161 | is_insurance = 1 | 1161 | is_insurance = 1 |
| 1162 | elif insurance_type == 'Comprehensive Insurance': | 1162 | elif insurance_type == 'Comprehensive Insurance': |
| 1163 | is_insurance = 2 | 1163 | is_insurance = 2 |
| 1164 | if is_insurance != 0: | 1164 | if is_insurance != 0: |
| 1165 | fp_campaign = cms_info.get('fpCampaign', '') | ||
| 1166 | if fp_campaign.find('OCU') == -1: | 1165 | if fp_campaign.find('OCU') == -1: |
| 1167 | ssx_amount = amount | 1166 | ssx_amount = amount |
| 1168 | else: | 1167 | else: |
| ... | @@ -1190,21 +1189,93 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1190,21 +1189,93 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
| 1190 | if len(other_info) > 0: | 1189 | if len(other_info) > 0: |
| 1191 | compare_info['other'] = other_info | 1190 | compare_info['other'] = other_info |
| 1192 | 1191 | ||
| 1192 | schedule_list = [] | ||
| 1193 | total_amount = 0 | ||
| 1194 | for schedule_dict in cms_info.get('paymentSchedule', []): | ||
| 1195 | tmp_str = "{1}{0}{2}".format(consts.SPLIT_STR, str(schedule_dict.get('no', '')), | ||
| 1196 | str(schedule_dict.get('grossRentalAmount', ''))) | ||
| 1197 | schedule_list.append(tmp_str) | ||
| 1198 | total_amount += float(schedule_dict.get('grossRentalAmount', '0.0')) | ||
| 1199 | schedule_list_str = consts.SCHEDULE_SPLIT_STR.join(schedule_list) | ||
| 1200 | |||
| 1201 | online_sign = cms_info.get('contractSource', 'Online Sign') == 'Online Sign' | ||
| 1202 | |||
| 1203 | contract_info = {} | ||
| 1193 | if application_entity in consts.HIL_SET: | 1204 | if application_entity in consts.HIL_SET: |
| 1194 | # HIL合同----------------------------------------------------------------------------------------- | 1205 | # HIL合同 售后回租合同 -------------------------------------------------------------------------------------- |
| 1206 | hil_contract_1_input = [ | ||
| 1207 | (consts.SE_HIL_CON_1_FIELD[0], [full_no] if online_sign else full_no), | ||
| 1208 | (consts.SE_HIL_CON_1_FIELD[1], full_no), | ||
| 1209 | (consts.SE_HIL_CON_1_FIELD[2], vin_no), | ||
| 1210 | (consts.SE_HIL_CON_1_FIELD[3], cms_info.get('dealerName', '')), | ||
| 1211 | (consts.SE_HIL_CON_1_FIELD[4], amount), | ||
| 1212 | (consts.SE_HIL_CON_1_FIELD[5], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))), | ||
| 1213 | (consts.SE_HIL_CON_1_FIELD[6], str(cms_info.get('terms', '0'))), | ||
| 1214 | (consts.SE_HIL_CON_1_FIELD[7], schedule_list_str), | ||
| 1215 | (consts.SE_HIL_CON_1_FIELD[8], asp_list), | ||
| 1216 | (consts.SE_HIL_CON_1_FIELD[9], gzs_list), | ||
| 1217 | ] | ||
| 1218 | |||
| 1219 | if isinstance(company_info, tuple): | ||
| 1220 | hil_contract_1_input.append((consts.SE_HIL_CON_1_FIELD[10], company_info[2])) | ||
| 1221 | |||
| 1222 | for key, app_type, id_idx, field_idx, is_force, e_write in consts.ROLE_LIST_1: | ||
| 1223 | if not e_write and not online_sign: | ||
| 1224 | continue | ||
| 1225 | is_find = False | ||
| 1226 | if app_type in main_role_info: | ||
| 1227 | if len(main_role_info[app_type]) >= id_idx+1: | ||
| 1228 | is_find = True | ||
| 1229 | if isinstance(field_idx, int): | ||
| 1230 | hil_contract_1_input.append((key, main_role_info[app_type][id_idx][field_idx])) | ||
| 1231 | else: | ||
| 1232 | hil_contract_1_input.append((key, field_idx)) | ||
| 1233 | if not is_find and is_force: | ||
| 1234 | hil_contract_1_input.append((key, empty_str)) | ||
| 1235 | contract_info[consts.HIL_CONTRACT_1_EN] = hil_contract_1_input | ||
| 1236 | |||
| 1237 | # HIL合同 车辆处置协议 -------------------------------------------------------------------------------------- | ||
| 1238 | if fp_campaign.find('Joy_Select') != -1: | ||
| 1239 | hil_contract_3_input = [ | ||
| 1240 | (consts.SE_HIL_CON_3_FIELD[0], [full_no] if online_sign else full_no), | ||
| 1241 | (consts.SE_HIL_CON_3_FIELD[1], hmh_name), | ||
| 1242 | (consts.SE_HIL_CON_3_FIELD[2], hmh_id), | ||
| 1243 | (consts.SE_HIL_CON_3_FIELD[3], cms_info.get('dealerName', '')), | ||
| 1244 | (consts.SE_HIL_CON_3_FIELD[4], full_no), | ||
| 1245 | (consts.SE_HIL_CON_3_FIELD[5], hmh_name), | ||
| 1246 | (consts.SE_HIL_CON_3_FIELD[6], hmh_id), | ||
| 1247 | ] | ||
| 1248 | if online_sign: | ||
| 1249 | hil_contract_3_input.append((consts.SE_HIL_CON_3_FIELD[7], hmh_name)) | ||
| 1250 | contract_info[consts.HIL_CONTRACT_3_EN] = hil_contract_3_input | ||
| 1251 | |||
| 1252 | # HIL合同 车辆租赁抵押合同 -------------------------------------------------------------------------------------- | ||
| 1253 | hil_contract_2_input = [ | ||
| 1254 | (consts.SE_HIL_CON_2_FIELD[0], full_no), | ||
| 1255 | (consts.SE_HIL_CON_2_FIELD[1], full_no), | ||
| 1256 | (consts.SE_HIL_CON_2_FIELD[2], vin_no), | ||
| 1257 | (consts.SE_HIL_CON_2_FIELD[3], format(total_amount, '.2f')), | ||
| 1258 | (consts.SE_HIL_CON_2_FIELD[4], str(cms_info.get('terms', '0'))), | ||
| 1259 | ] | ||
| 1195 | 1260 | ||
| 1261 | for key, app_type, id_idx, field_idx, is_force, e_write in consts.ROLE_LIST_2: | ||
| 1262 | if not e_write and not online_sign: | ||
| 1263 | continue | ||
| 1264 | is_find = False | ||
| 1265 | if app_type in main_role_info: | ||
| 1266 | if len(main_role_info[app_type]) >= id_idx+1: | ||
| 1267 | is_find = True | ||
| 1268 | if isinstance(field_idx, int): | ||
| 1269 | hil_contract_2_input.append((key, main_role_info[app_type][id_idx][field_idx])) | ||
| 1270 | else: | ||
| 1271 | hil_contract_2_input.append((key, field_idx)) | ||
| 1272 | if not is_find and is_force: | ||
| 1273 | hil_contract_2_input.append((key, empty_str)) | ||
| 1274 | contract_info[consts.HIL_CONTRACT_2_EN] = hil_contract_2_input | ||
| 1275 | compare_info['contract'] = contract_info | ||
| 1196 | return compare_info, cms_info.get('applicationVersion', 1) | 1276 | return compare_info, cms_info.get('applicationVersion', 1) |
| 1197 | else: | 1277 | else: |
| 1198 | # AFC合同----------------------------------------------------------------------------------------------------------- | 1278 | # AFC合同----------------------------------------------------------------------------------------------------------- |
| 1199 | contract_info = {} | ||
| 1200 | |||
| 1201 | schedule_list = [] | ||
| 1202 | for schedule_dict in cms_info.get('paymentSchedule', []): | ||
| 1203 | tmp_str = "{1}{0}{2}".format(consts.SPLIT_STR, str(schedule_dict.get('no', '')), | ||
| 1204 | str(schedule_dict.get('grossRentalAmount', ''))) | ||
| 1205 | schedule_list.append(tmp_str) | ||
| 1206 | schedule_list_str = consts.SCHEDULE_SPLIT_STR.join(schedule_list) | ||
| 1207 | |||
| 1208 | vehicle_principal_str = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0')) | 1279 | vehicle_principal_str = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0')) |
| 1209 | afc_contract_input = [ | 1280 | afc_contract_input = [ |
| 1210 | (consts.SE_AFC_CON_FIELD[0], full_no), | 1281 | (consts.SE_AFC_CON_FIELD[0], full_no), |
| ... | @@ -1238,7 +1309,6 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): | ... | @@ -1238,7 +1309,6 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list): |
| 1238 | afc_contract_input.pop(9) | 1309 | afc_contract_input.pop(9) |
| 1239 | 1310 | ||
| 1240 | # '借款人签字及时间', 'Borrower', 0, 0, True | 1311 | # '借款人签字及时间', 'Borrower', 0, 0, True |
| 1241 | online_sign = cms_info.get('contractSource', 'Online Sign') == 'Online Sign' | ||
| 1242 | for key, app_type, id_idx, field_idx, is_force, e_write in consts.ROLE_LIST: | 1312 | for key, app_type, id_idx, field_idx, is_force, e_write in consts.ROLE_LIST: |
| 1243 | if not e_write and not online_sign: | 1313 | if not e_write and not online_sign: |
| 1244 | continue | 1314 | continue |
| ... | @@ -1729,7 +1799,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list): | ... | @@ -1729,7 +1799,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list): |
| 1729 | return result_field_list, no_ocr_result, field_img_path_dict | 1799 | return result_field_list, no_ocr_result, field_img_path_dict |
| 1730 | 1800 | ||
| 1731 | 1801 | ||
| 1732 | def se_afc_contract_compare(license_en, ocr_res_dict, strip_list): | 1802 | def se_contract_compare(license_en, ocr_res_dict, strip_list): |
| 1733 | ocr_field, compare_logic, _ = consts.SE_COMPARE_FIELD[license_en] | 1803 | ocr_field, compare_logic, _ = consts.SE_COMPARE_FIELD[license_en] |
| 1734 | ocr_res_str = ocr_res_dict.get(ocr_field) | 1804 | ocr_res_str = ocr_res_dict.get(ocr_field) |
| 1735 | 1805 | ||
| ... | @@ -1983,8 +2053,8 @@ def se_compare_process(compare_info, ocr_res_dict): | ... | @@ -1983,8 +2053,8 @@ def se_compare_process(compare_info, ocr_res_dict): |
| 1983 | failure_field = [] | 2053 | failure_field = [] |
| 1984 | if license_en == consts.MVC34_EN: | 2054 | if license_en == consts.MVC34_EN: |
| 1985 | result_field_list, field_img_path_dict = se_mvc34_compare(license_en, ocr_res_dict, strip_list) | 2055 | result_field_list, field_img_path_dict = se_mvc34_compare(license_en, ocr_res_dict, strip_list) |
| 1986 | elif license_en == consts.AFC_CONTRACT_EN: | 2056 | elif license_en in [consts.HIL_CONTRACT_1_EN, consts.HIL_CONTRACT_2_EN, consts.HIL_CONTRACT_3_EN, consts.AFC_CONTRACT_EN]: |
| 1987 | result_field_list, field_img_path_dict = se_afc_contract_compare(license_en, ocr_res_dict, strip_list) | 2057 | result_field_list, field_img_path_dict = se_contract_compare(license_en, ocr_res_dict, strip_list) |
| 1988 | elif license_en == consts.BS_EN: | 2058 | elif license_en == consts.BS_EN: |
| 1989 | result_field_list, field_img_path_dict = se_bs_compare(license_en, ocr_res_dict, strip_list) | 2059 | result_field_list, field_img_path_dict = se_bs_compare(license_en, ocr_res_dict, strip_list) |
| 1990 | else: | 2060 | else: | ... | ... |
| ... | @@ -159,12 +159,17 @@ class Comparison: | ... | @@ -159,12 +159,17 @@ class Comparison: |
| 159 | 159 | ||
| 160 | return self.build_res(input_str == compare_str), compare_str | 160 | return self.build_res(input_str == compare_str), compare_str |
| 161 | 161 | ||
| 162 | def se_list_compare(self, input_str, ocr_str_or_list, **kwargs): | 162 | def se_list_compare(self, input_str_or_list, ocr_str_or_list, **kwargs): |
| 163 | if isinstance(ocr_str_or_list, list): | 163 | if isinstance(ocr_str_or_list, list) and len(ocr_str_or_list) > 0: |
| 164 | for item in ocr_str_or_list: | 164 | if isinstance(input_str_or_list, list) and len(input_str_or_list) > 0: |
| 165 | if item != input_str: | 165 | if input_str_or_list[0] == ocr_str_or_list[0]: |
| 166 | return self.RESULT_N | 166 | return self.RESULT_Y |
| 167 | return self.RESULT_Y | 167 | return self.RESULT_N |
| 168 | else: | ||
| 169 | for item in ocr_str_or_list: | ||
| 170 | if item != input_str_or_list: | ||
| 171 | return self.RESULT_N | ||
| 172 | return self.RESULT_Y | ||
| 168 | else: | 173 | else: |
| 169 | return self.RESULT_N | 174 | return self.RESULT_N |
| 170 | 175 | ||
| ... | @@ -177,7 +182,8 @@ class Comparison: | ... | @@ -177,7 +182,8 @@ class Comparison: |
| 177 | ocr_str_or_list.pop(0) | 182 | ocr_str_or_list.pop(0) |
| 178 | schedule_list = [] | 183 | schedule_list = [] |
| 179 | for row_list in ocr_str_or_list: | 184 | for row_list in ocr_str_or_list: |
| 180 | tmp_str = "{1}{0}{2}".format(self.SPLIT_STR, row_list[0], row_list[1].replace(',', '')) | 185 | tmp_str = "{1}{0}{2}".format( |
| 186 | self.SPLIT_STR, row_list[0], row_list[kwargs.get('value_idx', 1)].replace(',', '')) | ||
| 181 | schedule_list.append(tmp_str) | 187 | schedule_list.append(tmp_str) |
| 182 | return self.build_res(self.SCHEDULE_SPLIT_STR.join(schedule_list) == input_str) | 188 | return self.build_res(self.SCHEDULE_SPLIT_STR.join(schedule_list) == input_str) |
| 183 | else: | 189 | else: |
| ... | @@ -304,7 +310,6 @@ class Comparison: | ... | @@ -304,7 +310,6 @@ class Comparison: |
| 304 | except Exception as e: | 310 | except Exception as e: |
| 305 | return self.RESULT_N | 311 | return self.RESULT_N |
| 306 | 312 | ||
| 307 | |||
| 308 | def ca_date_compare(self, input_str, ocr_str, **kwargs): | 313 | def ca_date_compare(self, input_str, ocr_str, **kwargs): |
| 309 | if kwargs.get('long', False): | 314 | if kwargs.get('long', False): |
| 310 | if '长期' in ocr_str or '永久' in ocr_str: | 315 | if '长期' in ocr_str or '永久' in ocr_str: |
| ... | @@ -366,7 +371,7 @@ class Comparison: | ... | @@ -366,7 +371,7 @@ class Comparison: |
| 366 | def se_amount_lte_compare(self, input_str, ocr_str, **kwargs): | 371 | def se_amount_lte_compare(self, input_str, ocr_str, **kwargs): |
| 367 | try: | 372 | try: |
| 368 | float_input = float(input_str) | 373 | float_input = float(input_str) |
| 369 | float_ocr = float(ocr_str) | 374 | float_ocr = float(ocr_str.replace('元', '').replace(',', '')) |
| 370 | except Exception as e: | 375 | except Exception as e: |
| 371 | return self.RESULT_N | 376 | return self.RESULT_N |
| 372 | else: | 377 | else: | ... | ... |
-
Please register or sign in to post a comment