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
840e3367
authored
2024-05-27 14:54:16 +0800
by
冯轩
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
MOD:发票信息查询
1 parent
64ee3cbd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
0 deletions
src/apps/doc/internal_urls.py
src/apps/doc/views.py
src/apps/doc/internal_urls.py
View file @
840e336
...
...
@@ -5,5 +5,6 @@ from . import views
urlpatterns
=
[
path
(
r''
,
views
.
DocView
.
as_view
()),
path
(
r'invoice/downloadExcel'
,
views
.
InvoiceExcelView
.
as_view
()),
path
(
r'invoice/queryInfo'
,
views
.
InvoiceQueryInfoView
.
as_view
()),
path
(
r'contract/v1'
,
views
.
SEContractView
.
as_view
()),
]
...
...
src/apps/doc/views.py
View file @
840e336
...
...
@@ -55,6 +55,7 @@ from .models import (
HILCmsStatusInfo
,
AFCCmsStatusInfo
)
from
common.exceptions
import
(
NoPermissionException
)
from
.named_enum
import
ErrorType
,
AutoResult
,
WholeResult
,
RPAResult
,
SystemName
,
RequestTeam
from
.mixins
import
DocHandler
,
MPOSHandler
,
PreSEHandler
from
.
import
consts
...
...
@@ -1242,6 +1243,14 @@ class CompareResultView(GenericView):
scheme
=
args
.
get
(
'scheme'
)
case_id
=
args
.
get
(
'case_id'
)
is_auto
=
args
.
get
(
'auto'
)
# 角色权限不符,返回异常
token
=
request
.
META
.
get
(
"HTTP_AUTHORIZATION"
)
user_role
=
rh
.
get_token
(
token
[
-
11
:])
self
.
running_log
.
info
(
'[api doc] [user_role={0}] '
.
format
(
user_role
))
if
user_role
==
-
1
or
(
user_role
==
1
and
entity
==
'HIL'
)
or
(
user_role
==
2
and
entity
==
'AFC'
):
raise
NoPermissionException
(
'no permission'
)
if
is_auto
==
1
:
result_table
=
HILAutoSettlement
if
entity
==
consts
.
HIL_PREFIX
else
AFCAutoSettlement
...
...
@@ -1728,6 +1737,13 @@ class AutoSettlementExcelView(GenericView):
is_fsm
=
args
.
get
(
'is_fsm'
)
# 角色权限不符,返回异常
token
=
request
.
META
.
get
(
"HTTP_AUTHORIZATION"
)
user_role
=
rh
.
get_token
(
token
[
-
11
:])
self
.
running_log
.
info
(
'[api doc] [user_role={0}] '
.
format
(
user_role
))
if
user_role
==
-
1
or
(
user_role
==
1
and
business_type
==
'HIL'
)
or
(
user_role
==
2
and
business_type
==
'AFC'
):
raise
NoPermissionException
(
'no permission'
)
if
isinstance
(
auto_result
,
int
):
auto_result
=
consts
.
RESULT_MAP
.
get
(
auto_result
)
if
isinstance
(
whole_result
,
int
):
...
...
@@ -1886,6 +1902,13 @@ class InvoiceExcelView(GenericView):
application_ids
=
args
.
get
(
'application_ids'
)
application_entity
=
args
.
get
(
'application_entity'
)
# 角色权限不符,返回异常
token
=
request
.
META
.
get
(
"HTTP_AUTHORIZATION"
)
user_role
=
rh
.
get_token
(
token
[
-
11
:])
self
.
running_log
.
info
(
'[InvoiceExcelView] [user_role={0}] '
.
format
(
user_role
))
if
user_role
==
-
1
or
(
user_role
==
1
and
application_entity
==
'HIL'
)
or
(
user_role
==
2
and
application_entity
==
'AFC'
):
raise
NoPermissionException
(
'no permission'
)
url
=
'http://127.0.0.1:8088/napi/invoice/downloadExcelOri'
body
=
{
'applicationIds'
:
application_ids
,
...
...
@@ -1913,3 +1936,38 @@ class InvoiceExcelView(GenericView):
except
Exception
as
e
:
self
.
running_log
.
error
(
"invoice excel request to java error, url:{0}, param:{1}, errorMsg:{2}"
.
format
(
url
,
json
.
dumps
(
body
),
traceback
.
format_exc
()))
class
InvoiceQueryInfoView
(
GenericView
):
permission_classes
=
[
IsAuthenticated
]
authentication_classes
=
[
OAuth2AuthenticationWithUser
]
@use_args
(
invoice_download_args
,
location
=
'data'
)
def
post
(
self
,
request
,
args
):
application_ids
=
args
.
get
(
'application_ids'
)
application_entity
=
args
.
get
(
'application_entity'
)
# 角色权限不符,返回异常
token
=
request
.
META
.
get
(
"HTTP_AUTHORIZATION"
)
user_role
=
rh
.
get_token
(
token
[
-
11
:])
self
.
running_log
.
info
(
'[InvoiceQueryInfoView] [user_role={0}] '
.
format
(
user_role
))
if
user_role
==
-
1
or
(
user_role
==
1
and
application_entity
==
'HIL'
)
or
(
user_role
==
2
and
application_entity
==
'AFC'
):
raise
NoPermissionException
(
'no permission'
)
url
=
'http://127.0.0.1:8088/napi/invoice/queryInfoOri'
body
=
{
'applicationIds'
:
application_ids
,
'applicationEntity'
:
application_entity
}
try
:
self
.
running_log
.
info
(
"request java invoice info api, url:{0}, body:{1}"
.
format
(
url
,
json
.
dumps
(
body
)))
headers
=
{
'Content-Type'
:
'application/json'
}
resp
=
requests
.
post
(
url
,
headers
=
headers
,
json
=
body
)
self
.
running_log
.
info
(
"java invoice info api finish, applicationIds:{0},{1}"
.
format
(
application_ids
,
resp
.
text
))
res_json
=
json
.
loads
(
resp
.
text
)
java_result
=
res_json
.
get
(
'result'
)
return
response
.
ok
(
data
=
java_result
)
except
Exception
as
e
:
self
.
running_log
.
error
(
"invoice info request to java error, url:{0}, param:{1}, errorMsg:{2}"
.
format
(
url
,
json
.
dumps
(
body
),
traceback
.
format_exc
()))
...
...
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