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
32248866
Commit
32248866
authored
Jan 18, 2021
by
pengxiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
路径
parent
351d51e4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
19 deletions
+24
-19
engine.py
app/api/engine.py
+2
-0
tamp_diagnose_app.py
app/model/tamp_diagnose_app.py
+4
-1
draw.py
app/utils/draw.py
+16
-16
jinjia2html_v2.py
app/utils/jinjia2html_v2.py
+2
-2
No files found.
app/api/engine.py
View file @
32248866
...
@@ -22,6 +22,8 @@ CFG_FILEPATH = work_dir + '/app/config/config.yaml'
...
@@ -22,6 +22,8 @@ CFG_FILEPATH = work_dir + '/app/config/config.yaml'
config
=
yaml
.
load
(
open
(
CFG_FILEPATH
,
'r'
),
Loader
=
yaml
.
FullLoader
)
config
=
yaml
.
load
(
open
(
CFG_FILEPATH
,
'r'
),
Loader
=
yaml
.
FullLoader
)
temp_img_save_folder
=
work_dir
+
'/app/templates/temp_img/productionenv/ReportTempImg/'
pdf_save_folder
=
work_dir
+
'/app/pdf/'
template_folder
=
config
[
env
][
'oss'
][
'imgs_url_prefix'
]
template_folder
=
config
[
env
][
'oss'
][
'imgs_url_prefix'
]
pdf_folder
=
config
[
env
][
'oss'
][
'pdf_url_prefix'
]
pdf_folder
=
config
[
env
][
'oss'
][
'pdf_url_prefix'
]
...
...
app/model/tamp_diagnose_app.py
View file @
32248866
...
@@ -5,7 +5,7 @@ from sqlalchemy import Column, DECIMAL, Date, DateTime, Index, String, Table, Te
...
@@ -5,7 +5,7 @@ from sqlalchemy import Column, DECIMAL, Date, DateTime, Index, String, Table, Te
from
sqlalchemy.dialects.mysql
import
BIGINT
,
INTEGER
from
sqlalchemy.dialects.mysql
import
BIGINT
,
INTEGER
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.ext.declarative
import
declarative_base
from
app.api.engine
import
TAMP_SQL
,
tamp_user_engine
,
tamp_diagnose_app_engine
from
app.api.engine
import
TAMP_SQL
,
tamp_user_engine
,
tamp_diagnose_app_engine
,
pdf_folder
from
app.model.base
import
Base
from
app.model.base
import
Base
from
app.model.base
import
BaseModel
from
app.model.base
import
BaseModel
...
@@ -138,6 +138,7 @@ class HoldDiagnoseReport(Base, BaseModel):
...
@@ -138,6 +138,7 @@ class HoldDiagnoseReport(Base, BaseModel):
allow_field
=
set
(
allow_field
)
&
set
(
allow_field
)
allow_field
=
set
(
allow_field
)
&
set
(
allow_field
)
else
:
else
:
allow_field
=
all_field
allow_field
=
all_field
self
.
file
=
pdf_folder
+
self
.
file
data
=
{
c
:
int
(
getattr
(
self
,
c
)
.
timestamp
())
if
isinstance
(
getattr
(
self
,
c
),
datetime
.
datetime
)
else
getattr
(
self
,
c
)
for
c
in
allow_field
}
data
=
{
c
:
int
(
getattr
(
self
,
c
)
.
timestamp
())
if
isinstance
(
getattr
(
self
,
c
),
datetime
.
datetime
)
else
getattr
(
self
,
c
)
for
c
in
allow_field
}
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user
,
TAMP_SQL
(
tamp_diagnose_app_engine
)
as
tamp_diagnose_app
:
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user
,
TAMP_SQL
(
tamp_diagnose_app_engine
)
as
tamp_diagnose_app
:
tamp_user_session
=
tamp_user
.
session
tamp_user_session
=
tamp_user
.
session
...
@@ -177,6 +178,7 @@ class HoldReport(Base, BaseModel):
...
@@ -177,6 +178,7 @@ class HoldReport(Base, BaseModel):
allow_field
=
set
(
allow_field
)
&
set
(
allow_field
)
allow_field
=
set
(
allow_field
)
&
set
(
allow_field
)
else
:
else
:
allow_field
=
all_field
allow_field
=
all_field
self
.
file
=
pdf_folder
+
self
.
file
data
=
{
c
:
int
(
getattr
(
self
,
c
)
.
timestamp
())
if
isinstance
(
getattr
(
self
,
c
),
datetime
.
datetime
)
else
getattr
(
self
,
c
)
for
c
in
allow_field
}
data
=
{
c
:
int
(
getattr
(
self
,
c
)
.
timestamp
())
if
isinstance
(
getattr
(
self
,
c
),
datetime
.
datetime
)
else
getattr
(
self
,
c
)
for
c
in
allow_field
}
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user
,
TAMP_SQL
(
tamp_diagnose_app_engine
)
as
tamp_diagnose_app
:
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user
,
TAMP_SQL
(
tamp_diagnose_app_engine
)
as
tamp_diagnose_app
:
tamp_user_session
=
tamp_user
.
session
tamp_user_session
=
tamp_user
.
session
...
@@ -216,6 +218,7 @@ class PeriodicReport(Base, BaseModel):
...
@@ -216,6 +218,7 @@ class PeriodicReport(Base, BaseModel):
allow_field
=
set
(
allow_field
)
&
set
(
allow_field
)
allow_field
=
set
(
allow_field
)
&
set
(
allow_field
)
else
:
else
:
allow_field
=
all_field
allow_field
=
all_field
self
.
file
=
pdf_folder
+
self
.
file
data
=
{
c
:
int
(
getattr
(
self
,
c
)
.
timestamp
())
if
isinstance
(
getattr
(
self
,
c
),
datetime
.
datetime
)
else
getattr
(
self
,
c
)
for
c
in
allow_field
}
data
=
{
c
:
int
(
getattr
(
self
,
c
)
.
timestamp
())
if
isinstance
(
getattr
(
self
,
c
),
datetime
.
datetime
)
else
getattr
(
self
,
c
)
for
c
in
allow_field
}
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user
,
TAMP_SQL
(
tamp_diagnose_app_engine
)
as
tamp_diagnose_app
:
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user
,
TAMP_SQL
(
tamp_diagnose_app_engine
)
as
tamp_diagnose_app
:
tamp_user_session
=
tamp_user
.
session
tamp_user_session
=
tamp_user
.
session
...
...
app/utils/draw.py
View file @
32248866
...
@@ -19,7 +19,7 @@ from matplotlib import ticker
...
@@ -19,7 +19,7 @@ from matplotlib import ticker
from
matplotlib.ticker
import
FuncFormatter
from
matplotlib.ticker
import
FuncFormatter
from
matplotlib.font_manager
import
FontProperties
from
matplotlib.font_manager
import
FontProperties
from
app.api.engine
import
template_folder
from
app.api.engine
import
template_folder
,
work_dir
,
temp_img_save_folder
matplotlib
.
use
(
'Agg'
)
matplotlib
.
use
(
'Agg'
)
# 中文字体初始化
# 中文字体初始化
...
@@ -98,9 +98,9 @@ def draw_month_return_chart(xlabels, product_list, cumulative):
...
@@ -98,9 +98,9 @@ def draw_month_return_chart(xlabels, product_list, cumulative):
# imgdata.seek(0) # rewind the data
# imgdata.seek(0) # rewind the data
# month_return_img = 'data:image/png;base64,' + base64.b64encode(imgdata.getvalue()).decode('utf-8')
# month_return_img = 'data:image/png;base64,' + base64.b64encode(imgdata.getvalue()).decode('utf-8')
filename
=
str
(
uuid
.
uuid4
())
+
'.png'
filename
=
str
(
uuid
.
uuid4
())
+
'.png'
fi
lepath
=
template_folder
+
filename
fi
g
.
savefig
(
temp_img_save_folder
+
filename
,
format
=
'png'
,
bbox_inches
=
'tight'
)
fig
.
savefig
(
filepath
,
format
=
'png'
,
bbox_inches
=
'tight'
)
return_path
=
template_folder
+
filename
return
file
path
return
return_
path
def
draw_contribution_chart
(
xlabels
,
product_list
,
cumulative
):
def
draw_contribution_chart
(
xlabels
,
product_list
,
cumulative
):
...
@@ -165,9 +165,9 @@ def draw_contribution_chart(xlabels, product_list, cumulative):
...
@@ -165,9 +165,9 @@ def draw_contribution_chart(xlabels, product_list, cumulative):
# month_return_img = 'data:image/png;base64,' + base64.b64encode(imgdata.getvalue()).decode('utf-8')
# month_return_img = 'data:image/png;base64,' + base64.b64encode(imgdata.getvalue()).decode('utf-8')
# return month_return_img
# return month_return_img
filename
=
str
(
uuid
.
uuid4
())
+
'.png'
filename
=
str
(
uuid
.
uuid4
())
+
'.png'
fi
lepath
=
template_folder
+
filename
fi
g
.
savefig
(
temp_img_save_folder
+
filename
,
format
=
'png'
,
bbox_inches
=
'tight'
)
fig
.
savefig
(
filepath
,
format
=
'png'
,
bbox_inches
=
'tight'
)
return_path
=
template_folder
+
filename
return
file
path
return
return_
path
# def draw_contribution_chart(xlabels, product_list, cumulative):
# def draw_contribution_chart(xlabels, product_list, cumulative):
# """贡献分解图"""
# """贡献分解图"""
...
@@ -309,9 +309,9 @@ def draw_old_combination_chart(xlabels, origin_combination, index):
...
@@ -309,9 +309,9 @@ def draw_old_combination_chart(xlabels, origin_combination, index):
# return_compare_img = 'data:image/png;base64,' + base64.b64encode(imgdata.getvalue()).decode('utf-8')
# return_compare_img = 'data:image/png;base64,' + base64.b64encode(imgdata.getvalue()).decode('utf-8')
# return return_compare_img
# return return_compare_img
filename
=
str
(
uuid
.
uuid4
())
+
'.png'
filename
=
str
(
uuid
.
uuid4
())
+
'.png'
fi
lepath
=
template_folder
+
filename
fi
g
.
savefig
(
temp_img_save_folder
+
filename
,
format
=
'png'
,
bbox_inches
=
'tight'
)
fig
.
savefig
(
filepath
,
format
=
'png'
,
bbox_inches
=
'tight'
)
return_path
=
template_folder
+
filename
return
file
path
return
return_
path
def
draw_combination_chart
(
xlabels
,
new_combination
,
origin_combination
,
index
):
def
draw_combination_chart
(
xlabels
,
new_combination
,
origin_combination
,
index
):
...
@@ -359,9 +359,9 @@ def draw_combination_chart(xlabels, new_combination, origin_combination, index):
...
@@ -359,9 +359,9 @@ def draw_combination_chart(xlabels, new_combination, origin_combination, index):
# return_compare_img = 'data:image/png;base64,' + base64.b64encode(imgdata.getvalue()).decode('utf-8')
# return_compare_img = 'data:image/png;base64,' + base64.b64encode(imgdata.getvalue()).decode('utf-8')
# return return_compare_img
# return return_compare_img
filename
=
str
(
uuid
.
uuid4
())
+
'.png'
filename
=
str
(
uuid
.
uuid4
())
+
'.png'
fi
lepath
=
template_folder
+
filename
fi
g
.
savefig
(
temp_img_save_folder
+
filename
,
format
=
'png'
,
bbox_inches
=
'tight'
)
fig
.
savefig
(
filepath
,
format
=
'png'
,
bbox_inches
=
'tight'
)
return_path
=
template_folder
+
filename
return
file
path
return
return_
path
def
draw_index_combination_chart
(
compare_data
):
def
draw_index_combination_chart
(
compare_data
):
...
@@ -415,9 +415,9 @@ def draw_index_combination_chart(compare_data):
...
@@ -415,9 +415,9 @@ def draw_index_combination_chart(compare_data):
# return_compare_img = 'data:image/png;base64,' + base64.b64encode(imgdata.getvalue()).decode('utf-8')
# return_compare_img = 'data:image/png;base64,' + base64.b64encode(imgdata.getvalue()).decode('utf-8')
# return return_compare_img
# return return_compare_img
filename
=
str
(
uuid
.
uuid4
())
+
'.png'
filename
=
str
(
uuid
.
uuid4
())
+
'.png'
fi
lepath
=
template_folder
+
filename
fi
g
.
savefig
(
temp_img_save_folder
+
filename
,
format
=
'png'
,
bbox_inches
=
'tight'
)
fig
.
savefig
(
filepath
,
format
=
'png'
,
bbox_inches
=
'tight'
)
return_path
=
template_folder
+
filename
return
file
path
return
return_
path
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
# xlabels = ('2020-1', '2020-2', '2020-3', '2020-4', '2020-5', '2020-6', '2020-7', '2020-8', '2020-9', '2020-10', '2020-11', '2020-12')
# xlabels = ('2020-1', '2020-2', '2020-3', '2020-4', '2020-5', '2020-6', '2020-7', '2020-8', '2020-9', '2020-10', '2020-11', '2020-12')
...
...
app/utils/jinjia2html_v2.py
View file @
32248866
...
@@ -4,7 +4,7 @@ import uuid
...
@@ -4,7 +4,7 @@ import uuid
from
jinja2
import
PackageLoader
,
Environment
from
jinja2
import
PackageLoader
,
Environment
from
app.api.engine
import
work_dir
,
pdf_folder
,
template_folder
from
app.api.engine
import
work_dir
,
pdf_folder
,
template_folder
,
pdf_save_folder
from
app.config.default_template_params
import
hold_default_template
,
diagnose_default_template
from
app.config.default_template_params
import
hold_default_template
,
diagnose_default_template
from
app.service.portfolio_diagnose
import
PortfolioDiagnose
from
app.service.portfolio_diagnose
import
PortfolioDiagnose
from
app.service.result_service_v2
import
UserCustomerResultAdaptor
from
app.service.result_service_v2
import
UserCustomerResultAdaptor
...
@@ -305,7 +305,7 @@ class DataIntegrate:
...
@@ -305,7 +305,7 @@ class DataIntegrate:
# save_file = "app/html/v2/monthReportV2.html"
# save_file = "app/html/v2/monthReportV2.html"
# with open(save_file, 'w', encoding="utf-8") as f:
# with open(save_file, 'w', encoding="utf-8") as f:
# f.write(monthReport_html)
# f.write(monthReport_html)
html_to_pdf
(
monthReport_html
,
pdf_folder
+
self
.
pdf_name
)
html_to_pdf
(
monthReport_html
,
pdf_
save_
folder
+
self
.
pdf_name
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
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