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
f417660d
authored
2021-11-29 20:48:46 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
ltgt part 1
1 parent
a21cf252
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
src/apps/doc/management/commands/folder_ltgt_process.py
src/apps/doc/management/commands/folder_ltgt_process.py
View file @
f417660
...
...
@@ -74,12 +74,12 @@ class Command(BaseCommand, LoggerMixin):
# seperate folder name
self
.
seperate_map
=
{
consts
.
IC_CLASSIFY
:
'IDCard'
,
consts
.
BC_CLASSIFY
:
'BankCard'
consts
.
MVC_CLASSIFY
:
'GreenBook'
,
consts
.
CONTRACT_CLASSIFY
:
'Contract'
,
}
self
.
field_map
=
{
consts
.
VAT_CLASSIFY
:
(
consts
.
VAT_CN_NAME
,
None
,
None
,
consts
.
VATS_FIELD_ORDER
),
consts
.
IC_CLASSIFY
:
(
consts
.
IC_CN_NAME
,
'有效期限'
,
consts
.
IC_FIELD_ORDER_3
,
consts
.
IC_FIELD_ORDER_2
),
consts
.
BC_CLASSIFY
:
(
consts
.
BC_CN_NAME
,
None
,
None
,
consts
.
BC_FIELD_ORDER_2
)
}
# ocr相关
self
.
ocr_url
=
conf
.
OCR_URL_FOLDER
...
...
@@ -312,6 +312,9 @@ class Command(BaseCommand, LoggerMixin):
def
pdf_process
(
self
,
name
,
path
,
classify
,
img_output_dir
,
wb_output_dir
,
pdf_output_dir
,
seperate_dir
):
if
os
.
path
.
exists
(
path
):
rebuild_res
=
None
if
classify
==
consts
.
CONTRACT_CLASSIFY
:
pass
else
:
try
:
img_save_path
,
excel_path
,
pdf_save_path
,
seperate_path
=
self
.
get_path
(
name
,
img_output_dir
,
wb_output_dir
,
pdf_output_dir
,
seperate_dir
)
...
...
@@ -434,7 +437,6 @@ class Command(BaseCommand, LoggerMixin):
else
:
return
output_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
input_dir
),
'Output'
)
seperate_dir
=
os
.
path
.
join
(
output_dir
,
self
.
seperate_map
.
get
(
classify
,
'Unknown'
))
if
is_combined
else
None
img_output_dir
=
os
.
path
.
join
(
output_dir
,
'image'
)
wb_output_dir
=
os
.
path
.
join
(
output_dir
,
'excel'
)
pdf_output_dir
=
os
.
path
.
join
(
output_dir
,
'pdf'
)
...
...
@@ -446,8 +448,13 @@ class Command(BaseCommand, LoggerMixin):
os
.
makedirs
(
pdf_output_dir
,
exist_ok
=
True
)
os
.
makedirs
(
tiff_output_dir
,
exist_ok
=
True
)
os
.
makedirs
(
failed_output_dir
,
exist_ok
=
True
)
if
seperate_dir
is
not
None
:
if
is_combined
:
seperate_dir
=
os
.
path
.
join
(
output_dir
,
self
.
seperate_map
.
get
(
classify
,
'Unknown'
))
os
.
makedirs
(
seperate_dir
,
exist_ok
=
True
)
else
:
seperate_dir
=
None
os_error_filename_set
=
set
()
while
self
.
switch
:
# if not os.path.isdir(input_dir):
...
...
@@ -474,9 +481,13 @@ class Command(BaseCommand, LoggerMixin):
result
=
self
.
pdf_process
(
name
,
path
,
classify
,
img_output_dir
,
wb_output_dir
,
pdf_output_dir
,
seperate_dir
)
elif
name
.
endswith
(
'.tif'
)
or
name
.
endswith
(
'.TIF'
):
if
classify
==
consts
.
CONTRACT_CLASSIFY
:
raise
LTGTException
(
'e-contract must be pdf'
)
result
=
self
.
tif_process
(
name
,
path
,
classify
,
img_output_dir
,
wb_output_dir
,
tiff_output_dir
,
seperate_dir
)
else
:
if
classify
==
consts
.
CONTRACT_CLASSIFY
:
raise
LTGTException
(
'e-contract must be pdf'
)
result
=
self
.
img_process
(
name
,
path
,
classify
,
wb_output_dir
,
img_output_dir
,
pdf_output_dir
,
seperate_dir
)
self
.
folder_log
.
info
(
'{0} [file end] [path={1}]'
.
format
(
self
.
log_base
,
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