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
a83e81b1
Commit
a83e81b1
authored
Jan 22, 2021
by
pengxiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
json数据转换
parent
d144adb0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletion
+33
-1
report_service.py
app/service/report_service.py
+2
-1
format_transfer.py
app/utils/format_transfer.py
+31
-0
No files found.
app/service/report_service.py
View file @
a83e81b1
...
@@ -18,6 +18,7 @@ from app.api.engine import TAMP_SQL, tamp_diagnose_app_engine, template_folder,
...
@@ -18,6 +18,7 @@ from app.api.engine import TAMP_SQL, tamp_diagnose_app_engine, template_folder,
pdf_folder
pdf_folder
from
app.model.tamp_diagnose_app
import
HoldReport
,
HoldDiagnoseReport
,
PeriodicReport
,
Customer
,
ReportView
,
\
from
app.model.tamp_diagnose_app
import
HoldReport
,
HoldDiagnoseReport
,
PeriodicReport
,
Customer
,
ReportView
,
\
FundReportManange
FundReportManange
from
app.utils.format_transfer
import
npEncoder
from
app.utils.jinjia2html_v2
import
DataIntegrate
from
app.utils.jinjia2html_v2
import
DataIntegrate
from
app.utils.celery
import
save_pdf
from
app.utils.celery
import
save_pdf
...
@@ -234,7 +235,7 @@ def make_report(args):
...
@@ -234,7 +235,7 @@ def make_report(args):
try
:
try
:
dt
=
DataIntegrate
(
ifa_id
=
ifa_id
,
customer_id
=
customer_id
,
pdf_name
=
pdf_name
,
type
=
type
)
dt
=
DataIntegrate
(
ifa_id
=
ifa_id
,
customer_id
=
customer_id
,
pdf_name
=
pdf_name
,
type
=
type
)
report_data
=
dt
.
get_template_data
(
default_template
=
default_template
)
report_data
=
dt
.
get_template_data
(
default_template
=
default_template
)
report_data
=
json
.
dumps
(
report_data
)
.
replace
(
template_folder
,
temp_img_save_folder
)
report_data
=
json
.
dumps
(
report_data
,
cls
=
npEncoder
,
ensure_ascii
=
False
)
.
replace
(
template_folder
,
temp_img_save_folder
)
report_data
=
json
.
loads
(
report_data
)
report_data
=
json
.
loads
(
report_data
)
dt
.
render_data
(
data
=
report_data
)
dt
.
render_data
(
data
=
report_data
)
except
:
except
:
...
...
app/utils/format_transfer.py
0 → 100644
View file @
a83e81b1
# -*- encoding: utf-8 -*-
# -----------------------------------------------------------------------------
# @File Name : format_transfer.py
# @Time : 2021/1/6 下午7:58
# @Author : X. Peng
# @Email : acepengxiong@163.com
# @Software : PyCharm
# -----------------------------------------------------------------------------
import
base64
import
decimal
import
json
import
numpy
as
np
class
npEncoder
(
json
.
JSONEncoder
):
def
default
(
self
,
obj
):
if
isinstance
(
obj
,
np
.
ndarray
):
return
obj
.
tolist
()
elif
isinstance
(
obj
,
decimal
.
Decimal
):
return
obj
.
__str__
()
elif
isinstance
(
obj
,
np
.
int64
):
return
int
(
obj
)
elif
isinstance
(
obj
,
np
.
float64
):
return
float
(
obj
)
return
json
.
JSONEncoder
.
default
(
self
,
obj
)
def
img_transfer
(
url
):
""""""
img_content
=
'data:image/png;base64,'
with
open
(
url
,
'rb'
)
as
f
:
img_content
+=
base64
.
b64encode
(
f
.
read
())
.
decode
(
'utf-8'
)
return
img_content
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