Commit 8da45e8b authored by pengxiong's avatar pengxiong

Revert "报告列表"

This reverts commit 4237791b
parent 4237791b
......@@ -132,16 +132,12 @@ class HoldDiagnoseReport(Base, BaseModel):
report_data = Column(Text)
name = Column(String(100))
def __init__(self):
self.type = 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
allow_field.append('type')
if self.file:
self.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}
......@@ -163,6 +159,7 @@ class HoldDiagnoseReport(Base, BaseModel):
data['customer_name'] = res2[0]
else:
data['customer_name'] = ''
data['type'] = 2
return data
......@@ -179,16 +176,12 @@ class HoldReport(Base, BaseModel):
report_data = Column(Text)
name = Column(String(100))
def __init__(self):
self.type = 1
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
allow_field.append('type')
if self.file:
self.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}
......@@ -210,6 +203,7 @@ class HoldReport(Base, BaseModel):
data['customer_name'] = res2[0]
else:
data['customer_name'] = ''
data['type'] = 1
return data
......@@ -226,16 +220,12 @@ class PeriodicReport(Base, BaseModel):
report_data = Column(Text)
name = Column(String(100))
def __init__(self):
self.type = 3
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
allow_field.append('type')
if self.file:
self.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}
......@@ -257,6 +247,7 @@ class PeriodicReport(Base, BaseModel):
data['customer_name'] = res2[0]
else:
data['customer_name'] = ''
data['type'] = 3
return data
......
......@@ -47,15 +47,23 @@ def get_report_list(args):
PeriodicReport.update_time <= end_time
))
if type == 0:
res = hold_report.union_all(hold_diagnose_report).union_all(periodic_report)
if hold_report.all():
res.extend(hold_report)
if hold_diagnose_report.all():
res.append(hold_diagnose_report)
if periodic_report.all():
res.append(periodic_report)
# 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
totalSize = res.count()
data = res.offset(offset).limit(pageSize)
# totalSize = res.count()
# data = res.offset(offset).limit(pageSize)
totalSize = len(res)
data = res[offset: pageSize]
if data:
allow_field = ['id', 'customer_id', 'ifa_id', 'update_time', 'update_status', 'file', 'be_viewed', 'name']
data = [r.to_dict(allow_field=allow_field) for r in data]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment