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
9376a8f2
authored
2021-08-09 14:58:30 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add result errorType
1 parent
afa51c13
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
24 deletions
src/celery_compare/tasks.py
src/celery_compare/tasks.py
View file @
9376a8f
...
...
@@ -23,11 +23,12 @@ from apps.doc.models import (
from
apps.doc
import
consts
from
apps.doc.ocr.gcap
import
gcap
from
apps.doc.exceptions
import
GCAPException
from
apps.doc.named_enum
import
RequestTeam
,
RequestTrigger
,
ProcessName
from
apps.doc.named_enum
import
RequestTeam
,
RequestTrigger
,
ProcessName
,
ErrorType
from
common.tools.comparison
import
cp
compare_log
=
logging
.
getLogger
(
'compare'
)
log_base
=
'[Compare]'
empty_str
=
''
def
name_check
(
ocr_res_dict
,
second_ocr_field
,
second_compare_list
,
second_id_num
,
name
):
...
...
@@ -209,7 +210,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
'applicationVersion'
:
last_obj
.
application_version
,
'vehicleStatus'
:
last_obj
.
vehicle_status
,
'wholeResult'
:
'N'
,
'wholeResultMessage'
:
''
,
'wholeResultMessage'
:
empty_str
,
'applicationLink'
:
r'//china.bmw.corp/WINFS/SF-CN-data/SF3-CN-S/SF3-CN-S-1-New Business/CA/OCR II test'
,
}
})
...
...
@@ -230,7 +231,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
sep_name
=
order_individual_cus_info
.
get
(
'customerChineseName'
)
if
isinstance
(
sep_name
,
str
):
sep_name
=
sep_name
.
strip
()
if
sep_name
==
''
:
if
sep_name
==
empty_str
:
sep_name
=
None
else
:
sep_name
=
None
...
...
@@ -296,12 +297,12 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
consts
.
PCUSD_DL
,
res_set
)
if
mvc_find
is
True
and
dl_find
is
False
:
vino
=
dl_vinos
[
-
1
]
if
len
(
dl_vinos
)
>
0
else
''
vino
=
dl_vinos
[
-
1
]
if
len
(
dl_vinos
)
>
0
else
empty_str
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
0
]]
=
'{0}-{1} {2} {3}-{4}'
.
format
(
consts
.
PREFIX_MVC
,
consts
.
RESULT_Y
,
consts
.
SPLIT
,
consts
.
PREFIX_DL
,
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
[
-
1
]
if
len
(
mvc_vinos
)
>
0
else
''
vino
=
mvc_vinos
[
-
1
]
if
len
(
mvc_vinos
)
>
0
else
empty_str
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
0
]]
=
'{0}-{1} {2} {3}-{4}'
.
format
(
consts
.
PREFIX_MVC
,
vino
,
consts
.
SPLIT
,
consts
.
PREFIX_DL
,
consts
.
RESULT_Y
)
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
4
]]
=
consts
.
RESULT_N
...
...
@@ -310,8 +311,8 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
0
]]
=
None
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
4
]]
=
consts
.
RESULT_NA
else
:
mvc_vino
=
mvc_vinos
[
-
1
]
if
len
(
mvc_vinos
)
>
0
else
''
dl_vino
=
dl_vinos
[
-
1
]
if
len
(
dl_vinos
)
>
0
else
''
mvc_vino
=
mvc_vinos
[
-
1
]
if
len
(
mvc_vinos
)
>
0
else
empty_str
dl_vino
=
dl_vinos
[
-
1
]
if
len
(
dl_vinos
)
>
0
else
empty_str
vino
=
'{0}-{1} {2} {3}-{4}'
.
format
(
consts
.
PREFIX_MVC
,
mvc_vino
,
consts
.
SPLIT
,
consts
.
PREFIX_DL
,
dl_vino
)
order_usedcar_info
[
consts
.
PCUSD_MVC
[
0
][
0
]]
=
vino
...
...
@@ -452,7 +453,7 @@ def ca_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
failure_reason
=
'、'
.
join
(
reason_list
)
else
:
failure_reason
=
''
failure_reason
=
empty_str
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
...
...
@@ -652,7 +653,7 @@ def se_compare_license(license_en, ocr_res_dict, field_list):
ocr_str
=
ocr_res_list
[
res_idx
]
.
get
(
compare_logic
[
name
][
0
])
if
not
isinstance
(
ocr_str
,
str
):
result
=
consts
.
RESULT_N
ocr_str
=
''
ocr_str
=
empty_str
else
:
result
=
getattr
(
cp
,
compare_logic
[
name
][
1
])(
value
,
ocr_str
,
**
compare_logic
[
name
][
2
])
...
...
@@ -670,11 +671,12 @@ def se_compare_license(license_en, ocr_res_dict, field_list):
result
=
expiry_date_res
break
result_field_list
.
append
((
name
,
value
,
result
,
ocr_str
))
error_type
=
empty_str
if
result
==
consts
.
RESULT_Y
else
ErrorType
.
OCR
.
value
result_field_list
.
append
((
name
,
value
,
result
,
ocr_str
,
error_type
))
if
not
is_find
:
for
name
,
value
in
field_list
:
result_field_list
.
append
((
name
,
value
,
consts
.
RESULT_N
,
''
))
result_field_list
.
append
((
name
,
value
,
consts
.
RESULT_N
,
empty_str
,
ErrorType
.
NF
.
value
))
return
result_field_list
...
...
@@ -698,11 +700,11 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list):
try
:
transfer_name
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
TRANSFER_NAME
,
[])[
idx
]
except
Exception
as
e
:
transfer_name
=
''
transfer_name
=
empty_str
try
:
transfer_num
=
ocr_res_list
[
res_idx
]
.
get
(
consts
.
TRANSFER_NUM
,
[])[
idx
]
except
Exception
as
e
:
transfer_num
=
''
transfer_num
=
empty_str
core_info
=
{
consts
.
TRANSFER_NAME
:
transfer_name
,
consts
.
TRANSFER_NUM
:
transfer_num
,
...
...
@@ -729,14 +731,15 @@ def se_mvc34_compare(license_en, ocr_res_dict, field_list):
ocr_str
=
ocr_res
.
get
(
compare_logic
[
name
][
0
])
if
not
isinstance
(
ocr_str
,
str
):
result
=
consts
.
RESULT_N
ocr_str
=
''
ocr_str
=
empty_str
else
:
result
=
getattr
(
cp
,
compare_logic
[
name
][
1
])(
value
,
ocr_str
,
**
compare_logic
[
name
][
2
])
result_field_list
.
append
((
name
,
value
,
result
,
ocr_str
))
error_type
=
empty_str
if
result
==
consts
.
RESULT_Y
else
ErrorType
.
OCR
.
value
result_field_list
.
append
((
name
,
value
,
result
,
ocr_str
,
error_type
))
if
not
is_find
:
for
name
,
value
in
field_list
:
result_field_list
.
append
((
name
,
value
,
consts
.
RESULT_N
,
''
))
result_field_list
.
append
((
name
,
value
,
consts
.
RESULT_N
,
empty_str
,
ErrorType
.
NF
.
value
))
return
result_field_list
...
...
@@ -759,7 +762,7 @@ def se_compare_process(compare_info, ocr_res_dict):
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
:
for
name
,
value
,
result
,
ocr_str
,
error_type
in
result_field_list
:
total_fields
+=
1
if
result
==
consts
.
RESULT_N
:
failed_count
+=
1
...
...
@@ -774,9 +777,9 @@ def se_compare_process(compare_info, ocr_res_dict):
'Input'
:
value
,
'OCR'
:
ocr_str
,
'Result'
:
result
,
'Position'
:
''
,
'Image'
:
''
,
'errorType'
:
''
,
'Position'
:
empty_str
,
'Image'
:
empty_str
,
'errorType'
:
error_type
,
}
)
failure_reason
.
setdefault
(
license_en
,
[])
.
append
(
'/'
.
join
(
failure_field
))
...
...
@@ -787,7 +790,7 @@ def se_compare_process(compare_info, ocr_res_dict):
result_field_list
=
se_mvc34_compare
(
license_en
,
ocr_res_dict
,
field_list
)
else
:
result_field_list
=
se_compare_license
(
license_en
,
ocr_res_dict
,
field_list
)
for
name
,
value
,
result
,
ocr_str
in
result_field_list
:
for
name
,
value
,
result
,
ocr_str
,
error_type
in
result_field_list
:
total_fields
+=
1
if
result
==
consts
.
RESULT_N
:
failed_count
+=
1
...
...
@@ -802,9 +805,9 @@ def se_compare_process(compare_info, ocr_res_dict):
'Input'
:
value
,
'OCR'
:
ocr_str
,
'Result'
:
result
,
'Position'
:
''
,
'Image'
:
''
,
'errorType'
:
''
,
'Position'
:
empty_str
,
'Image'
:
empty_str
,
'errorType'
:
error_type
,
}
)
failure_reason
.
setdefault
(
license_en
,
[])
.
append
(
'/'
.
join
(
failure_field
))
...
...
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