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
4c2b01b1
authored
2020-11-07 16:30:33 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix bug
1 parent
dd512564
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
src/apps/doc/views.py
src/apps/doc/views.py
View file @
4c2b01b
...
...
@@ -3,6 +3,7 @@ import time
import
random
import
datetime
import
fitz
import
shutil
from
django.utils
import
timezone
from
django.db.utils
import
IntegrityError
from
django.db.models
import
Q
...
...
@@ -277,13 +278,17 @@ class DocView(GenericView, DocHandler):
random_int
=
random
.
randint
(
0
,
consts
.
TIME_NUM
)
metadata_version_id
=
str
(
int
(
time
.
time
())
-
random_int
)
#
tmp_save_path = os.path.join(conf.DATA_DIR, '{0}.pdf'.format(metadata_version_id))
tmp_save_path
=
os
.
path
.
join
(
conf
.
DATA_DIR
,
'{0}.pdf'
.
format
(
metadata_version_id
))
pdf_file
=
args
.
get
(
'pdf_file'
)
#
file_write(pdf_file, tmp_save_path)
file_write
(
pdf_file
,
tmp_save_path
)
if
not
fitz
.
open
(
"pdf"
,
pdf_file
)
.
isPDF
:
# if not fitz.open("pdf", pdf_file).isPDF:
file
=
fitz
.
Document
(
tmp_save_path
)
if
not
file
.
isPDF
:
file
.
close
()
raise
self
.
invalid_params
(
msg
=
'invalid params: not a PDF file'
)
file
.
close
()
# 1. 上传信息记录
application_id
=
'{0}{1}'
.
format
(
consts
.
FIXED_APPLICATION_ID_PREFIX
,
metadata_version_id
)
upload_finish_time
=
timezone
.
now
()
...
...
@@ -323,7 +328,8 @@ class DocView(GenericView, DocHandler):
save_dir_path
=
os
.
path
.
join
(
conf
.
DATA_DIR
,
business_type
,
str
(
doc
.
id
))
save_file_path
=
os
.
path
.
join
(
save_dir_path
,
'{0}.pdf'
.
format
(
doc
.
id
))
os
.
makedirs
(
save_dir_path
,
exist_ok
=
True
)
file_write
(
pdf_file
,
save_file_path
)
# file_write(pdf_file, save_file_path)
shutil
.
move
(
tmp_save_path
,
save_file_path
)
# 4. 选择队列进入
is_priority
=
False
...
...
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