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
be68ba59
authored
2022-11-29 18:08:33 +0800
by
王聪
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
de_mortgage 接口更新,兼容不同文档类型
1 parent
297f47e6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
12 deletions
src/apps/doc/mixins.py
src/pos/views.py
src/apps/doc/mixins.py
View file @
be68ba5
...
...
@@ -211,12 +211,7 @@ class PosHandler:
return
result_obj
@staticmethod
def
de_mortgage_ocr_process1
(
img_base64
):
result_obj
=
{
'customerName'
:
''
,
'application'
:
''
,
'deMortgageDate'
:
''
}
def
greenbook_process
(
result_obj
,
img_base64
):
url
=
conf
.
OCR_URL_FOLDER
json_data
=
{
"file"
:
img_base64
,
"classify"
:
consts
.
MVC_CLASSIFY
,
"version"
:
"green"
}
try
:
...
...
@@ -227,7 +222,7 @@ class PosHandler:
LoggerMixin
.
exception_log
.
error
(
"[PosHandler de_mortgage_ocr_process1] request error, url:
%
s, response:
%
s"
,
url
,
response
.
text
)
return
result_obj
return
result
=
response
.
json
()
data
=
result
.
get
(
'data'
,
[])
for
item
in
data
:
...
...
@@ -248,5 +243,18 @@ class PosHandler:
if
word_result
.
get
(
'chinese_key'
,
''
)
==
'1.机动车所有人/身份证名称/号码'
:
result_obj
[
'customerName'
]
=
word_result
.
get
(
'words'
,
''
)
.
split
(
'/'
)[
0
]
except
Exception
as
e
:
LoggerMixin
.
exception_log
.
error
(
"[PosHandler de_mortgage_ocr_process1] error"
,
exc_info
=
1
)
LoggerMixin
.
exception_log
.
error
(
"[PosHandler greenbook_process] error"
,
exc_info
=
1
)
@staticmethod
def
de_mortgage_ocr_process1
(
file_obj
):
result_obj
=
{
'customerName'
:
''
,
'application'
:
''
,
'deMortgageDate'
:
''
}
doc_type
=
file_obj
.
get
(
'documentType'
,
''
)
img_base64
=
file_obj
.
get
(
'fileBase64'
)
if
doc_type
==
'Greenbook'
:
PosHandler
.
greenbook_process
(
result_obj
,
img_base64
)
return
result_obj
...
...
src/pos/views.py
View file @
be68ba5
...
...
@@ -53,11 +53,16 @@ class NSCInvoiceView(GenericView):
return
response
.
ok
()
file_param
=
{
'documentType'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
Length
(
max
=
20
)),
'fileBase64'
:
fields
.
Str
(
required
=
True
),
}
de_mortgage_args
=
{
'customerName'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
Length
(
max
=
64
)),
'application'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
Length
(
max
=
64
)),
'deMortgageDate'
:
fields
.
Date
(
required
=
True
),
'file
_base64'
:
fields
.
List
(
fields
.
Str
(),
required
=
True
,
validate
=
validate
.
Length
(
min
=
1
)
),
'file
s'
:
fields
.
Nested
(
file_param
,
required
=
True
),
}
...
...
@@ -75,7 +80,7 @@ class DeMortgageView(GenericView):
@use_args
(
de_mortgage_args
,
location
=
'data'
)
def
post
(
self
,
request
,
args
):
# interface_report mpos to ocr
img_files
=
args
.
get
(
'file_base64
'
,
[])
files
=
args
.
get
(
'files
'
,
[])
customer_name
=
args
.
get
(
'customerName'
,
''
)
application
=
args
.
get
(
'application'
,
''
)
de_mortgage_date
=
args
.
get
(
'deMortgageDate'
)
...
...
@@ -87,8 +92,8 @@ class DeMortgageView(GenericView):
}
de_mortgage_info
=
{}
# 绿本必须分开ocr
for
img_file
in
img_
files
:
info
=
PosHandler
.
de_mortgage_ocr_process1
(
img_file
)
for
file_obj
in
files
:
info
=
PosHandler
.
de_mortgage_ocr_process1
(
file_obj
)
de_mortgage_info
.
update
(
info
)
request_pass
=
True
...
...
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