e199bcb2 by 周伟奇

add hil contract compare

1 parent 7dafa058
......@@ -909,11 +909,10 @@ class Command(BaseCommand, LoggerMixin):
)
return res
def rebuild_contract(self, contract_result_compare):
res_list = []
def rebuild_contract(self, license_summary, contract_result_compare):
for classify, page_info_dict in contract_result_compare.items():
res = {}
if classify == consts.CONTRACT_CLASSIFY:
res = {}
is_asp = page_info_dict.get(consts.ASP_KEY, False)
for key, (pno_not_asp, pno_asp, key1, key2) in consts.SE_AFC_CON_MAP.items():
pno = pno_asp if is_asp else pno_not_asp
......@@ -927,8 +926,26 @@ class Command(BaseCommand, LoggerMixin):
res[key] = page_info_dict.get(str(pno), {}).get(key1, '')
else:
res[key] = page_info_dict.get(str(pno), {}).get(key1, {}).get(key2, '')
res_list.append(res)
return res_list
license_summary[classify] = [res]
else:
res = {}
for key, (pno1, pno2, end_idx, key1, key2) in consts.SE_HIL_CON_MAP[classify].items():
if pno1 is None:
for i in range(1, end_idx):
res.setdefault(key, list()).append(page_info_dict.get(str(i), {}).get(key1, ''))
elif key2 is None:
tmp_res = page_info_dict.get(str(pno1), {}).get(key1)
if tmp_res is None and isinstance(pno2, int):
tmp_res = page_info_dict.get(str(pno2), {}).get(key1, '')
res[key] = tmp_res
else:
tmp_res = page_info_dict.get(str(pno1), {}).get(key1, {}).get(key2)
if tmp_res is None and isinstance(pno2, int):
tmp_res = page_info_dict.get(str(pno2), {}).get(key1, {}).get(key2, '')
res[key] = tmp_res
license_summary[classify] = [res]
def rebuild_bs_summary(self, bs_summary, unknown_summary):
# bs_summary = {
......@@ -1659,9 +1676,7 @@ class Command(BaseCommand, LoggerMixin):
finally:
# TODO 识别结果存一张表,方便跑报表
contract_result_compare_rebuild = self.rebuild_contract(contract_result_compare)
if len(contract_result_compare_rebuild) > 0:
license_summary[consts.CONTRACT_CLASSIFY] = contract_result_compare_rebuild
self.rebuild_contract(license_summary, contract_result_compare)
bs_rebuild = self.rebuild_bs(merged_bs_summary)
if len(bs_rebuild) > 0:
......
......@@ -925,7 +925,7 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list):
license_dict[consts.BL_EN] = bl_field_input
all_id_num.append(id_num)
if individual_info.get('customersubType', '') == 'Corporate':
company_info_list.append((customer_name, id_num))
company_info_list.append((customer_name, id_num, legal_name))
# SME营业执照---------------------------------------------------------------------------------------------------
if individual_info.get('customersubType', '').startswith('Self Employed'):
......@@ -1091,7 +1091,6 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list):
bs_info[consts.BS_EN] = bs_field_input
compare_info['Bank Statement'] = bs_info
# 抵押登记豁免函----------------------------------------------------------------------------------------------------
other_info = {}
full_no = cms_info.get('settlemnetVerification', {}).get('applicationNo', '')
......@@ -1156,13 +1155,13 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list):
# 保单 -----------------------------------------------------------------------------------------------------------
is_insurance = 0
fp_campaign = cms_info.get('fpCampaign', '')
insurance_type = cms_info.get('insuranceDetails', {}).get('insuranceType', '')
if insurance_type == 'Waive Insurance' and isinstance(insurance_price, str):
is_insurance = 1
elif insurance_type == 'Comprehensive Insurance':
is_insurance = 2
if is_insurance != 0:
fp_campaign = cms_info.get('fpCampaign', '')
if fp_campaign.find('OCU') == -1:
ssx_amount = amount
else:
......@@ -1190,21 +1189,93 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list):
if len(other_info) > 0:
compare_info['other'] = other_info
schedule_list = []
total_amount = 0
for schedule_dict in cms_info.get('paymentSchedule', []):
tmp_str = "{1}{0}{2}".format(consts.SPLIT_STR, str(schedule_dict.get('no', '')),
str(schedule_dict.get('grossRentalAmount', '')))
schedule_list.append(tmp_str)
total_amount += float(schedule_dict.get('grossRentalAmount', '0.0'))
schedule_list_str = consts.SCHEDULE_SPLIT_STR.join(schedule_list)
online_sign = cms_info.get('contractSource', 'Online Sign') == 'Online Sign'
contract_info = {}
if application_entity in consts.HIL_SET:
# HIL合同-----------------------------------------------------------------------------------------
# HIL合同 售后回租合同 --------------------------------------------------------------------------------------
hil_contract_1_input = [
(consts.SE_HIL_CON_1_FIELD[0], [full_no] if online_sign else full_no),
(consts.SE_HIL_CON_1_FIELD[1], full_no),
(consts.SE_HIL_CON_1_FIELD[2], vin_no),
(consts.SE_HIL_CON_1_FIELD[3], cms_info.get('dealerName', '')),
(consts.SE_HIL_CON_1_FIELD[4], amount),
(consts.SE_HIL_CON_1_FIELD[5], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))),
(consts.SE_HIL_CON_1_FIELD[6], str(cms_info.get('terms', '0'))),
(consts.SE_HIL_CON_1_FIELD[7], schedule_list_str),
(consts.SE_HIL_CON_1_FIELD[8], asp_list),
(consts.SE_HIL_CON_1_FIELD[9], gzs_list),
]
if isinstance(company_info, tuple):
hil_contract_1_input.append((consts.SE_HIL_CON_1_FIELD[10], company_info[2]))
for key, app_type, id_idx, field_idx, is_force, e_write in consts.ROLE_LIST_1:
if not e_write and not online_sign:
continue
is_find = False
if app_type in main_role_info:
if len(main_role_info[app_type]) >= id_idx+1:
is_find = True
if isinstance(field_idx, int):
hil_contract_1_input.append((key, main_role_info[app_type][id_idx][field_idx]))
else:
hil_contract_1_input.append((key, field_idx))
if not is_find and is_force:
hil_contract_1_input.append((key, empty_str))
contract_info[consts.HIL_CONTRACT_1_EN] = hil_contract_1_input
# HIL合同 车辆处置协议 --------------------------------------------------------------------------------------
if fp_campaign.find('Joy_Select') != -1:
hil_contract_3_input = [
(consts.SE_HIL_CON_3_FIELD[0], [full_no] if online_sign else full_no),
(consts.SE_HIL_CON_3_FIELD[1], hmh_name),
(consts.SE_HIL_CON_3_FIELD[2], hmh_id),
(consts.SE_HIL_CON_3_FIELD[3], cms_info.get('dealerName', '')),
(consts.SE_HIL_CON_3_FIELD[4], full_no),
(consts.SE_HIL_CON_3_FIELD[5], hmh_name),
(consts.SE_HIL_CON_3_FIELD[6], hmh_id),
]
if online_sign:
hil_contract_3_input.append((consts.SE_HIL_CON_3_FIELD[7], hmh_name))
contract_info[consts.HIL_CONTRACT_3_EN] = hil_contract_3_input
# HIL合同 车辆租赁抵押合同 --------------------------------------------------------------------------------------
hil_contract_2_input = [
(consts.SE_HIL_CON_2_FIELD[0], full_no),
(consts.SE_HIL_CON_2_FIELD[1], full_no),
(consts.SE_HIL_CON_2_FIELD[2], vin_no),
(consts.SE_HIL_CON_2_FIELD[3], format(total_amount, '.2f')),
(consts.SE_HIL_CON_2_FIELD[4], str(cms_info.get('terms', '0'))),
]
for key, app_type, id_idx, field_idx, is_force, e_write in consts.ROLE_LIST_2:
if not e_write and not online_sign:
continue
is_find = False
if app_type in main_role_info:
if len(main_role_info[app_type]) >= id_idx+1:
is_find = True
if isinstance(field_idx, int):
hil_contract_2_input.append((key, main_role_info[app_type][id_idx][field_idx]))
else:
hil_contract_2_input.append((key, field_idx))
if not is_find and is_force:
hil_contract_2_input.append((key, empty_str))
contract_info[consts.HIL_CONTRACT_2_EN] = hil_contract_2_input
compare_info['contract'] = contract_info
return compare_info, cms_info.get('applicationVersion', 1)
else:
# AFC合同-----------------------------------------------------------------------------------------------------------
contract_info = {}
schedule_list = []
for schedule_dict in cms_info.get('paymentSchedule', []):
tmp_str = "{1}{0}{2}".format(consts.SPLIT_STR, str(schedule_dict.get('no', '')),
str(schedule_dict.get('grossRentalAmount', '')))
schedule_list.append(tmp_str)
schedule_list_str = consts.SCHEDULE_SPLIT_STR.join(schedule_list)
vehicle_principal_str = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0'))
afc_contract_input = [
(consts.SE_AFC_CON_FIELD[0], full_no),
......@@ -1238,7 +1309,6 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list):
afc_contract_input.pop(9)
# '借款人签字及时间', 'Borrower', 0, 0, True
online_sign = cms_info.get('contractSource', 'Online Sign') == 'Online Sign'
for key, app_type, id_idx, field_idx, is_force, e_write in consts.ROLE_LIST:
if not e_write and not online_sign:
continue
......@@ -1729,7 +1799,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list):
return result_field_list, no_ocr_result, field_img_path_dict
def se_afc_contract_compare(license_en, ocr_res_dict, strip_list):
def se_contract_compare(license_en, ocr_res_dict, strip_list):
ocr_field, compare_logic, _ = consts.SE_COMPARE_FIELD[license_en]
ocr_res_str = ocr_res_dict.get(ocr_field)
......@@ -1983,8 +2053,8 @@ def se_compare_process(compare_info, ocr_res_dict):
failure_field = []
if license_en == consts.MVC34_EN:
result_field_list, field_img_path_dict = se_mvc34_compare(license_en, ocr_res_dict, strip_list)
elif license_en == consts.AFC_CONTRACT_EN:
result_field_list, field_img_path_dict = se_afc_contract_compare(license_en, ocr_res_dict, strip_list)
elif license_en in [consts.HIL_CONTRACT_1_EN, consts.HIL_CONTRACT_2_EN, consts.HIL_CONTRACT_3_EN, consts.AFC_CONTRACT_EN]:
result_field_list, field_img_path_dict = se_contract_compare(license_en, ocr_res_dict, strip_list)
elif license_en == consts.BS_EN:
result_field_list, field_img_path_dict = se_bs_compare(license_en, ocr_res_dict, strip_list)
else:
......
......@@ -159,12 +159,17 @@ class Comparison:
return self.build_res(input_str == compare_str), compare_str
def se_list_compare(self, input_str, ocr_str_or_list, **kwargs):
if isinstance(ocr_str_or_list, list):
for item in ocr_str_or_list:
if item != input_str:
return self.RESULT_N
return self.RESULT_Y
def se_list_compare(self, input_str_or_list, ocr_str_or_list, **kwargs):
if isinstance(ocr_str_or_list, list) and len(ocr_str_or_list) > 0:
if isinstance(input_str_or_list, list) and len(input_str_or_list) > 0:
if input_str_or_list[0] == ocr_str_or_list[0]:
return self.RESULT_Y
return self.RESULT_N
else:
for item in ocr_str_or_list:
if item != input_str_or_list:
return self.RESULT_N
return self.RESULT_Y
else:
return self.RESULT_N
......@@ -177,7 +182,8 @@ class Comparison:
ocr_str_or_list.pop(0)
schedule_list = []
for row_list in ocr_str_or_list:
tmp_str = "{1}{0}{2}".format(self.SPLIT_STR, row_list[0], row_list[1].replace(',', ''))
tmp_str = "{1}{0}{2}".format(
self.SPLIT_STR, row_list[0], row_list[kwargs.get('value_idx', 1)].replace(',', ''))
schedule_list.append(tmp_str)
return self.build_res(self.SCHEDULE_SPLIT_STR.join(schedule_list) == input_str)
else:
......@@ -304,7 +310,6 @@ class Comparison:
except Exception as e:
return self.RESULT_N
def ca_date_compare(self, input_str, ocr_str, **kwargs):
if kwargs.get('long', False):
if '长期' in ocr_str or '永久' in ocr_str:
......@@ -366,7 +371,7 @@ class Comparison:
def se_amount_lte_compare(self, input_str, ocr_str, **kwargs):
try:
float_input = float(input_str)
float_ocr = float(ocr_str)
float_ocr = float(ocr_str.replace('元', '').replace(',', ''))
except Exception as e:
return self.RESULT_N
else:
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!