d56c5dd6 by 周伟奇

Merge branch 'feature/slice6' into feature/1119

2 parents d2114106 400c41a9
......@@ -1176,6 +1176,7 @@ UCI_OCR_FIELD = 'uci_ocr'
DDA_OCR_FIELD = 'bs_ocr'
HMH_OCR_FIELD = 'hmh_ocr'
JYPZ_OCR_FIELD = 'jypz_ocr'
HT_FIELD = 'ht_ocr'
RESULT_MAPPING = {
MVI_CLASSIFY: MVI_OCR_FIELD,
......@@ -1191,7 +1192,8 @@ RESULT_MAPPING = {
DDA_CLASSIFY: DDA_OCR_FIELD,
# VAT_CLASSIFY: 'vat_ocr',
HMH_CLASSIFY: HMH_OCR_FIELD,
JYPZ_CLASSIFY: JYPZ_OCR_FIELD
JYPZ_CLASSIFY: JYPZ_OCR_FIELD,
CONTRACT_CLASSIFY: HT_FIELD,
}
COMPARE_FIELDS = (MVI_OCR_FIELD,
......@@ -1391,6 +1393,26 @@ SE_HMH_FIELD = ['借款人/承租人姓名', '借款人/承租人证件号', '
SE_BANK_FIELD = ['accountNo', 'bankName']
SE_DDA_FIELD = ['applicationId(1)', 'applicationId(2)', 'bankName', 'companyName', 'customerName', 'idNum', 'accountHolderName', 'accountNo']
SE_AFC_CON_MAP = {
'合同编号-每页': (None, '合同编号', None),
'所购车辆价格-小写-重要条款': (1, '所购车辆价格', None),
'车架号-重要条款': (1, '车架号', None),
'贷款本金金额-重要条款': (1, '贷款本金金额', '小写'),
'贷款期限-重要条款': (1, '贷款期限', None),
'车辆贷款本金金额-重要条款': (1, '车辆贷款本金金额', None),
'附加产品融资贷款本金总额-重要条款': (1, '附加产品融资贷款本金总金额', None),
'所购车辆价格': (2, '所购车辆价格', None),
'车架号': (2, '车架号', None),
'经销商': (2, '经销商', None),
'贷款本金金额': (2, '贷款本金金额', '小写'),
'车辆贷款本金金额': (2, '车辆贷款本金金额', None),
'附加产品融资贷款本金总额': (2, '附加产品融资贷款本金总额', None),
'贷款期限': (2, '贷款期限', None),
'还款账号': (2, '还款账号', '账号'),
'户名': (2, '还款账号', '户名'),
'开户行': (2, '还款账号', '开户行'),
}
SE_AFC_CON_FIELD = ['合同编号-每页', '所购车辆价格-小写-重要条款', '车架号-重要条款', '贷款本金金额-重要条款', '贷款期限-重要条款',
'车辆贷款本金金额-重要条款', '附加产品融资贷款本金总额-重要条款', '所购车辆价格', '车架号', '经销商',
'贷款本金金额', '车辆贷款本金金额', '附加产品融资贷款本金总额', '贷款期限', '还款账号', '户名', '开户行',
......@@ -1576,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]
......@@ -1594,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)
}
......
......@@ -220,7 +220,8 @@ class Command(BaseCommand, LoggerMixin):
else:
res_list.append((pno, ino, part_idx, consts.RES_SUCCESS_EMPTY))
def contract_process(self, classify, ocr_data, contract_result, res_list, pno, ino, part_idx, img_path):
def contract_process(self, classify, ocr_data, contract_result, res_list, pno, ino, part_idx,
img_path, contract_result_compare):
contract_dict = ocr_data.get('data')
if not contract_dict or contract_dict.get('page_num') is None or contract_dict.get('page_info') is None:
res_list.append((pno, ino, part_idx, consts.RES_SUCCESS_EMPTY))
......@@ -260,9 +261,30 @@ class Command(BaseCommand, LoggerMixin):
for row_list in sub_value[text_key]:
rebuild_page_info.append(row_list)
# contract_result.setdefault(page_num_only, []).append(rebuild_page_info)
contract_result.setdefault(classify, dict()).setdefault(page_num_only, []).append(rebuild_page_info)
page_compare_dict = {}
for key, value in contract_dict.get('page_info', {}).items():
if not isinstance(value, dict):
continue
elif text_key in value:
if value[text_key] is None:
page_compare_dict[key] = ''
elif isinstance(value[text_key], str):
page_compare_dict[key] = value[text_key]
elif isinstance(value[text_key], list):
page_compare_dict[key] = value[text_key]
else:
page_compare_dict[key] = {}
for sub_key, sub_value in value.items():
if sub_value[text_key] is None:
page_compare_dict[key][sub_key] = ''
elif isinstance(sub_value[text_key], str):
page_compare_dict[key][sub_key] = sub_value[text_key]
contract_result_compare.setdefault(classify, dict())[page_num_only] = page_compare_dict
# def rebuild_result(self, ocr_data, classify, img_path):
# license_data = ocr_data.get('data')
# if not license_data:
......@@ -831,6 +853,22 @@ class Command(BaseCommand, LoggerMixin):
summary['role'] = self.get_most(summary['role'])
return bs_summary
def rebuild_contract(self, contract_result_compare):
res_list = []
for classify, page_info_dict in contract_result_compare.items():
res = {}
if classify == consts.CONTRACT_CLASSIFY:
for key, (pno, key1, key2) in consts.SE_AFC_CON_MAP.items():
if pno is None:
for i in range(1, 9):
res.setdefault(key, list()).append(page_info_dict.get(str(i), {}).get(key1, ''))
elif key2 is None:
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
def rebuild_bs_summary(self, bs_summary, unknown_summary):
# bs_summary = {
# '卡号': {
......@@ -1248,7 +1286,7 @@ class Command(BaseCommand, LoggerMixin):
self.online_log.error('{0} [process error (store ocr res)] [img_path={1}] [error={2}]'.format(
self.log_base, img_path, traceback.format_exc()))
def res_2_wb(self, res_dict, img_queue, finish_queue, lock, error_list):
def res_2_wb(self, res_dict, img_queue, finish_queue, error_list):
while len(error_list) == 0 or not img_queue.empty() or not finish_queue.empty():
try:
task_str = finish_queue.get(block=False)
......@@ -1289,6 +1327,7 @@ class Command(BaseCommand, LoggerMixin):
unknown_summary = {}
license_summary = {}
contract_result = {}
contract_result_compare = {}
res_list = []
interest_keyword = Keywords.objects.filter(
type=KeywordsType.INTEREST.value, on_off=True).values_list('keyword', flat=True)
......@@ -1441,7 +1480,7 @@ class Command(BaseCommand, LoggerMixin):
'{0} [ocr_2 failed] [img_path={1}]'.format(self.log_base, img_path))
elif classify in consts.CONTRACT_SET:
self.contract_process(classify, ocr_data, contract_result, res_list, pno,
ino, part_idx, img_path)
ino, part_idx, img_path, contract_result_compare)
else: # 流水处理
bs_classify_set.add(classify)
self.bs_process(wb, ocr_data, bs_summary, unknown_summary, classify, res_list, pno, ino, part_idx)
......@@ -1554,6 +1593,10 @@ 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
# 比对
if len(license_summary) > 0 and doc.document_scheme != consts.DOC_SCHEME_LIST[2]:
try:
......@@ -1929,7 +1972,7 @@ class Command(BaseCommand, LoggerMixin):
img_queue, todo_count_dict, res_dict, finish_queue, lock, url, error_list))
process_list.append(ocr_1_process)
wb_process = Process(target=self.res_2_wb, args=(res_dict, img_queue, finish_queue, lock, error_list))
wb_process = Process(target=self.res_2_wb, args=(res_dict, img_queue, finish_queue, error_list))
process_list.append(wb_process)
for p in process_list:
......
......@@ -313,6 +313,7 @@ class AFCOCRResult(models.Model):
vat_ocr = models.TextField(null=True, verbose_name="增值税发票")
hmh_ocr = models.TextField(null=True, verbose_name="豁免函")
jypz_ocr = models.TextField(null=True, verbose_name="二手车交易凭证")
ht_ocr = models.TextField(null=True, verbose_name="AFC合同")
update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
......@@ -342,6 +343,7 @@ class HILOCRResult(models.Model):
vat_ocr = models.TextField(null=True, verbose_name="增值税发票")
hmh_ocr = models.TextField(null=True, verbose_name="豁免函")
jypz_ocr = models.TextField(null=True, verbose_name="二手车交易凭证")
ht_ocr = models.TextField(null=True, verbose_name="AFC合同")
update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
......@@ -370,6 +372,7 @@ class AFCSEOCRResult(models.Model):
vat_ocr = models.TextField(null=True, verbose_name="增值税发票")
hmh_ocr = models.TextField(null=True, verbose_name="豁免函")
jypz_ocr = models.TextField(null=True, verbose_name="二手车交易凭证")
ht_ocr = models.TextField(null=True, verbose_name="AFC合同")
update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
......@@ -399,6 +402,7 @@ class HILSEOCRResult(models.Model):
vat_ocr = models.TextField(null=True, verbose_name="增值税发票")
hmh_ocr = models.TextField(null=True, verbose_name="豁免函")
jypz_ocr = models.TextField(null=True, verbose_name="二手车交易凭证")
ht_ocr = models.TextField(null=True, verbose_name="AFC合同")
update_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')
create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
......
......@@ -1088,77 +1088,80 @@ def get_se_cms_compare_info(last_obj, application_entity, detect_list):
other_info[consts.HMH_EN] = hmh_field_input
compare_info['other'] = other_info
# 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)
#
# afc_contract_input = [
# (consts.SE_AFC_CON_FIELD[0], full_no),
# (consts.SE_AFC_CON_FIELD[1], amount),
# (consts.SE_AFC_CON_FIELD[2], vin_no),
# (consts.SE_AFC_CON_FIELD[3], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))),
# (consts.SE_AFC_CON_FIELD[4], str(cms_info.get('terms', '0'))),
# (consts.SE_AFC_CON_FIELD[5], str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0'))),
# (consts.SE_AFC_CON_FIELD[6], str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.0'))),
# (consts.SE_AFC_CON_FIELD[7], amount),
# (consts.SE_AFC_CON_FIELD[8], vin_no),
# (consts.SE_AFC_CON_FIELD[9], cms_info.get('dealerName', '')),
# (consts.SE_AFC_CON_FIELD[10], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))),
# (consts.SE_AFC_CON_FIELD[11], str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0'))),
# (consts.SE_AFC_CON_FIELD[12], str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.0'))),
# (consts.SE_AFC_CON_FIELD[13], str(cms_info.get('terms', '0'))),
# (consts.SE_AFC_CON_FIELD[14], account_no),
# (consts.SE_AFC_CON_FIELD[15], cms_info.get('bankAccountDetails', {}).get('accountHolderName', '')),
# (consts.SE_AFC_CON_FIELD[16], bank_name),
# (consts.SE_AFC_CON_FIELD[17], schedule_list_str),
# ]
#
# asp_list = []
# for asp_info in cms_info.get('associatedServices', []):
# asp_list.append(
# (
# asp_info.get('associatedServices', ''),
# asp_info.get('price', 0.0),
# asp_info.get('financed', 0.0)
# )
# )
#
# if len(asp_list) > 0:
# fin_total = 0
# gzs_status = consts.GZS_STATUS[1]
# for asp_name, asp_price, asp_fin in asp_list:
# if gzs_status == consts.GZS_STATUS[1]:
# if consts.GZS_NAME in asp_name:
# gzs_status = consts.GZS_STATUS[0]
# if gzs_status == consts.GZS_STATUS[0]:
# if consts.GZS_NAME not in asp_name:
# gzs_status = consts.GZS_STATUS[2]
# afc_contract_input.extend(
# [
# (consts.SE_AFC_CON_FIELD[18], asp_name),
# (consts.SE_AFC_CON_FIELD[19], str(asp_price)),
# (consts.SE_AFC_CON_FIELD[20], str(asp_fin)),
# ]
# )
# fin_total += asp_fin
# afc_contract_input.append((consts.SE_AFC_CON_FIELD[21], str(fin_total)))
#
# # CMS Vehicle Price / 1.13 * 10 %
# gzs_list = [gzs_status]
# if gzs_status != consts.GZS_STATUS[1]:
# gzs_value = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', 0.0) * 0.1 / 1.13)
# gzs_list.append(gzs_value)
# afc_contract_input.append((consts.SE_AFC_CON_FIELD[22], consts.SPLIT_STR.join(gzs_list)))
#
# # role_name, _, role_id = main_role_info[applicant_type][0]
#
# contract_info[consts.AFC_CONTRACT_EN] = afc_contract_input
# compare_info['contract'] = contract_info
if application_entity in consts.HIL_SET:
return compare_info, cms_info.get('applicationVersion', 1)
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)
afc_contract_input = [
(consts.SE_AFC_CON_FIELD[0], full_no),
(consts.SE_AFC_CON_FIELD[1], amount),
(consts.SE_AFC_CON_FIELD[2], vin_no),
(consts.SE_AFC_CON_FIELD[3], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))),
(consts.SE_AFC_CON_FIELD[4], str(cms_info.get('terms', '0'))),
(consts.SE_AFC_CON_FIELD[5], str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0'))),
(consts.SE_AFC_CON_FIELD[6], str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.0'))),
(consts.SE_AFC_CON_FIELD[7], amount),
(consts.SE_AFC_CON_FIELD[8], vin_no),
(consts.SE_AFC_CON_FIELD[9], cms_info.get('dealerName', '')),
(consts.SE_AFC_CON_FIELD[10], str(cms_info.get('financialInformation', {}).get('originationPrincipal', '0.0'))),
(consts.SE_AFC_CON_FIELD[11], str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', '0.0'))),
(consts.SE_AFC_CON_FIELD[12], str(cms_info.get('financialInformation', {}).get('associatedServicePrincipal', '0.0'))),
(consts.SE_AFC_CON_FIELD[13], str(cms_info.get('terms', '0'))),
(consts.SE_AFC_CON_FIELD[14], account_no),
(consts.SE_AFC_CON_FIELD[15], cms_info.get('bankAccountDetails', {}).get('accountHolderName', '')),
(consts.SE_AFC_CON_FIELD[16], bank_name),
(consts.SE_AFC_CON_FIELD[17], schedule_list_str),
]
asp_list = []
for asp_info in cms_info.get('associatedServices', []):
asp_list.append(
(
asp_info.get('associatedServices', ''),
asp_info.get('price', 0.0),
asp_info.get('financed', 0.0)
)
)
if len(asp_list) > 0:
fin_total = 0
gzs_status = consts.GZS_STATUS[1]
for asp_name, asp_price, asp_fin in asp_list:
if gzs_status == consts.GZS_STATUS[1]:
if consts.GZS_NAME in asp_name:
gzs_status = consts.GZS_STATUS[0]
if gzs_status == consts.GZS_STATUS[0]:
if consts.GZS_NAME not in asp_name:
gzs_status = consts.GZS_STATUS[2]
afc_contract_input.extend(
[
(consts.SE_AFC_CON_FIELD[18], asp_name),
(consts.SE_AFC_CON_FIELD[19], str(asp_price)),
(consts.SE_AFC_CON_FIELD[20], str(asp_fin)),
]
)
fin_total += asp_fin
afc_contract_input.append((consts.SE_AFC_CON_FIELD[21], str(fin_total)))
# CMS Vehicle Price / 1.13 * 10 %
gzs_list = [gzs_status]
if gzs_status != consts.GZS_STATUS[1]:
gzs_value = str(cms_info.get('financialInformation', {}).get('vehiclePrincipal', 0.0) * 0.1 / 1.13)
gzs_list.append(gzs_value)
afc_contract_input.append((consts.SE_AFC_CON_FIELD[22], consts.SPLIT_STR.join(gzs_list)))
# role_name, _, role_id = main_role_info[applicant_type][0]
contract_info[consts.AFC_CONTRACT_EN] = afc_contract_input
compare_info['contract'] = contract_info
return compare_info, cms_info.get('applicationVersion', 1)
......@@ -1669,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)
......@@ -1847,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:
......
......@@ -158,6 +158,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(' ', '')
......@@ -285,6 +294,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
......
# import pyodbc
import pyodbc
# afc_sql = """
# create table afc_contract
# (
# id bigint identity primary key,
# application_id nvarchar(64) not null,
# create_time datetime not null
# );
hil_sql = """
ALTER TABLE hil_ocr_result ADD ht_ocr nvarchar(max);
ALTER TABLE hil_se_ocr_result ADD ht_ocr nvarchar(max);
"""
# create index afc_contract_application_id_index
# on afc_contract (application_id);
# """
afc_sql = """
ALTER TABLE afc_ocr_result ADD ht_ocr nvarchar(max);
ALTER TABLE afc_se_ocr_result ADD ht_ocr nvarchar(max);
"""
# hil_sql = """
# create table hil_contract
# (
# id bigint identity primary key,
# application_id nvarchar(64) not null,
# create_time datetime not null
# );
hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True)
# create index hil_contract_application_id_index
# on hil_contract (application_id);
# """
hil_cursor = hil_cnxn.cursor()
hil_cursor.execute(hil_sql)
# hil_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True)
hil_cursor.close()
hil_cnxn.close()
# hil_cursor = hil_cnxn.cursor()
# hil_cursor.execute(hil_sql)
afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True)
# hil_cursor.close()
# hil_cnxn.close()
afc_cursor = afc_cnxn.cursor()
afc_cursor.execute(afc_sql)
# afc_cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};', autocommit=True)
# afc_cursor = afc_cnxn.cursor()
# afc_cursor.execute(afc_sql)
# afc_cursor.close()
# afc_cnxn.close()
afc_cursor.close()
afc_cnxn.close()
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!