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
97905aa8
authored
2023-03-28 17:36:19 +0800
by
冯轩
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
ADD
1 parent
66e1870b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
5 deletions
src/apps/doc/views.py
src/apps/doc/views.py
View file @
97905aa
...
...
@@ -360,6 +360,10 @@ compare_result_args = {
upload_pdf_args
=
{
'pdf_file'
:
fields
.
Raw
(
required
=
True
),
'business_type'
:
fields
.
Str
(
required
=
True
),
'document_scheme'
:
fields
.
Str
(
required
=
True
),
'data_source'
:
fields
.
Str
(
required
=
True
),
'document_name'
:
fields
.
Str
(
required
=
True
),
}
application_information
=
{
...
...
@@ -1102,8 +1106,13 @@ class DocView(GenericView, DocHandler):
if
not
pdf_file
.
name
.
endswith
(
'pdf'
)
and
not
pdf_file
.
name
.
endswith
(
'PDF'
):
self
.
invalid_params
(
msg
=
'invalid params: not a PDF file'
)
business_type
=
args
.
get
(
'business_type'
,
''
)
document_scheme
=
args
.
get
(
'document_scheme'
,
''
)
data_source
=
args
.
get
(
'data_source'
,
''
)
document_name
=
args
.
get
(
'document_name'
,
''
)
# business_type = random.choice(consts.BUSINESS_TYPE_LIST)
business_type
=
consts
.
BUSINESS_TYPE_LIST
[
0
]
#
business_type = consts.BUSINESS_TYPE_LIST[0]
tmp_save_path
=
os
.
path
.
join
(
conf
.
DATA_DIR
,
business_type
,
'{0}.pdf'
.
format
(
metadata_version_id
))
file_write
(
pdf_file
,
tmp_save_path
)
...
...
@@ -1126,8 +1135,8 @@ class DocView(GenericView, DocHandler):
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)
document_scheme
=
consts
.
DOC_SCHEME_LIST
[
1
]
data_source
=
random
.
choice
(
consts
.
DATA_SOURCE_LIST
)
#
document_scheme = consts.DOC_SCHEME_LIST[1]
#
data_source = random.choice(consts.DATA_SOURCE_LIST)
# UploadDocRecords.objects.create(
# metadata_version_id=metadata_version_id,
# application_id=application_id,
...
...
@@ -1166,8 +1175,25 @@ class DocView(GenericView, DocHandler):
# 4. 选择队列进入
is_priority
=
False
tasks
=
[
'{0}{1}{2}'
.
format
(
prefix
,
consts
.
SPLIT_STR
,
doc
.
id
)]
enqueue_res
=
rh
.
enqueue
(
tasks
,
is_priority
)
classify_1
=
0
# 电子合同 Econtract or OVP(FSM)
if
data_source
==
consts
.
DATA_SOURCE_LIST
[
2
]
or
data_source
==
consts
.
DATA_SOURCE_LIST
[
3
]:
if
document_scheme
==
consts
.
DOC_SCHEME_LIST
[
1
]:
for
keyword
,
classify_1_tmp
in
consts
.
ECONTRACT_KEYWORDS_MAP
.
get
(
prefix
):
if
keyword
in
document_name
:
classify_1
=
classify_1_tmp
break
# FSM合同:WEP/MSI/SC
elif
data_source
==
consts
.
DATA_SOURCE_LIST
[
0
]
and
document_scheme
==
consts
.
DOC_SCHEME_LIST
[
0
]:
for
keyword
,
classify_1_tmp
in
consts
.
FSM_ECONTRACT_KEYWORDS_MAP
.
get
(
prefix
):
if
keyword
in
document_name
:
classify_1
=
classify_1_tmp
break
# tasks = ['{0}{1}{2}'.format(prefix, consts.SPLIT_STR, doc.id)]
task
=
consts
.
SPLIT_STR
.
join
([
prefix
,
str
(
doc
.
id
),
str
(
classify_1
)])
enqueue_res
=
rh
.
enqueue
([
task
],
is_priority
)
self
.
running_log
.
info
(
'[mock doc upload success] [args={0}] [business_type={1}] [doc_id={2}] '
'[is_priority={3}] [enqueue_res={4}]'
.
format
(
args
,
prefix
,
doc
.
id
,
...
...
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