c9458276 by 冯轩

Merge branch 'feature/CHINARPA-5015'

2 parents 5d76daa9 08da5011
......@@ -1503,7 +1503,7 @@ SE_DYSYR_VALUE = '无'
SE_LAYOUT_VALUE = '旧版-旧打印、新版-新打印'
SE_GB_NEW_FIELD = ['vinNo']
SE_GB_USED_FIELD = ['customerName', 'idNum', 'date']
SE_BS_FIELD = ['户名', '打印日期', '流水日期', '(担保人1)户名', '(担保人1)打印日期', '(担保人1)流水日期', '(担保人2)户名', '(担保人2)打印日期', '(担保人2)流水日期']
SE_BS_FIELD = ['户名', '打印日期', '流水日期', '(担保人1)户名', '(担保人1)打印日期', '(担保人1)流水日期', '(担保人2)户名', '(担保人2)打印日期', '(担保人2)流水日期', '类型']
SE_HMH_FIELD = ['借款人/承租人姓名', '借款人/承租人证件号', '申请号', '渠道', '签字']
SE_BD_FIELD = ['被保险人姓名', '被保险人证件号码', '车架号', '机动车损失保险金额', '第三者责任保险金额', '绝对免赔率', '保险起始日期', '保险截止日期', '保单章', '第一受益人', '保险费合计']
JDMPV_VALUE = ['-', '--', '0%', '0.00', '/', '0', '']
......@@ -2017,6 +2017,7 @@ BS_COMPARE_LOGIC = {
'流水日期': ('timedelta', 'se_bs_date_compare', {}, '主共借人银行流水日期不满足3个月'),
'(担保人1)流水日期': ('timedelta', 'se_bs_date_compare', {}, '担保人1银行流水日期不满足3个月'),
'(担保人2)流水日期': ('timedelta', 'se_bs_date_compare', {}, '担保人2银行流水日期不满足3个月'),
'类型': ('bankStatement_type', 'se_bs_type_compare', {}, '高风险经销商流水类型异常'),
}
BS_COMPARE_LOGIC_AUTO = {
......@@ -2029,6 +2030,7 @@ BS_COMPARE_LOGIC_AUTO = {
'流水日期': ('timedelta', 'se_bs_date_compare', {}, '主共借人银行流水日期不满足2个月'),
'(担保人1)流水日期': ('timedelta', 'se_bs_date_compare', {}, '担保人1银行流水日期不满足2个月'),
'(担保人2)流水日期': ('timedelta', 'se_bs_date_compare', {}, '担保人2银行流水日期不满足2个月'),
'类型': ('bankStatement_type', 'se_bs_type_compare', {}, '高风险经销商流水类型异常'),
}
SPECIAL_REASON = '主共借人未提供银行流水,含担保人需人工查看直系亲属关系'
......
......@@ -1205,6 +1205,8 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d
compare_info['bankInfo'] = bank_info
# 银行流水 --------------------------------------------------------------------
#增加 allow_bs_type 默认值,防止不需要比对流水的申请报错
allow_bs_type = '全部'
if cms_info.get('autoApprovedDetails', {}).get('aaType', '') in ['CAA1', 'CAA2'] and \
'无需提供银行流水' not in cms_info.get('autoApprovedDetails', {}).get('PolicyComments', ''):
date_timedelta = 60 if auto else 90
......@@ -1221,6 +1223,14 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d
(consts.SE_BS_FIELD[2], date_timedelta),
]
#在比对逻辑中添加字段
if '仅接受银行流水' in cms_info.get('autoApprovedDetails', {}).get('PolicyComments', ''):
#bs_field_input.append((consts.SE_BS_FIELD[9], '仅接受银行流水'))
allow_bs_type = '仅接受银行流水'
else:
#bs_field_input.append((consts.SE_BS_FIELD[9], '全部'))
allow_bs_type = '全部'
dbr_bs_role_list = []
for dbr_bs_role, _, _ in main_role_info.get(consts.APPLICANT_TYPE_ORDER[2], []):
dbr_bs_role_list.append(dbr_bs_role)
......@@ -1481,7 +1491,7 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d
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('autoApprovedDetails', {}).get('aaType', ''), is_gsyh
return compare_info, cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh, allow_bs_type
else:
# AFC合同------------------------------------------------------------------------------------------------------
vehicle_principal_str = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0'))
......@@ -1560,7 +1570,7 @@ def get_se_cms_compare_info_auto(application_id, last_obj, application_entity, d
contract_info[consts.AFC_CONTRACT_QRS_EN] = afc_contract_qrs_input
compare_info['contract'] = contract_info
return compare_info, cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh
return compare_info, cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh, allow_bs_type
def get_se_cms_compare_info(application_id, last_obj, application_entity, detect_list, data_source, auto=False, ignore_bank=False):
......@@ -1865,6 +1875,8 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect
compare_info['bankInfo'] = bank_info
# 银行流水 --------------------------------------------------------------------
#增加 allow_bs_type 默认值,防止不需要比对流水的申请报错
allow_bs_type = '全部'
if cms_info.get('autoApprovedDetails', {}).get('aaType', '') in ['CAA1', 'CAA2'] and \
'无需提供银行流水' not in cms_info.get('autoApprovedDetails', {}).get('PolicyComments', ''):
date_timedelta = 60 if auto else 90
......@@ -1881,6 +1893,14 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect
(consts.SE_BS_FIELD[2], date_timedelta),
]
#在比对逻辑中添加字段
if '仅接受银行流水' in cms_info.get('autoApprovedDetails', {}).get('PolicyComments', ''):
#bs_field_input.append((consts.SE_BS_FIELD[9], '仅接受银行流水'))
allow_bs_type = '仅接受银行流水'
else:
#bs_field_input.append((consts.SE_BS_FIELD[9], '全部'))
allow_bs_type = '全部'
dbr_bs_role_list = []
for dbr_bs_role, _, _ in main_role_info.get(consts.APPLICANT_TYPE_ORDER[2], []):
dbr_bs_role_list.append(dbr_bs_role)
......@@ -2107,7 +2127,7 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect
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), cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh
return compare_info, cms_info.get('applicationVersion', 1), cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh, allow_bs_type
else:
# AFC合同------------------------------------------------------------------------------------------------------
vehicle_principal_str = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0'))
......@@ -2185,10 +2205,10 @@ def get_se_cms_compare_info(application_id, last_obj, application_entity, detect
afc_contract_qrs_input = [(consts.SE_AFC_CON_QRS_FIELD[0], '{0}{1}{2}'.format(role_count, consts.SPLIT_STR, full_no))]
contract_info[consts.AFC_CONTRACT_QRS_EN] = afc_contract_qrs_input
compare_info['contract'] = contract_info
return compare_info, cms_info.get('applicationVersion', 1), cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh
return compare_info, cms_info.get('applicationVersion', 1), cms_info.get('autoApprovedDetails', {}).get('aaType', ''), is_gsyh, allow_bs_type
def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type):
def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type, allow_bs_type):
# 主共借至少提供一个
# 有担保人,担保人必须提供。主共借没有时,修改comment:人工查看担保人亲属关系
......@@ -2202,6 +2222,7 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type):
field_img_path_dict = dict()
if ocr_res_str is not None:
# 字段在比对逻辑中添加的,这个地方不用改,如果要是在get_info时添加,要改这个
pre_field_list = strip_list[:3]
dbr1_field_list = strip_list[3:6]
dbr2_field_list = strip_list[6:]
......@@ -2220,11 +2241,18 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type):
auto_paper_verify_false_idx_list = []
auto_elec_verify_false_idx_list = []
all_zhifubao_weixin = True
for tmp_idx, ocr_res in enumerate(ocr_res_list):
correct_count = 0
pre_tmp_res_part = {}
verify_bool = ocr_res.get('verify', False)
e_bank = ocr_res.get('e_bank', False)
bankStatement_type = ocr_res.get('bankStatement_type', '')
# 如果是高风险经销商,cms信息中包含‘仅接受银行流水’,但是识别出的流水是支付宝/微信,直接跳过这个文件,就当不存在
if allow_bs_type == '仅接受银行流水' and bankStatement_type in ['12', '13', '48']:
continue
all_zhifubao_weixin = False
#verify_list.append(verify_bool)
if not verify_bool:
verify_false_idx_list.append(str(tmp_idx+1))
......@@ -2308,12 +2336,24 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type):
reason2 = '第{0}份银行流水为纸质版,请核查流水真伪。'.format('、'.join(auto_paper_verify_false_idx_list))
reason = reason1 + reason2
result_field_list.append((name, empty_str, result, json.dumps(verify_list, ensure_ascii=False), empty_str, empty_error_type, reason))
if all_zhifubao_weixin:
# 核查点名称,cms传值,比对结果,ocr结果,图片路径,错误类型,错误描述
result_field_list.append(('类型', allow_bs_type, consts.RESULT_N, '全部为支付宝/微信', empty_str, ErrorType.NF.value, '高风险经销商流水类型异常'))
else:
result_field_list.append(('类型', allow_bs_type, consts.RESULT_Y, '包含支持的流水类型', empty_str, empty_error_type, ''))
# 担保人1
dbr1_best_res = {}
if len(dbr1_field_list) > 0:
max_correct_count = 0
for ocr_res in ocr_res_list:
bankStatement_type = ocr_res.get('bankStatement_type', '')
# 如果是高风险经销商,cms信息中包含‘仅接受银行流水’,但是识别出的流水是支付宝/微信,直接跳过这个文件,就当不存在
if allow_bs_type == '仅接受银行流水' and bankStatement_type in ['12', '13', '48']:
continue
correct_count = 0
dbr1_tmp_res_part = {}
for idx, (name, value) in enumerate(dbr1_field_list):
......@@ -2346,6 +2386,10 @@ def se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type):
if len(dbr1_field_list) > 0:
max_correct_count = 0
for ocr_res in ocr_res_list:
bankStatement_type = ocr_res.get('bankStatement_type', '')
# 如果是高风险经销商,cms信息中包含‘仅接受银行流水’,但是识别出的流水是支付宝/微信,直接跳过这个文件,就当不存在
if allow_bs_type == '仅接受银行流水' and bankStatement_type in ['12', '13', '48']:
continue
correct_count = 0
dbr2_tmp_res_part = {}
for idx, (name, value) in enumerate(dbr2_field_list):
......@@ -3253,7 +3297,7 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list):
return result_field_list, field_img_path_dict
def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list, aa_type):
def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list, aa_type, allow_bs_type):
# individualCusInfo
# corporateCusInfo
# vehicleInfo
......@@ -3350,7 +3394,8 @@ def se_compare_process(compare_info, ocr_res_dict, is_gsyh, is_auto, id_res_list
elif license_en == consts.AFC_CONTRACT_QRS_EN:
result_field_list, field_img_path_dict = se_contract_qrs_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, is_auto, aa_type)
# 银行流水的比对,是只要有正确的就可以,所以没有按照时间顺序,先比最新的,在比最早的,如果以后要改逻辑,切记这个
result_field_list, field_img_path_dict = se_bs_compare(license_en, ocr_res_dict, strip_list, is_auto, aa_type, allow_bs_type)
elif license_en == consts.FS_EN:
result_field_list, field_img_path_dict = se_fs_compare(license_en, ocr_res_dict, strip_list)
else:
......@@ -3439,11 +3484,11 @@ def se_compare_auto(application_id, application_entity, ocr_res_id, last_obj, oc
try:
# 比对逻辑
# detect_list = se_result_detect(ocr_res_dict)
compare_info, aa_type, is_gsyh = get_se_cms_compare_info_auto(
compare_info, aa_type, is_gsyh, allow_bs_type = get_se_cms_compare_info_auto(
application_id, last_obj, application_entity, data_source, ignore_bank=ignore_bank)
compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, \
cn_failure_reason_str, bs_failure_reason_str, _, field_result_dict = se_compare_process(
compare_info, ocr_res_dict, is_gsyh, True, id_res_list, aa_type)
compare_info, ocr_res_dict, is_gsyh, True, id_res_list, aa_type, allow_bs_type)
compare_log.info('{0} [Auto SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format(
log_base, application_entity, application_id, ocr_res_id, compare_result))
except Exception as e:
......@@ -3506,11 +3551,11 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
# 比对逻辑
start_time = datetime.now()
detect_list = se_result_detect(ocr_res_dict)
compare_info, application_version, aa_type, is_gsyh = get_se_cms_compare_info(
compare_info, application_version, aa_type, is_gsyh, allow_bs_type = get_se_cms_compare_info(
application_id, last_obj, application_entity, detect_list, data_source, ignore_bank=ignore_bank)
compare_result, total_fields, failed_count, successful_at_this_level, failure_reason_str, \
cn_failure_reason_str, bs_failure_reason_str, rpa_failure_reason, field_result_dict = se_compare_process(
compare_info, ocr_res_dict, is_gsyh, False, id_res_list, aa_type)
compare_info, ocr_res_dict, is_gsyh, False, id_res_list, aa_type, allow_bs_type)
compare_log.info('{0} [SE] [compare success] [entity={1}] [id={2}] [ocr_res_id={3}] [result={4}]'.format(
log_base, application_entity, application_id, ocr_res_id, compare_result))
except Exception as e:
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!