Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
dca5de92
authored
2021-07-12 01:06:43 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
se compare part 6
1 parent
eccdff28
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
432 additions
and
10 deletions
src/apps/doc/consts.py
src/apps/doc/views.py
src/celery_compare/tasks.py
src/apps/doc/consts.py
View file @
dca5de9
...
...
@@ -1023,12 +1023,12 @@ IC_RES_MAPPING = {
1
:
'真实证件'
,
}
# ----------------- compare ---------------------
# -----------------
CA
compare ---------------------
ENTITY
=
[
'HIL'
,
'AFC'
]
CUSTOMER_TYPE
=
[
'TCCOR'
,
'TCDAS'
,
'TCFRE'
,
'TCIAS'
,
'TCIND'
,
'TCSEP'
,
'TCURE'
]
VEHICLE_STATUS
=
[
'PCUSD'
,
'PCNEW'
]
APPLICANT_TYPE
=
[
'C
OAPP'
,
'CUSTR
'
,
'GAUTR1'
,
'GAUTR2'
]
APPLICANT_TYPE
=
[
'C
USTR'
,
'COAPP
'
,
'GAUTR1'
,
'GAUTR2'
]
ID_TYPE
=
[
'ITARI'
,
'ITHKM'
,
'ITPRC'
,
'ITPSP'
,
'ITRES'
,
'ITTID'
,
'ITUSC'
,
'ITCCU'
]
SECOND_ID_TYPE
=
[
'ITARI'
,
'ITHKM'
,
'ITPRC'
,
'ITPSP'
,
'ITRES'
,
'ITTID'
]
SUB_TYPE
=
[
'CSIBM'
,
'CSOTH'
,
'CSSME'
]
...
...
@@ -1074,7 +1074,18 @@ RESULT_MAPPING = {
# VAT_CLASSIFY: 'vat_ocr',
}
COMPARE_FIELDS
=
(
IC_OCR_FIELD
,
RP_OCR_FIELD
,
BL_OCR_FIELD
,
EEP_OCR_FIELD
,
DL_OCR_FIELD
,
PP_OCR_FIELD
,
MVC_OCR_FIELD
)
COMPARE_FIELDS
=
(
MVI_OCR_FIELD
,
IC_OCR_FIELD
,
RP_OCR_FIELD
,
BC_OCR_FIELD
,
BL_OCR_FIELD
,
UCI_OCR_FIELD
,
EEP_OCR_FIELD
,
DL_OCR_FIELD
,
PP_OCR_FIELD
,
MVC_OCR_FIELD
,
DDA_OCR_FIELD
,
)
# 身份证
ITPRC
=
[
...
...
@@ -1224,3 +1235,163 @@ DDA_MAPPING = [
(
DDA_BC_ID
,
BC_FIELD
),
]
# ----------------------- SE compare -----------------------
SE_FIRST_ID_FIELD
=
[
'customerName'
,
'idNum'
,
'dateOfBirth'
,
'idExpiryDate'
]
SE_ID_CARD_FIELD
=
[
'customerName'
,
'idNum'
,
'dateOfBirth'
,
'idExpiryDate'
,
'hukouProvince'
,
'hukouCity'
]
SE_SECOND_ID_FIELD
=
[
(
'customerName'
,
'customerName'
),
(
'secondIdNum'
,
'idNum'
),
]
SE_CORPORATE_ID_FIELD
=
[
(
'legalRepName'
,
'customerName'
),
(
'firstIdNo'
,
'idNum'
)
]
SE_SEP_FIELD
=
[
(
'companyName'
,
'companyName'
),
(
'customerName'
,
'legalRepName'
),
(
'registeredCapital'
,
'registeredCapital'
),
(
'selfEmployedSubType'
,
'organizationType'
)
]
SE_CORPORATE_FIELD
=
[
'companyName'
,
'legalRepName'
,
'businessLicenseNo'
,
'organizationCreditCode'
,
'taxRegistrationCertificateNo'
,
'establishmentDate'
,
'businessLicenseDueDate'
,
'organizationType'
]
SE_CORPORATE_ALL_FIELD
=
[
'companyName'
,
'legalRepName'
,
'firstIdNo'
,
'businessLicenseNo'
,
'organizationCreditCode'
,
'taxRegistrationCertificateNo'
,
'establishmentDate'
,
'businessLicenseDueDate'
,
'organizationType'
]
SE_NEW_FIELD
=
[
'vinNo'
,
'dealer'
,
'vehicleTransactionAmount'
]
SE_USED_FIELD
=
[
'vinNo'
,
'vehicleTransactionAmount'
]
SE_NEW_ADD_FIELD
=
[
'customerName'
,
'idNum'
,
'dateOfInvoice'
]
SE_BANK_FIELD
=
[
'accountNo'
,
'bankName'
]
SE_DDA_FIELD
=
[
'applicationId(1)'
,
'applicationId(2)'
,
'bankName'
,
'companyName'
,
'customerName'
,
'idNum'
,
'accountHolderName'
,
'accountNo'
]
HIL_COMPANY_NAME
=
'先锋国际融资租赁有限公司'
AFC_COMPANY_NAME
=
'宝马汽车金融(中国)有限公司'
ID_EN
=
'PRC ID'
PP_EN
=
'Passport'
EEP_EN
=
'Resident Permit to Mainland'
RP_EN
=
'Resident ID'
BL_EN
=
'Business permit'
MVI_EN
=
'newCar Invoice'
UCI_EN
=
'usedCar Invoice'
BC_EN
=
'Bank Card'
DDA_EN
=
'DDA'
ID_COMPARE_LOGIC
=
[
(
'customerName'
,
'姓名'
),
(
'idNum'
,
'公民身份号码'
),
(
'dateOfBirth'
,
'出生年月'
),
(
'idExpiryDate'
,
'有效期限'
),
(
'hukouProvince'
,
'住址'
),
(
'hukouCity'
,
'住址'
),
]
PP_COMPARE_LOGIC
=
[
(
'customerName'
,
'英文姓名'
),
(
'idNum'
,
'护照号码'
),
(
'dateOfBirth'
,
'出生日期'
),
(
'idExpiryDate'
,
'有效期至'
),
]
EEP_COMPARE_LOGIC
=
[
(
'customerName'
,
'中文名'
),
(
'idNum'
,
'证件号码'
),
(
'dateOfBirth'
,
'出生日期'
),
(
'idExpiryDate'
,
'有效期限'
),
]
RP_COMPARE_LOGIC
=
[
(
'customerName'
,
'姓名'
),
(
'idNum'
,
'公民身份号码'
),
(
'dateOfBirth'
,
'出生年月'
),
(
'idExpiryDate'
,
'有效期限'
),
(
'hukouProvince'
,
'住址'
),
(
'hukouCity'
,
'住址'
),
]
BL_COMPARE_LOGIC
=
[
(
'companyName'
,
'企业名称'
,
),
(
'legalRepName'
,
'经营者姓名'
,
),
(
'firstIdNo'
,
'注册号'
,
),
(
'businessLicenseNo'
,
'注册号'
,
),
(
'organizationCreditCode'
,
'注册号'
,
),
(
'taxRegistrationCertificateNo'
,
'注册号'
,
),
(
'establishmentDate'
,
'成立日期'
,
),
# 2017年07月11日
# 2017年07月11日至长期 1. OCR识别为长期,向GCAP发送:2099-12-31 00:00:00.0
(
'businessLicenseDueDate'
,
'营业期限'
),
(
'organizationType'
,
'企业类型'
,
),
# 有限责任公司
(
'registeredCapital'
,
'注册资本'
,
),
# 壹拾万元整 将OCR识别结果(人民币大写)转化为数字
]
MVI_COMPARE_LOGIC
=
[
(
'vinNo'
,
'车辆识别代码'
),
(
'dealer'
,
'销方名称'
),
(
'vehicleTransactionAmount'
,
'价税合计小写'
),
(
'customerName'
,
'购方名称'
),
(
'idNum'
,
'购买方身份证号或组织机构代码'
),
(
'dateOfInvoice'
,
'开票日期'
),
]
UCI_COMPARE_LOGIC
=
[
(
'vinNo'
,
'车架号'
),
(
'vehicleTransactionAmount'
,
'价税合计小写'
),
(
'customerName'
,
'购方名称'
),
(
'idNum'
,
'购方纳税人识别号'
),
]
SE_DDA_FIELD
=
[
'applicationId(1)'
,
'applicationId(2)'
,
'bankName'
,
'companyName'
,
'customerName'
,
'idNum'
,
'accountHolderName'
,
'accountNo'
]
BC_COMPARE_LOGIC
=
[
(
'accountNo'
,
'CardNum'
),
(
'bankName'
,
'BankName'
),
]
DDA_COMPARE_LOGIC
=
[
(
'applicationId(1)'
,
'CardNum'
),
(
'applicationId(2)'
,
'BankName'
),
(
'bankName'
,
'BankName'
),
(
'companyName'
,
'BankName'
),
(
'customerName'
,
'BankName'
),
(
'idNum'
,
'BankName'
),
(
'accountHolderName'
,
'BankName'
),
(
'accountNo'
,
'BankName'
),
]
# MVC_OCR_FIELD = 'mvc_ocr'
SE_COMPARE_FIELD
=
{
ID_EN
:
(
IC_OCR_FIELD
,
ID_COMPARE_LOGIC
,
True
),
PP_EN
:
(
PP_OCR_FIELD
,
PP_COMPARE_LOGIC
,
False
),
EEP_EN
:
(
EEP_OCR_FIELD
,
EEP_COMPARE_LOGIC
,
False
),
RP_EN
:
(
RP_OCR_FIELD
,
RP_COMPARE_LOGIC
,
True
),
BL_EN
:
(
BL_OCR_FIELD
,
BL_COMPARE_LOGIC
,
False
),
MVI_EN
:
(
MVI_OCR_FIELD
,
MVI_COMPARE_LOGIC
,
False
),
UCI_EN
:
(
UCI_OCR_FIELD
,
UCI_COMPARE_LOGIC
,
False
),
BC_EN
:
(
BC_OCR_FIELD
,
BC_COMPARE_LOGIC
,
False
),
DDA_EN
:
(
DDA_OCR_FIELD
,
DDA_COMPARE_LOGIC
,
False
),
}
SE_FIRST_ID_FIELD_MAPPING
=
{
'ITPRC'
:
(
ID_EN
,
SE_ID_CARD_FIELD
),
'ITPSP'
:
(
PP_EN
,
SE_FIRST_ID_FIELD
),
'ITHKM'
:
(
EEP_EN
,
SE_FIRST_ID_FIELD
),
'ITTID'
:
(
EEP_EN
,
SE_FIRST_ID_FIELD
),
'ITRES'
:
(
RP_EN
,
SE_FIRST_ID_FIELD
),
}
SE_SECOND_ID_FIELD_MAPPING
=
{
'ITPRC'
:
(
ID_EN
,
SE_SECOND_ID_FIELD
),
'ITPSP'
:
(
PP_EN
,
SE_SECOND_ID_FIELD
),
'ITHKM'
:
(
EEP_EN
,
SE_SECOND_ID_FIELD
),
'ITTID'
:
(
EEP_EN
,
SE_SECOND_ID_FIELD
),
'ITRES'
:
(
RP_EN
,
SE_SECOND_ID_FIELD
),
}
HEAD_LIST
=
[
'Info'
,
'Index'
,
'License'
,
'Field'
,
'Input'
,
'OCR'
,
'Result'
,
'Position'
,
'Image'
,
'errorType'
]
...
...
src/apps/doc/views.py
View file @
dca5de9
...
...
@@ -778,12 +778,11 @@ class CompareResultView(GenericView):
if
len
(
compare_result_list
)
==
0
:
body_html
=
"<h1>没有比对结果</h1>"
else
:
head_list
=
[
'Info'
,
'Index'
,
'License'
,
'Field'
,
'Result'
,
'Input'
,
'OCR'
,
'Position'
,
'Image'
,
'errorType'
]
head_content
=
''
.
join
([
'<th>{0}</th>'
.
format
(
head_name
)
for
head_name
in
head_list
])
head_content
=
''
.
join
([
'<th>{0}</th>'
.
format
(
head_name
)
for
head_name
in
consts
.
HEAD_LIST
])
head_html
=
'<tr>{0}</tr>'
.
format
(
head_content
)
row_html_list
=
[]
for
row_dict
in
compare_result_list
:
row_list
=
[
row_dict
.
get
(
head
,
''
)
for
head
in
head_list
]
row_list
=
[
row_dict
.
get
(
head
,
''
)
for
head
in
consts
.
HEAD_LIST
]
row_content
=
''
.
join
([
'<td>{0}</td>'
.
format
(
row_str
)
for
row_str
in
row_list
])
row_html
=
'<tr>{0}</tr>'
.
format
(
row_content
)
row_html_list
.
append
(
row_html
)
...
...
src/celery_compare/tasks.py
View file @
dca5de9
...
...
@@ -435,10 +435,261 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
traceback
.
format_exc
()))
def
get_se_compare_info
(
last_obj
,
application_entity
):
compare_info
=
{}
individual_info_dict
=
{}
main_role_info
=
{}
for
individual_info
in
json
.
loads
(
last_obj
.
individual_cus_info
):
main_role_info
.
setdefault
(
individual_info
[
'applicantType'
],
[])
.
append
(
(
individual_info
[
'customerName'
],
individual_info
[
'idNum'
]))
license_dict
=
{}
if
individual_info
[
'idType'
]
in
consts
.
SE_FIRST_ID_FIELD_MAPPING
:
license_en
,
field_list
=
consts
.
SE_FIRST_ID_FIELD_MAPPING
[
individual_info
[
'idType'
]]
field_input
=
[]
for
field
in
field_list
:
if
field
in
individual_info
:
field_input
.
append
((
field
,
individual_info
[
field
]))
license_dict
[
license_en
]
=
field_input
if
individual_info
[
'secondIdType'
]
in
consts
.
SE_SECOND_ID_FIELD_MAPPING
:
second_license_en
,
second_field_list
=
consts
.
SE_SECOND_ID_FIELD_MAPPING
[
individual_info
[
'secondIdType'
]]
if
second_license_en
not
in
license_dict
:
second_field_input
=
[]
for
second_field
,
write_field
in
second_field_list
:
if
second_field
in
individual_info
:
second_field_input
.
append
((
write_field
,
individual_info
[
second_field
]))
license_dict
[
second_license_en
]
=
second_field_input
if
individual_info
[
'customerType'
]
==
consts
.
CUSTOMER_TYPE
[
5
]:
sep_field_input
=
[]
for
sep_field
,
sep_write_field
in
consts
.
SE_SEP_FIELD
:
if
sep_field
in
individual_info
:
sep_field_input
.
append
((
sep_write_field
,
individual_info
[
sep_field
]))
license_dict
[
consts
.
BL_EN
]
=
sep_field_input
if
len
(
license_dict
)
>
0
:
individual_info_dict
.
setdefault
(
individual_info
[
'applicantType'
],
[])
.
append
(
license_dict
)
compare_info
[
'individualCusInfo'
]
=
individual_info_dict
for
applicant_type
in
consts
.
APPLICANT_TYPE
:
if
applicant_type
in
main_role_info
:
main_name
,
main_num
=
main_role_info
[
applicant_type
][
0
]
break
del
main_role_info
company_info
=
None
if
isinstance
(
last_obj
.
corporate_cus_info
,
str
):
corporate_info_dict
=
json
.
loads
(
last_obj
.
corporate_cus_info
)
corporate_info
=
{}
company_info
=
(
corporate_info_dict
[
'companyName'
],
corporate_info_dict
[
'businessLicenseNo'
])
if
corporate_info_dict
[
'firstIdType'
]
==
consts
.
ID_TYPE
[
6
]:
bl_field_input
=
[]
for
bl_field
in
consts
.
SE_CORPORATE_ALL_FIELD
:
bl_field_input
.
append
((
bl_field
,
corporate_info_dict
[
bl_field
]))
corporate_info
[
consts
.
BL_EN
]
=
bl_field_input
else
:
if
corporate_info_dict
[
'firstIdType'
]
in
consts
.
SE_FIRST_ID_FIELD_MAPPING
:
license_en
,
_
=
consts
.
SE_FIRST_ID_FIELD_MAPPING
[
corporate_info_dict
[
'firstIdType'
]]
first_id_field_input
=
[]
for
first_id_field
,
first_id_write_field
in
consts
.
SE_CORPORATE_ID_FIELD
:
first_id_field_input
.
append
((
first_id_write_field
,
corporate_info_dict
[
first_id_field
]))
corporate_info
[
license_en
]
=
first_id_field_input
bl_field_input
=
[]
for
bl_field
in
consts
.
SE_CORPORATE_FIELD
:
bl_field_input
.
append
((
bl_field
,
corporate_info_dict
[
bl_field
]))
corporate_info
[
consts
.
BL_EN
]
=
bl_field_input
compare_info
[
'corporateCusInfo'
]
=
corporate_info
vehicle_info_dict
=
json
.
loads
(
last_obj
.
vehicle_info
)
# TODO 车辆登记证
vehicle_info
=
{}
vehicle_field_input
=
[]
if
vehicle_info_dict
[
'vehicleStatus'
]
==
'New'
:
for
vehicle_field
in
consts
.
SE_NEW_FIELD
:
vehicle_field_input
.
append
((
vehicle_field
,
vehicle_info_dict
[
vehicle_field
]))
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
0
],
main_name
))
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
1
],
main_num
))
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
2
],
last_obj
.
first_submmison_date
))
vehicle_info
[
consts
.
MVI_EN
]
=
vehicle_field_input
else
:
for
vehicle_field
in
consts
.
SE_USED_FIELD
:
vehicle_field_input
.
append
((
vehicle_field
,
vehicle_info_dict
[
vehicle_field
]))
if
isinstance
(
company_info
,
tuple
):
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
0
],
company_info
[
0
]))
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
1
],
company_info
[
1
]))
else
:
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
0
],
main_name
))
vehicle_field_input
.
append
((
consts
.
SE_NEW_ADD_FIELD
[
1
],
main_num
))
vehicle_info
[
consts
.
UCI_EN
]
=
vehicle_field_input
compare_info
[
'vehicleInfo'
]
=
vehicle_info
bank_info_dict
=
json
.
loads
(
last_obj
.
bank_info
)
bank_info
=
{}
bank_field_input
=
[]
for
bank_field
in
consts
.
SE_BANK_FIELD
:
bank_field_input
.
append
((
bank_field
,
bank_info_dict
[
bank_field
]))
bank_info
[
consts
.
BC_EN
]
=
bank_field_input
dda_field_input
=
[]
for
dda_field
in
consts
.
SE_DDA_FIELD
:
if
dda_field
.
startswith
(
'applicationId'
):
dda_field_input
.
append
((
dda_field
,
last_obj
.
application_id
))
elif
dda_field
==
'companyName'
:
company_name
=
consts
.
HIL_COMPANY_NAME
if
application_entity
in
consts
.
HIL_SET
else
consts
.
AFC_COMPANY_NAME
dda_field_input
.
append
((
dda_field
,
company_name
))
elif
dda_field
==
'customerName'
:
dda_field_input
.
append
((
dda_field
,
main_name
))
elif
dda_field
==
'idNum'
:
dda_field_input
.
append
((
dda_field
,
main_num
))
else
:
dda_field_input
.
append
((
dda_field
,
bank_info_dict
[
dda_field
]))
bank_info
[
consts
.
DDA_EN
]
=
dda_field_input
compare_info
[
'bankInfo'
]
=
bank_info
return
compare_info
def
se_compare_license
(
license_en
,
ocr_res_dict
,
field_list
):
ocr_field
,
compare_logic
,
special_expiry_date
=
consts
.
SE_COMPARE_FIELD
[
license_en
]
is_find
=
False
ocr_res_str
=
ocr_res_dict
.
get
(
ocr_field
)
if
ocr_res_str
is
not
None
:
ocr_res_list
=
json
.
loads
(
ocr_res_str
)
length
=
len
(
ocr_res_list
)
# 身份证、居住证 过期期限特殊处理
if
special_expiry_date
:
expiry_dates
=
[]
key
=
compare_logic
[
2
][
1
]
# for ocr_res in tmp_list:
for
ocr_res
in
ocr_res_list
:
if
ocr_res
.
get
(
key
):
expiry_dates
.
append
(
ocr_res
.
get
(
key
))
else
:
expiry_dates
=
[]
# for ocr_res in tmp_list:
for
ocr_res
in
ocr_res_list
:
if
is_find
:
break
for
idx
,
compare_tuple
in
enumerate
(
compare_list
):
input_str
=
info_dict
.
get
(
compare_tuple
[
0
])
ocr_str
=
ocr_res
.
get
(
compare_tuple
[
1
])
compare_res
,
ocr_output
=
getattr
(
cp
,
compare_tuple
[
2
])(
input_str
,
ocr_str
,
idx
,
**
compare_tuple
[
3
])
# print('type: {0}, idx: {1}, field: {2}, input: {3}, ocr: {4}, res: {5}, out: {6}'.format(ocr_field, idx, compare_tuple[0], input_str, ocr_str, compare_res, ocr_output))
if
idx
==
0
and
compare_res
in
[
consts
.
RESULT_N
,
consts
.
RESULT_NA
]
and
length
>
1
:
break
is_find
=
True
# 过期期限特殊处理
if
idx
==
2
and
has_expiry_date
and
compare_res
==
consts
.
RESULT_NA
:
for
expiry_date
in
expiry_dates
:
expiry_date_compare_res
,
expiry_date_ocr_output
=
getattr
(
cp
,
compare_tuple
[
2
])(
input_str
,
expiry_date
,
idx
,
**
compare_tuple
[
3
]
)
if
expiry_date_compare_res
==
consts
.
RESULT_Y
:
compare_res
=
consts
.
RESULT_Y
ocr_output
=
expiry_date_ocr_output
ocr_str
=
expiry_date
break
info_dict
[
compare_tuple
[
4
]]
=
compare_res
if
input_str
is
not
None
:
if
ocr_str
is
None
or
ocr_output
is
None
:
del
info_dict
[
compare_tuple
[
0
]]
else
:
info_dict
[
compare_tuple
[
0
]]
=
ocr_output
res_set
.
add
(
compare_res
)
if
not
is_find
:
res_set
.
add
(
consts
.
RESULT_N
)
for
compare_tuple
in
compare_list
:
info_dict
[
compare_tuple
[
4
]]
=
consts
.
RESULT_NA
if
compare_tuple
[
0
]
in
info_dict
:
del
info_dict
[
compare_tuple
[
0
]]
def
se_compare_process
(
compare_info
,
ocr_res_dict
):
# individualCusInfo
# corporateCusInfo
# vehicleInfo
# bankInfo
compare_result
=
[]
total_fields
=
0
failed_count
=
0
successful_at_this_level
=
True
failure_reason
=
{}
for
info_key
,
info_value
in
compare_info
.
items
():
if
info_key
==
'individualCusInfo'
:
for
idx
,
license_dict
in
info_value
.
items
():
for
license_en
,
field_list
in
license_dict
.
items
():
failure_field
=
[]
result_field_list
=
se_compare_license
(
license_en
,
ocr_res_dict
,
field_list
)
for
name
,
value
,
result
,
ocr_str
in
result_field_list
:
total_fields
+=
1
if
result
==
consts
.
RESULT_N
:
failed_count
+=
1
successful_at_this_level
=
False
failure_field
.
append
(
name
)
compare_result
.
append
(
{
'Info'
:
info_key
,
'Index'
:
idx
,
'License'
:
license_en
,
'Field'
:
name
,
'Input'
:
value
,
'OCR'
:
ocr_str
,
'Result'
:
result
,
'Position'
:
''
,
'Image'
:
''
,
'errorType'
:
''
,
}
)
failure_reason
.
setdefault
(
license_en
,
[])
.
append
(
'/'
.
join
(
failure_field
))
else
:
for
license_en
,
field_list
in
info_value
.
items
():
failure_field
=
[]
result_field_list
=
se_compare_license
(
license_en
,
ocr_res_dict
,
field_list
)
for
name
,
value
,
result
,
ocr_str
in
result_field_list
:
total_fields
+=
1
if
result
==
consts
.
RESULT_N
:
failed_count
+=
1
successful_at_this_level
=
False
failure_field
.
append
(
name
)
compare_result
.
append
(
{
'Info'
:
info_key
,
'Index'
:
0
,
'License'
:
license_en
,
'Field'
:
name
,
'Input'
:
value
,
'OCR'
:
ocr_str
,
'Result'
:
result
,
'Position'
:
''
,
'Image'
:
''
,
'errorType'
:
''
,
}
)
failure_reason
.
setdefault
(
license_en
,
[])
.
append
(
'/'
.
join
(
failure_field
))
failure_reason_list
=
[]
for
license_en
,
failed_field_list
in
failure_reason
.
items
():
failure_reason_list
.
append
(
'{0}:{1}'
.
format
(
license_en
,
';'
.
join
(
failed_field_list
)))
failure_reason_str
=
'、'
.
join
(
failure_reason_list
)
return
compare_result
,
total_fields
,
failed_count
,
successful_at_this_level
,
failure_reason_str
def
se_compare
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
):
try
:
# 比对逻辑
pass
start_time
=
datetime
.
now
()
compare_info
=
get_se_compare_info
(
last_obj
,
application_entity
)
compare_result
,
total_fields
,
failed_count
,
successful_at_this_level
,
failure_reason_str
=
se_compare_process
(
compare_info
,
ocr_res_dict
)
except
Exception
as
e
:
pass
else
:
...
...
@@ -452,7 +703,7 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
res_obj
.
compare_count
=
total_fields
res_obj
.
failed_count
=
failed_count
# res_obj.reason1_count = reason1_count
res_obj
.
result
=
json
.
dumps
(
compare_result
_str
)
res_obj
.
result
=
json
.
dumps
(
compare_result
)
res_obj
.
save
()
compare_log
.
info
(
'{0} [SE] [result save success] [entity={1}] [id={2}] [ocr_res_id={3}]'
.
format
(
log_base
,
application_entity
,
application_id
,
ocr_res_id
))
...
...
@@ -462,6 +713,7 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
traceback
.
format_exc
()))
# report
end_time
=
datetime
.
now
()
try
:
request_trigger
=
RequestTrigger
.
SUBMITING
.
value
if
ocr_res_id
is
None
else
RequestTrigger
.
UPLOADING
.
value
report_class
=
HILCompareReport
if
application_entity
==
consts
.
HIL_PREFIX
else
AFCCompareReport
...
...
@@ -472,10 +724,10 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
transaction_start
=
start_time
,
transaction_end
=
end_time
,
successful_at_this_level
=
successful_at_this_level
,
failure_reason
=
failure_reason
,
failure_reason
=
failure_reason
_str
,
process_name
=
ProcessName
.
SE_CACOMPARE
.
value
,
total_fields
=
total_fields
,
workflow_name
=
customer_type
,
workflow_name
=
last_obj
.
customer_type
,
)
compare_log
.
info
(
'{0} [SE] [report save success] [entity={1}] [id={2}] [ocr_res_id={3}]'
.
format
(
log_base
,
application_entity
,
application_id
,
ocr_res_id
))
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment