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
022411dc
authored
2021-04-25 15:00:05 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix vino
1 parent
a473474e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
37 deletions
src/apps/doc/consts.py
src/celery_compare/tasks.py
src/apps/doc/consts.py
View file @
022411d
...
...
@@ -1163,5 +1163,8 @@ UC_ORDER = ('vinNo', 'manufactureDate', 'firstRegistrationDate')
CO_ORDER
=
(
'customerType'
,
'customerChineseName'
,
'legalRepName'
,
'idNum'
,
'businessLicenseNo'
,
'taxRegistrationCode'
,
'incorporationDate'
,
'businessLicenseDueDate'
,
'capitalRegAmount'
)
PREFIX_MVC
=
'GB'
PREFIX_DL
=
'DL'
...
...
src/celery_compare/tasks.py
View file @
022411d
...
...
@@ -49,23 +49,22 @@ def field_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_set, has
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
))
#
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
:
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
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
:
...
...
@@ -90,17 +89,16 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s
if
ocr_res_str
is
not
None
:
ocr_res_list
=
json
.
loads
(
ocr_res_str
)
# 车辆登记证3、4页去除
if
ocr_field
==
consts
.
MVC_OCR_FIELD
:
tmp_list
=
[]
for
res
in
ocr_res_list
:
if
res
.
get
(
compare_list
[
0
][
1
])
is
not
None
:
tmp_list
.
append
(
res
)
ocr_res_list
=
tmp_list
# 3、4页/副页去除
# if ocr_field == consts.MVC_OCR_FIELD:
tmp_list
=
[]
for
res
in
ocr_res_list
:
if
res
.
get
(
compare_list
[
0
][
1
])
is
not
None
:
tmp_list
.
append
(
res
)
length
=
len
(
ocr_res
_list
)
length
=
len
(
tmp
_list
)
for
ocr_res
in
ocr_res
_list
:
for
ocr_res
in
tmp
_list
:
if
is_find
:
break
for
idx
,
compare_tuple
in
enumerate
(
compare_list
):
...
...
@@ -108,7 +106,7 @@ def usedcar_info_compare(info_dict, ocr_res_dict, ocr_field, compare_list, res_s
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
))
#
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
]:
if
ocr_str
is
not
None
:
no_match_vino
.
append
(
ocr_str
)
...
...
@@ -226,21 +224,22 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id):
dl_find
,
dl_vinos
=
usedcar_info_compare
(
order_usedcar_info
,
ocr_res_dict
,
consts
.
DL_OCR_FIELD
,
consts
.
PCUSD_DL
,
res_set
)
if
mvc_find
is
True
and
dl_find
is
False
:
vino
=
dl_vinos
[
0
]
if
len
(
dl_vinos
)
>
0
else
''
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
0
]]
=
vino
vino
=
dl_vinos
[
-
1
]
if
len
(
dl_vinos
)
>
0
else
''
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
0
]]
=
'{0}: {1}'
.
format
(
consts
.
PREFIX_MVC
,
vino
)
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
4
]]
=
consts
.
RESULT_N
elif
mvc_find
is
False
and
dl_find
is
True
:
vino
=
mvc_vinos
[
0
]
if
len
(
mvc_vinos
)
>
0
else
''
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
0
]]
=
vino
vino
=
mvc_vinos
[
-
1
]
if
len
(
mvc_vinos
)
>
0
else
''
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
0
]]
=
'{0}: {1}'
.
format
(
consts
.
PREFIX_DL
,
vino
)
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
4
]]
=
consts
.
RESULT_N
elif
mvc_find
is
False
and
dl_find
is
False
:
vino_list
=
[]
if
len
(
mvc_vinos
)
>
0
:
vino_list
.
append
(
mvc_vinos
[
0
])
if
len
(
dl_vinos
)
>
0
:
vino_list
.
append
(
dl_vinos
[
0
])
vino
=
'、'
.
join
(
vino_list
)
mvc_vino
=
mvc_vinos
[
-
1
]
if
len
(
mvc_vinos
)
>
0
else
''
dl_vino
=
dl_vinos
[
-
1
]
if
len
(
dl_vinos
)
>
0
else
''
vino_list
.
append
(
'{0}: {1}'
.
format
(
consts
.
PREFIX_MVC
,
mvc_vino
))
vino_list
.
append
(
dl_vinos
[
-
1
])
vino
=
'、'
.
join
(
'{0}: {1}'
.
format
(
consts
.
PREFIX_DL
,
dl_vino
)
)
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
0
]]
=
vino
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
4
]]
=
consts
.
RESULT_N
comparison_res
[
'OCR_Input'
][
'usedCarInfo'
]
=
order_usedcar_info
...
...
@@ -262,6 +261,12 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id):
'[compare_res={5}]'
.
format
(
log_base
,
application_entity
,
application_id
,
uniq_seq
,
ocr_res_id
,
comparison_res
))
is_gcap_send
=
Configs
.
objects
.
filter
(
id
=
1
)
.
first
()
if
is_gcap_send
is
not
None
and
is_gcap_send
.
value
==
'N'
:
compare_log
.
info
(
'{0} [gcap closed] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}]'
.
format
(
log_base
,
application_entity
,
application_id
,
uniq_seq
,
ocr_res_id
))
return
# 时间延迟
send_time
=
last_obj
.
create_time
+
timedelta
(
seconds
=
15
)
while
datetime
.
now
()
<
send_time
:
...
...
@@ -269,12 +274,6 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id):
log_base
,
application_entity
,
application_id
,
uniq_seq
,
ocr_res_id
))
time
.
sleep
(
5
)
is_gcap_send
=
Configs
.
objects
.
filter
(
id
=
1
)
.
first
()
if
is_gcap_send
is
not
None
and
is_gcap_send
.
value
==
'N'
:
compare_log
.
info
(
'{0} [gcap closed] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}]'
.
format
(
log_base
,
application_entity
,
application_id
,
uniq_seq
,
ocr_res_id
))
return
# 将比对结果发送GCAP
try
:
data
=
gcap
.
dict_to_xml
(
comparison_res
)
...
...
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