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
377754e8
Commit
377754e8
authored
Dec 10, 2020
by
pengxiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
任务优化
parent
14de95aa
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
2212 additions
and
21 deletions
+2212
-21
engine.py
app/api/engine.py
+2
-2
jinjia2html_v2.py
app/utils/jinjia2html_v2.py
+1
-1
timed_task.py
app/utils/timed_task.py
+25
-18
fund_report_log.log
logs/fund_report_log.log
+2184
-0
No files found.
app/api/engine.py
View file @
377754e8
...
...
@@ -91,8 +91,8 @@ tamp_fund_engine = create_engine(
# )
logging
.
basicConfig
(
level
=
logging
.
INFO
,
#
filename=work_dir + config[env]['log']['filename'],
#
filemode=config[env]['log']['filemode'],
filename
=
work_dir
+
config
[
env
][
'log'
][
'filename'
],
filemode
=
config
[
env
][
'log'
][
'filemode'
],
format
=
config
[
env
][
'log'
][
'format'
],
datefmt
=
config
[
env
][
'log'
][
'datefmt'
]
)
...
...
app/utils/jinjia2html_v2.py
View file @
377754e8
...
...
@@ -327,5 +327,5 @@ class DataIntegrate:
if
__name__
==
'__main__'
:
start
=
time
.
time
()
DataIntegrate
(
ifa_id
=
'
USER_INFO15916072577875'
,
customer_id
=
'6716613804182482944
'
)
DataIntegrate
(
ifa_id
=
'
188843568193236992'
,
customer_id
=
'6734729261802467328
'
)
print
(
'耗时{}秒'
.
format
(
round
(
time
.
time
()
-
start
,
2
)))
app/utils/timed_task.py
View file @
377754e8
...
...
@@ -6,6 +6,9 @@
进行月报生成
"""
import
time
import
traceback
from
app.api.engine
import
logging
,
pdf_folder
import
os
from
app.api.engine
import
tamp_user_engine
,
tamp_order_engine
,
TAMP_SQL
from
sqlalchemy.ext.declarative
import
declarative_base
...
...
@@ -35,12 +38,26 @@ class Customer(Base):
id
=
Column
(
String
(
64
),
primary_key
=
True
)
customer_name
=
Column
(
String
(
128
))
# class CustomerOrder(Base):
# __tablename__ = 'customer_order'
#
# user_id = Column(String(128))
# customer_id = Column(String(128))
# class UserInfo(Base):
# __tablename__ = 'user_info'
#
# id = Column(String(64), primary_key=True)
# ui_username = Column(String(128))
def
call_month_report
(
ifauser_id
,
ifauser_name
,
customer_id
,
customer_name
):
# ifauser_id = args[0]
# ifauser_name = args[1]
# customer_id = args[2]
# customer_name = args[3]
filename
=
'{}_{}_.pdf'
.
format
(
ifauser_name
,
customer_name
)
if
os
.
path
.
exists
(
pdf_folder
+
filename
):
return
None
print
(
'开始制作IFA: {}, 客户: {}的基金月报'
.
format
(
ifauser_name
,
customer_name
))
start
=
time
.
time
()
try
:
...
...
@@ -48,27 +65,17 @@ def call_month_report(ifauser_id, ifauser_name, customer_id, 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
))
except
Exception
as
e
:
logging
.
error
(
"IFA: {}, 客户: {}的基金月报生成异常,错误追踪:{}"
.
format
(
ifauser_name
,
customer_name
,
traceback
.
format_exc
()))
print
(
"IFA: {}, 客户: {}的基金月报生成异常,错误追踪:{}"
.
format
(
ifauser_name
,
customer_name
,
traceback
.
format_exc
()))
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
)
.
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
(
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
)
call_month_report
(
ifauser
.
id
,
ifauser
.
ui_username
,
customer_full
.
id
,
customer_full
.
customer_name
)
res
=
tamp_user_session
.
execute
(
'SELECT DISTINCT user_id, customer_id , realname, customer_name FROM (select f1.user_id, f1.customer_id, f2.realname,f3.customer_name from customer_order f1, user_info f2,customer_info f3 where f2.id=f1.user_id and f3.id=f1.customer_id) res;'
)
data
=
res
.
fetchall
()
for
d
in
data
:
call_month_report
(
d
[
0
],
d
[
2
],
d
[
1
],
d
[
3
])
# 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)
...
...
logs/fund_report_log.log
0 → 100644
View file @
377754e8
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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