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
02dfaa1f
authored
2022-11-10 14:13:23 +0800
by
王聪
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
增加权限校验类
1 parent
7cd920c4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
43 deletions
src/pos/views.py
src/pos/views.py
View file @
02dfaa1
...
...
@@ -5,6 +5,8 @@ from apps.doc.views import CustomDecimal, CustomDate
from
common
import
response
from
apps.doc.mixins
import
PosHandler
from
common.tools.comparison
import
cp
from
rest_framework.permissions
import
IsAuthenticated
from
apps.account.authentication
import
OAuth2AuthenticationWithUser
params
=
{
'invoiceCode'
:
fields
.
Str
(
required
=
True
,
validate
=
validate
.
Length
(
max
=
128
)),
...
...
@@ -28,6 +30,9 @@ input_args = {
# poss 接口接收NSC 发票信息
class
NSCInvoiceView
(
GenericView
):
permission_classes
=
[
IsAuthenticated
]
authentication_classes
=
[
OAuth2AuthenticationWithUser
]
@use_args
(
input_args
,
location
=
'data'
)
def
post
(
self
,
request
,
args
):
# interface_report mpos to ocr
content
=
args
.
get
(
'content'
,
{})
...
...
@@ -63,46 +68,46 @@ de_mortgage_comments = {
# 解除抵押识别处理
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'
,
[])
customer_name
=
args
.
get
(
'customerName'
,
''
)
application
=
args
.
get
(
'application'
,
''
)
de_mortgage_date
=
args
.
get
(
'deMortgageDate'
)
fields_input
=
{
'customerName'
:
customer_name
,
'application'
:
application
,
'deMortgageDate'
:
de_mortgage_date
}
de_mortgage_info
=
{}
# 绿本必须分开ocr
for
img_file
in
img_files
:
info
=
PosHandler
.
de_mortgage_ocr_process
(
img_file
)
de_mortgage_info
.
update
(
info
)
request_pass
=
True
fields_result
=
[]
for
field_name
,
input_val
in
enumerate
(
fields_input
):
field_result
=
{
"name"
:
field_name
,
"input"
:
input_val
,
"ocr"
:
de_mortgage_info
.
get
(
field_name
,
''
),
"field_is_pass"
:
False
,
"comments"
:
''
}
result
,
_
=
cp
.
common_compare
(
field_result
[
'input'
],
field_result
[
'ocr'
])
if
result
==
cp
.
RESULT_Y
:
fields_result
[
'field_is_pass'
]
=
result
else
:
request_pass
=
False
fields_result
[
'comments'
]
=
de_mortgage_comments
.
get
(
field_name
,
''
)
fields_result
.
append
(
field_result
)
result
=
{
"is_pass"
:
request_pass
,
"fields"
:
fields_result
}
return
response
.
ok
(
data
=
result
)
#
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', [])
#
customer_name = args.get('customerName', '')
#
application = args.get('application', '')
#
de_mortgage_date = args.get('deMortgageDate')
#
#
fields_input = {
#
'customerName': customer_name,
#
'application': application,
#
'deMortgageDate': de_mortgage_date
#
}
#
de_mortgage_info = {}
#
# 绿本必须分开ocr
#
for img_file in img_files:
#
info = PosHandler.de_mortgage_ocr_process(img_file)
#
de_mortgage_info.update(info)
#
#
request_pass = True
#
fields_result = []
#
for field_name, input_val in enumerate(fields_input):
#
field_result = {
#
"name": field_name,
#
"input": input_val,
#
"ocr": de_mortgage_info.get(field_name, ''),
#
"field_is_pass": False,
#
"comments": ''
#
}
#
result, _ = cp.common_compare(field_result['input'], field_result['ocr'])
#
if result == cp.RESULT_Y:
#
fields_result['field_is_pass'] = result
#
else:
#
request_pass = False
#
fields_result['comments'] = de_mortgage_comments.get(field_name, '')
#
#
fields_result.append(field_result)
#
#
result = {
#
"is_pass": request_pass,
#
"fields": fields_result
#
}
#
return response.ok(data=result)
...
...
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