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
43ce3393
authored
2022-01-11 11:40:05 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
add auto excel test
1 parent
135d5714
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
2 deletions
src/apps/doc/compare_urls.py
src/apps/doc/views.py
src/common/response.py
src/apps/doc/compare_urls.py
View file @
43ce339
...
...
@@ -6,6 +6,7 @@ urlpatterns = [
path
(
r'v1'
,
views
.
CompareView
.
as_view
()),
path
(
r'settlement/v1'
,
views
.
SECompareView
.
as_view
()),
path
(
r'settlement/auto/v1'
,
views
.
AutoSettlementView
.
as_view
()),
path
(
r'settlement/auto/wb/v1'
,
views
.
AutoSettlementExcelView
.
as_view
()),
path
(
r'settlement/cms/v1'
,
views
.
SECMSView
.
as_view
()),
path
(
r'offline/v1'
,
views
.
CompareOfflineView
.
as_view
()),
path
(
r'result'
,
views
.
CompareResultView
.
as_view
()),
...
...
src/apps/doc/views.py
View file @
43ce339
import
os
import
io
import
time
import
json
import
random
import
datetime
import
fitz
import
shutil
from
openpyxl
import
Workbook
from
django.utils
import
timezone
# from django.http import HttpResponse
from
django.db.models
import
Q
...
...
@@ -1287,7 +1289,7 @@ class AutoSettlementView(GenericView):
# permission_classes = [IsAuthenticated]
# authentication_classes = [OAuth2AuthenticationWithUser]
# 获取
比对结果
# 获取
auto settlement列表
@use_args
(
auto_list_args
,
location
=
'querystring'
)
def
get
(
self
,
request
,
args
):
page
=
args
.
get
(
'page'
,
consts
.
PAGE_DEFAULT
)
...
...
@@ -1356,3 +1358,22 @@ class AutoSettlementView(GenericView):
}
self
.
running_log
.
info
(
'[get auto list] [args={0}] [res={1}]'
.
format
(
args
,
res
))
return
response
.
ok
(
data
=
res
)
class
AutoSettlementExcelView
(
GenericView
):
permission_classes
=
[]
authentication_classes
=
[]
# permission_classes = [IsAuthenticated]
# authentication_classes = [OAuth2AuthenticationWithUser]
# 获取auto settlement excel
@use_args
(
auto_list_args
,
location
=
'querystring'
)
def
get
(
self
,
request
,
args
):
wb
=
Workbook
()
ws
=
wb
.
active
ws
.
append
([
'序号'
,
'告警id'
,
'设备编号'
])
io_content
=
io
.
BytesIO
()
# 创建在内存中处理对象
wb
.
save
(
io_content
)
wb
.
close
()
file_name
=
'AutoSettlement'
return
response
.
excel_response
(
file_name
,
io_content
)
...
...
src/common/response.py
View file @
43ce339
import
enum
from
django.http
import
JsonResponse
from
django.http
import
JsonResponse
,
HttpResponse
from
.named_enum
import
NamedEnum
...
...
@@ -37,3 +37,10 @@ def ok(**kwargs):
def
need_update
(
**
kwargs
):
return
APIResponse
(
MetaStatus
.
NEED_UPDATE
.
value
,
msg
=
MetaStatus
.
NEED_UPDATE
.
verbose_name
,
**
kwargs
)
def
excel_response
(
file_name
,
io_content
):
http_response
=
HttpResponse
(
content_type
=
"application/vnd.ms-excel"
)
http_response
[
'Content-Disposition'
]
=
'attachment;filename={0}.xlsx'
.
format
(
file_name
)
http_response
.
write
(
io_content
.
getvalue
())
return
http_response
...
...
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