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
e8b1b6bb
authored
2025-08-27 17:09:19 +0800
by
冯轩
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
ADD:批量接口
1 parent
91ff8153
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
1 deletions
src/apps/doc/internal_urls.py
src/apps/doc/views.py
src/apps/doc/internal_urls.py
View file @
e8b1b6b
...
...
@@ -10,4 +10,7 @@ urlpatterns = [
path
(
r'invoice/downloadExcel'
,
views
.
InvoiceExcelView
.
as_view
()),
path
(
r'invoice/queryInfo'
,
views
.
InvoiceQueryInfoView
.
as_view
()),
path
(
r'contract/v1'
,
views
.
SEContractView
.
as_view
()),
path
(
r'reocr'
,
views
.
DocReOcrView
.
as_view
()),
path
(
r'batch/reocr'
,
views
.
BatchReOcrView
.
as_view
()),
]
...
...
src/apps/doc/views.py
View file @
e8b1b6b
...
...
@@ -591,7 +591,11 @@ invoice_download_args = {
doc_reocr_args
=
{
'doc_id'
:
fields
.
Int
(
required
=
True
),
'application_entity'
:
fields
.
Int
(
required
=
True
),
'application_entity'
:
fields
.
Str
(
required
=
True
),
}
batch_reocr_args
=
{
'application_entity'
:
fields
.
Str
(
required
=
True
),
}
...
...
@@ -2123,4 +2127,59 @@ class DocReOcrView(GenericView, DocHandler):
'[is_priority={3}] [enqueue_res={4}] [classify_1={5}]'
.
format
(
args
,
prefix
,
doc
.
id
,
is_priority
,
enqueue_res
,
classify_1
))
return
response
.
ok
()
class
BatchReOcrView
(
GenericView
,
DocHandler
):
permission_classes
=
[
IsAuthenticated
]
authentication_classes
=
[
OAuth2AuthenticationWithUser
]
# 现有文件批量重新识别接口
@use_args
(
batch_reocr_args
,
location
=
'data'
)
def
post
(
self
,
request
,
args
):
start_time
=
time
.
time
()
application_entity
=
args
.
get
(
'application_entity'
)
today
=
timezone
.
now
()
.
date
()
start_of_day
=
timezone
.
make_aware
(
timezone
.
datetime
.
combine
(
today
,
timezone
.
datetime
.
min
.
time
()))
end_of_day
=
timezone
.
make_aware
(
timezone
.
datetime
.
combine
(
today
,
timezone
.
datetime
.
max
.
time
()))
doc_class
,
prefix
=
self
.
get_doc_class
(
application_entity
)
docs
=
doc_class
.
objects
.
filter
(
status
=
2
,
create_time__range
=
(
start_of_day
,
end_of_day
))
# 遍历
for
doc
in
docs
.
iterator
():
# 3. 选择队列进入
is_priority
=
PriorityApplication
.
objects
.
filter
(
application_id
=
doc
.
application_id
,
on_off
=
True
)
.
exists
()
is_zip
=
False
classify_1
=
0
# 电子合同 Econtract or OVP(FSM)
if
doc
.
data_source
==
consts
.
DATA_SOURCE_LIST
[
2
]
or
doc
.
data_source
==
consts
.
DATA_SOURCE_LIST
[
3
]:
if
doc
.
document_scheme
==
consts
.
DOC_SCHEME_LIST
[
1
]:
for
keyword
,
classify_1_tmp
in
consts
.
ECONTRACT_KEYWORDS_MAP
.
get
(
prefix
):
if
keyword
in
doc
.
document_name
:
classify_1
=
classify_1_tmp
break
# FSM合同:WEP/MSI/SC/SC2
elif
doc
.
data_source
==
consts
.
DATA_SOURCE_LIST
[
0
]
and
doc
.
document_scheme
==
consts
.
DOC_SCHEME_LIST
[
0
]:
for
keyword
,
classify_1_tmp
in
consts
.
FSM_ECONTRACT_KEYWORDS_MAP
.
get
(
prefix
):
if
keyword
in
doc
.
document_name
:
classify_1
=
classify_1_tmp
break
if
doc
.
document_name
.
endswith
(
'.zip'
)
or
doc
.
document_name
.
endswith
(
'.rar'
)
or
doc
.
document_name
.
endswith
(
'.ZIP'
)
\
or
doc
.
document_name
.
endswith
(
'.RAR'
):
is_zip
=
True
# task = 'AFC_11001_0_Y' 'AFC_11001_0_N' 最后的Y,N表示是否是reocr,N否,Y是
task
=
consts
.
SPLIT_STR
.
join
([
prefix
,
str
(
doc
.
id
),
str
(
classify_1
),
'Y'
])
enqueue_res
=
rh
.
enqueue
([
task
],
is_priority
,
is_zip
)
self
.
running_log
.
info
(
'[doc upload success] [args={0}] [business_type={1}] [doc_id={2}] '
'[is_priority={3}] [enqueue_res={4}] [classify_1={5}]'
.
format
(
args
,
prefix
,
doc
.
id
,
is_priority
,
enqueue_res
,
classify_1
))
return
response
.
ok
()
\ No newline at end of file
...
...
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