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
e04a86bf
Commit
e04a86bf
authored
Dec 23, 2020
by
pengxiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
app端月报生成接口
parent
ce855a22
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
123 additions
and
2317 deletions
+123
-2317
engine.py
app/api/engine.py
+5
-5
config.yaml
app/config/config.yaml
+9
-2
order.py
app/controller/order.py
+0
-52
report.py
app/controller/report.py
+98
-0
order.py
app/model/order.py
+1
-1
version1.py
app/router/version1.py
+2
-2
monthReportV2 .html
app/templates/v2/monthReportV2 .html
+0
-2251
draw.py
app/utils/draw.py
+3
-0
jinjia2html_v2.py
app/utils/jinjia2html_v2.py
+5
-4
No files found.
app/api/engine.py
View file @
e04a86bf
...
...
@@ -96,11 +96,11 @@ tamp_diagnose_app_engine = create_engine(
)
#
redis = redis.StrictRedis(
#
host=config[env]['redis']['host'],
#
port=config[env]['redis']['port'],
#
db=config[env]['redis']['db']
#
)
redis
=
redis
.
StrictRedis
(
host
=
config
[
env
][
'redis'
][
'host'
],
port
=
config
[
env
][
'redis'
][
'port'
],
db
=
config
[
env
][
'redis'
][
'db'
]
)
logging
.
basicConfig
(
level
=
logging
.
INFO
,
filename
=
work_dir
+
config
[
env
][
'log'
][
'filename'
],
...
...
app/config/config.yaml
View file @
e04a86bf
...
...
@@ -11,6 +11,9 @@ dev:
host
:
localhost
port
:
6379
db
:
0
oss
:
account
:
LTAI4FzkGhAMecinBCKwuoUW
password
:
KJpPWg9U0kYO71yB41gqYbrFNJ4hso
log
:
filename
:
/logs/fund_report.log
filemode
:
a
...
...
@@ -44,14 +47,18 @@ prod:
tamp_order_db
:
tamp_order
tamp_user_db
:
tamp_user
tamp_fund_db
:
tamp_fund
tamp_diagnose_app_db
:
tamp_diagnose_app
host
:
tamper.mysql.polardb.rds.aliyuncs.com
port
:
3306
user
:
tamp_
admin
password
:
'
@imeng
123
'
user
:
tamp_
fund
password
:
'
@imeng
408
'
redis
:
host
:
localhost
port
:
6379
db
:
0
oss
:
account
:
LTAI4FzkGhAMecinBCKwuoUW
password
:
KJpPWg9U0kYO71yB41gqYbrFNJ4hso
log
:
filename
:
/logs/fund_report.log
filemode
:
a
...
...
app/controller/order.py
deleted
100644 → 0
View file @
ce855a22
# -*- encoding: utf-8 -*-
# -----------------------------------------------------------------------------
# @File Name : order.py
# @Time : 2020/11/18 下午3:19
# @Author : X. Peng
# @Email : acepengxiong@163.com
# @Software : PyCharm
# -----------------------------------------------------------------------------
import
uuid
from
flask_restful
import
Resource
,
reqparse
from
flask
import
request
,
render_template
from
flask
import
make_response
from
app.utils.html_to_pdf
import
html_to_pdf
from
app.api.engine
import
pdf_folder
class
OrderHandlers
(
Resource
):
"""."""
def
__init__
(
self
):
"""."""
self
.
parser
=
reqparse
.
RequestParser
()
def
get
(
self
):
"""."""
# self.parser.add_argument('product_id',type=str,required=True,help='商品ID不能为空')
# args = self.parser.parse_args()
STUDENT_LIST
=
[
{
'name'
:
'pj'
,
'age'
:
38
,
'gender'
:
'中'
},
{
'name'
:
'lc'
,
'age'
:
73
,
'gender'
:
'男'
},
{
'name'
:
'fy'
,
'age'
:
84
,
'gender'
:
'女'
}
]
params
=
{
'a'
:
'hello'
,
'b'
:
'world'
}
template
=
render_template
(
'student.html'
,
student
=
STUDENT_LIST
,
params
=
params
)
html_to_pdf
(
template
,
pdf_folder
+
str
(
uuid
.
uuid4
())
+
'.pdf'
)
resp
=
make_response
(
template
)
resp
.
headers
[
'Content-Type'
]
=
'text/html'
return
resp
def
post
(
self
):
"""."""
pass
def
put
(
self
,
id
):
"""."""
pass
def
delete
(
self
,
id
):
"""."""
pass
app/controller/report.py
0 → 100644
View file @
e04a86bf
# -*- encoding: utf-8 -*-
# -----------------------------------------------------------------------------
# @File Name : report.py
# @Time : 2020/11/18 下午3:19
# @Author : X. Peng
# @Email : acepengxiong@163.com
# @Software : PyCharm
# -----------------------------------------------------------------------------
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.utils.jinjia2html_v2
import
DataIntegrate
class
ReportHandlers
(
Resource
):
"""."""
def
__init__
(
self
):
"""."""
self
.
parser
=
reqparse
.
RequestParser
()
def
get
(
self
):
"""."""
# self.parser.add_argument('ifa_id', type=str, required=True, help='ifa_id不能为空')
self
.
parser
.
add_argument
(
'customer_id'
,
type
=
str
,
required
=
True
,
help
=
'customer_id不能为空'
)
args
=
self
.
parser
.
parse_args
()
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"
:
"请登陆"
}
ifa_id
=
ifa_id
.
replace
(
'
\'
'
,
''
)
customer_id
=
args
[
'customer_id'
]
pdf_name
=
str
(
uuid
.
uuid4
())
+
'.pdf'
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='{}' where ifa_id='{}' and customer_id='{}'"
.
format
(
datetime
.
datetime
.
now
(),
1
,
ifa_id
,
customer_id
)
tamp_diagnose_app_session
.
execute
(
sql
)
start
=
time
.
time
()
try
:
dt
=
DataIntegrate
(
ifa_id
=
ifa_id
,
customer_id
=
customer_id
,
pdf_name
=
pdf_name
)
dt
.
render_data
()
except
:
pass
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'
,
'tamperdev'
)
# 生成下载文件的签名URL,有效时间为60s。
path
=
bucket
.
sign_url
(
'GET'
,
'productionenv/Start/'
+
pdf_name
,
60
)
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
(
datetime
.
datetime
.
now
(),
2
,
pdf_name
,
ifa_id
,
customer_id
)
tamp_diagnose_app_session
.
execute
(
sql
)
resp
=
{
"code"
:
0
,
"data"
:
{
"path"
:
path
},
"lang"
:
"zh_CN"
,
"msg"
:
"成功"
}
return
resp
def
post
(
self
):
"""."""
pass
def
put
(
self
,
id
):
"""."""
pass
def
delete
(
self
,
id
):
"""."""
pass
app/model/order.py
View file @
e04a86bf
# -*- encoding: utf-8 -*-
# -----------------------------------------------------------------------------
# @File Name :
order
.py
# @File Name :
report
.py
# @Time : 2020/11/18 下午3:11
# @Author : X. Peng
# @Email : acepengxiong@163.com
...
...
app/router/version1.py
View file @
e04a86bf
...
...
@@ -7,8 +7,8 @@
# @Software : PyCharm
# -----------------------------------------------------------------------------
from
app.controller.
order
import
*
from
app.controller.
report
import
*
def
add_route
(
api
):
"""注册路由"""
api
.
add_resource
(
OrderHandlers
,
'/tamp_course_order/order
'
)
api
.
add_resource
(
ReportHandlers
,
'/fund_report/report
'
)
app/templates/v2/monthReportV2 .html
deleted
100644 → 0
View file @
ce855a22
This diff is collapsed.
Click to expand it.
app/utils/draw.py
View file @
e04a86bf
...
...
@@ -12,11 +12,14 @@ from urllib import parse
from
io
import
BytesIO
import
numpy
as
np
import
matplotlib
import
matplotlib.pyplot
as
plt
from
matplotlib
import
ticker
from
matplotlib.ticker
import
FuncFormatter
from
matplotlib.font_manager
import
FontProperties
matplotlib
.
use
(
'Agg'
)
# 中文字体初始化
plt
.
rcParams
[
'font.sans-serif'
]
=
[
'Heiti TC'
]
...
...
app/utils/jinjia2html_v2.py
View file @
e04a86bf
...
...
@@ -22,7 +22,8 @@ class DataIntegrate:
self
.
user_customer
=
UserCustomerResultAdaptor
(
ifa_id
,
customer_id
)
self
.
customer_name
=
self
.
user_customer
.
customer_real_name
self
.
ifa_name
=
self
.
user_customer
.
ifa_real_name
self
.
pdf_name
=
self
.
ifa_name
+
"_"
+
self
.
customer_name
+
"_"
+
'.pdf'
# self.pdf_name = self.ifa_name + "_" + self.customer_name + "_" + '.pdf'
self
.
pdf_name
=
pdf_name
# 全部数据
self
.
df
=
self
.
user_customer
.
calculate_total_data
()
# 组合结果数据
...
...
@@ -313,9 +314,9 @@ class DataIntegrate:
template
=
env
.
get_template
(
'/v2/monthReportV2.1.html'
)
# 获取一个模板文件
monthReport_html
=
template
.
render
(
data
)
# 渲染
# 保存 monthReport_html
save_file
=
"app/html/monthReport.html"
with
open
(
save_file
,
'w'
,
encoding
=
"utf-8"
)
as
f
:
f
.
write
(
monthReport_html
)
#
save_file = "app/html/monthReport.html"
#
with open(save_file, 'w', encoding="utf-8") as f:
#
f.write(monthReport_html)
# save_file = "app/html/v2/monthReportV2.html"
# with open(save_file, 'w', encoding="utf-8") as f:
...
...
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