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
329ae9e3
authored
2022-11-11 13:43:45 +0800
by
王聪
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
增加权限校验类
1 parent
02dfaa1f
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 @
329ae9e
...
...
@@ -5,6 +5,7 @@ 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
...
...
@@ -68,46 +69,50 @@ 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
):
permission_classes
=
[
IsAuthenticated
]
authentication_classes
=
[
OAuth2AuthenticationWithUser
]
@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