400c41a9 by 周伟奇

afc ht part2

1 parent 24c2e20c
......@@ -1598,6 +1598,31 @@ HMH_COMPARE_LOGIC = {
'签字': ('借款人签字/盖章', 'se_common_compare', {}, '抵押登记豁免函签字需人工核查'),
}
SE_AFC_CON_FIELD = ['合同编号-每页', '所购车辆价格-小写-重要条款', '车架号-重要条款', '贷款本金金额-重要条款', '贷款期限-重要条款',
'车辆贷款本金金额-重要条款', '附加产品融资贷款本金总额-重要条款', '所购车辆价格', '车架号', '经销商',
'贷款本金金额', '车辆贷款本金金额', '附加产品融资贷款本金总额', '贷款期限', '还款账号', '户名', '开户行',
'还款计划表', '项目1', '用途总金额', '贷款本金', '附加产品融资贷款本金总金额', '购置税校验']
HT_COMPARE_LOGIC = {
'合同编号-每页': ('合同编号-每页', 'se_list_compare', {}, '合同编号与系统不一致'),
'所购车辆价格-小写-重要条款': ('所购车辆价格-小写-重要条款', 'se_amount_str_compare', {}, '合同首页中车辆价格与系统不一致'),
'车架号-重要条款': ('车架号-重要条款', 'se_common_compare', {}, '合同首页中车架号与系统不一致'),
'贷款本金金额-重要条款': ('贷款本金金额-重要条款', 'se_amount_str_compare', {}, '合同首页中贷款本金与系统不一致'),
'贷款期限-重要条款': ('贷款期限-重要条款', 'se_common_compare', {}, '合同首页中贷款期限与系统不一致'),
'车辆贷款本金金额-重要条款': ('车辆贷款本金金额-重要条款', 'se_amount_str_compare', {}, '车辆贷款本金金额-重要条款'),
'附加产品融资贷款本金总额-重要条款': ('附加产品融资贷款本金总额-重要条款', 'se_amount_str_compare', {}, '合同首页中附加产品融资金额与系统不一致'),
'所购车辆价格': ('所购车辆价格', 'se_amount_str_compare', {}, '主合同页中车辆价格与系统不一致'),
'车架号': ('车架号', 'se_common_compare', {}, '主合同页中车架号与系统不一致'),
'经销商': ('经销商', 'se_common_compare', {}, '主合同页中经销商与系统不一致'),
'贷款本金金额': ('贷款本金金额', 'se_amount_str_compare', {}, '主合同页中贷款本金金额与系统不一致'),
'车辆贷款本金金额': ('车辆贷款本金金额', 'se_amount_str_compare', {}, '主合同页中车辆贷款本金金额与系统不一致'),
'附加产品融资贷款本金总额': ('附加产品融资贷款本金总额', 'se_amount_str_compare', {}, '主合同页中附加产品融资贷款本金总额与系统不一致'),
'贷款期限': ('贷款期限', 'se_common_compare', {}, '主合同页中贷款期限与系统不一致'),
'还款账号': ('还款账号', 'se_common_compare', {}, '主合同页中还款账号与系统不一致'),
'户名': ('户名', 'se_common_compare', {}, '主合同页中户名与系统不一致'),
'开户行': ('开户行', 'se_both_contain_compare', {}, '主合同页中开户行与系统不一致'),
}
# MVC_OCR_FIELD = 'mvc_ocr'
SE_DETECT_CARD = [UCI_EN, JYPZ_EN, HMH_EN, DDA_EN]
......@@ -1616,6 +1641,7 @@ SE_COMPARE_FIELD = {
DDA_EN: (DDA_OCR_FIELD, DDA_COMPARE_LOGIC, False),
HMH_EN: (HMH_OCR_FIELD, HMH_COMPARE_LOGIC, False),
JYPZ_EN: (JYPZ_OCR_FIELD, JYPZ_COMPARE_LOGIC, False),
AFC_CONTRACT_EN: (HT_FIELD, HT_COMPARE_LOGIC, False)
}
......
......@@ -1672,6 +1672,41 @@ 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):
ocr_field, compare_logic, _ = consts.SE_COMPARE_FIELD[license_en]
ocr_res_str = ocr_res_dict.get(ocr_field)
result_field_list = []
field_img_path_dict = dict()
if ocr_res_str is not None:
ocr_res_list = json.loads(ocr_res_str)
ocr_res = ocr_res_list.pop()
for name, value in strip_list:
ocr_str_or_list = ocr_res.get(compare_logic[name][0])
if isinstance(ocr_str_or_list, str) or isinstance(ocr_str_or_list, list):
result = getattr(cp, compare_logic[name][1])(value, ocr_str_or_list, **compare_logic[name][2])
if isinstance(ocr_str_or_list, list):
ocr_str = '、'.join(ocr_str_or_list)
else:
ocr_str = ocr_str_or_list
else:
result = consts.RESULT_N
ocr_str = empty_str
img_path = empty_str
error_type = empty_error_type if result == consts.RESULT_Y else ErrorType.OCR.value
result_field_list.append((name, value, result, ocr_str, img_path, error_type, compare_logic[name][3]))
else:
for name, value in strip_list:
result_field_list.append((name, value, consts.RESULT_N, empty_str, empty_str, ErrorType.NF.value,
'{0}未找到'.format(license_en)))
return result_field_list, field_img_path_dict
def se_mvc34_compare(license_en, ocr_res_dict, field_list):
ocr_field, compare_logic, _ = consts.SE_COMPARE_FIELD[license_en]
ocr_res_str = ocr_res_dict.get(ocr_field)
......@@ -1850,6 +1885,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)
else:
result_field_list, _, field_img_path_dict = se_compare_license(license_en, ocr_res_dict, strip_list)
for name, value, result, ocr_str, img_path, error_type, cn_reason in result_field_list:
......
......@@ -153,6 +153,15 @@ 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
else:
return self.RESULT_N
def se_name_compare(self, input_str, ocr_str, **kwargs):
if kwargs.get('is_passport'):
input_tmp = input_str.upper().replace(' ', '')
......@@ -280,6 +289,14 @@ class Comparison:
else:
return self.RESULT_Y
def se_amount_str_compare(self, input_str, ocr_str, **kwargs):
if input_str == ocr_str:
return self.RESULT_Y
else:
ocr_tmp = ocr_str.replace('元', '').replace(',', '')
input_tmp = input_str.replace('元', '').replace(',', '')
return self.build_res(ocr_tmp == input_tmp)
def se_amount_compare(self, input_str, ocr_str, **kwargs):
if input_str == ocr_str:
return self.RESULT_Y
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!