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
ee5848ab
Commit
ee5848ab
authored
Dec 10, 2020
by
赵杰
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into dev
parents
c9f3d8fa
de43bddb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
27 deletions
+29
-27
engine.py
app/api/engine.py
+5
-15
jinjia2html_v2.py
app/utils/jinjia2html_v2.py
+1
-1
timed_task.py
app/utils/timed_task.py
+23
-11
No files found.
app/api/engine.py
View file @
ee5848ab
...
...
@@ -77,22 +77,12 @@ tamp_fund_engine = create_engine(
user
=
config
[
env
][
'MySQL'
][
'user'
],
password
=
config
[
env
][
'MySQL'
][
'password'
],
charset
=
"utf8"
)
)
tamp_order_engine
=
create_engine
(
'mysql+pymysql://{user}:{password}@{host}:{port}/{db}?charset={charset}'
.
format
(
db
=
config
[
env
][
'MySQL'
][
'tamp_order_db'
],
host
=
config
[
env
][
'MySQL'
][
'host'
],
port
=
config
[
env
][
'MySQL'
][
'port'
],
user
=
config
[
env
][
'MySQL'
][
'user'
],
password
=
config
[
env
][
'MySQL'
][
'password'
],
charset
=
"utf8"
),
echo
=
True
),
max_overflow
=
0
,
# 超过连接池大小外最多创建的连接
pool_size
=
100
,
# 连接池大小
pool_timeout
=
5
,
pool_recycle
=
600
)
# tamp_product_session = scoped_session(sessionmaker(bind=tamp_product_engine))()
# tamp_order_session = scoped_session(sessionmaker(bind=tamp_order_engine))()
# tamp_user_session = scoped_session(sessionmaker(bind=tamp_user_engine))()
# redis = redis.StrictRedis(
# host=config[env]['redis']['host'],
...
...
app/utils/jinjia2html_v2.py
View file @
ee5848ab
...
...
@@ -245,7 +245,7 @@ class DataIntegrate:
'cover_back'
:
template_folder
+
'/v2/img/cover-back.png'
,
'logo'
:
template_folder
+
'/v2/img/logo.png'
,
'scene'
:
template_folder
+
'/v2/img/scene.png'
,
'team'
:
template_folder
+
'/v2/img/
team
.png'
,
'team'
:
template_folder
+
'/v2/img/
default-user
.png'
,
# 全局数据
'customer_name'
:
self
.
customer_name
,
'year_month'
:
self
.
user_customer
.
month_start_date
.
strftime
(
"
%
Y-
%
m"
),
...
...
app/utils/timed_task.py
View file @
ee5848ab
...
...
@@ -5,11 +5,13 @@
找出 ifa 所有的客户
进行月报生成
"""
import
time
from
app.api.engine
import
tamp_user_engine
,
tamp_order_engine
,
TAMP_SQL
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy
import
Column
,
String
,
Integer
,
and_
from
app.utils.jinjia2html_v2
import
DataIntegrate
from
concurrent
import
futures
Base
=
declarative_base
()
class
IfaUser
(
Base
):
...
...
@@ -34,30 +36,40 @@ class Customer(Base):
customer_name
=
Column
(
String
(
128
))
def
call_month_report
(
ifauser_id
,
ifauser_name
,
customer_id
,
customer_name
):
# print('开始制作IFA: {}, 客户: {}的基金月报'.format(ifauser_name, customer_name))
# try:
DataIntegrate
(
ifauser_id
,
customer_id
,
'{}_{}_.pdf'
.
format
(
ifauser_name
,
customer_name
))
# except IndexError:
# print("发生异常,下一个走起!")
# ifauser_id = args[0]
# ifauser_name = args[1]
# customer_id = args[2]
# customer_name = args[3]
print
(
'开始制作IFA: {}, 客户: {}的基金月报'
.
format
(
ifauser_name
,
customer_name
))
start
=
time
.
time
()
try
:
DataIntegrate
(
ifauser_id
,
customer_id
,
'{}_{}_.pdf'
.
format
(
ifauser_name
,
customer_name
))
print
(
'IFA: {}, 客户: {}的基金月报已经生成, 耗时{}秒'
.
format
(
ifauser_name
,
customer_name
,
time
.
time
()
-
start
))
except
OSError
:
print
(
'IFA: {}, 客户: {}的基金月报已经生成,耗时{}秒'
.
format
(
ifauser_name
,
customer_name
,
time
.
time
()
-
start
))
except
:
print
(
"IFA: {}, 客户: {}的基金月报生成异常,开始制作下一个"
.
format
(
ifauser_name
,
customer_name
))
with
TAMP_SQL
(
tamp_user_engine
)
as
tamp_user
,
TAMP_SQL
(
tamp_order_engine
)
as
tamp_order
:
tamp_user_session
=
tamp_user
.
session
# 获取所有 ifauser
ifausers
=
tamp_user_session
.
query
(
IfaUser
)
.
filter
(
IfaUser
.
id
.
in_
([
'USER_INFO15916072577875'
]))
.
all
()
ifausers
=
tamp_user_session
.
query
(
IfaUser
)
.
all
()
tamp_order_session
=
tamp_order
.
session
# for ifauser in ifausers:
for
ifauser
in
ifausers
:
# 获取某个 ifa 的所有 customer
customers
=
tamp_order_session
.
query
(
Ifa_Customer
)
.
\
filter
(
and_
(
Ifa_Customer
.
ifa_id
==
ifauser
.
id
,
Ifa_Customer
.
customer_id
.
in_
([
'6716613804182482944'
]))
)
.
all
()
filter
(
Ifa_Customer
.
ifa_id
==
ifauser
.
id
)
.
all
()
# 循环这个 ifa 的所有 customer
# args = []
for
customer
in
customers
:
customer_full
=
tamp_order_session
.
query
(
Customer
)
.
\
get
(
customer
.
customer_id
)
customer_full
=
tamp_order_session
.
query
(
Customer
)
.
get
(
customer
.
customer_id
)
call_month_report
(
ifauser
.
id
,
ifauser
.
ui_username
,
customer_full
.
id
,
customer_full
.
customer_name
)
# args.append((ifauser.id, ifauser.ui_username, customer_full.id, customer_full.customer_name))
# with futures.ProcessPoolExecutor(8) as executor:
# executor.map(call_month_report, args)
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