Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
F
fund_report
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
彭熊
fund_report
Commits
c34a78d4
Commit
c34a78d4
authored
Dec 25, 2020
by
wang zhengwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改返回值
parent
2d94348f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
12 deletions
+26
-12
engine.py
app/api/engine.py
+2
-1
report.py
app/controller/report.py
+24
-11
No files found.
app/api/engine.py
View file @
c34a78d4
...
...
@@ -23,7 +23,8 @@ template_folder = work_dir+'/app/templates'
config
=
yaml
.
load
(
open
(
CFG_FILEPATH
,
'r'
),
Loader
=
yaml
.
FullLoader
)
pdf_folder
=
os
.
path
.
join
(
work_dir
,
"app/pdf"
,
config
[
env
][
'PDF'
][
'pdf_folder'
])
pdf_folder
=
os
.
path
.
join
(
work_dir
,
"app/pdf"
,
config
[
env
][
'PDF'
][
'pdf_folder'
])
http_dir
=
config
[
env
][
'PDF'
][
'http_dir'
]
tamp_product_engine
=
create_engine
(
'mysql+mysqldb://{user}:{password}@{host}:{port}/{db}?charset={charset}'
.
format
(
...
...
app/controller/report.py
View file @
c34a78d4
...
...
@@ -8,16 +8,14 @@
# -----------------------------------------------------------------------------
import
datetime
import
time
import
uuid
import
oss2
from
flask_restful
import
Resource
,
reqparse
from
flask
import
request
,
render_template
from
flask
import
make_response
from
app.api.engine
import
config
from
app.utils.html_to_pdf
import
html_to_pdf
from
app.api.engine
import
pdf_folder
,
redis
,
env
,
TAMP_SQL
,
tamp_diagnose_app_engine
from
app.api.engine
import
pdf_folder
,
redis
,
env
,
TAMP_SQL
,
tamp_diagnose_app_engine
,
http_dir
from
app.utils.jinjia2html_v2
import
DataIntegrate
...
...
@@ -36,6 +34,7 @@ class ReportHandlers(Resource):
token
=
request
.
headers
.
get
(
'Authorization'
,
''
)
token
=
's:sid:'
+
token
.
split
(
' '
)[
1
]
ifa_id
=
redis
.
get
(
token
)
.
decode
()
if
not
ifa_id
:
return
{
"code"
:
40005
,
"data"
:
None
,
"lang"
:
"zh_CN"
,
"msg"
:
"请登陆"
}
if
'
\'
'
in
ifa_id
:
...
...
@@ -59,15 +58,16 @@ class ReportHandlers(Resource):
dt
=
DataIntegrate
(
ifa_id
=
ifa_id
,
customer_id
=
customer_id
,
pdf_name
=
pdf_name
)
dt
.
render_data
()
except
:
pass
return
{
"code"
:
-
1
,
"msg"
:
"内部错误"
}
print
(
'耗时{}秒'
.
format
(
round
(
time
.
time
()
-
start
,
2
)))
auth
=
oss2
.
Auth
(
config
[
env
][
'oss'
][
'account'
],
config
[
env
][
'oss'
][
'password'
])
# Endpoint以杭州为例,其它Region请按实际情况填写。
bucket
=
oss2
.
Bucket
(
auth
,
'http://oss-cn-shanghai.aliyuncs.com'
,
config
[
env
][
'oss'
][
'env'
])
#
auth = oss2.Auth(config[env]['oss']['account'], config[env]['oss']['password'])
#
#
Endpoint以杭州为例,其它Region请按实际情况填写。
#
bucket = oss2.Bucket(auth, 'http://oss-cn-shanghai.aliyuncs.com', config[env]['oss']['env'])
# 生成下载文件的签名URL,有效时间为60s。
path
=
bucket
.
sign_url
(
'GET'
,
config
[
env
][
'oss'
][
'path'
]
+
pdf_name
,
config
[
env
][
'oss'
][
'validtime'
])
# path = bucket.sign_url('GET', config[env]['oss']['path'] + pdf_name, config[env]['oss']['validtime'])
with
TAMP_SQL
(
tamp_diagnose_app_engine
)
as
tamp_diagnose_app
:
tamp_diagnose_app_session
=
tamp_diagnose_app
.
session
sql
=
"update hold_report set update_time='{}', update_status='{}', file='{}' where ifa_id='{}' and customer_id='{}'"
.
format
(
...
...
@@ -78,14 +78,27 @@ class ReportHandlers(Resource):
customer_id
)
tamp_diagnose_app_session
.
execute
(
sql
)
with
TAMP_SQL
(
tamp_diagnose_app_engine
)
as
tamp_diagnose_app
:
tamp_diagnose_app_session
=
tamp_diagnose_app
.
session
sql
=
"SELECT id, file, customer_id, ifa_id, update_status, update_time from hold_report where ifa_id='{}' and customer_id='{}'"
.
format
(
ifa_id
,
customer_id
,
)
ret
=
tamp_diagnose_app_session
.
execute
(
sql
)
.
fetchone
()
data
=
{
"id"
:
ret
[
0
],
"file"
:
http_dir
+
ret
[
1
],
"customer_id"
:
ret
[
2
],
"ifa_id"
:
ret
[
3
],
"update_status"
:
ret
[
4
],
"update_time"
:
ret
[
5
]
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)}
resp
=
{
"code"
:
0
,
"data"
:
{
"path"
:
path
},
"data"
:
data
,
"lang"
:
"zh_CN"
,
"msg"
:
"成功"
}
return
resp
def
post
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment