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
0a880f7e
Commit
0a880f7e
authored
Jan 11, 2021
by
pengxiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新建模版,更新模版,删除模版,获取默认列表分页数据
parent
1c6b5c23
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
1278 additions
and
42 deletions
+1278
-42
__main__.py
app/api/__main__.py
+1
-1
default_template_params.py
app/config/default_template_params.py
+795
-14
template_manage.py
app/controller/template_manage.py
+78
-22
tamp_diagnose_app.py
app/model/tamp_diagnose_app.py
+253
-0
version1.py
app/router/version1.py
+4
-2
template_manage_service.py
app/service/template_manage_service.py
+141
-0
jinjia2html_v2.py
app/utils/jinjia2html_v2.py
+6
-3
No files found.
app/api/__main__.py
View file @
0a880f7e
...
@@ -9,5 +9,5 @@
...
@@ -9,5 +9,5 @@
from
app.api.app
import
app
from
app.api.app
import
app
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
app
.
run
(
'0.0.0.0'
,
port
=
8000
,
debug
=
Tru
e
)
app
.
run
(
'0.0.0.0'
,
port
=
8000
,
debug
=
Fals
e
)
app/config/default_template_params.py
View file @
0a880f7e
This source diff could not be displayed because it is too large. You can
view the blob
instead.
app/controller/template_manage.py
View file @
0a880f7e
...
@@ -12,7 +12,12 @@ from flask_restful import Resource, reqparse
...
@@ -12,7 +12,12 @@ from flask_restful import Resource, reqparse
from
flask
import
request
from
flask
import
request
from
app.api.engine
import
redis
from
app.api.engine
import
redis
from
app.config.default_template_params
import
hold_default_template
,
hold_default_data
,
diagnose_default_data
,
\
diagnose_default_template
from
app.service.template_manage_service
import
add_template
,
update_template
,
delete_template
,
get_template_list
,
\
get_default_template
from
app.utils.format_transfer
import
npEncoder
from
app.utils.format_transfer
import
npEncoder
from
flask
import
jsonify
from
app.utils.jinjia2html_v2
import
DataIntegrate
from
app.utils.jinjia2html_v2
import
DataIntegrate
import
numpy
as
np
import
numpy
as
np
...
@@ -22,25 +27,19 @@ class TemplateManage(Resource):
...
@@ -22,25 +27,19 @@ class TemplateManage(Resource):
def
__init__
(
self
):
def
__init__
(
self
):
"""."""
"""."""
token
=
request
.
headers
.
get
(
'Authorization'
,
''
)
token
=
's:sid:'
+
token
.
split
(
' '
)[
1
]
ifa_id
=
redis
.
get
(
token
)
if
not
ifa_id
:
return
{
"code"
:
'9005'
,
"message"
:
"请登录"
,
"attributes"
:
[]}
self
.
ifa_id
=
ifa_id
.
decode
()
.
replace
(
'
\'
'
,
''
)
self
.
parser
=
reqparse
.
RequestParser
()
self
.
parser
=
reqparse
.
RequestParser
()
def
get
(
self
):
def
get
(
self
):
"""."""
"""
获取默认模版数据
."""
self
.
parser
.
add_argument
(
'
customer_id'
,
type
=
str
,
required
=
True
,
help
=
'customer_id
不能为空'
)
self
.
parser
.
add_argument
(
'
type'
,
type
=
int
,
required
=
True
,
help
=
'type
不能为空'
)
args
=
self
.
parser
.
parse_args
()
args
=
self
.
parser
.
parse_args
()
token
=
request
.
headers
.
get
(
'Authorization'
,
''
)
data
=
get_default_template
(
args
)
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
.
get
(
'customer_id'
)
data
=
[]
try
:
dt
=
DataIntegrate
(
ifa_id
=
ifa_id
,
customer_id
=
customer_id
)
data
=
dt
.
get_template_data
()
except
:
pass
resp
=
{
resp
=
{
"statusCode"
:
"0000"
,
"statusCode"
:
"0000"
,
"message"
:
"成功"
,
"message"
:
"成功"
,
...
@@ -48,14 +47,71 @@ class TemplateManage(Resource):
...
@@ -48,14 +47,71 @@ class TemplateManage(Resource):
}
}
return
json
.
dumps
(
resp
,
cls
=
npEncoder
,
ensure_ascii
=
False
)
return
json
.
dumps
(
resp
,
cls
=
npEncoder
,
ensure_ascii
=
False
)
def
post
(
self
):
def
post
(
self
):
"""."""
"""新建定义模版."""
pass
self
.
parser
.
add_argument
(
'name'
,
type
=
str
,
required
=
True
,
help
=
'模版名称不能为空'
)
self
.
parser
.
add_argument
(
'custom_template'
,
type
=
str
,
required
=
True
,
help
=
'模版数据不能为空'
)
self
.
parser
.
add_argument
(
'type'
,
type
=
int
,
required
=
True
,
help
=
'模版类型不能为空'
)
args
=
self
.
parser
.
parse_args
()
args
[
'ifa_id'
]
=
self
.
ifa_id
add_template
(
args
)
def
put
(
self
,
id
):
def
put
(
self
):
"""."""
"""更新模版."""
pass
self
.
parser
.
add_argument
(
'update_type'
,
type
=
int
,
required
=
True
,
help
=
'1默认模版2自定义模版'
)
self
.
parser
.
add_argument
(
'type'
,
type
=
int
,
required
=
True
,
help
=
'1持仓报告2诊断报告'
)
self
.
parser
.
add_argument
(
'name'
,
type
=
int
,
required
=
False
,
help
=
'自定义模版名称'
)
self
.
parser
.
add_argument
(
'default_template'
,
type
=
str
,
required
=
False
,
help
=
'模版数据不能为空'
)
self
.
parser
.
add_argument
(
'custom_template'
,
type
=
str
,
required
=
False
,
help
=
'模版数据不能为空'
)
args
=
self
.
parser
.
parse_args
()
args
[
'ifa_id'
]
=
self
.
ifa_id
update_template
(
args
)
resp
=
{
"statusCode"
:
"0000"
,
"message"
:
"成功"
,
"attributes"
:
[]
}
return
resp
def
delete
(
self
):
"""删除模版."""
self
.
parser
.
add_argument
(
'id'
,
type
=
str
,
required
=
True
,
help
=
'模版id'
)
args
=
self
.
parser
.
parse_args
()
args
[
'ifa_id'
]
=
self
.
ifa_id
delete_template
(
args
)
resp
=
{
"statusCode"
:
"0000"
,
"message"
:
"成功"
,
"attributes"
:
[]
}
return
resp
class
TemplateList
(
Resource
):
"""."""
def
delete
(
self
,
id
):
def
__init__
(
self
):
"""."""
"""."""
pass
token
=
request
.
headers
.
get
(
'Authorization'
,
''
)
\ No newline at end of file
token
=
's:sid:'
+
token
.
split
(
' '
)[
1
]
ifa_id
=
redis
.
get
(
token
)
if
not
ifa_id
:
return
{
"code"
:
'9005'
,
"message"
:
"请登录"
,
"attributes"
:
[]}
self
.
ifa_id
=
ifa_id
.
decode
()
.
replace
(
'
\'
'
,
''
)
self
.
parser
=
reqparse
.
RequestParser
()
def
get
(
self
):
"""获取模版列表,分页."""
self
.
parser
.
add_argument
(
'type'
,
type
=
int
,
required
=
True
,
help
=
'0为全部1为持仓报告2为诊断报告'
)
self
.
parser
.
add_argument
(
'pageNumber'
,
type
=
int
,
required
=
False
)
self
.
parser
.
add_argument
(
'pageSize'
,
type
=
int
,
required
=
False
)
args
=
self
.
parser
.
parse_args
()
args
[
'ifa_id'
]
=
self
.
ifa_id
data
=
get_template_list
(
args
)
resp
=
{
"statusCode"
:
"0000"
,
"message"
:
"成功"
,
"attributes"
:
data
}
return
resp
app/model/tamp_diagnose_app.py
0 → 100644
View file @
0a880f7e
# coding: utf-8
from
sqlalchemy
import
Column
,
DECIMAL
,
Date
,
DateTime
,
Index
,
String
,
Table
,
Text
,
text
from
sqlalchemy.dialects.mysql
import
BIGINT
,
INTEGER
from
sqlalchemy.ext.declarative
import
declarative_base
from
app.model.base
import
Base
from
app.model.base
import
BaseModel
class
Customer
(
Base
,
BaseModel
):
__tablename__
=
'customer'
id
=
Column
(
String
(
64
),
primary_key
=
True
,
comment
=
'id'
)
customer_name
=
Column
(
String
(
64
),
index
=
True
,
comment
=
'客户姓名'
)
name
=
Column
(
String
(
64
))
valueSex
=
Column
(
INTEGER
(
11
),
comment
=
'性别 -- 1.男 2.女'
)
valueBirth
=
Column
(
DateTime
,
comment
=
'生日'
)
phone
=
Column
(
String
(
20
),
comment
=
'手机'
)
email
=
Column
(
String
(
120
),
comment
=
'邮箱'
)
landline
=
Column
(
String
(
20
),
comment
=
'座机'
)
address
=
Column
(
String
(
120
),
comment
=
'家庭地址'
)
fax
=
Column
(
String
(
20
),
comment
=
'传真'
)
qq
=
Column
(
String
(
20
))
wechat
=
Column
(
String
(
30
),
comment
=
'微信号'
)
wechatNickName
=
Column
(
String
(
30
),
comment
=
'微信昵称'
)
weibo
=
Column
(
String
(
30
),
comment
=
'微博'
)
work
=
Column
(
String
(
50
),
comment
=
'工作'
)
staff
=
Column
(
String
(
50
),
comment
=
'职务'
)
school
=
Column
(
String
(
50
),
comment
=
'毕业学校'
)
nativeplace
=
Column
(
String
(
30
),
comment
=
'籍贯'
)
valueMarry
=
Column
(
INTEGER
(
11
),
comment
=
'婚姻状况1.未婚 2.已婚 3.离异'
)
familyList
=
Column
(
String
(
500
),
comment
=
'家庭成员'
)
favor
=
Column
(
String
(
100
),
comment
=
'兴趣爱好'
)
concatTime
=
Column
(
String
(
30
),
comment
=
'方便联系时间'
)
wealth
=
Column
(
String
(
30
),
comment
=
'财产'
)
extra
=
Column
(
String
(
120
))
total_assets
=
Column
(
DECIMAL
(
22
,
6
))
floating_earnings
=
Column
(
DECIMAL
(
22
,
6
))
create_by
=
Column
(
String
(
64
))
create_time
=
Column
(
DateTime
)
update_by
=
Column
(
String
(
64
))
update_time
=
Column
(
DateTime
)
delete_tag
=
Column
(
INTEGER
(
11
))
member_since
=
Column
(
DateTime
)
last_seen
=
Column
(
DateTime
)
remark
=
Column
(
Text
,
comment
=
'备注'
)
group_id
=
Column
(
INTEGER
(
11
),
index
=
True
,
comment
=
'组id'
)
company_address
=
Column
(
String
(
200
),
comment
=
'单位地址'
)
other_address
=
Column
(
String
(
200
),
comment
=
'其他地址'
)
class
CustomerAsset
(
Base
,
BaseModel
):
__tablename__
=
'customer_assets'
id
=
Column
(
String
(
64
),
primary_key
=
True
,
nullable
=
False
,
comment
=
'客户id'
)
total_market
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'总市值'
)
total_principal
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'总本金'
)
accumulated_earnings
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'累计收益'
)
floating_earnings_proportion
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'累计收益率'
)
delete_tag
=
Column
(
INTEGER
(
11
))
ifa_id
=
Column
(
String
(
64
),
primary_key
=
True
,
nullable
=
False
,
comment
=
'理财师id'
)
seven_profit_rate
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'最近7天收益率'
)
thirty_profit_rate
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'最近30天收益率'
)
ninety_profit_rate
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'最近90天收益率'
)
half_year_profit_rate
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'最近半年收益率'
)
year_profit_rate
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'今年收益率'
)
class
FundReportManange
(
Base
,
BaseModel
):
__tablename__
=
'fund_report_manange'
id
=
Column
(
String
(
64
),
primary_key
=
True
,
comment
=
'id'
)
ifa_id
=
Column
(
String
(
64
),
comment
=
'理财师id'
)
default_template
=
Column
(
String
(
1000
),
comment
=
'默认模板'
)
custom_template
=
Column
(
String
(
1000
),
comment
=
'自定义模版'
)
create_by
=
Column
(
String
(
64
))
create_time
=
Column
(
DateTime
)
update_by
=
Column
(
String
(
64
))
update_time
=
Column
(
DateTime
)
delete_tag
=
Column
(
INTEGER
(
2
),
server_default
=
text
(
"'0'"
))
name
=
Column
(
String
(
300
),
comment
=
'模版名称'
)
type
=
Column
(
INTEGER
(
2
),
comment
=
'模版类型1持仓报告2诊断报告'
)
class
Group
(
Base
,
BaseModel
):
__tablename__
=
'group'
__table_args__
=
(
Index
(
'describe'
,
'describe'
,
'ifauser_id'
,
unique
=
True
),
)
id
=
Column
(
INTEGER
(
11
),
primary_key
=
True
)
describe
=
Column
(
String
(
50
))
createtime
=
Column
(
DateTime
)
ifauser_id
=
Column
(
String
(
64
))
class
HoldDiagnoseReport
(
Base
,
BaseModel
):
__tablename__
=
'hold_diagnose_report'
id
=
Column
(
INTEGER
(
11
),
primary_key
=
True
)
customer_id
=
Column
(
String
(
64
))
ifa_id
=
Column
(
String
(
64
))
update_time
=
Column
(
DateTime
)
update_status
=
Column
(
INTEGER
(
11
))
file
=
Column
(
String
(
128
))
be_viewed
=
Column
(
INTEGER
(
2
),
comment
=
'0未查看1已查看'
)
class
HoldReport
(
Base
,
BaseModel
):
__tablename__
=
'hold_report'
id
=
Column
(
INTEGER
(
11
),
primary_key
=
True
)
customer_id
=
Column
(
String
(
64
))
ifa_id
=
Column
(
String
(
64
))
update_time
=
Column
(
DateTime
)
update_status
=
Column
(
INTEGER
(
11
))
file
=
Column
(
String
(
128
))
be_viewed
=
Column
(
INTEGER
(
2
),
comment
=
'0未查看1已查看'
)
class
IfaCustomer
(
Base
,
BaseModel
):
__tablename__
=
'ifa_customer'
id
=
Column
(
String
(
64
),
primary_key
=
True
)
customer_id
=
Column
(
String
(
64
))
ifa_id
=
Column
(
String
(
64
))
fund_count
=
Column
(
INTEGER
(
11
))
revision
=
Column
(
INTEGER
(
11
))
create_by
=
Column
(
String
(
64
))
create_time
=
Column
(
DateTime
)
update_by
=
Column
(
String
(
64
))
update_time
=
Column
(
DateTime
)
delete_tag
=
Column
(
INTEGER
(
11
))
class
IfaFundCollection
(
Base
,
BaseModel
):
__tablename__
=
'ifa_fund_collection'
__table_args__
=
(
Index
(
'unique'
,
'fund_id'
,
'ifa_id'
,
'delete_tag'
),
)
id
=
Column
(
INTEGER
(
11
),
primary_key
=
True
,
comment
=
'id'
)
fund_id
=
Column
(
String
(
64
))
ifa_id
=
Column
(
String
(
64
))
create_time
=
Column
(
DateTime
)
create_by
=
Column
(
String
(
255
))
update_time
=
Column
(
DateTime
)
update_by
=
Column
(
DateTime
)
delete_tag
=
Column
(
INTEGER
(
4
),
server_default
=
text
(
"'0'"
))
type
=
Column
(
INTEGER
(
4
))
class
IfauserFund
(
Base
,
BaseModel
):
__tablename__
=
'ifauser_fund'
id
=
Column
(
INTEGER
(
11
),
primary_key
=
True
)
type
=
Column
(
INTEGER
(
11
),
index
=
True
)
fund_id
=
Column
(
String
(
30
),
index
=
True
)
fund_name
=
Column
(
String
(
30
))
ifauser_id
=
Column
(
String
(
64
))
customer_count
=
Column
(
INTEGER
(
11
))
sum
=
Column
(
DECIMAL
(
22
,
6
))
class
Operation
(
Base
,
BaseModel
):
__tablename__
=
'operations'
id
=
Column
(
INTEGER
(
11
),
primary_key
=
True
)
operator_id
=
Column
(
String
(
64
),
index
=
True
)
describe
=
Column
(
Text
)
timestamp
=
Column
(
DateTime
,
index
=
True
)
ip
=
Column
(
Text
)
class
RelocateSuggestion
(
Base
,
BaseModel
):
__tablename__
=
'relocate_suggestion'
id
=
Column
(
String
(
64
),
primary_key
=
True
)
fund_id
=
Column
(
String
(
64
))
substrategy
=
Column
(
INTEGER
(
11
))
fund_name
=
Column
(
String
(
255
))
percent
=
Column
(
DECIMAL
(
22
,
6
))
group_id
=
Column
(
String
(
255
))
delete_tag
=
Column
(
INTEGER
(
11
))
type
=
Column
(
INTEGER
(
11
))
register_number
=
Column
(
String
(
20
))
class
RelocateSuggestionGroup
(
Base
,
BaseModel
):
__tablename__
=
'relocate_suggestion_group'
id
=
Column
(
String
(
64
),
primary_key
=
True
)
group_name
=
Column
(
String
(
255
))
ifa_id
=
Column
(
String
(
255
))
customer_id
=
Column
(
String
(
255
))
create_time
=
Column
(
DateTime
)
create_by
=
Column
(
String
(
255
))
update_time
=
Column
(
DateTime
)
update_by
=
Column
(
String
(
255
))
delete_tag
=
Column
(
INTEGER
(
11
))
class
UserHoldFundAsset
(
Base
,
BaseModel
):
__tablename__
=
'user_hold_fund_assets'
id
=
Column
(
String
(
64
),
primary_key
=
True
)
reference_market
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'市值'
)
holding_net
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'累计收益率'
)
profit_or_loss
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'累计收益'
)
delete_tag
=
Column
(
INTEGER
(
11
))
annual_profit_rate
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'年化收益率'
)
seven_profit
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'最近7天收益'
)
seven_profit_rate
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'最近7天收益率'
)
seven_annual_profit_rate
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'最近7天年化收益率'
)
thirty_profit
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'最近30天收益'
)
thirty_profit_rate
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'最近30天收益率'
)
thirty_annual_profit_rate
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'最近30天年化收益率'
)
ninety_profit
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'最近90天收益'
)
ninety_profit_rate
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'最近90天收益率'
)
ninety_annual_profit_rate
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'最近90天年化收益率'
)
half_year_profit
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'最近半年收益'
)
half_year_profit_rate
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'最近半年收益率'
)
half_year_annual_profit_rate
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'最近半年年化收益率'
)
year_profit
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'今年收益'
)
year_profit_rate
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'今年收益率'
)
year_annual_profit_rate
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'今年年化收益率'
)
class
UserHoldFundFromApp
(
Base
,
BaseModel
):
__tablename__
=
'user_hold_fund_from_app'
id
=
Column
(
String
(
64
),
primary_key
=
True
)
type
=
Column
(
INTEGER
(
11
),
index
=
True
,
comment
=
'0 公募 1 私募 2 优选'
)
fund_id
=
Column
(
String
(
64
),
index
=
True
)
fund_name
=
Column
(
String
(
30
))
customer_id
=
Column
(
String
(
64
),
index
=
True
,
comment
=
'customer id'
)
subscription_fee
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'申购费'
)
nav
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'购买时候的净值'
)
create_by
=
Column
(
String
(
64
))
create_time
=
Column
(
DateTime
)
update_by
=
Column
(
String
(
64
))
update_time
=
Column
(
DateTime
)
delete_tag
=
Column
(
INTEGER
(
11
))
confirm_amount
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'确认金额'
)
confirm_share
=
Column
(
DECIMAL
(
22
,
6
),
comment
=
'确认份额'
)
order_source
=
Column
(
INTEGER
(
11
))
order_type
=
Column
(
INTEGER
(
1
),
comment
=
'1、申购或追加 2、赎回 4 暂时其他'
)
remark
=
Column
(
String
(
255
),
comment
=
'订单备注'
)
user_id
=
Column
(
String
(
64
),
index
=
True
,
server_default
=
text
(
"''"
),
comment
=
'ifa的id'
)
folio_name
=
Column
(
String
(
64
),
comment
=
'组合名称,默认是default'
)
confirm_share_date
=
Column
(
Date
,
comment
=
'确认份额日期'
)
pay_date
=
Column
(
Date
,
comment
=
'订单支付时间'
)
app/router/version1.py
View file @
0a880f7e
...
@@ -12,5 +12,7 @@ from app.controller.template_manage import *
...
@@ -12,5 +12,7 @@ from app.controller.template_manage import *
def
add_route
(
api
):
def
add_route
(
api
):
"""注册路由"""
"""注册路由"""
api
.
add_resource
(
ReportHandlers
,
'/fund_report/report'
)
api
.
add_resource
(
ReportHandlers
,
'/api/fund_report/report'
)
api
.
add_resource
(
TemplateManage
,
'/template_manage/get_data'
)
api
.
add_resource
(
TemplateManage
,
'/api/template_manage'
)
api
.
add_resource
(
TemplateList
,
'/api/template_list'
)
app/service/template_manage_service.py
0 → 100644
View file @
0a880f7e
# -*- encoding: utf-8 -*-
# -----------------------------------------------------------------------------
# @File Name : template_manage_service.py
# @Time : 2021/1/8 下午5:26
# @Author : X. Peng
# @Email : acepengxiong@163.com
# @Software : PyCharm
# -----------------------------------------------------------------------------
import
datetime
import
json
import
uuid
from
sqlalchemy
import
and_
from
app.api.engine
import
TAMP_SQL
,
tamp_diagnose_app_engine
from
app.config.default_template_params
import
hold_default_template
,
hold_default_data
,
diagnose_default_data
,
\
diagnose_default_template
from
app.model.tamp_diagnose_app
import
*
def
get_default_template
(
args
):
""""""
type
=
args
.
get
(
'type'
)
data
=
[]
with
TAMP_SQL
(
tamp_diagnose_app_engine
)
as
tamp_diagnose_app
:
tamp_diagnose_session
=
tamp_diagnose_app
.
session
res
=
tamp_diagnose_session
.
query
(
FundReportManange
)
.
filter
(
and_
(
FundReportManange
.
ifa_id
==
args
.
get
(
'ifa_id'
),
FundReportManange
.
type
==
type
,
FundReportManange
.
delete_tag
==
0
,
FundReportManange
.
default_template
is
not
None
))
.
first
()
default_template
,
default_data
=
None
,
None
if
type
==
1
:
default_template
=
hold_default_template
default_data
=
hold_default_data
elif
type
==
2
:
default_template
=
diagnose_default_template
default_data
=
diagnose_default_data
if
res
:
data
=
{
**
json
.
loads
(
res
.
get
(
'default_template'
)),
**
default_data
}
else
:
data
=
{
**
default_template
,
**
default_data
}
return
data
def
add_template
(
args
):
"""新建模版"""
with
TAMP_SQL
(
tamp_diagnose_app_engine
)
as
tamp_diagnose_app
:
tamp_diagnose_session
=
tamp_diagnose_app
.
session
args
[
'id'
]
=
str
(
uuid
.
uuid4
())
args
[
'default_template'
]
=
json
.
dumps
(
hold_default_template
)
args
[
'create_by'
]
=
args
.
get
(
'ifa_id'
)
args
[
'create_time'
]
=
datetime
.
datetime
.
now
()
fund_report_manange
=
FundReportManange
(
args
)
tamp_diagnose_session
.
add
(
fund_report_manange
)
def
update_template
(
args
):
"""更新默认模版"""
with
TAMP_SQL
(
tamp_diagnose_app_engine
)
as
tamp_diagnose_app
:
tamp_diagnose_session
=
tamp_diagnose_app
.
session
update_type
=
args
.
get
(
'update_type'
)
type
=
args
.
get
(
'type'
)
res
=
tamp_diagnose_session
.
query
(
FundReportManange
)
.
filter
(
and_
(
FundReportManange
.
ifa_id
==
args
.
get
(
'ifa_id'
),
FundReportManange
.
type
==
type
,
FundReportManange
.
delete_tag
==
0
,
))
if
update_type
==
1
:
# 更新默认模版
if
type
==
1
:
args
[
'name'
]
=
'持仓报告默认模版'
elif
type
==
2
:
args
[
'name'
]
=
'诊断报告默认模版'
if
res
:
res
.
update
({
'default_template'
:
args
.
get
(
'default_template'
),
'update_by'
:
args
.
get
(
'ifa_id'
),
'update_time'
:
datetime
.
datetime
.
now
()
})
else
:
args
[
'create_by'
]
=
args
.
get
(
'ifa_id'
)
args
[
'create_time'
]
=
datetime
.
datetime
.
now
()
new_template
=
FundReportManange
(
**
args
)
tamp_diagnose_session
.
add
(
new_template
)
elif
update_type
==
2
:
# 更新自定义模版
args
[
'update_by'
]
=
args
.
get
(
'ifa_id'
)
args
[
'update_time'
]
=
datetime
.
datetime
.
now
()
res
.
update
({
'name'
:
args
.
get
(
'name'
),
'custom_template'
:
args
.
get
(
'custom_template'
),
'update_by'
:
args
.
get
(
'ifa_id'
),
'update_time'
:
datetime
.
datetime
.
now
()
})
return
True
def
delete_template
(
args
):
"""."""
with
TAMP_SQL
(
tamp_diagnose_app_engine
)
as
tamp_diagnose_app
:
tamp_diagnose_session
=
tamp_diagnose_app
.
session
tamp_diagnose_session
.
query
(
FundReportManange
)
.
filter
(
FundReportManange
.
id
==
args
.
get
(
id
)
)
.
update
({
'delete_tag'
:
1
,
'update_by'
:
args
.
get
(
'ifa_id'
),
'update_time'
:
datetime
.
datetime
.
now
()
})
def
get_template_list
(
args
):
"""."""
pageNumber
=
args
[
'pageNumber'
]
pageSize
=
args
[
'pageSize'
]
offset
=
(
pageNumber
-
1
)
*
pageSize
dtype
=
args
.
get
(
'type'
)
with
TAMP_SQL
(
tamp_diagnose_app_engine
)
as
tamp_diagnose_app
:
tamp_diagnose_session
=
tamp_diagnose_app
.
session
res
=
[]
if
dtype
==
0
:
res
=
tamp_diagnose_session
.
query
(
FundReportManange
)
.
filter
(
and_
(
FundReportManange
.
delete_tag
==
0
,
FundReportManange
.
ifa_id
==
args
.
get
(
'ifa_id'
)
))
else
:
res
=
tamp_diagnose_session
.
query
(
FundReportManange
)
.
filter
(
and_
(
FundReportManange
.
delete_tag
==
0
,
FundReportManange
.
ifa_id
==
args
.
get
(
'ifa_id'
),
FundReportManange
.
type
==
args
.
get
(
'type'
)
))
if
not
res
:
return
False
totalSize
=
res
.
count
()
data
=
res
.
offset
(
offset
)
.
limit
(
pageSize
)
data
=
[
r
.
to_dict
()
for
r
in
data
]
return
{
'content'
:
data
,
'pageNum'
:
pageNumber
,
'pageSize'
:
pageSize
,
'totalSize'
:
totalSize
}
app/utils/jinjia2html_v2.py
View file @
0a880f7e
...
@@ -19,7 +19,7 @@ from app.utils.radar_chart import gen_radar_chart
...
@@ -19,7 +19,7 @@ from app.utils.radar_chart import gen_radar_chart
class
DataIntegrate
:
class
DataIntegrate
:
def
__init__
(
self
,
ifa_id
=
'USER_INFO1591
4346866762'
,
customer_id
=
'202009281545001
'
,
pdf_name
=
str
(
uuid
.
uuid4
())
+
'.pdf'
,
type
=
1
):
def
__init__
(
self
,
ifa_id
=
'USER_INFO1591
7850824287'
,
customer_id
=
'6716613802534121472
'
,
pdf_name
=
str
(
uuid
.
uuid4
())
+
'.pdf'
,
type
=
1
):
self
.
user_customer
=
UserCustomerResultAdaptor
(
ifa_id
,
customer_id
)
self
.
user_customer
=
UserCustomerResultAdaptor
(
ifa_id
,
customer_id
)
self
.
customer_name
=
self
.
user_customer
.
customer_real_name
self
.
customer_name
=
self
.
user_customer
.
customer_real_name
self
.
ifa_name
=
self
.
user_customer
.
ifa_real_name
self
.
ifa_name
=
self
.
user_customer
.
ifa_real_name
...
@@ -254,7 +254,8 @@ class DataIntegrate:
...
@@ -254,7 +254,8 @@ class DataIntegrate:
'all_folio_result'
:
self
.
all_folio_result
,
'all_folio_result'
:
self
.
all_folio_result
,
}
}
self
.
data
=
{
**
hold_default_template
,
**
data
}
# self.data = {**hold_default_template, **data}
self
.
data
=
data
elif
self
.
type
==
2
:
elif
self
.
type
==
2
:
# 诊断报告数据
# 诊断报告数据
data
=
{
data
=
{
...
@@ -284,7 +285,9 @@ class DataIntegrate:
...
@@ -284,7 +285,9 @@ class DataIntegrate:
# 组合数据
# 组合数据
'all_folio_result'
:
self
.
all_folio_result
,
'all_folio_result'
:
self
.
all_folio_result
,
}
}
self
.
data
=
{
**
diagnose_default_template
,
**
data
}
# self.data = {**diagnose_default_template, **data}
self
.
data
=
data
print
(
data
)
return
self
.
data
return
self
.
data
def
render_data
(
self
):
def
render_data
(
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