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
6ae14e64
authored
2024-06-07 16:58:10 +0800
by
冯轩
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
merge
2 parents
08e21eab
b0ca4ade
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
4 deletions
src/apps/doc/internal_urls.py
src/apps/doc/management/commands/ocr_process.py
src/apps/doc/views.py
src/common/electronic_afc_contract/afc_contract_ocr.py
src/apps/doc/internal_urls.py
View file @
6ae14e6
...
...
@@ -4,5 +4,6 @@ from . import views
urlpatterns
=
[
path
(
r''
,
views
.
DocView
.
as_view
()),
path
(
r'query/employee'
,
views
.
EmployeeView
.
as_view
()),
path
(
r'contract/v1'
,
views
.
SEContractView
.
as_view
()),
]
...
...
src/apps/doc/management/commands/ocr_process.py
View file @
6ae14e6
...
...
@@ -1507,7 +1507,7 @@ class Command(BaseCommand, LoggerMixin):
# AFC合同
if
classify_1_str
==
str
(
consts
.
CONTRACT_CLASSIFY
):
is_fsm
=
doc
.
is_ovp_fsm
==
1
ocr_result
=
afc_predict
(
self
,
pdf_handler
.
pdf_info
,
is_fsm
=
is_fsm
)
ocr_result
=
afc_predict
(
pdf_handler
.
pdf_info
,
is_fsm
=
is_fsm
)
page_res
=
{}
for
page_num
,
page_info
in
ocr_result
.
get
(
'page_info'
,
{})
.
items
():
if
isinstance
(
page_num
,
str
)
and
page_num
.
startswith
(
'page_'
):
...
...
src/apps/doc/views.py
View file @
6ae14e6
...
...
@@ -92,6 +92,10 @@ class CustomDecimal(fields.Decimal):
def
load_data
(
request
,
schema
):
return
request
.
data
employee_args
=
{
'applicationId'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
Length
(
max
=
64
)),
'business_type'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
Length
(
max
=
64
)),
}
go_args
=
{
'image'
:
fields
.
Raw
(
required
=
True
),
...
...
@@ -1890,3 +1894,24 @@ def notifyCmsPass(self, request):
else
:
self
.
running_log
.
info
(
'[pressure cms success] [response={0}]'
.
format
(
response
))
return
True
class
EmployeeView
(
GenericView
):
permission_classes
=
[
IsAuthenticated
]
authentication_classes
=
[
OAuth2AuthenticationWithUser
]
@use_args
(
employee_args
,
location
=
'data'
)
def
post
(
self
,
request
,
args
):
application_id
=
args
.
get
(
'application_id'
)
business_type
=
args
.
get
(
'business_type'
)
ocr_result_class
=
HILOCRResult
if
business_type
in
consts
.
HIL_SET
else
AFCOCRResult
ocr_result_info
=
ocr_result_class
.
objects
.
filter
(
application_id
=
application_id
)
.
first
()
if
not
ocr_result_info
:
return
response
.
ok
(
data
=
False
)
bss_ocr_str
=
ocr_result_info
.
bss_ocr
bss_ocr
=
json
.
loads
(
bss_ocr_str
)
for
one_bss
in
bss_ocr
:
income_keywords
=
one_bss
[
'income_keywords'
]
if
income_keywords
is
not
None
and
len
(
income_keywords
)
>
0
:
return
response
.
ok
(
data
=
True
)
return
response
.
ok
(
data
=
False
)
\ No newline at end of file
...
...
src/common/electronic_afc_contract/afc_contract_ocr.py
View file @
6ae14e6
...
...
@@ -24,7 +24,7 @@ def extract_info(ocr_results):
return
{
'page_1'
:
{
'合同编号'
:
contract_no
}}
def
predict
(
self
,
pdf_info
,
is_qrs
=
False
,
is_fsm
=
False
):
def
predict
(
pdf_info
,
is_qrs
=
False
,
is_fsm
=
False
):
pop_seceond_page_info
=
{}
if
not
is_fsm
and
not
is_qrs
and
len
(
pdf_info
)
==
9
:
pop_seceond_page_info
=
pdf_info
.
pop
(
'1'
,
{})
...
...
@@ -61,10 +61,8 @@ def predict(self, pdf_info, is_qrs=False, is_fsm=False):
else
:
# 输入是整个 PDF 中的信息
if
is_fsm
:
self
.
online_log
.
info
(
'afc_contract_is_fsm'
)
f
=
FSMFinder
(
pdf_info
,
ocr_results
=
ocr_results
)
else
:
self
.
online_log
.
info
(
'afc_contract_is_non_fsm'
)
f
=
Finder
(
pdf_info
,
ocr_results
=
ocr_results
)
results
=
f
.
get_info
()
return
results
...
...
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