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
d777eccb
authored
2021-07-12 13:49:00 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
se compare part 7
1 parent
dca5de92
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
104 deletions
src/apps/doc/consts.py
src/celery_compare/tasks.py
src/apps/doc/consts.py
View file @
d777ecc
...
...
@@ -1260,6 +1260,8 @@ SE_CORPORATE_ALL_FIELD = ['companyName', 'legalRepName', 'firstIdNo', 'businessL
SE_NEW_FIELD
=
[
'vinNo'
,
'dealer'
,
'vehicleTransactionAmount'
]
SE_USED_FIELD
=
[
'vinNo'
,
'vehicleTransactionAmount'
]
SE_NEW_ADD_FIELD
=
[
'customerName'
,
'idNum'
,
'dateOfInvoice'
]
SE_GB_NEW_FIELD
=
[
'vinNo'
]
SE_GB_USED_FIELD
=
[
'customerName'
,
'idNum'
,
'date'
]
SE_BANK_FIELD
=
[
'accountNo'
,
'bankName'
]
SE_DDA_FIELD
=
[
'applicationId(1)'
,
'applicationId(2)'
,
'bankName'
,
'companyName'
,
'customerName'
,
'idNum'
,
'accountHolderName'
,
'accountNo'
]
...
...
@@ -1274,89 +1276,93 @@ RP_EN = 'Resident ID'
BL_EN
=
'Business permit'
MVI_EN
=
'newCar Invoice'
UCI_EN
=
'usedCar Invoice'
MVC_EN
=
'Green Book'
BC_EN
=
'Bank Card'
DDA_EN
=
'DDA'
ID_COMPARE_LOGIC
=
[
(
'customerName'
,
'姓名'
),
(
'idNum'
,
'公民身份号码'
),
(
'dateOfBirth'
,
'出生年月'
),
(
'idExpiryDate'
,
'有效期限'
),
(
'hukouProvince'
,
'住址'
),
(
'hukouCity'
,
'住址'
),
]
PP_COMPARE_LOGIC
=
[
(
'customerName'
,
'英文姓名'
),
(
'idNum'
,
'护照号码'
),
(
'dateOfBirth'
,
'出生日期'
),
(
'idExpiryDate'
,
'有效期至'
),
]
ID_COMPARE_LOGIC
=
{
'customerName'
:
(
'姓名'
,
),
'idNum'
:
(
'公民身份号码'
,
),
'dateOfBirth'
:
(
'出生年月'
,
),
'idExpiryDate'
:
(
'有效期限'
,
),
'hukouProvince'
:
(
'住址'
,
),
'hukouCity'
:
(
'住址'
,
),
}
EEP_COMPARE_LOGIC
=
[
(
'customerName'
,
'中文名'
),
(
'idNum'
,
'证件号码'
),
(
'dateOfBirth'
,
'出生日期'
),
(
'idExpiryDate'
,
'有效期限'
),
]
PP_COMPARE_LOGIC
=
{
'customerName'
:
(
'英文姓名'
,
),
'idNum'
:
(
'护照号码'
,
),
'dateOfBirth'
:
(
'出生日期'
,
),
'idExpiryDate'
:
(
'有效期至'
,
),
}
RP_COMPARE_LOGIC
=
[
(
'customerName'
,
'姓名'
),
(
'idNum'
,
'公民身份号码'
),
(
'dateOfBirth'
,
'出生年月'
),
(
'idExpiryDate'
,
'有效期限'
),
(
'hukouProvince'
,
'住址'
),
(
'hukouCity'
,
'住址'
),
]
EEP_COMPARE_LOGIC
=
{
'customerName'
:
(
'中文名'
,
),
'idNum'
:
(
'证件号码'
,
),
'dateOfBirth'
:
(
'出生日期'
,
),
'idExpiryDate'
:
(
'有效期限'
,
),
}
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识别结果(人民币大写)转化为数字
]
RP_COMPARE_LOGIC
=
{
'customerName'
:
(
'姓名'
,
),
'idNum'
:
(
'公民身份号码'
,
),
'dateOfBirth'
:
(
'出生年月'
,
),
'idExpiryDate'
:
(
'有效期限'
,
),
'hukouProvince'
:
(
'住址'
,
),
'hukouCity'
:
(
'住址'
,
),
}
MVI_COMPARE_LOGIC
=
[
(
'vinNo'
,
'车辆识别代码'
),
(
'dealer'
,
'销方名称'
),
(
'vehicleTransactionAmount'
,
'价税合计小写'
),
(
'customerName'
,
'购方名称'
),
(
'idNum'
,
'购买方身份证号或组织机构代码'
),
(
'dateOfInvoice'
,
'开票日期'
),
]
BL_COMPARE_LOGIC
=
{
'companyName'
:
(
'企业名称'
,
),
'legalRepName'
:
(
'经营者姓名'
,
),
'firstIdNo'
:
(
'注册号'
,
),
'businessLicenseNo'
:
(
'注册号'
,
),
'organizationCreditCode'
:
(
'注册号'
,
),
'taxRegistrationCertificateNo'
:
(
'注册号'
,
),
'establishmentDate'
:
(
'成立日期'
,
),
'businessLicenseDueDate'
:
(
'营业期限'
,
),
'organizationType'
:
(
'企业类型'
,
),
'registeredCapital'
:
(
'注册资本'
,
),
}
UCI_COMPARE_LOGIC
=
[
(
'vinNo'
,
'车架号'
),
(
'vehicleTransactionAmount'
,
'价税合计小写'
),
(
'customerName'
,
'购方名称'
),
(
'idNum'
,
'购方纳税人识别号'
),
]
MVI_COMPARE_LOGIC
=
{
'vinNo'
:
(
'车辆识别代码'
,
),
'dealer'
:
(
'销方名称'
,
),
'vehicleTransactionAmount'
:
(
'价税合计小写'
,
),
'customerName'
:
(
'购方名称'
,
),
'idNum'
:
(
'购买方身份证号或组织机构代码'
,
),
'dateOfInvoice'
:
(
'开票日期'
,
),
}
SE_DDA_FIELD
=
[
'applicationId(1)'
,
'applicationId(2)'
,
'bankName'
,
'companyName'
,
'customerName'
,
'idNum'
,
'accountHolderName'
,
'accountNo'
]
UCI_COMPARE_LOGIC
=
{
'vinNo'
:
(
'车架号'
,
),
'vehicleTransactionAmount'
:
(
'价税合计小写'
,
),
'customerName'
:
(
'购方名称'
,
),
'idNum'
:
(
'购方纳税人识别号'
,
),
}
MVC_COMPARE_LOGIC
=
{
'vinNo'
:
(
'9.车辆识别代号/车架号'
,
),
# 'customerName': ('姓名/名称', ),
# 'idNum': ('身份证明名称/号码', ),
# 'date': ('转移登记日期', ),
}
BC_COMPARE_LOGIC
=
[
(
'accountNo'
,
'CardNum'
),
(
'bankName'
,
'BankName'
),
]
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'
),
]
DDA_COMPARE_LOGIC
=
{
'applicationId(1)'
:
(
'check_Num'
,
),
'applicationId(2)'
:
(
'check_Num'
,
),
'bankName'
:
(
'to_bank'
,
),
'companyName'
:
(
'to_company'
,
),
'customerName'
:
(
DDA_IC_NAME
,
),
'idNum'
:
(
DDA_IC_ID
,
),
'accountHolderName'
:
(
DDA_BC_NAME
,
),
'accountNo'
:
(
DDA_BC_ID
,
),
}
# MVC_OCR_FIELD = 'mvc_ocr'
...
...
@@ -1369,6 +1375,7 @@ SE_COMPARE_FIELD = {
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
),
MVC_EN
:
(
MVC_OCR_FIELD
,
MVC_COMPARE_LOGIC
,
False
),
BC_EN
:
(
BC_OCR_FIELD
,
BC_COMPARE_LOGIC
,
False
),
DDA_EN
:
(
DDA_OCR_FIELD
,
DDA_COMPARE_LOGIC
,
False
),
}
...
...
src/celery_compare/tasks.py
View file @
d777ecc
...
...
@@ -507,23 +507,35 @@ def get_se_compare_info(last_obj, application_entity):
vehicle_info_dict
=
json
.
loads
(
last_obj
.
vehicle_info
)
# TODO 车辆登记证
vehicle_info
=
{}
vehicle_field_input
=
[]
gb_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
))
for
gb_field
in
consts
.
SE_GB_NEW_FIELD
:
gb_field_input
.
append
((
gb_field
,
vehicle_info_dict
[
gb_field
]))
vehicle_info
[
consts
.
MVI_EN
]
=
vehicle_field_input
vehicle_info
[
consts
.
MVC_EN
]
=
gb_field_input
else
:
for
vehicle_field
in
consts
.
SE_USED_FIELD
:
vehicle_field_input
.
append
((
vehicle_field
,
vehicle_info_dict
[
vehicle_field
]))
for
gb_field
in
consts
.
SE_GB_NEW_FIELD
:
gb_field_input
.
append
((
gb_field
,
vehicle_info_dict
[
gb_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
]))
# gb_field_input.append((consts.SE_GB_USED_FIELD[0], company_info[0]))
# gb_field_input.append((consts.SE_GB_USED_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
))
# gb_field_input.append((consts.SE_GB_USED_FIELD[0], main_name))
# gb_field_input.append((consts.SE_GB_USED_FIELD[1], main_num))
# gb_field_input.append((consts.SE_GB_USED_FIELD[2], last_obj.first_submmison_date))
vehicle_info
[
consts
.
UCI_EN
]
=
vehicle_field_input
vehicle_info
[
consts
.
MVC_EN
]
=
gb_field_input
compare_info
[
'vehicleInfo'
]
=
vehicle_info
bank_info_dict
=
json
.
loads
(
last_obj
.
bank_info
)
...
...
@@ -556,6 +568,7 @@ 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
result_field_list
=
[]
ocr_res_str
=
ocr_res_dict
.
get
(
ocr_field
)
if
ocr_res_str
is
not
None
:
ocr_res_list
=
json
.
loads
(
ocr_res_str
)
...
...
@@ -563,54 +576,46 @@ def se_compare_license(license_en, ocr_res_dict, field_list):
# 身份证、居住证 过期期限特殊处理
if
special_expiry_date
:
expiry_dates
=
[]
key
=
compare_logic
[
2
][
1
]
# for ocr_res in tmp_list:
expiry_dates
=
set
()
key
=
compare_logic
.
get
(
'idExpiryDate'
)[
0
]
for
ocr_res
in
ocr_res_list
:
if
ocr_res
.
get
(
key
)
:
expiry_dates
.
a
ppend
(
ocr_res
.
get
(
key
)
)
if
key
in
ocr_res
:
expiry_dates
.
a
dd
(
ocr_res
[
key
]
)
else
:
expiry_dates
=
[]
expiry_dates
=
set
()
# 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
:
for
idx
,
(
name
,
value
)
in
enumerate
(
field_list
):
ocr_str
=
ocr_res
.
get
(
compare_logic
[
name
][
0
])
if
not
isinstance
(
ocr_str
,
str
):
result
=
consts
.
RESULT_N
else
:
result
=
getattr
(
cp
,
compare_logic
[
name
][
1
])(
value
,
ocr_str
,
**
compare_logic
[
name
][
2
])
if
idx
==
0
and
result
==
consts
.
RESULT_N
and
length
>
1
:
break
is_find
=
True
# 过期期限特殊处理
if
idx
==
2
and
has_expiry_date
and
compare_res
==
consts
.
RESULT_NA
:
if
special_expiry_date
and
name
==
'idExpiryDate'
and
result
==
consts
.
RESULT_N
:
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
expiry_date_res
=
getattr
(
cp
,
compare_logic
[
name
][
1
])(
value
,
expiry_date
,
**
compare_logic
[
name
][
2
])
if
expiry_date_res
==
consts
.
RESULT_Y
:
ocr_str
=
expiry_date
result
=
expiry_date_res
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
)
result_field_list
.
append
((
name
,
value
,
result
,
ocr_str
))
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
]]
for
name
,
value
in
field_list
:
result_field_list
.
append
((
name
,
value
,
consts
.
RESULT_N
,
''
))
return
result_field_list
def
se_compare_process
(
compare_info
,
ocr_res_dict
):
...
...
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