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
d47405de
authored
2021-07-08 20:03:15 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
se compare part 4
1 parent
0c7454b6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
8 deletions
src/apps/doc/named_enum.py
src/celery_compare/tasks.py
src/apps/doc/named_enum.py
View file @
d47405d
...
...
@@ -49,6 +49,7 @@ class ProcessName(NamedEnum):
IDCARD
=
(
2
,
'F2_IDReport'
)
DDA
=
(
3
,
'CL_S1_DDAConsolidation'
)
CACOMPARE
=
(
4
,
'S1_CA_DocumentVerify'
)
SE_CACOMPARE
=
(
5
,
'S1_SE_DocumentVerify'
)
class
WorkflowName
(
NamedEnum
):
...
...
src/celery_compare/tasks.py
View file @
d47405d
...
...
@@ -7,9 +7,13 @@ from collections import OrderedDict
from
.
import
app
from
apps.doc.models
import
(
AFCOCRResult
,
AFCSEOCRResult
,
HILOCRResult
,
HILSEOCRResult
,
AFCComparisonInfo
,
AFCSEComparisonInfo
,
HILComparisonInfo
,
HILSEComparisonInfo
,
Configs
,
HILCompareReport
,
AFCCompareReport
,
...
...
@@ -440,9 +444,22 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
else
:
# 将比对结果写入数据库
try
:
pass
result_table
=
HILSECompareResult
if
application_entity
==
consts
.
HIL_PREFIX
else
AFCSECompareResult
res_obj
=
result_table
.
objects
.
filter
(
application_id
=
application_id
)
.
first
()
if
res_obj
is
None
:
res_obj
=
result_table
()
res_obj
.
application_id
=
application_id
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
.
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
))
except
Exception
as
e
:
pass
compare_log
.
error
(
'{0} [SE] [result save error] [entity={1}] [id={2}] [ocr_res_id={3}] '
'[error={4}]'
.
format
(
log_base
,
application_entity
,
application_id
,
ocr_res_id
,
traceback
.
format_exc
()))
# report
try
:
...
...
@@ -456,12 +473,11 @@ def se_compare(application_id, application_entity, ocr_res_id, last_obj, ocr_res
transaction_end
=
end_time
,
successful_at_this_level
=
successful_at_this_level
,
failure_reason
=
failure_reason
,
process_name
=
ProcessName
.
CACOMPARE
.
value
,
process_name
=
ProcessName
.
SE_
CACOMPARE
.
value
,
total_fields
=
total_fields
,
workflow_name
=
customer_type
,
)
compare_log
.
info
(
'{0} [SE] [report save success] [entity={1}] [id={2}] [ocr_res_id={3}]'
.
format
(
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
))
except
Exception
as
e
:
compare_log
.
error
(
'{0} [SE] [report save error] [entity={1}] [id={2}] [ocr_res_id={3}] '
...
...
@@ -478,7 +494,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True
log_base
,
application_entity
,
application_id
,
uniq_seq
,
ocr_res_id
,
is_ca
))
# 根据application_id查找最新的比对信息,如果没有,结束
comparison_class
=
HILComparisonInfo
if
application_entity
==
consts
.
HIL_PREFIX
else
AFCComparisonInfo
if
is_ca
:
comparison_class
=
HILComparisonInfo
if
application_entity
==
consts
.
HIL_PREFIX
else
AFCComparisonInfo
else
:
comparison_class
=
HILSEComparisonInfo
if
application_entity
==
consts
.
HIL_PREFIX
else
AFCSEComparisonInfo
last_obj
=
comparison_class
.
objects
.
filter
(
application_id
=
application_id
)
.
last
()
if
last_obj
is
None
:
compare_log
.
info
(
'{0} [comparison info empty] [entity={1}] [id={2}] [uniq_seq={3}] [ocr_res_id={4}] '
...
...
@@ -486,7 +505,10 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True
return
# 根据application_id查找OCR累计结果指定license字段,如果没有,结束
result_class
=
HILOCRResult
if
application_entity
==
consts
.
HIL_PREFIX
else
AFCOCRResult
if
is_ca
:
result_class
=
HILOCRResult
if
application_entity
==
consts
.
HIL_PREFIX
else
AFCOCRResult
else
:
result_class
=
HILSEOCRResult
if
application_entity
==
consts
.
HIL_PREFIX
else
AFCSEOCRResult
if
ocr_res_id
is
None
:
ocr_res_dict
=
result_class
.
objects
.
filter
(
application_id
=
application_id
)
.
values
(
*
consts
.
COMPARE_FIELDS
)
.
first
()
else
:
...
...
@@ -499,7 +521,7 @@ def compare(application_id, application_entity, uniq_seq, ocr_res_id, is_ca=True
if
is_ca
:
ca_compare
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
ocr_res_dict
)
else
:
se_compare
()
se_compare
(
application_id
,
application_entity
,
ocr_res_id
,
last_obj
,
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