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
b85484cd
Commit
b85484cd
authored
Jan 20, 2021
by
pengxiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
报告列表视图
parent
dc7dcac2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
126 deletions
+80
-126
tamp_diagnose_app.py
app/model/tamp_diagnose_app.py
+34
-60
report_service.py
app/service/report_service.py
+46
-66
No files found.
app/model/tamp_diagnose_app.py
View file @
b85484cd
...
...
@@ -142,26 +142,7 @@ class HoldDiagnoseReport(Base, BaseModel):
if
self
.
file
:
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
}
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_diagnose_app_session
=
tamp_diagnose_app
.
session
sql
=
"select ui_username_mp from user_info where id = '{}'"
.
format
(
self
.
ifa_id
)
res
=
tamp_user_session
.
execute
(
sql
)
sql2
=
"select customer_name from tamp_diagnose_app.customer_view where id = '{}'"
.
format
(
self
.
customer_id
)
res2
=
tamp_diagnose_app_session
.
execute
(
sql2
)
res
=
res
.
fetchone
()
res2
=
res2
.
fetchone
()
if
data
:
data
[
'file'
]
=
file
if
res
:
data
[
'author_name'
]
=
res
[
0
]
else
:
data
[
'author_name'
]
=
''
if
res2
:
data
[
'customer_name'
]
=
res2
[
0
]
else
:
data
[
'customer_name'
]
=
''
data
[
'type'
]
=
2
data
[
'file'
]
=
file
return
data
...
...
@@ -188,26 +169,7 @@ class HoldReport(Base, BaseModel):
if
self
.
file
:
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
}
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_diagnose_app_session
=
tamp_diagnose_app
.
session
sql
=
"select ui_username_mp from user_info where id = '{}'"
.
format
(
self
.
ifa_id
)
res
=
tamp_user_session
.
execute
(
sql
)
sql2
=
"select customer_name from tamp_diagnose_app.customer_view where id = '{}'"
.
format
(
self
.
customer_id
)
res2
=
tamp_diagnose_app_session
.
execute
(
sql2
)
res
=
res
.
fetchone
()
res2
=
res2
.
fetchone
()
if
data
:
data
[
'file'
]
=
file
if
res
:
data
[
'author_name'
]
=
res
[
0
]
else
:
data
[
'author_name'
]
=
''
if
res2
:
data
[
'customer_name'
]
=
res2
[
0
]
else
:
data
[
'customer_name'
]
=
''
data
[
'type'
]
=
1
data
[
'file'
]
=
file
return
data
...
...
@@ -234,29 +196,41 @@ class PeriodicReport(Base, BaseModel):
if
self
.
file
:
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
}
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_diagnose_app_session
=
tamp_diagnose_app
.
session
sql
=
"select ui_username_mp from user_info where id = '{}'"
.
format
(
self
.
ifa_id
)
res
=
tamp_user_session
.
execute
(
sql
)
sql2
=
"select customer_name from tamp_diagnose_app.customer_view where id = '{}'"
.
format
(
self
.
customer_id
)
res2
=
tamp_diagnose_app_session
.
execute
(
sql2
)
res
=
res
.
fetchone
()
res2
=
res2
.
fetchone
()
if
data
:
data
[
'file'
]
=
file
if
res
:
data
[
'author_name'
]
=
res
[
0
]
else
:
data
[
'author_name'
]
=
''
if
res2
:
data
[
'customer_name'
]
=
res2
[
0
]
else
:
data
[
'customer_name'
]
=
''
data
[
'type'
]
=
3
data
[
'file'
]
=
file
return
data
class
ReportView
(
Base
,
BaseModel
):
__tablename__
=
'report_view'
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已查看'
)
report_data
=
Column
(
Text
)
name
=
Column
(
String
(
100
))
customer_name
=
Column
(
String
(
100
))
author_name
=
Column
(
String
(
100
))
type
=
Column
(
INTEGER
(
2
))
def
to_dict
(
self
,
allow_field
=
None
):
all_field
=
[
r
.
name
for
r
in
self
.
__table__
.
columns
]
if
allow_field
:
allow_field
=
set
(
allow_field
)
&
set
(
allow_field
)
else
:
allow_field
=
all_field
file
=
''
if
self
.
file
:
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
[
'file'
]
=
file
return
data
class
IfaCustomer
(
Base
,
BaseModel
):
__tablename__
=
'ifa_customer'
...
...
app/service/report_service.py
View file @
b85484cd
...
...
@@ -11,11 +11,11 @@ import json
import
os
import
uuid
from
sqlalchemy
import
and_
from
sqlalchemy
import
and_
,
or_
# from sqlalchemy import union_all
from
app.api.engine
import
TAMP_SQL
,
tamp_diagnose_app_engine
,
template_folder
,
temp_img_save_folder
from
app.model.tamp_diagnose_app
import
HoldReport
,
HoldDiagnoseReport
,
PeriodicReport
from
app.model.tamp_diagnose_app
import
HoldReport
,
HoldDiagnoseReport
,
PeriodicReport
,
Customer
,
ReportView
from
app.utils.jinjia2html_v2
import
DataIntegrate
...
...
@@ -23,61 +23,56 @@ def get_report_list(args):
"""."""
type
=
args
.
get
(
'type'
)
ifa_id
=
args
.
get
(
'ifa_id'
)
name
=
args
.
get
(
'name'
)
pageNumber
=
args
[
'pageNumber'
]
pageSize
=
args
[
'pageSize'
]
start_time
=
args
.
get
(
'start_time'
)
end_time
=
args
.
get
(
'end_time'
)
offset
=
(
pageNumber
-
1
)
*
pageSize
res
=
[]
allow_field
=
[
'id'
,
'customer_id'
,
'ifa_id'
,
'update_time'
,
'update_status'
,
'file'
,
'be_viewed'
,
'name'
]
conditions
=
()
if
type
==
0
:
conditions
=
[
and_
(
ReportView
.
ifa_id
==
ifa_id
,
ReportView
.
name
.
like
(
'
%
'
+
name
+
'
%
'
),
ReportView
.
update_time
>=
start_time
,
HoldReport
.
update_time
<=
end_time
),
and_
(
ReportView
.
ifa_id
==
ifa_id
,
ReportView
.
customer_name
.
like
(
'
%
'
+
name
+
'
%
'
),
ReportView
.
update_time
>=
start_time
,
HoldReport
.
update_time
<=
end_time
)
]
else
:
conditions
=
[
and_
(
ReportView
.
ifa_id
==
ifa_id
,
ReportView
.
type
==
type
,
ReportView
.
name
.
like
(
'
%
'
+
name
+
'
%
'
),
ReportView
.
update_time
>=
start_time
,
HoldReport
.
update_time
<=
end_time
),
and_
(
ReportView
.
ifa_id
==
ifa_id
,
ReportView
.
type
==
type
,
ReportView
.
customer_name
.
like
(
'
%
'
+
name
+
'
%
'
),
ReportView
.
update_time
>=
start_time
,
HoldReport
.
update_time
<=
end_time
)
]
allow_field
=
[
'id'
,
'customer_id'
,
'ifa_id'
,
'update_time'
,
'update_status'
,
'file'
,
'be_viewed'
,
'name'
,
'customer_name'
,
'author_name'
,
'type'
]
with
TAMP_SQL
(
tamp_diagnose_app_engine
)
as
tamp_diagnose_app
:
tamp_diagnose_session
=
tamp_diagnose_app
.
session
hold_report
=
tamp_diagnose_session
.
query
(
HoldReport
)
.
filter
(
and_
(
HoldReport
.
ifa_id
==
ifa_id
,
HoldReport
.
update_time
>=
start_time
,
HoldReport
.
update_time
<=
end_time
))
hold_diagnose_report
=
tamp_diagnose_session
.
query
(
HoldDiagnoseReport
)
.
filter
(
and_
(
HoldDiagnoseReport
.
ifa_id
==
ifa_id
,
HoldDiagnoseReport
.
update_time
>=
start_time
,
HoldDiagnoseReport
.
update_time
<=
end_time
))
periodic_report
=
tamp_diagnose_session
.
query
(
PeriodicReport
)
.
filter
(
and_
(
PeriodicReport
.
ifa_id
==
ifa_id
,
PeriodicReport
.
update_time
>=
start_time
,
PeriodicReport
.
update_time
<=
end_time
))
if
hold_report
.
all
():
hold_report
=
[
r
.
to_dict
(
allow_field
=
allow_field
)
for
r
in
hold_report
]
else
:
hold_report
=
[]
if
hold_diagnose_report
.
all
():
hold_diagnose_report
=
[
r
.
to_dict
(
allow_field
=
allow_field
)
for
r
in
hold_diagnose_report
]
else
:
hold_diagnose_report
=
[]
if
periodic_report
.
all
():
periodic_report
=
[
r
.
to_dict
(
allow_field
=
allow_field
)
for
r
in
periodic_report
]
else
:
periodic_report
=
[]
if
type
==
0
:
# res = hold_report.union_all(hold_diagnose_report).union_all(periodic_report)
res
.
extend
(
hold_report
)
res
.
extend
(
hold_diagnose_report
)
res
.
extend
(
periodic_report
)
elif
type
==
1
:
res
=
hold_report
elif
type
==
2
:
res
=
hold_diagnose_report
elif
type
==
3
:
res
=
periodic_report
# totalSize = res.count()
# data = res.offset(offset).limit(pageSize)
# if data:
# data = [r.to_dict(allow_field=allow_field) for r in data]
totalSize
=
len
(
res
)
data
=
res
[
offset
:
offset
+
pageSize
]
report_res
=
tamp_diagnose_session
.
query
(
ReportView
)
.
filter
(
or_
(
*
conditions
))
.
offset
(
offset
)
.
limit
(
pageSize
)
res
=
[
r
.
to_dict
(
allow_field
=
allow_field
)
for
r
in
report_res
]
totalSize
=
res
.
count
()
return
{
'content'
:
data
,
'content'
:
res
,
'pageNum'
:
pageNumber
,
'pageSize'
:
pageSize
,
'totalSize'
:
totalSize
...
...
@@ -116,26 +111,11 @@ def get_one_report(args):
res
=
[]
with
TAMP_SQL
(
tamp_diagnose_app_engine
)
as
tamp_diagnose_app
:
tamp_diagnose_session
=
tamp_diagnose_app
.
session
hold_report
=
tamp_diagnose_session
.
query
(
HoldReport
)
.
filter
(
and_
(
HoldReport
.
id
==
id
,
res
=
tamp_diagnose_session
.
query
(
ReportView
)
.
filter
(
and_
(
ReportView
.
id
==
id
,
ReportView
.
type
==
type
,
HoldReport
.
ifa_id
==
ifa_id
,
))
hold_diagnose_report
=
tamp_diagnose_session
.
query
(
HoldDiagnoseReport
)
.
filter
(
and_
(
HoldDiagnoseReport
.
id
==
id
,
HoldDiagnoseReport
.
ifa_id
==
ifa_id
,
))
periodic_report
=
tamp_diagnose_session
.
query
(
PeriodicReport
)
.
filter
(
and_
(
PeriodicReport
.
id
==
id
,
PeriodicReport
.
ifa_id
==
ifa_id
,
))
if
type
==
0
:
res
=
hold_report
.
union_all
(
hold_diagnose_report
)
.
union_all
(
periodic_report
)
elif
type
==
1
:
res
=
hold_report
elif
type
==
2
:
res
=
hold_diagnose_report
elif
type
==
3
:
res
=
periodic_report
data
=
[
r
.
to_dict
()
for
r
in
res
]
if
data
:
return
data
[
0
]
...
...
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