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
78354bef
authored
2021-03-30 17:22:52 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
cancel test
1 parent
201ab38c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
45 deletions
src/apps/doc/management/commands/ocr_process.py
src/apps/doc/views.py
src/apps/doc/management/commands/ocr_process.py
View file @
78354be
...
...
@@ -888,54 +888,54 @@ class Command(BaseCommand, LoggerMixin):
os
.
remove
(
excel_path
)
finally
:
# TODO 识别结果存一张表,方便跑报表
# if doc.document_scheme == consts.DOC_SCHEME_LIST[0]:
try
:
# 更新OCR累计识别结果表
result_class
=
HILOCRResult
if
business_type
==
consts
.
HIL_PREFIX
else
AFCOCRResult
res_obj
=
result_class
.
objects
.
filter
(
application_id
=
doc
.
application_id
)
.
first
()
if
res_obj
is
None
:
res_obj
=
result_class
()
res_obj
.
application_id
=
doc
.
application_id
for
classify
,
field
in
consts
.
RESULT_MAPPING
.
items
():
license_list
=
license_summary
.
get
(
classify
)
if
not
license_list
:
continue
if
classify
==
consts
.
IC_CLASSIFY
and
ic_merge
:
license_list
[
0
]
.
update
(
license_list
[
1
])
license_list
.
pop
(
1
)
elif
classify
==
consts
.
RP_CLASSIFY
and
rp_merge
:
license_list
[
0
]
.
update
(
license_list
[
1
])
license_list
.
pop
(
1
)
if
not
hasattr
(
res_obj
,
field
):
continue
old_res_str
=
getattr
(
res_obj
,
field
)
if
old_res_str
is
None
:
last_res_str
=
json
.
dumps
(
license_list
)
else
:
old_res_list
=
json
.
loads
(
old_res_str
)
old_res_list
.
extend
(
license_list
)
last_res_str
=
json
.
dumps
(
old_res_list
)
setattr
(
res_obj
,
field
,
last_res_str
)
res_obj
.
save
()
except
Exception
as
e
:
self
.
online_log
.
error
(
'{0} [process error (ocr result save)] [task={1}] [error={2}]'
.
format
(
self
.
log_base
,
task_str
,
traceback
.
format_exc
()))
else
:
self
.
online_log
.
info
(
'{0} [ocr result save success] [task={1}] [res_id={2}]'
.
format
(
self
.
log_base
,
task_str
,
res_obj
.
id
))
# 触发比对
if
doc
.
document_scheme
==
consts
.
DOC_SCHEME_LIST
[
0
]:
try
:
# pass
compare
.
apply_async
((
doc
.
application_id
,
business_type
,
None
,
res_obj
.
id
),
queue
=
'queue_compare'
)
# 更新OCR累计识别结果表
result_class
=
HILOCRResult
if
business_type
==
consts
.
HIL_PREFIX
else
AFCOCRResult
res_obj
=
result_class
.
objects
.
filter
(
application_id
=
doc
.
application_id
)
.
first
()
if
res_obj
is
None
:
res_obj
=
result_class
()
res_obj
.
application_id
=
doc
.
application_id
for
classify
,
field
in
consts
.
RESULT_MAPPING
.
items
():
license_list
=
license_summary
.
get
(
classify
)
if
not
license_list
:
continue
if
classify
==
consts
.
IC_CLASSIFY
and
ic_merge
:
license_list
[
0
]
.
update
(
license_list
[
1
])
license_list
.
pop
(
1
)
elif
classify
==
consts
.
RP_CLASSIFY
and
rp_merge
:
license_list
[
0
]
.
update
(
license_list
[
1
])
license_list
.
pop
(
1
)
if
not
hasattr
(
res_obj
,
field
):
continue
old_res_str
=
getattr
(
res_obj
,
field
)
if
old_res_str
is
None
:
last_res_str
=
json
.
dumps
(
license_list
)
else
:
old_res_list
=
json
.
loads
(
old_res_str
)
old_res_list
.
extend
(
license_list
)
last_res_str
=
json
.
dumps
(
old_res_list
)
setattr
(
res_obj
,
field
,
last_res_str
)
res_obj
.
save
()
except
Exception
as
e
:
self
.
online_log
.
error
(
'{0} [process error (
comparison info send
)] [task={1}] [error={2}]'
.
format
(
'{0} [process error (
ocr result save
)] [task={1}] [error={2}]'
.
format
(
self
.
log_base
,
task_str
,
traceback
.
format_exc
()))
else
:
self
.
online_log
.
info
(
'{0} [comparison info send success] [task={1}] '
'[res_id={2}]'
.
format
(
self
.
log_base
,
task_str
,
res_obj
.
id
))
self
.
online_log
.
info
(
'{0} [ocr result save success] [task={1}] [res_id={2}]'
.
format
(
self
.
log_base
,
task_str
,
res_obj
.
id
))
# 触发比对
try
:
# pass
compare
.
apply_async
((
doc
.
application_id
,
business_type
,
None
,
res_obj
.
id
),
queue
=
'queue_compare'
)
except
Exception
as
e
:
self
.
online_log
.
error
(
'{0} [process error (comparison info send)] [task={1}] [error={2}]'
.
format
(
self
.
log_base
,
task_str
,
traceback
.
format_exc
()))
else
:
self
.
online_log
.
info
(
'{0} [comparison info send success] [task={1}] '
'[res_id={2}]'
.
format
(
self
.
log_base
,
task_str
,
res_obj
.
id
))
finally
:
try
:
img_save_path
=
os
.
path
.
join
(
doc_data_path
,
'img'
)
...
...
src/apps/doc/views.py
View file @
78354be
...
...
@@ -443,8 +443,7 @@ class DocView(GenericView, DocHandler):
file
.
close
()
# 1. 上传信息记录
# application_id = '{0}{1}'.format(consts.FIXED_APPLICATION_ID_PREFIX, metadata_version_id)
application_id
=
'CH-S200012727'
application_id
=
'{0}{1}'
.
format
(
consts
.
FIXED_APPLICATION_ID_PREFIX
,
metadata_version_id
)
upload_finish_time
=
timezone
.
now
()
document_scheme
=
random
.
choice
(
consts
.
DOC_SCHEME_LIST
)
data_source
=
random
.
choice
(
consts
.
DATA_SOURCE_LIST
)
...
...
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