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
582db5c6
authored
2021-04-15 12:58:43 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix bug
1 parent
bf81e885
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
5 deletions
src/apps/doc/consts.py
src/celery_compare/tasks.py
src/common/tools/comparison.py
src/apps/doc/consts.py
View file @
582db5c
...
...
@@ -1138,7 +1138,7 @@ TCCOR = [
(
'taxRegistrationCode'
,
'注册号'
,
'common_compare'
,
{},
'taxRegistrationCodeResult'
),
(
'incorporationDate'
,
'成立日期'
,
'date_compare'
,
{
'ocr_replace'
:
True
},
'incorporationDateResult'
),
# 2017年07月11日
# 2017年07月11日至长期 1. OCR识别为长期,向GCAP发送:2099-12-31 00:00:00.0
(
'businessLicenseDueDate'
,
'营业期限'
,
'date_compare'
,
{
'long'
:
True
,
'ocr_replace'
:
True
},
'businessLicenseDueDateResult'
),
(
'businessLicenseDueDate'
,
'营业期限'
,
'date_compare'
,
{
'
ocr_split'
:
True
,
'
long'
:
True
,
'ocr_replace'
:
True
},
'businessLicenseDueDateResult'
),
(
'capitalRegAmount'
,
'注册资本'
,
'rmb_compare'
,
{},
'capitalRegAmountResult'
),
# 壹拾万元整 将OCR识别结果(人民币大写)转化为数字
]
...
...
src/celery_compare/tasks.py
View file @
582db5c
...
...
@@ -24,12 +24,22 @@ def get_order_dict(src_dict, order_tuple):
return
order_dict
def
field_compare
(
info_dict
,
ocr_res_dict
,
ocr_field
,
compare_list
,
res_set
):
def
field_compare
(
info_dict
,
ocr_res_dict
,
ocr_field
,
compare_list
,
res_set
,
has_expiry_date
=
False
):
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
)
# res_len = len(ocr_res_list)
# 过期期限特殊处理
if
has_expiry_date
:
expiry_dates
=
[]
key
=
compare_list
[
2
][
1
]
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
ocr_res_list
:
if
is_find
:
break
...
...
@@ -42,6 +52,20 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set):
if
idx
==
0
and
compare_res
in
[
consts
.
RESULT_N
,
consts
.
RESULT_NA
]:
break
is_find
=
True
# 过期期限特殊处理
if
idx
==
2
and
has_expiry_date
:
if
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
:
...
...
@@ -151,7 +175,7 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id):
id_type
=
order_individual_cus_info
.
get
(
'idType'
)
compare_info_list
=
consts
.
ID_TYPE_COMPARE
.
get
(
id_type
)
if
compare_info_list
is
not
None
:
field_compare
(
order_individual_cus_info
,
ocr_res_dict
,
compare_info_list
[
0
],
compare_info_list
[
1
],
res_set
)
field_compare
(
order_individual_cus_info
,
ocr_res_dict
,
compare_info_list
[
0
],
compare_info_list
[
1
],
res_set
,
has_expiry_date
=
True
)
# 第二证件
second_id_type
=
order_individual_cus_info
.
get
(
'secondIdType'
)
...
...
src/common/tools/comparison.py
View file @
582db5c
...
...
@@ -78,7 +78,10 @@ class Comparison:
if
kwargs
.
get
(
'long'
,
False
)
and
'长期'
in
ocr_str
:
return
self
.
RESULT_Y
,
'2099-12-31'
if
kwargs
.
get
(
'ocr_split'
,
False
):
ocr_str
=
ocr_str
.
split
(
'-'
)[
-
1
]
if
'至'
in
ocr_str
:
ocr_str
=
ocr_str
.
split
(
'至'
)[
-
1
]
elif
'-'
in
ocr_str
:
ocr_str
=
ocr_str
.
split
(
'-'
)[
-
1
]
if
kwargs
.
get
(
'ocr_replace'
,
False
):
ocr_str
=
ocr_str
.
replace
(
'年'
,
'-'
)
.
replace
(
'月'
,
'-'
)
.
replace
(
'日'
,
''
)
if
kwargs
.
get
(
'input_replace'
)
is
not
None
:
...
...
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