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
f085b3b6
authored
2021-12-02 15:52:52 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix bug
1 parent
a94ce721
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
src/apps/doc/management/commands/folder_ltgt_process.py
src/apps/doc/management/commands/folder_ltgt_process.py
View file @
f085b3b
...
...
@@ -259,7 +259,7 @@ class Command(BaseCommand, LoggerMixin):
for
c
,
res_list
in
all_res
.
items
():
sheet_name
,
key_field
,
side_field_order
,
src_field_order
=
self
.
field_map
.
get
(
c
)
ws
=
wb
.
create_sheet
(
sheet_name
)
for
res
in
all_res
:
for
res
in
res_list
:
if
key_field
is
not
None
and
key_field
in
res
:
field_order
=
side_field_order
else
:
...
...
@@ -293,8 +293,9 @@ class Command(BaseCommand, LoggerMixin):
file_data
=
base64_data
.
decode
()
json_data
=
{
"file"
:
file_data
,
"channel"
:
consts
.
AFC_PREFIX
,
}
if
len
(
seperate_path_map
)
>
0
:
if
len
(
seperate_path_map
)
==
0
:
json_data
[
"classify"
]
=
classify
for
times
in
range
(
consts
.
RETRY_TIMES
):
...
...
@@ -318,19 +319,20 @@ class Command(BaseCommand, LoggerMixin):
data_list
=
ocr_res
.
get
(
'data'
,
[])
if
isinstance
(
data_list
,
list
):
for
ocr_data
in
data_list
:
if
ocr_data
.
get
(
'classify'
)
in
seperate_path_map
or
ocr_data
.
get
(
'classify'
)
==
classify
:
if
ocr_data
.
get
(
'classify'
)
in
seperate_path_map
:
seperate_dir
=
seperate_path_map
[
ocr_data
.
get
(
'classify'
)]
new_classify
=
ocr_data
.
get
(
'classify'
)
if
new_classify
in
seperate_path_map
or
new_classify
==
classify
:
if
new_classify
in
seperate_path_map
:
seperate_dir
=
seperate_path_map
[
new_classify
]
os
.
makedirs
(
seperate_dir
,
exist_ok
=
True
)
real_dst
=
os
.
path
.
join
(
seperate_dir
,
self
.
basename
(
img_path
))
if
not
os
.
path
.
exists
(
real_dst
):
shutil
.
move
(
img_path
,
seperate_dir
)
if
classify
in
consts
.
LICENSE_CLASSIFY_SET_1
:
self
.
license1_process
(
ocr_data
,
all_res
,
classify
)
elif
classify
in
consts
.
LICENSE_CLASSIFY_SET_2
:
self
.
license2_process
(
ocr_data
,
all_res
,
classify
,
img_path
)
elif
classify
in
consts
.
CONTRACT_SET
:
self
.
contract_process
(
ocr_data
,
contract_result
,
classify
)
if
new_
classify
in
consts
.
LICENSE_CLASSIFY_SET_1
:
self
.
license1_process
(
ocr_data
,
all_res
,
new_
classify
)
elif
new_
classify
in
consts
.
LICENSE_CLASSIFY_SET_2
:
self
.
license2_process
(
ocr_data
,
all_res
,
new_
classify
,
img_path
)
elif
new_
classify
in
consts
.
CONTRACT_SET
:
self
.
contract_process
(
ocr_data
,
contract_result
,
new_
classify
)
break
else
:
self
.
folder_log
.
warn
(
'{0} [ocr failed] [img_path={1}]'
.
format
(
self
.
log_base
,
img_path
))
...
...
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